# RUST / CARGO # https://docs.fedoraproject.org/en-US/packaging-guidelines/Rust/ # https://doc.rust-lang.org/nightly/cargo/reference/registry-index.html # 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.*$ # %%global _build_id_links none # %%bcond_with XXX : opt build with XXX; default, without # %%bcond_without XXX : opt build without XXX; default, with # SPAMASSASSIN MILTER # https://codeberg.org/glts/spamassassin-milter # XXXX https://gitlab.com/glts/spamassassin-milter # https://crates.io/crates/spamassassin-milter %global _spm_name spamassassin-milter %global _spm_pkgnm spamassassin-milter %global _spm_unitnm spamassassin-milter %global _spm_comment Lightweight SpamAssassin milter %global _spm_descrip %{expand: %{_spm_comment}.} # https://spdx.org/licenses/GPL-3.0-or-later.html %global _spm_license GPL-3.0-or-later %global _spm_usr spamassassin-milter %global _spm_grp postfix-milter %global _sa_run_dir /run/spamd %global _sa_spamc_bin_r spamc %global _sa_socket spamd.sock %global _sa_conf_dir /usr/local/etc/spamassassin %global _spm_install_dir /usr/local/postfix-pgnd/spamassassin-milter %global _spm_unit_dir /etc/systemd/system %global _spm_pid_file %{_spm_pkgnm}.pid %global _spm_run_dir /run/%{_spm_pkgnm} %global _spm_socket %{_spm_pkgnm}.sock # https://docs.fedoraproject.org/en-US/packaging-guidelines/SourceURL/ # https://codeberg.org/glts/spamassassin-milter %global _spm0_scm_host https://codeberg.org %global _spm0_scm_repo glts/spamassassin-milter %global _spm0_scm_branch main %global _spm0_scm_url %{_spm0_scm_host}/%{_spm0_scm_repo} %global _spm0_commit %( git ls-remote %{_spm0_scm_url} | grep /%{_spm0_scm_branch}$ | cut -f1 ) %global _spm0_shortcommit %( c=%{_spm0_commit}; echo ${c} | head -c 7 ) %global _spm0_scm_repo_esc %( echo %{_spm0_scm_repo} | sed 's|_|-|g' | sed 's|/|%2F|g') %global _spm0_scm_repo_norm %( echo %{_spm0_scm_repo} | sed 's|_|-|g' | sed 's|/|-|g' ) %global _spm0_scm_branch_norm %( echo %{_spm0_scm_branch} | sed 's|_|-|g' | sed 's|/|-|g' ) # CODEBERG/FORGEJO API: # https://codeberg.org/api/swagger#/repository/repoGetArchive %global _spm0_scm_host_api %{_spm0_scm_host}/api/v1/repos %global _spm0_scm_tarball %{_spm0_scm_host_api}/%{_spm0_scm_repo}/archive/%{_spm0_commit}.tar.gz %global _spm0_scm_extract_dir %( basename %{_spm0_scm_repo} | tr '[:upper:]' '[:lower:]' | sed 's|_|-|g') %global forgeurl0 %{_spm0_scm_url} %global commit0 %{_spm0_commit} %global shortcommit0 %{_spm0_shortcommit} %global forgesource0 %{_spm0_scm_tarball} %global extractdir0 %{_spm0_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: %{_spm_pkgnm} Epoch: 3 # https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/ Version: %{scm0}_%( echo %{_spm0_scm_branch} | 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: %{_spm_comment} License: %{_spm_license} URL: %{forgeurl0} Source0: %{forgesource0} Source100: %{_spm_unitnm}.service # https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets # https://docs.pagure.org/packaging-guidelines/Packaging:Scriptlets.html BuildRequires: cargo BuildRequires: cargo-rpm-macros >= 24 BuildRequires: git BuildRequires: rust BuildRequires: systemd BuildRequires: systemd-rpm-macros %{?systemd_requires} Requires(pre): user(spamassassin-milter) Requires(pre): group(postfix-milter) Requires: spamassassin Provides: spamassassin-milter = %{_same_evr} Obsoletes: spamassassin-milter < %{_same_evr} Recommends: postfix-current %description %{_spm_descrip} %prep echo '##### STARTING PREP #####' %forgesetup -a %build echo '##### STARTING BUILD #####' cd %{_builddir}/%{extractdir0} # SpamAssassin Milter uses the `spamc` program for communication with SpamAssassin # server. By default, `/usr/bin/spamc` is used as the executable. To override # this, set the environment variable `SPAMASSASSIN_MILTER_SPAMC` to the desired # path when building the application. SPAMASSASSIN_MILTER_SPAMC='%{_sa_spamc_bin_r}' \ PKG_CONFIG_PATH=. CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 RUSTFLAGS='%{build_rustflags}' \ cargo build -j${RPM_BUILD_NCPUS} -Z avoid-dev-deps %install echo '##### STARTING INSTALL #####' cd %{_builddir}/%{extractdir0} SPAMASSASSIN_MILTER_SPAMC='%{_sa_spamc_bin_r}' \ PKG_CONFIG_PATH=. CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 RUSTFLAGS='%{build_rustflags}' \ cargo install --root ${RPM_BUILD_ROOT}/%{_spm_install_dir} \ --locked -j${RPM_BUILD_NCPUS} -Z avoid-dev-deps --no-track --path . rm -f ${RPM_BUILD_ROOT}/%{_spm_install_dir}/.crates.toml rm -f ${RPM_BUILD_ROOT}/%{_spm_install_dir}/.crates2.json sed -i \ -e 's|__SPM_EXEC__|%{_spm_install_dir}/bin/spamassassin-milter|g' \ -e 's|__SPM_USR__|%{_spm_usr}|g' \ -e 's|__SPM_GRP__|%{_spm_grp}|g' \ -e 's|__SPM_RUNDIR__|%{_spm_run_dir}|g' \ -e 's|__SPM_PIDFILE__|%{_spm_pid_file}|g' \ -e 's|__SPM_SOCKET__|%{_spm_socket}|g' \ -e 's|__SA_RUNDIR__|%{_sa_run_dir}|g' \ -e 's|__SA_SOCKET__|%{_sa_socket}|g' \ -e 's|__SA_CONFDIR__|%{_sa_conf_dir}|g' \ %{SOURCE100} mkdir -p ${RPM_BUILD_ROOT}/%{_spm_unit_dir} install -D -p -m 644 \ %{SOURCE100} \ ${RPM_BUILD_ROOT}/%{_spm_unit_dir}/%{_spm_unitnm}.service %pre %post %systemd_post %{_spm_unitnm}.service %preun %systemd_preun %{_spm_unitnm}.service %postun %systemd_postun_with_restart %{_spm_unitnm}.service %if %{with check} %check PKG_CONFIG_PATH=. CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 RUSTFLAGS='%{build_rustflags}' \ cargo test -j${RPM_BUILD_NCPUS} -Z avoid-dev-deps --no-fail-fast %endif %files # http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html %doc %license %dir %{_spm_install_dir} %{_spm_install_dir}/* %attr(0644,root,root) %{_spm_unit_dir}/%{_spm_pkgnm}.service %changelog * Wed Nov 13 2024 pgnd _ - bump 1731532934