# 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://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 %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.*$ # RHEL8 rpmbuild and /usr/lib/.build-id # https://access.redhat.com/discussions/5045161 %global _build_id_links none # %%bcond_with XXX : opt build with XXX; default, without # %%bcond_without XXX : opt build without XXX; default, with # FANGFRISCH # https://github.com/rseichter/fangfrisch # https://rseichter.github.io/fangfrisch/ # https://pypi.org/project/fangfrisch/ %global _ff_name fangfrisch %global _ff_pkgnm fangfrisch %global _ff_unitnm fangfrisch %global _ff_comment Fangfrisch Download unofficial clamav virus definition files %global _ff_descrip %{expand: %{_ff_comment}.} # https://spdx.org/licenses/GPL-3.0-only.html %global _ff_license GPL-3.0-only %global _ff_usr clamupdate %global _ff_grp clamav %global _ff_bin_dir_r bin %global _ff_conf fangfrisch.conf %global _ff_conf_dir /usr/local/etc/clamav %global _ff_db db.sqlite %global _ff_init_sh fangfrisch-init.sh %global _ff_install_dir /usr/local/postfix-pgnd/fangfrisch %global _ff_script_dir_r scripts %global _ff_unit_dir /etc/systemd/system %global _ff_work_dir /var/lib/fangfrisch # https://docs.fedoraproject.org/en-US/packaging-guidelines/SourceURL/ %global _ff_scm_repo rseichter/fangfrisch %global _ff_scm_branch master %global _ff_scm_repo_esc %( echo %{_ff_scm_repo} | sed 's|_|-|g' | sed 's|/|%2F|g') %global _ff_scm_repo_norm %( echo %{_ff_scm_repo} | sed 's|_|-|g' | sed 's|/|-|g' ) %global _ff_scm_branch_norm %( echo %{_ff_scm_branch} | sed 's|_|-|g' | sed 's|/|-|g' ) %global _ff_scm_host https://github.com %global _ff_scm_host_api https://api.github.com/repos %global _ff_scm_url %{_ff_scm_host}/%{_ff_scm_repo} %global _ff_scm_tarball %{_ff_scm_host_api}/%{_ff_scm_repo}/tarball/%{commit0} # !!NOTE!! GH API tarball extracts to: %global _ff_scm_extract_dir %{_ff_scm_repo_norm}-%{shortcommit0} %global forgeurl0 %{_ff_scm_url} %global commit0 %( git ls-remote %{forgeurl0} | grep /%{_ff_scm_branch}$ | cut -f1 ) %global shortcommit0 %( c=%{commit0}; echo ${c} | head -c 7 ) %global forgesource0 %{_ff_scm_tarball} %global extractdir0 %{_ff_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: %{_ff_pkgnm} Epoch: 3 # https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/ Version: %{scm0}_%( echo %{_ff_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: %{_ff_comment} License: %{_ff_license} URL: %{forgeurl0} Source0: %{forgesource0} Source100: %{_ff_unitnm}.service Source101: %{_ff_unitnm}.timer Source200: %{_ff_init_sh} # 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-units %{?systemd_requires} Requires: findutils Requires: logrotate Requires: rsyslog Requires: clamav-current Requires(pre): user(clamav) Requires(pre): group(clamav) Provides: fangfrisch = %{_same_evr} Obsoletes: fangfrisch < %{_same_evr} Recommends: postfix-current %description %{_ff_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 %{_ff_pkgnm} source %{_ff_pkgnm}/bin/activate echo '##### VERIFY VENV #####' pip3 -V # pip 23.2.1 from /builddir/build/BUILD/fangfrisch-5cb2fbb1a5eb24946f5c999af88b87e1a844676d/fangfrisch/lib64/python3.12/site-packages/pip (python 3.12) echo '##### PIP BUILD/INSTALL #####' pip3 -q install --upgrade pip wheel pip3 -q install fangfrisch pip3 -q cache purge deactivate %install echo '##### STARTING INSTALL #####' cd %{_builddir}/%{extractdir0} # 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 sed -i \ "1s|.*|#\!%{_ff_install_dir}/bin/python3|" \ $(grep -rlni '^#!.*python3' %{_ff_pkgnm}) mkdir -p ${RPM_BUILD_ROOT}/$(dirname %{_ff_install_dir}) cp -prT \ %{_ff_pkgnm} \ ${RPM_BUILD_ROOT}/%{_ff_install_dir} # mkdir -p ${RPM_BUILD_ROOT}/%%{_ff_unit_dir} sed -i \ -e 's|__FF_EXEC__|%{_ff_install_dir}/%{_ff_bin_dir_r}/fangfrisch|g' \ -e 's|__FF_WORKDIR__|%{_ff_work_dir}|g' \ -e 's|__FF_CONF__|%{_ff_conf_dir}/%{_ff_conf}|g' \ -e 's|__FF_USR__|%{_ff_usr}|g' \ -e 's|__FF_GRP__|%{_ff_grp}|g' \ -e 's|__FF_DB__|%{_ff_work_dir}/%{_ff_db}|g' \ -e 's|__FF_INITSH__|%{_ff_install_dir}/%{_ff_script_dir_r}/%{_ff_init_sh}|g' \ %{SOURCE100} install -D --preserve-timestamps --mode=0644 --verbose \ %{SOURCE100} \ ${RPM_BUILD_ROOT}/%{_ff_unit_dir}/%{_ff_unitnm}.service install -D --preserve-timestamps --mode=0644 --verbose \ %{SOURCE101} \ ${RPM_BUILD_ROOT}/%{_ff_unit_dir}/%{_ff_unitnm}.timer sed -i \ -e 's|__FF_EXEC__|%{_ff_install_dir}/%{_ff_bin_dir_r}/fangfrisch|g' \ -e 's|__FF_WORKDIR__|%{_ff_work_dir}|g' \ -e 's|__FF_CONF__|%{_ff_conf_dir}/%{_ff_conf}|g' \ -e 's|__FF_USR__|%{_ff_usr}|g' \ -e 's|__FF_DB__|%{_ff_work_dir}/%{_ff_db}|g' \ %{SOURCE200} install -D --preserve-timestamps --mode=0750 --verbose \ %{SOURCE200} \ ${RPM_BUILD_ROOT}/%{_ff_install_dir}/%{_ff_script_dir_r}/%{_ff_init_sh} # REMOVE git artifacts from pkging find ${RPM_BUILD_ROOT} -name '.gitignore' -type f -exec rm -f {} + %pre %post -e %systemd_post %{_ff_unitnm}.timer %preun %systemd_preun %{_ff_unitnm}.timer %postun %systemd_postun_with_restart %{_ff_unitnm}.timer %files # http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html %dir %{_ff_install_dir} %{_ff_install_dir}/* %attr(0644,root,root) %{_ff_unit_dir}/%{_ff_unitnm}.* %attr(0750,%{_ff_usr},%{_ff_grp}) %{_ff_install_dir}/%{_ff_script_dir_r}/%{_ff_init_sh} %changelog * Wed Sep 18 2024 pgnd _ - bump 1726672571