# 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 # APACHE SPAMASSASSIN # https://spamassassin.apache.org/ # https://github.com/apache/spamassassin # https://metacpan.org/pod/Mail::SpamAssassin # https://spamassassin.apache.org/full/4.0.x/doc/ #%%global _sa_name spamassassinWIP #%%global _sa_pkgnm spamassassinWIP %global _sa_name spamassassin %global _sa_pkgnm spamassassin %global _sa_daemonnm spamd %global _sa_unitnm %{_sa_daemonnm} %global _sa_comment Spamassassin4 filter %global _sa_descrip %{expand: %{_sa_comment}.} # https://spdx.org/licenses/Apache-2.0.html %global _sa_license Apache-2.0 %global _sa_usr spamd %global _sa_grp_private spamd %global _sa_grp postfix-milter %global _sa_bin_dir_r bin %global _sa_cache_dir /var/cache/authentication_milter %global _sa_conf_dir /usr/local/etc/spamassassin %global _sa_install_dir /usr/local/postfix-pgnd/spamassassin %global _sa_unit_dir /etc/systemd/system %global _sa_libexec_dir /libexec %global _sa_log_dir /var/log/%{_sa_daemonnm} %global _sa_perl_ver %(perl -e 'print "$]"') %global _sa_run_dir /run/%{_sa_daemonnm} %global _sa_spool_dir /var/spool/authentication_milter %global _sa_localstate_dir /var/lib # single "/" s %global _sa_local_lib %( echo "/builddir/%{_sa_install_dir}" | sed -E 's|/{2,}|/|g' ) %global _spamc_path_r spamc.path # https://docs.fedoraproject.org/en-US/packaging-guidelines/SourceURL/ %global _sa_scm_repo apache/spamassassin # latest/current release version from CPAN %global _sa_cpan_tag %( curl -s https://fastapi.metacpan.org/v1/release/Mail-SpamAssassin | jq .version | sed 's|"||g' ) %global _sa_data_dir %{_sa_localstate_dir}/spamassassin %global _sa_data_dir_build %( echo "/builddir/%{_sa_data_dir}/%{_sa_cpan_tag}" | sed -E 's|/{2,}|/|g' ) %global _sa_scm_repo_esc %( echo %{_sa_scm_repo} | sed 's|_|-|g' | sed 's|/|%2F|g') %global _sa_scm_repo_norm %( echo %{_sa_scm_repo} | sed 's|_|-|g' | sed 's|/|-|g' ) %global _sa_scm_host https://github.com %global _sa_scm_url %{_sa_scm_host}/%{_sa_scm_repo} %global dist %{_dist} # Vendor Pinning Vendor: %{_owner} # NEVRA (n-e:v-r.a) Name: %{_sa_pkgnm} Epoch: 3 # https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/ Version: cpan_%( echo %{_sa_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: %{_sa_comment} License: %{_sa_license} URL: %{_sa_scm_url} Source100: %{_sa_unitnm}.service Source101: %{_sa_unitnm}.target Source200: spamassassin-feeds.service Source201: spamassassin-feeds.timer Source202: spamassassin-update.service Source203: spamassassin-update.timer Source204: spamassassin-compile.service Source300: spamc-learn-wrapper.pl BuildRequires: curl BuildRequires: dcc BuildRequires: findutils BuildRequires: gcc BuildRequires: geoipupdate 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(icu-uc) BuildRequires: libidn BuildRequires: libidn-devel BuildRequires: openssl BuildRequires: pkgconfig(libidn2) BuildRequires: pkgconfig(libmaxminddb) BuildRequires: pkgconfig(libnsl) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(libzstd) BuildRequires: pkgconfig(openssl) BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(zlib) BuildRequires: re2c # 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: curl Requires: dcc Requires: findutils Requires: geoipupdate Requires: logrotate Requires: perl(local::lib) Requires: pyzor Requires: re2c Requires: rsyslog # spamc-learn-wrapper.pl Requires: perl(File::Temp) Requires: perl(Getopt::Long) Requires: perl(MIME::Parser) Requires: perl(MIME::Tools) Requires: perl(Net::IP) Requires: perl(POSIX) Requires(pre): user(spamassassin) Requires(pre): group(spamassassin) Provides: %{_sa_pkgnm} = %{_same_evr} Obsoletes: %{_sa_pkgnm} < %{_same_evr} %description %{_sa_comment} %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 %{_sa_local_lib}" _opts+=" --self-contained" # use cpan CDN # https://www.cpan.org/SITES.html # _opts+=" --from https://www.cpan.org/" export PERL_CPANM_OPT="${_opts}" export PERL_CPANM_HOME="/builddir/.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 %{_sa_local_lib} cd %{_sa_local_lib} # perl -Mlocal::lib=./ eval $(perl -Mlocal::lib=./) echo '##### PERL ENV #####' printenv | grep PERL | sort # PERL5LIB=/builddir/usr/local/postfix-pgnd/spamassassin/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//usr/local/postfix-pgnd/spamassassin --self-contained # PERL_LOCAL_LIB_ROOT=/builddir/usr/local/postfix-pgnd/spamassassin/ # PERL_MB_OPT=--install_base "/builddir/usr/local/postfix-pgnd/spamassassin/" # PERL_MM_OPT=INSTALL_BASE=/builddir/usr/local/postfix-pgnd/spamassassin/ cpanm --quiet Module::Info # module_info Module::Info ##################### ## GET/FIX PREREQS cpanm --quiet Test::NoWarnings ## Path::Class # Signature FAIL, 2024-10-16 _mod="Path::Class" echo "##### PREREQ: ${_mod} #####" pushd . rm -rf ./tmpwork mkdir -p ./tmpwork cd ./tmpwork _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 zxf ${_mod_vers}.tar.gz cd ${_mod_vers} export PERL_MM_USE_DEFAULT=1 perl Build.PL ./Build --quiet installdeps --cpan_client 'cpanm --quiet' ./Build --quiet ./Build --quiet install popd rm -rf ./tmpwork ## Module::Runtime # Signature FAIL, 2024-10-16 _mod="Module::Runtime" echo "##### PREREQ: ${_mod} #####" pushd . rm -rf ./tmpwork mkdir -p ./tmpwork cd ./tmpwork _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 zxf ${_mod_vers}.tar.gz cd ${_mod_vers} export PERL_MM_USE_DEFAULT=1 perl Build.PL ./Build --quiet installdeps --cpan_client 'cpanm --quiet' ./Build --quiet ./Build --quiet install popd rm -rf ./tmpwork # LWP _mod="LWP" echo "##### PREREQ: ${_mod} #####" pushd . rm -rf ./tmpwork mkdir -p ./tmpwork cd ./tmpwork _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 zxf ${_mod_vers}.tar.gz cd ${_mod_vers} export PERL_MM_USE_DEFAULT=1 cpanm --quiet --installdeps . perl Makefile.PL make -j${RPM_BUILD_NCPUS} make install popd rm -rf ./tmpwork cpanm --quiet install --force LWP::Protocol::https # 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" echo "##### PREREQ: ${_mod} #####" pushd . rm -rf ./tmpwork mkdir -p ./tmpwork cd ./tmpwork _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 zxf ${_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 ./tmpwork # MaxMind::DB::Reader::Role::HasMetadata _mod="MaxMind::DB::Reader::Role::HasMetadata" echo "##### PREREQ: ${_mod} #####" pushd . rm -rf ./tmpwork mkdir -p ./tmpwork cd ./tmpwork _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 zxf ${_mod_vers}.tar.gz cd ${_mod_vers} export PERL_MM_USE_DEFAULT=1 cpanm --quiet --installdeps . perl Makefile.PL make -j${RPM_BUILD_NCPUS} make install popd rm -rf ./tmpwork cpanm --quiet GeoIP2 cpanm --quiet Razor2::Client::Agent ##/GET/FIX PREREQS ##################### # Mail::SpamAssassin _mod="Mail::SpamAssassin" echo "##### PREREQ: ${_mod} #####" #_v="" _v="--quiet" #_v="--verbose" pushd . rm -rf ./tmpwork mkdir -p ./tmpwork cd ./tmpwork _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 zxf ${_mod_vers}.tar.gz cd ${_mod_vers} export PERL_MM_USE_DEFAULT=1 cpanm ${_v} --installdeps . mkdir -p /builddir/%{_sa_data_dir} perl Makefile.PL \ CONFDIR=%{_sa_conf_dir} \ LOCALSTATEDIR=%{_sa_data_dir} \ DATADIR=%{_sa_data_dir_build} make -j${RPM_BUILD_NCPUS} make install popd rm -rf ./tmpwork %install echo '##### STARTING INSTALL #####' cd %{_builddir} mkdir -p ${RPM_BUILD_ROOT}/$(dirname %{_sa_install_dir}) mv -f \ %{_sa_local_lib} \ ${RPM_BUILD_ROOT}/$(dirname %{_sa_install_dir}) sed -i \ -e 's|__SA_CONFDIR__|%{_sa_conf_dir}|g' \ -e 's|__SA_EXECDIR__|%{_sa_install_dir}/bin|g' \ -e 's|__SA_GRP__|%{_sa_grp}|g' \ -e 's|__SA_GRP_PRIVATE__|%{_sa_grp_private}|g' \ -e 's|__SA_LOCAL_PERLLIB_DIR__|%{_sa_install_dir}/lib/perl5|g' \ -e 's|__SA_LOGDIR__|%{_sa_log_dir}|g' \ -e 's|__SA_LOGFILE__|%{_sa_daemonnm}.log|g' \ -e 's|__SA_PERL_VER__|%{_sa_perl_ver}|g' \ -e 's|__SA_PIDFILE__|%{_sa_daemonnm}.pid|g' \ -e 's|__SA_RUNDIR__|%{_sa_run_dir}|g' \ -e 's|__SA_SA_VERSION__|%{_sa_cpan_tag}|g' \ -e 's|__SA_SOCKET__|%{_sa_daemonnm}.sock|g' \ -e 's|__SA_DATA_DIR__|%{_sa_data_dir}|g' \ -e 's|__SA_USR__|%{_sa_usr}|g' \ %{SOURCE100} %{SOURCE200} %{SOURCE202} %{SOURCE204} %{SOURCE300} install -D -p -m 644 -v \ %{SOURCE100} \ ${RPM_BUILD_ROOT}/%{_sa_unit_dir}/%{_sa_unitnm}.service install -D -p -m 644 -v \ %{SOURCE101} \ ${RPM_BUILD_ROOT}/%{_sa_unit_dir}/%{_sa_unitnm}.target install -D -p -m 644 -v \ %{SOURCE200} \ ${RPM_BUILD_ROOT}/%{_sa_unit_dir}/spamassassin-feeds.service install -D -p -m 644 -v \ %{SOURCE201} \ ${RPM_BUILD_ROOT}/%{_sa_unit_dir}/spamassassin-feeds.timer install -D -p -m 644 -v \ %{SOURCE202} \ ${RPM_BUILD_ROOT}/%{_sa_unit_dir}/spamassassin-update.service install -D -p -m 644 -v \ %{SOURCE203} \ ${RPM_BUILD_ROOT}/%{_sa_unit_dir}/spamassassin-update.timer install -D -p -m 644 -v \ %{SOURCE204} \ ${RPM_BUILD_ROOT}/%{_sa_unit_dir}/spamassassin-compile.service install -D -p -m 775 -v \ %{SOURCE300} \ ${RPM_BUILD_ROOT}/%{_sa_conf_dir}/scripts/spamc-learn-wrapper.pl echo '##### FIX PATHS #####' grep -rlni \ --binary-files=without-match \ --exclude="spamc" \ "%{_sa_local_lib}" ${RPM_BUILD_ROOT}/ \ | xargs -i@ sed -i 's|/builddir/|/|g' @ # write spamc path for spamassassin-milter.service use mkdir -p ${RPM_BUILD_ROOT}/%{_sa_conf_dir} cat << EOF > ${RPM_BUILD_ROOT}/%{_sa_conf_dir}/%{_spamc_path_r} # systemd-path search-binaries-default # /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin PATH=%{_sa_install_dir}/bin:/usr/sbin:/usr/bin EOF chmod 0644 ${RPM_BUILD_ROOT}/%{_sa_conf_dir}/%{_spamc_path_r} %pre /usr/bin/systemctl mask spamassassin.service /usr/bin/systemctl -q --no-block try-restart spamassassin-update.service %post -e %systemd_post %{_sa_unitnm}.service /usr/bin/systemctl -q --no-block try-restart spamassassin-update.service %preun %systemd_preun %{_sa_unitnm}.service %postun %systemd_postun_with_restart %{_sa_unitnm}.service %files # http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html %dir %{_sa_install_dir} %{_sa_install_dir}/* %attr(0644,root,root) %{_sa_unit_dir}/%{_sa_unitnm}.* %attr(0644,root,root) %{_sa_unit_dir}/spamassassin-*.* %attr(0644,%{_sa_usr},%{_sa_grp_private}) %{_sa_conf_dir}/%{_spamc_path_r} %attr(0775,%{_sa_usr},%{_sa_grp_private}) %{_sa_conf_dir}/scripts/spamc-learn-wrapper.pl %changelog * Wed Nov 13 2024 pgnd _ - bump 1731532934