# PYTHON # https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/ # https://docs.fedoraproject.org/en-US/packaging-guidelines/Python_Appendix/ # https://python-rpm-porting.readthedocs.io/en/latest/application-modules.html # https://rpmbuildtut.wordpress.com/python-setuptools/ # https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/installing_and_using_dynamic_programming_languages/assembly_packaging-python-3-rpms_installing-and-using-dynamic-programming-languages # 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 # DKIMPY MILTER # https://launchpad.net/dkimpy-milter # https://git.launchpad.net/dkimpy-milter # https://pypi.org/project/dkimpy/ # https://salsa.debian.org/python-team/packages/dkimpy-milter %global _dkm_name dkimpy-milter %global _dkm_pkgnm dkimpy-milter %global _dkm_unitnm dkimpy-milter %global _dkm_comment DKIM signing & verification milter %global _dkm_descrip %{expand: %{_dkm_comment}.} # https://spdx.org/licenses/GPL-2.0-or-later.html %global _dkm_license GPL-2.0-or-later %global _dkm_usr dkimpy-milter %global _dkm_grp dkimpy-milter %global _dkm_grp_milter postfix-milter %global _dkm_conf_dir /usr/local/etc/dkimpy-milter %global _dkm_conf_file %{_dkm_pkgnm}.conf %global _dkm_env_file %{_dkm_pkgnm}.env %global _dkm_install_dir /usr/local/postfix-pgnd/dkimpy-milter %global _dkm_unit_dir /etc/systemd/system %global _dkm_run_dir /run/%{_dkm_pkgnm} %global _dkm_log_dir /var/log/%{_dkm_pkgnm} %global _dkm_pid_file %{_dkm_pkgnm}.pid %global _dkm_socket %{_dkm_pkgnm}.sock # https://docs.fedoraproject.org/en-US/packaging-guidelines/SourceURL/ %global _dkm0_ORIG_repo https://git.launchpad.net/dkimpy-milter # mirrored @: https://codeberg.org/pgnd/dkimpy-milter-UPSTREAM-MIRROR.git %global _dkm0_scm_host https://codeberg.org %global _dkm0_scm_repo pgnd/dkimpy-milter-UPSTREAM-MIRROR %global _dkm0_scm_branch stable1.2 %global _dkm0_scm_url %{_dkm0_scm_host}/%{_dkm0_scm_repo} %global _dkm0_commit %( git ls-remote %{_dkm0_scm_url} | grep /%{_dkm0_scm_branch}$ | cut -f1 ) %global _dkm0_shortcommit %( c=%{_dkm0_commit}; echo ${c} | head -c 7 ) %global _dkm0_scm_repo_esc %( echo %{_dkm0_scm_repo} | sed 's|_|-|g' | sed 's|/|%2F|g') %global _dkm0_scm_repo_norm %( echo %{_dkm0_scm_repo} | sed 's|_|-|g' | sed 's|/|-|g' ) %global _dkm0_scm_branch_norm %( echo %{_dkm0_scm_branch} | sed 's|_|-|g' | sed 's|/|-|g' ) # CODEBERG/FORGEJO API: # https://codeberg.org/api/swagger#/repository/repoGetArchive %global _dkm0_scm_host_api %{_dkm0_scm_host}/api/v1/repos %global _dkm0_scm_tarball %{_dkm0_scm_host_api}/%{_dkm0_scm_repo}/archive/%{_dkm0_commit}.tar.gz %global _dkm0_scm_extract_dir %( basename %{_dkm0_scm_repo} | tr '[:upper:]' '[:lower:]' | sed 's|_|-|g') %global forgeurl0 %{_dkm0_scm_url} %global commit0 %{_dkm0_commit} %global shortcommit0 %{_dkm0_shortcommit} %global forgesource0 %{_dkm0_scm_tarball} %global extractdir0 %{_dkm0_scm_extract_dir} %global forgesetupargs0 -T -D -b 0 -n %{extractdir0} %forgemeta -i -a -v %global dist %{_dist} # Vendor Pinning Vendor: %{_owner} # NEVRA (n-e:v-r.a) Name: %{_dkm_pkgnm} Epoch: 3 # https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/ Version: %{scm0}_%( echo %{_dkm0_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: %{_dkm_comment} License: %{_dkm_license} URL: %{forgeurl0} Source0: %{forgesource0} Source100: %{_dkm_unitnm}.service Source101: %{_dkm_pkgnm}.conf # https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets # https://docs.pagure.org/packaging-guidelines/Packaging:Scriptlets.html BuildRequires: findutils BuildRequires: gcc BuildRequires: python3 BuildRequires: python3-devel BuildRequires: sendmail-milter-devel BuildRequires: zlib-devel BuildRequires: systemd BuildRequires: systemd-rpm-macros %{?systemd_requires} Requires: findutils Requires: logrotate Requires: rsyslog Requires(pre): user(dkimpy-milter) Requires(pre): group(postfix-milter) Provides: dkimpy-milter = %{_same_evr} Obsoletes: dkimpy-milter < %{_same_evr} Recommends: postfix-current %description %{_dkm_descrip} %prep echo '##### STARTING PREP #####' %forgesetup -a %build echo '##### STARTING BUILD #####' cd %{_builddir}/%{extractdir0} # https://github.com/kevinconway/rpmvenv # https://stackoverflow.com/questions/60959081/python-script-in-systemd-virtual-environment-or-real-environment python3 -m venv --clear --copies %{_dkm_pkgnm} source %{_dkm_pkgnm}/bin/activate echo '##### VERIFY VENV #####' pip3 -V # pip 23.2.1 from /builddir/build/BUILD/dkimpy-milter-UPSTREAM-MIRROR-5cb2fbb1a5eb24946f5c999af88b87e1a844676d-5cb2fbb1a5eb24946f5c999af88b87e1a844676d/dkimpy-milter/lib64/python3.12/site-packages/pip (python 3.12) echo '##### PIP BUILD/INSTALL #####' pip3 -q install --upgrade pip wheel pip3 -q install dkimpy dkimpy-milter pip3 -q cache purge deactivate %install echo '##### STARTING INSTALL #####' cd %{_builddir}/%{extractdir0} mkdir -p ${RPM_BUILD_ROOT}/$(dirname %{_dkm_install_dir}) mkdir -p ${RPM_BUILD_ROOT}/%{_dkm_log_dir} mkdir -p ${RPM_BUILD_ROOT}/%{_dkm_conf_dir} # mkdir -p ${RPM_BUILD_ROOT}/%%{_dkm_unit_dir} sed -i \ -e 's|__DKM_EXEC__|%{_dkm_install_dir}/bin/dkimpy-milter|g' \ -e 's|__DKM_USR__|%{_dkm_usr}|g' \ -e 's|__DKM_GRP__|%{_dkm_grp}|g' \ -e 's|__DKM_GRP_MILTER__|%{_dkm_grp_milter}|g' \ -e 's|__DKM_CONFDIR__|%{_dkm_conf_dir}|g' \ -e 's|__DKM_CONFFILE__|%{_dkm_conf_file}|g' \ -e 's|__DKM_ENVFILE__|%{_dkm_env_file}|g' \ -e 's|__DKM_LOGDIR__|%{_dkm_log_dir}|g' \ -e 's|__DKM_RUNDIR__|%{_dkm_run_dir}|g' \ -e 's|__DKM_PIDFILE__|%{_dkm_pid_file}|g' \ -e 's|__DKM_SOCKET__|%{_dkm_socket}|g' \ %{SOURCE100} %{SOURCE101} # FIX venv SHEBANGS # https://docs.fedoraproject.org/en-US/packaging-guidelines/#_shebang_lines # Deploying python application internally using venv and rpm # https://stackoverflow.com/questions/58088468/deploying-python-application-internally-using-venv-and-rpm grep -rlni \ --binary-files=without-match \ '^#!.*python3' %{_dkm_pkgnm} \ | xargs -i@ sed -i "1s|.*|#\!%{_dkm_install_dir}/bin/python3|" @ echo '##### WHATS HERE #####' grep -rlni \ --binary-files=without-match \ "exec.*%{extractdir0}" %{_dkm_pkgnm} \ | xargs -i@ sed -i "s|/builddir/build/BUILD/%( basename %{_dkm0_scm_repo} | tr '[:upper:]' '[:lower:]' )/%{_dkm_pkgnm}|%{_dkm_install_dir}|g" @ # | xargs -i@ sed -i "s|/builddir/build/BUILD/%%( basename %%{_dkm0_scm_repo} | tr '[:upper:]' '[:lower:]' )/%%{_dkm_pkgnm}/bin/python3|%%{_dkm_install_dir}/bin/python3|g" @ cp -prT \ %{_dkm_pkgnm} \ ${RPM_BUILD_ROOT}/%{_dkm_install_dir} install -D -p -m 644 \ %{SOURCE100} \ ${RPM_BUILD_ROOT}/%{_dkm_unit_dir}/%{_dkm_unitnm}.service install -D -p -m 664 \ %{SOURCE101} \ ${RPM_BUILD_ROOT}/%{_dkm_conf_dir}/%{_dkm_conf_file} # REMOVE git artifacts from pkging find ${RPM_BUILD_ROOT} -name '.gitignore' -type f -exec rm -f {} + %pre %post -e %systemd_post %{_dkm_unitnm}.service %preun %systemd_preun %{_dkm_unitnm}.service %postun %systemd_postun_with_restart %{_dkm_unitnm}.service %files # http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html %dir %{_dkm_install_dir} %{_dkm_install_dir}/* %attr(0644,root,root) %{_dkm_unit_dir}/%{_dkm_unitnm}.service %dir %attr(0775,%{_dkm_usr},%{_dkm_grp_milter}) %{_dkm_log_dir} %attr(0664,%{_dkm_usr},%{_dkm_grp}) %{_dkm_conf_dir}/%{_dkm_conf_file} %changelog * Wed Nov 13 2024 pgnd _ - bump 1731532935