# 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 # %%define __spec_install_pre /bin/true # %%define __arch_install_post %%{nil} # %%define __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} # %%define __requires_exclude ^.*/xxx/bin/python.*$ # %%define __requires_exclude_from ^.*/xxx/bin/python.*$ # %%define _build_id_links none # %%bcond_with XXX : opt build with XXX; default, without # %%bcond_without XXX : opt build without XXX; default, with # MILTER-REGEX # https://github.com/milter-regex/milter-regex # https://www.benzedrine.ch/milter-regex.html # https://src.fedoraproject.org/rpms/milter-regex/raw/rawhide/f/milter-regex.spec %global _mrgx_name milter-regex %global _mrgx_pkgnm milter-regex %global _mrgx_unitnm milter-regex %global _mrgx_comment Milter-Regex milter %global _mrgx_descrip %{expand: %{_mrgx_comment}.} # https://spdx.org/licenses/BSD-2-Clause.html %global _mrgx_license BSD-2-Clause %global _mrgx_usr milter-regex %global _mrgx_grp postfix-milter %global _mrgx_conf_dir /usr/local/etc/milter-regex %global _mrgx_install_dir /usr/local/postfix-pgnd/milter-regex %global _mrgx_run_dir /run/%{_mrgx_pkgnm} %global _mrgx_bin_dir bin %global _mrgx_man_dir man %global _mrgx_unit_dir /etc/systemd/system %global _mrgx_log_dir /var/log/%{_mrgx_pkgnm} # https://docs.fedoraproject.org/en-US/packaging-guidelines/SourceURL/ %global _mrgx_scm_repo milter-regex/milter-regex %global _mrgx_scm_branch main %global _mrgx_scm_repo_esc %( echo %{_mrgx_scm_repo} | sed 's|_|-|g' | sed 's|/|%2F|g') %global _mrgx_scm_repo_norm %( echo %{_mrgx_scm_repo} | sed 's|_|-|g' | sed 's|/|-|g' ) %global _mrgx_scm_branch_norm %( echo %{_mrgx_scm_branch} | sed 's|_|-|g' | sed 's|/|-|g' ) %global _mrgx_scm_host https://github.com %global _mrgx_scm_host_api https://api.github.com/repos %global _mrgx_scm_url %{_mrgx_scm_host}/%{_mrgx_scm_repo} %global _mrgx_scm_tarball %{_mrgx_scm_host_api}/%{_mrgx_scm_repo}/tarball/%{commit0} # !!NOTE!! GH API tarball extracts to: %global _mrgx_scm_extract_dir %{_mrgx_scm_repo_norm}-%{shortcommit0} %global forgeurl0 %{_mrgx_scm_url} %global commit0 %( git ls-remote %{forgeurl0} | grep /%{_mrgx_scm_branch}$ | cut -f1 ) %global shortcommit0 %( c=%{commit0}; echo ${c} | head -c 7 ) %global forgesource0 %{_mrgx_scm_tarball} %global extractdir0 %{_mrgx_scm_extract_dir} %global forgesetupargs0 -T -D -b 0 -n %{extractdir0} %forgemeta -i -a %global dist %{_dist} # Vendor Pinning Vendor: %{_owner} # NEVRA (n-e:v-r.a) Name: %{_mrgx_pkgnm} Epoch: 3 # https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/ Version: %{scm0}_%( echo %{_mrgx_scm_branch} | sed 's|-|_|g' ) Release: 0%{?dist} # https://blog.jasonantman.com/2014/07/how-yum-and-rpm-compare-versions/ %global sameevr %{epoch}:%{version}-%{release} Summary: %{_mrgx_comment} License: %{_mrgx_license} URL: %{forgeurl0} Source0: %{forgesource0} Source100: %{_mrgx_unitnm}.service Source101: %{_mrgx_unitnm}.sysusers # https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets # https://docs.pagure.org/packaging-guidelines/Packaging:Scriptlets.html BuildRequires: byacc BuildRequires: coreutils BuildRequires: gcc BuildRequires: groff BuildRequires: make BuildRequires: sendmail-milter-devel >= 8.13 BuildRequires: sed BuildRequires: systemd BuildRequires: systemd-devel %{?systemd_requires} Requires(pre): user(milter-regex) Requires(pre): group(postfix-milter) Recommends: postfix-current # Packaging:Conflicts # https://fedoraproject.org/wiki/Packaging:Conflicts Obsoletes: %{_mrgx_pkgnm} <= %{version} Provides: %{_mrgx_pkgnm} = %{version} Conflicts: milter-regex %description %{_mrgx_comment} %prep echo '##### STARTING PREP #####' %forgesetup -a cd %{_builddir}/%{extractdir0} # Customize config file location and dæmon user sed -i 's|/etc/milter-regex\.conf|%{_mrgx_conf_dir}/milter-regex.conf|g' milter-regex.[8c] # sed -i 's|_milter-regex|milter-regex|g' milter-regex.[8c] # Copy out the license text from the source code head -n +31 milter-regex.c > LICENSE %build echo '##### STARTING BUILD #####' cd %{_builddir}/%{extractdir0} echo '##### MRGX SOURCE FLAGS PREP #####' _CFLAGS=${CFLAGS} _CFLAGS+=" -Wextra" _CFLAGS+=" -Wwrite-strings" _CFLAGS+=" -DYYMAXDEPTH=8192" _CFLAGS+=" -Wno-discarded-qualifiers" _LDFLAGS="${LDFLAGS}" _LDFLAGS+=" -lmilter" _LDFLAGS+=" -lpthread" make -f Makefile.linux \ V=1 \ -j${RPM_BUILD_NCPUS} \ CFLAGS="${_CFLAGS}" \ LDFLAGS="${_LDFLAGS}" %install echo '##### STARTING INSTALL #####' cd %{_builddir}/%{extractdir0} # mkdir -p ${RPM_BUILD_ROOT}/%%{_mrgx_install_dir} # pushd . # cd ${RPM_BUILD_ROOT}/%%{_mrgx_install_dir} # mkdir -p %%{_mrgx_bin_dir} # mkdir -p %%{_mrgx_man_dir}/man8 # popd mkdir -p ${RPM_BUILD_ROOT}/%{_mrgx_install_dir}/%{_mrgx_bin_dir} install --preserve-timestamps --mode=0755 --verbose \ milter-regex \ ${RPM_BUILD_ROOT}/%{_mrgx_install_dir}/%{_mrgx_bin_dir}/ mkdir -p ${RPM_BUILD_ROOT}/%{_mrgx_install_dir}/%{_mrgx_man_dir}/man8 install -D --preserve-timestamps --mode=0644 --verbose \ milter-regex.8 \ ${RPM_BUILD_ROOT}/%{_mrgx_install_dir}/%{_mrgx_man_dir}/man8/ sed -i \ -e 's|__MRGX_EXEC__|%{_mrgx_install_dir}/bin/milter-regex|g' \ -e 's|__MRGX_USR__|%{_mrgx_usr}|g' \ -e 's|__MRGX_GRP__|%{_mrgx_grp}|g' \ -e 's|__MRGX_CONFDIR__|%{_mrgx_conf_dir}|g' \ -e 's|__MRGX_RUNDIR__|%{_mrgx_run_dir}|g' \ -e 's|__MRGX_PIDFILE__|%{_mrgx_pkgnm}.pid|g' \ -e 's|__MRGX_SOCKNM__|%{_mrgx_pkgnm}.sock|g' \ %{SOURCE100} install -D --preserve-timestamps --mode=644 --verbose \ %{SOURCE100} \ ${RPM_BUILD_ROOT}/%{_mrgx_unit_dir}/%{_mrgx_unitnm}.service install -d --mode=0775 ${RPM_BUILD_ROOT}/%{_mrgx_log_dir} %pre %post %systemd_post %{_mrgx_unitnm}.service %preun %systemd_preun %{_mrgx_unitnm}.service %postun %systemd_postun_with_restart %{_mrgx_unitnm}.service %files # http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html %license LICENSE %dir %{_mrgx_install_dir} %{_mrgx_install_dir}/* %attr(0644,root,root) %{_mrgx_unit_dir}/%{_mrgx_unitnm}.service %dir %attr(0775,%{_mrgx_usr},%{_mrgx_grp}) %{_mrgx_log_dir} %changelog * Wed Nov 13 2024 pgnd _ - bump 1731532934