# PERL # https://docs.fedoraproject.org/en-US/packaging-guidelines/Perl/ # https://fedoraproject.org/wiki/Perl/Tips # https://thrig.me/tmp/rpm-a-directory.txt # https://docs.fedoraproject.org/en-US/quick-docs/publish-rpm-on-copr # http://ftp.rpm.org/max-rpm/s1-rpm-inside-scripts.html # https://rpm-software-management.github.io/rpm/manual/macros.html # https://rpm-packaging-guide.github.io/ %global _owner pgnd %global _build_timestamp %( date +%%Y%%m%%d_%%H%%M%%S --utc ) %global _dist .%{_build_timestamp}.%{_owner}.fc%{fedora} # https://stackoverflow.com/questions/47838041/rpmbuild-how-to-disable-check-buildroot # https://rpm-software-management.github.io/rpm/manual/dependency_generators.html # %%global __spec_install_pre /bin/true # %%global __arch_install_post %%{nil} # %%global __os_install_post %%{nil} %global _disable_source_fetch 0 # %%undefine _auto_set_build_flags %global _hardened_build 1 %global __brp_mangle_shebangs %{nil} # DEBUG %global debug_package %{nil} # fix 'Error: Transaction test error:' ; RHEL8 rpmbuild and /usr/lib/.build-id # https://access.redhat.com/discussions/5045161 # https://unix.stackexchange.com/questions/688839/if-i-do-not-care-about-debug-support-in-red-hat-packages-what-are-the-drawbacks %global _build_id_links none # STRIP # do NOT strip bins -- specifically, spamc breaks if stripped # https://devel.fedoraproject.narkive.com/Ljv01e3Z/disabling-brp-strip-for-mock-builds # https://www.reddit.com/r/Fedora/comments/wsumts/weird_copr_build_result/ %global __brp_strip %{nil} %global __strip /bin/true %global __os_install_post %(echo '%{__os_install_post}' | sed -e 's|/usr/lib/rpm/[^/]*/?brp-strip %{__strip}||g') # %%global __requires_exclude ^.*/xxx/bin/python.*$ # %%global __requires_exclude_from ^.*/xxx/bin/python.*$ # %%bcond_with XXX : opt build with XXX; default, without # %%bcond_without XXX : opt build without XXX; default, with # FASTMAIL AUTHENTICATION MILTER # https://github.com/fastmail/authentication_milter # https://metacpan.org/pod/Mail::Milter::Authentication %global _fmam_name fm-auth-milter %global _fmam_pkgnm fm-auth-milter %global _fmam_unitnm fm-auth-milter %global _fmam_comment Object Oriented Authentication-Results email headers %global _fmam_descrip %{expand: %{_fmam_comment}.} # https://spdx.org/licenses/GPL-1.0-or-later.html or https://spdx.org/licenses/Artistic-1.0-Perl.html %global _fmam_license GPL-1.0-or-later or Artistic-1.0-Perl %global _fmam_usr fm-auth-milter %global _fmam_grp postfix-milter %global _fmam_bin_dir /bin %global _fmam_cache_dir /var/cache/authentication_milter %global _fmam_conf_dir /usr/local/etc/fm-auth-milter %global _fmam_install_dir /usr/local/postfix-pgnd/fm-auth-milter %global _fmam_libexec_dir /libexec %global _fmam_run_dir /run/%{_fmam_pkgnm} %global _fmam_spool_dir /var/spool/authentication_milter %global _fmam_unit_dir /etc/systemd/system # single "/" s %global _fmam_local_lib %( echo "/builddir/%{_fmam_install_dir}" | sed -E 's|/{2,}|/|g' ) # https://docs.fedoraproject.org/en-US/packaging-guidelines/SourceURL/ %global _fmam_scm_repo fastmail/authentication_milter # latest/current release version from CPAN %global _fmam_cpan_tag %( curl -s https://fastapi.metacpan.org/v1/release/Mail-Milter-Authentication | jq .version | sed 's|"||g' ) %global _fmam_scm_repo_esc %( echo %{_fmam_scm_repo} | sed 's|_|-|g' | sed 's|/|%2F|g') %global _fmam_scm_repo_norm %( echo %{_fmam_scm_repo} | sed 's|_|-|g' | sed 's|/|-|g' ) %global _fmam_scm_host https://github.com %global _fmam_scm_url %{_fmam_scm_host}/%{_fmam_scm_repo} %global dist %{_dist} # Vendor Pinning Vendor: %{_owner} # NEVRA (n-e:v-r.a) Name: %{_fmam_pkgnm} Epoch: 3 # https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/ Version: cpan_%( echo %{_fmam_cpan_tag} | sed 's|-|_|g' ) Release: 0%{?dist} # https://blog.jasonantman.com/2014/07/how-yum-and-rpm-compare-versions/ %global _same_evr %{epoch}:%{version}-%{release} Summary: %{_fmam_comment} License: %{_fmam_license} URL: %{_fmam_scm_url} Source100: %{_fmam_unitnm}.service BuildRequires: curl BuildRequires: findutils BuildRequires: gcc BuildRequires: make BuildRequires: pcre2-devel BuildRequires: perl(local::lib) BuildRequires: perl(App::cpanminus) BuildRequires: perl(deprecate) BuildRequires: perl(ExtUtils::MakeMaker) BuildRequires: perl(File::Copy) BuildRequires: pkgconf BuildRequires: pkgconfig(libidn2) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(libzstd) BuildRequires: pkgconfig(openssl) BuildRequires: pkgconfig(sqlite3) sqlite BuildRequires: pkgconfig(zlib) # XML::LibXML # @ rawhide error: incompatible-pointer-types # https://fedoraproject.org/wiki/Toolchain/PortingToModernC # https://www.spinics.net/lists/fedora-devel/msg315840.html # https://src.fedoraproject.org/rpms/perl-XML-LibXML/blob/rawhide/f/perl-XML-LibXML.spec #??? BuildRequires: perl(XML::LibXML) # https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_systemd # https://docs.pagure.org/packaging-guidelines/Packaging:Scriptlets.html BuildRequires: systemd BuildRequires: systemd-rpm-macros %{?systemd_requires} Requires: findutils Requires: logrotate Requires: perl(local::lib) Requires: rsyslog Requires(pre): user(fm-auth-milter) Requires(pre): group(fm-auth-milter) Provides: fm-auth-milter = %{_same_evr} Obsoletes: fm-auth-milter < %{_same_evr} Recommends: postfix-current %description %{_fmam_comment} %global _build_work_dir /builddir %prep echo '##### STARTING PREP #####' %build echo '##### STARTING BUILD #####' cd %{_builddir} echo '##### SETUP BUILD ENV #####' # https://metacpan.org/dist/App-cpanminus/view/bin/cpanm _opts="" _opts+=" --verify" _opts+=" --no-prompt" _opts+=" --notest" _opts+=" --no-sudo" _opts+=" --no-interactive" _opts+=" --with-recommends" _opts+=" --with-suggests" _opts+=" --local-lib %{_fmam_local_lib}" _opts+=" --self-contained" # http://mirrors.cpan.org/ # use cpan CDN # https://www.cpan.org/SITES.html #_opts+=" --from http://mirrors.rit.edu/CPAN/" _opts+=" --from https://www.cpan.org/" #_opts+=" --from https://cpan.metacpan.org" export PERL_CPANM_OPT="${_opts}" export PERL_CPANM_HOME="%{_build_work_dir}/.cpanm" # local::lib INSTALL #####' # https://manpages.ubuntu.com/manpages/lunar/man3/local::lib.3pm.html # https://www.perlmonks.org/?node_id=967116 # https://metacpan.org/pod/local::lib#Bootstrapping-into-an-alternate-directory # Build RPMs of CPAN Modules # https://perlhacks.com/2015/10/build-rpms-of-cpan-modules/ mkdir -p %{_fmam_local_lib} cd %{_fmam_local_lib} # perl -Mlocal::lib=./ eval $(perl -Mlocal::lib=./) printenv | grep PERL | sort # PERL5LIB=/builddir/perlbuilddir/lib/perl5 # PERL_CPANM_HOME=/builddir/.cpanm # PERL_CPANM_OPT= --verify --no-prompt --notest --no-sudo --no-interactive --with-recommends --with-suggests --local-lib /builddir/perlbuilddir --self-contained --from https://www.cpan.org/ # PERL_LOCAL_LIB_ROOT=/builddir/perlbuilddir/ # PERL_MB_OPT=--install_base "/builddir/perlbuilddir/" # PERL_MM_OPT=INSTALL_BASE=/builddir/perlbuilddir/ cpanm --quiet Module::Info # module_info Module::Info ##################### ## GET/FIX PREREQS # Net::IDN::Encode @F40 # fix "-Werror=implicit-function-declaration" on rawhide # https://github.com/fastmail/authentication_milter/issues/149 # https://github.com/cfaerber/Net-IDN-Encode/pull/11 # https://src.fedoraproject.org/rpms/perl-Net-IDN-Encode/blob/rawhide/f/Net-IDN-Encode-2.500-use_uvchr_to_utf8_flags_instead_of_uvuni_to_utf8_flags.patch _mod="Net::IDN::Encode" pushd . rm -rf ./tmpdir mkdir -p ./tmpdir cd ./tmpdir _mod_info=$( cpanm --info ${_mod} ) _mod_vers=$( echo ${_mod_info} | sed 's|.*/||g' | sed 's|\.tar\.gz||g' ) curl -O https://cpan.metacpan.org/authors/id/${_mod_info:0:1}/${_mod_info:0:2}/${_mod_info} tar zxvf ${_mod_vers}.tar.gz cd ${_mod_vers} export PERL_MM_USE_DEFAULT=1 curl -o _this.patch \ https://src.fedoraproject.org/rpms/perl-Net-IDN-Encode/raw/rawhide/f/Net-IDN-Encode-2.500-use_uvchr_to_utf8_flags_instead_of_uvuni_to_utf8_flags.patch patch --quiet -p1 -i _this.patch perl Build.PL ./Build --quiet installdeps --cpan_client 'cpanm --quiet' ./Build --quiet ./Build --quiet install popd rm -rf ./tmpdir # Test::File::Contents # ! ! Checksum file downloaded from /builddir/.cpanm/sources/https%%www.cpan.org/ARISTOTLE.CHECKSUMS is broken. # https://github.com/ap/Test-File-Contents/issues/5 cpanm Module::Build::Tiny # Net::DNS::Paranoid # cpanm install FAILs for v0.09, not found in cpan DBs/mirrors; v0.08 install OK # https://github.com/tokuhirom/Net-DNS-Paranoid/issues/8 _mod="Net::DNS::Paranoid" pushd . rm -rf ./tmpdir mkdir -p ./tmpdir cd ./tmpdir #_mod_info=$( cpanm --info ${_mod} ) _mod_info="TOKUHIROM/Net-DNS-Paranoid-0.09.tar.gz" _mod_vers=$( echo ${_mod_info} | sed 's|.*/||g' | sed 's|\.tar\.gz||g' ) curl -O https://cpan.metacpan.org/authors/id/${_mod_info:0:1}/${_mod_info:0:2}/${_mod_info} tar zxvf ${_mod_vers}.tar.gz cd ${_mod_vers} export PERL_MM_USE_DEFAULT=1 perl Build.PL # !!no --quiet option ./Build ./Build install popd rm -rf ./tmpdir ##\GET/FIX PREREQS ##################### cpanm --quiet --installdeps Mail::Milter::Authentication cpanm --quiet Mail::Milter::Authentication %install echo '##### STARTING INSTALL #####' cd %{_builddir} mkdir -p ${RPM_BUILD_ROOT}/$(dirname %{_fmam_install_dir}) mv -f \ %{_fmam_local_lib} \ ${RPM_BUILD_ROOT}/$(dirname %{_fmam_install_dir}) sed -i \ -e 's|__FMAM_LOCAL_PERLLIB_DIR__|%{_fmam_install_dir}/lib/perl5|g' \ -e 's|__FMAM_EXEC__|%{_fmam_install_dir}/bin/authentication_milter|g' \ -e 's|__FMAM_USR__|%{_fmam_usr}|g' \ -e 's|__FMAM_GRP__|%{_fmam_grp}|g' \ -e 's|__FMAM_CONFDIR__|%{_fmam_conf_dir}|g' \ -e 's|__FMAM_RUNDIR__|%{_fmam_run_dir}|g' \ -e 's|__FMAM_PIDFILE__|%{_fmam_pkgnm}.pid|g' \ -e 's|__FMAM_CACHEDIR__|%{_fmam_cache_dir}|g' \ -e 's|__FMAM_SPOOLDIR__|%{_fmam_spool_dir}|g' \ %{SOURCE100} # SERVICEs install -D --preserve-timestamps --mode=644 --verbose \ %{SOURCE100} \ ${RPM_BUILD_ROOT}/%{_fmam_unit_dir}/%{_fmam_unitnm}.service echo '##### FIX PATHS #####' # --exclude="spamc" \ grep -rlni \ --binary-files=without-match \ "%{_fmam_local_lib}" ${RPM_BUILD_ROOT}/ \ | xargs -i@ sed -i 's|/builddir/|/|g' @ %pre %post -e %systemd_post %{_fmam_unitnm}.service %preun %systemd_preun %{_fmam_unitnm}.service %postun %systemd_postun_with_restart %{_fmam_unitnm}.service %files # http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html %dir %{_fmam_install_dir} %{_fmam_install_dir}/* %attr(0644,root,root) %{_fmam_unit_dir}/%{_fmam_unitnm}.service %changelog * Mon Jun 17 2024 pgnd _ - bump 1718623908