# https://rpm-packaging-guide.github.io/ # https://rpm-software-management.github.io/rpm/manual/macros.html # https://docs.fedoraproject.org/en-US/quick-docs/publish-rpm-on-copr %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 %global debug_package %{nil} # %%undefine _auto_set_build_flags %global _hardened_build 1 # %%global __brp_mangle_shebangs %%{nil} # %%global __brp_strip %%{nil} # %%global __requires_exclude ^.*/xxx/bin/python.*$ # %%global __requires_exclude_from ^.*/xxx/bin/python.*$ # fix 'Error: Transaction test error:'; RHEL8 rpmbuild and /usr/lib/.build-id # https://access.redhat.com/discussions/5045161 # https://bugzilla.redhat.com/show_bug.cgi?id=1820370 # %%global _build_id_links none # %%bcond_with XXX : opt build with XXX; default, without # %%bcond_without XXX : opt build without XXX; default, with # DCC # http://www.dcc-servers.net/dcc/INSTALL.html # http://wiki.apache.org/spamassassin/UsingDcc # https://www.dcc-servers.net/dcc/FAQ.html#postfix %global _dcc_name dcc %global _dcc_pkgnm dcc %global _dcc_pkgnm_ifd dccifd %global _dcc_unitnm_ifd dccifd %global _dcc_comment Distributed Checksum Clearinghouse content filter %global _dcc_descrip %{expand: %{_dcc_comment}.} # https://www.dcc-servers.net/dcc/dcc-tree/LICENSE %global _dcc_license DCC free license # https://docs.fedoraproject.org/en-US/packaging-guidelines/SourceURL/ %global _dcc_source_url https://www.dcc-servers.net/dcc/source/dcc.tar.Z %global _dcc_scm_tarball %{_dcc_source_url} # https://www.dcc-servers.net/dcc/CHANGES %global _dcc_version 2.3.169 %global _dcc_usr spamd %global _dcc_grp postfix-milter %global _dcc_bin_dir_r bin %global _dcc_conf_dir /usr/local/etc/dcc %global _dcc_home_dir %{_dcc_conf_dir} %global _dcc_home_dir_default %{_dcc_conf_dir}/homedir.DEFAULT %global _dcc_install_dir /usr/local/postfix-pgnd/dcc %global _dcc_libexec_dir_r libexec %global _dcc_log_dir /var/log/%{_dcc_pkgnm} %global _dcc_man_dir_r man %global _dcc_run_dir /run/%{_dcc_pkgnm} %global _dcc_tmp_dir /tmp %global _dcc_unit_dir /etc/systemd/system %global _dccifd_exec %{_dcc_install_dir}/%{_dcc_libexec_dir_r}/dccifd %global _dccifd_pid_file %{_dcc_pkgnm_ifd}.pid %global _dccifd_socket %{_dcc_pkgnm_ifd}.sock # !!NOTE!! tarball extracts to: %global _dcc_release_extract_dir dcc-%{_dcc_version} %global forgeurl0 %{_dcc_source_url} %global forgesource0 %{_dcc_scm_tarball} %global extractdir0 %{_dcc_release_extract_dir} %global forgesetupargs0 -T -D -b 0 -n %{extractdir0} %global forgesource0 %{_dcc_source_url} # Packaging a release requires setting Version before calling forgemeta. Version: release_%( echo %{_dcc_version} | sed 's|-|_|g' ) %forgemeta -i -a -v %global dist %{_dist} # Vendor Pinning Vendor: %{_owner} # NEVRA (n-e:v-r.a) Name: %{_dcc_pkgnm} Epoch: 3 # https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/ Release: 0%{?dist} # https://blog.jasonantman.com/2014/07/how-yum-and-rpm-compare-versions/ %global _same_evr %{epoch}:%{version}-%{release} Summary: %{_dcc_comment} License: %{_dcc_license} URL: %{forgeurl0} Source0: %{forgesource0} Source100: %{_dcc_unitnm_ifd}.service # Source200: dcc_svr_hostname.patch BuildRequires: coreutils BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: make BuildRequires: systemd BuildRequires: systemd-rpm-macros BuildRequires: systemd-units %{?systemd_requires} # https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets # https://docs.pagure.org/packaging-guidelines/Packaging:Scriptlets.html Requires(pre): user(dcc) Requires(pre): group(dcc) Provides: dcc = %{_same_evr} Provides: dccifd = %{_same_evr} Obsoletes: dcc < %{_same_evr} Obsoletes: dccifd < %{_same_evr} Recommends: spamassassin %description %{_dcc_descrip} %prep echo '##### STARTING PREP #####' %forgesetup -a %build echo '##### STARTING BUILD #####' cd %{_builddir}/%{extractdir0} mkdir -p %{_builddir}/%{_dcc_install_dir}/{%{_dcc_bin_dir_r},%{_dcc_man_dir_r}/man8,%{_dcc_libexec_dir_r}} mkdir -p %{_builddir}/%{_dcc_home_dir_default} # unset CFLAGS LDFLAGS rpm -qa | grep -iE "gcc|glibc" # FIXED in 2.3.169 # https://www.dcc-servers.net/dcc/CHANGES # @ >= f40/gcc14 # error: installation or configuration problem: C compiler cannot create executables. #-> conftest.c:4:1: error: return type defaults to 'int' [-Wimplicit-int] # https://fedoraproject.org/wiki/Changes/PortingToModernC#Removal_of_implicit_int # sed -i 's|^\(main(){return(0);}\)|int \1|g' ./configure # patch -p0 < %%{SOURCE200} # https://www.dcc-servers.net/dcc/dccm.html ./configure \ --with-installroot=%{_builddir} \ --bindir=%{_dcc_install_dir}/%{_dcc_bin_dir_r} \ --homedir=%{_dcc_home_dir_default} \ --libexecdir=%{_dcc_install_dir}/%{_dcc_libexec_dir_r} \ --mandir=%{_dcc_install_dir}/%{_dcc_man_dir_r} \ --with-rundir=%{_dcc_run_dir} \ --enable-64-bits \ --enable-dccifd \ --disable-sys-inst \ --disable-server \ --disable-dccm make \ V=1 \ -j${RPM_BUILD_NCPUS} make V=1 install %install echo '##### STARTING INSTALL #####' cd %{_builddir}/%{extractdir0} mkdir -p ${RPM_BUILD_ROOT}/%{_dcc_home_dir_default} mkdir -p ${RPM_BUILD_ROOT}/%{_dcc_install_dir} install -d --mode=0775 ${RPM_BUILD_ROOT}/%{_dcc_log_dir} # GENERATE .service FILES sed -i \ -e 's|__DCCIFD_EXEC__|%{_dccifd_exec}|g' \ -e 's|__DCCIFD_PIDFILE__|%{_dccifd_pid_file}|g' \ -e 's|__DCCIFD_SOCKET__|%{_dccifd_socket}|g' \ -e 's|__DCC_CONFDIR__|%{_dcc_conf_dir}|g' \ -e 's|__DCC_GRP__|%{_dcc_grp}|g' \ -e 's|__DCC_HOMEDIR__|%{_dcc_home_dir}|g' \ -e 's|__DCC_LOGDIR__|%{_dcc_log_dir}|g' \ -e 's|__DCC_RUNDIR__|%{_dcc_run_dir}|g' \ -e 's|__DCC_TMPDIR__|%{_dcc_tmp_dir}|g' \ -e 's|__DCC_USR__|%{_dcc_usr}|g' \ %{SOURCE100} install -D --preserve-timestamps --mode=644 --verbose \ %{SOURCE100} \ ${RPM_BUILD_ROOT}/%{_dcc_unit_dir}/%{_dcc_unitnm_ifd}.service cp -prT \ %{_builddir}/%{_dcc_install_dir} \ ${RPM_BUILD_ROOT}/%{_dcc_install_dir} cp -prT \ %{_builddir}/%{_dcc_home_dir_default} \ ${RPM_BUILD_ROOT}/%{_dcc_home_dir_default} sed -i 's|^\(DDCUID=\).*|\1spamd|g' ${RPM_BUILD_ROOT}/%{_dcc_home_dir_default}/dcc_conf %pre %post -e %systemd_post %{_dcc_unitnm_ifd}.service chown -R %{_dcc_usr}:%{_dcc_grp} %{_dcc_home_dir_default} # check: # /usr/local/postfix-pgnd/dcc/bin/cdcc info # /usr/local/postfix-pgnd/spamassassin/perl5app/bin/spamassassin -D DCC --prefs-file=/usr/local/etc/spamassassin/local.cf - bump 1726677191