# RUST / CARGO # https://docs.fedoraproject.org/en-US/packaging-guidelines/Rust/ # https://doc.rust-lang.org/nightly/cargo/reference/registry-index.html # https://docs.fedoraproject.org/en-US/quick-docs/publish-rpm-on-copr # 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.*$ # %%global _build_id_links none # %%bcond_with XXX : opt build with XXX; default, without # %%bcond_without XXX : opt build without XXX; default, with # CLAMAV # https://www.clamav.net/ # https://github.com/Cisco-Talos/clamav # https://docs.clamav.net/manual/Installing/Installing-from-source-Unix.html#redhat--centos--fedora # Clam AntiVirus Milter Setup and Debugging # http://novosial.org/clamav/clamav-milter/index.html %global _clam_name clamav %global _clam_pkgnm clamav-current %global _clam_pkgnm_daemon clamav-daemon %global _clam_pkgnm_fresh clamav-freshclam %global _clam_pkgnm_milter clamav-milter %global _clam_unitnm_daemon clamav-daemon %global _clam_unitnm_fresh clamav-freshclam %global _clam_unitnm_milter clamav-milter %global _clam_comment Clam Antivirus (Current Upstream Release) %global _clam_descrip %{expand: %{_clam_comment}.} # https://spdx.org/licenses/GPL-2.0-only.html %global _clam_license GPL-2.0-only %global _clam_usr_daemon clamav %global _clam_grp_daemon clamav %global _clam_usr_fresh %{_clam_usr_update} %global _clam_grp_fresh %{_clam_grp_daemon} %global _clam_usr_milter clamav-milter %global _clam_grp_milter clamav-milter %global _clam_grp_milter_pfx postfix-milter %global _clam_usr_update clamupdate # https://docs.fedoraproject.org/en-US/packaging-guidelines/RPMMacros/#macros_installation %global _clam_bin_dir_r bin %global _clam_build_dir_r clam-build %global _clam_conf_dir /usr/local/etc/clamav %global _clam_conf_dir_milter /usr/local/etc/clamav-milter %global _clam_conf_file clamd.conf %global _clam_conf_file_fresh freshclam.conf %global _clam_conf_file_milter clamav-milter.conf %global _clam_db_dir /var/lib/clamav %global _clam_install_dir /usr/local/postfix-pgnd/clamav-current %global _clam_lib_dir %{_clam_install_dir}/lib64 %global _clam_libexec_dir_r libexec %global _clam_log_dir /var/log/clamav %global _clam_log_dir_milter /var/log/clamav-milter %global _clam_pid_file %{_clam_pkgnm_daemon}.pid %global _clam_pid_file_fresh %{_clam_pkgnm_fresh}.pid %global _clam_pid_file_milter %{_clam_pkgnm_milter}.pid %global _clam_run_dir /run/clamav %global _clam_run_dir_milter /run/clamav-milter #!!! https://fedoraproject.org/wiki/Changes/Unify_bin_and_sbin %global _clam_sbin_dir_r sbin %global _clam_unit_dir /etc/systemd/system %global _clam_exec %{_clam_install_dir}/%{_clam_sbin_dir_r}/clamd %global _clam_exec_fresh %{_clam_install_dir}/%{_clam_bin_dir_r}/freshclam %global _clam_exec_milter %{_clam_install_dir}/%{_clam_sbin_dir_r}/clamav-milter %global _clam_c /usr/bin/gcc %global _clam_cxx /usr/bin/g++ %global _clam_linker /usr/bin/ld.bfd %global _clam_make_type ninja # https://docs.fedoraproject.org/en-US/packaging-guidelines/SourceURL/ # https://github.com/Cisco-Talos/clamav # https://github.com/Cisco-Talos/clamav/tags %global _clam_scm_repo Cisco-Talos/clamav %global _clam_scm_branch clamav-1.4.1 %global _clam_scm_repo_esc %( echo %{_clam_scm_repo} | sed 's|_|-|g' | sed 's|/|%2F|g') %global _clam_scm_repo_norm %( echo %{_clam_scm_repo} | sed 's|_|-|g' | sed 's|/|-|g' ) %global _clam_scm_branch_norm %( echo %{_clam_scm_branch} | sed 's|_|-|g' | sed 's|/|-|g' ) %global _clam_scm_host https://github.com %global _clam_scm_host_api https://api.github.com/repos %global _clam_scm_url %{_clam_scm_host}/%{_clam_scm_repo} %global _clam_scm_tarball %{_clam_scm_host_api}/%{_clam_scm_repo}/tarball/%{commit0} # !!NOTE!! GH API tarball extracts to: %global _clam_scm_extract_dir %{_clam_scm_repo_norm}-%{shortcommit0} %global forgeurl0 %{_clam_scm_url} %global commit0 %( git ls-remote %{forgeurl0} | grep /%{_clam_scm_branch}$ | cut -f1 ) %global shortcommit0 %( c=%{commit0}; echo ${c} | head -c 7 ) %global forgesource0 %{_clam_scm_tarball} %global extractdir0 %{_clam_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: %{_clam_pkgnm} Epoch: 3 # https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/ Version: %{scm0}_%( echo %{_clam_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: %{_clam_comment} License: %{_clam_license} URL: %{forgeurl0} Source0: %{forgesource0} Source100: %{_clam_unitnm_daemon}.service Source101: %{_clam_unitnm_daemon}.target Source200: %{_clam_unitnm_fresh}.service Source201: %{_clam_unitnm_fresh}.target Source300: %{_clam_unitnm_milter}.service Source301: %{_clam_unitnm_milter}.target # https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets # https://docs.pagure.org/packaging-guidelines/Packaging:Scriptlets.html BuildRequires: bindgen BuildRequires: cbindgen BuildRequires: coreutils BuildRequires: git BuildRequires: cmake BuildRequires: cmake-filesystem BuildRequires: cmake-rpm-macros BuildRequires: findutils BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: make BuildRequires: ninja-build BuildRequires: pcre2-devel BuildRequires: pigz BuildRequires: pkgconfig(bzip2) BuildRequires: pkgconfig(check) BuildRequires: pkgconfig(json-c) BuildRequires: pkgconfig(libcurl) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(openssl) BuildRequires: pkgconfig(zlib) BuildRequires: pkgconfig(ncurses++) BuildRequires: pkgconfig(ncursesw) BuildRequires: python3 BuildRequires: python3-cmake-build-extension BuildRequires: python3-pip BuildRequires: python3-pytest BuildRequires: sendmail-devel BuildRequires: valgrind BuildRequires: systemd BuildRequires: systemd-rpm-macros %{?systemd_requires} Provides: clamav = %{_same_evr} Provides: clamav-daemon = %{_same_evr} Provides: clamd = %{_same_evr} Provides: clamav-milter = %{_same_evr} Provides: clamav-freshclam = %{_same_evr} Provides: clamav-filesystem = %{_same_evr} Obsoletes: clamav < %{_same_evr} Obsoletes: clamav-daemon < %{_same_evr} Obsoletes: clamd < %{_same_evr} Obsoletes: clamav-milter < %{_same_evr} Obsoletes: clamav-freshclam < %{_same_evr} Obsoletes: clamav-filesystem < %{_same_evr} Requires(pre): user(clamav) Requires(pre): group(clamav) Requires(pre): group(postfix-milter) Recommends: postfix-current %description %{_clam_descrip} %prep echo '##### STARTING PREP #####' %forgesetup -a # RUSTUP # https://rustup.rs/ # https://rust-lang.github.io/rustup/ # https://github.com/rust-lang/rustup # https://idroot.us/install-rust-fedora-38/ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y source $HOME/.cargo/env rustc --version # rustc 1.76.0 (07dca489a 2024-02-04) rustup toolchain install stable %build echo '##### STARTING BUILD #####' # https://docs.clamav.net/manual/Installing/Installing-from-source-Unix.html#build-clamav cd %{_builddir} mkdir %{_clam_build_dir_r} echo '##### CLAMAV SOURCE FLAGS PREP #####' BDO="" BDO+=" -Wno-dev" BDO+=" -DENABLE_WERROR=OFF" BDO+=" -DENABLE_ALL_THE_WARNINGS=OFF" #BDO+=" -DNDEBUG" #BDO+=" -DCMAKE_VERBOSE_MAKEFILE=1" _this_BUILD_DEBUG_OPTS=${BDO} export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS # CMAKE_BUILD_TYPE-STRINGS:INTERNAL=None;Debug;Release;MinSizeRel;RelWithDebInfo _this_CMAKE_BUILD_TYPE="None" #_this_CMAKE_BUILD_TYPE="Release" #_this_CMAKE_BUILD_TYPE="Debug" %if "%{_clam_make_type}" == "ninja" _this_MAKEFILE_TYPE="Ninja" %else _this_MAKEFILE_TYPE="Unix Makefiles" %endif echo '##### CLAMAV CMAKE DEFAULT CONFIG #####' _log_level="ERROR" cmake \ --log-level=${_log_level} \ -LAH \ -S "%{extractdir0}" \ -B "%{_clam_build_dir_r}" echo '##### CLAMAV CMAKE CONFIG #####' # https://github.com/Cisco-Talos/clamav/blob/main/INSTALL.md # --log-level= _log_level="ERROR" RUSTC_BOOTSTRAP=1 \ cmake \ --fresh \ --log-level="${_log_level}" \ -DCMAKE_BUILD_TYPE="${_this_CMAKE_BUILD_TYPE}" \ -S "%{extractdir0}" \ -B "%{_clam_build_dir_r}" \ -G "${_this_MAKEFILE_TYPE}" \ ${_this_BUILD_DEBUG_OPTS} \ -DCMAKE_C_COMPILER="%{_clam_c}" \ -DCMAKE_CXX_COMPILER="%{_clam_cxx}" \ -DCMAKE_LINKER="%{_clam_linker}" \ -DCMAKE_C_FLAGS="${CFLAGS}" \ -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ -DBUILD_SHARED_LIBS=1 \ -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \ -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \ -DCMAKE_SKIP_INSTALL_RPATH=0 \ -DCMAKE_SKIP_RPATH=0 \ -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=1 \ -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_unicode_ci \ -DWITH_EXTRA_CHARSETS=all \ -DCMAKE_POLICY_DEFAULT_CMP0056=NEW \ -DCMAKE_INSTALL_PREFIX="%{_clam_install_dir}" \ -DAPP_CONFIG_DIRECTORY="etc" \ -DBYTECODE_RUNTIME="interpreter" \ -DCLAMAV_USER=%{_clam_usr_daemon} -DCLAMAV_GROUP=%{_clam_grp_daemon} \ -DDATABASE_DIRECTORY="%{_clam_db_dir}" \ -DENABLE_APP=ON \ -DENABLE_CLAMONACC=ON \ -DENABLE_MILTER=ON \ -DENABLE_JSON_SHARED=OFF \ -DJSONC_INCLUDE_DIR="/usr/include/json-c" \ -DJSONC_LIBRARY="/usr/lib64/libjson-c.so" \ -DENABLE_SHARED_LIB=ON -DENABLE_STATIC_LIB=OFF \ -DENABLE_SYSTEMD=ON \ -DSYSTEMD_UNIT_DIR="etc" \ -DENABLE_TESTS=OFF \ -DENABLE_UNRAR=OFF \ -DMAINTAINER_MODE=OFF # echo '##### RESULT CMAKECACHE #####' # cat "%%{_clam_build_dir_r}/CMakeCache.txt" echo '##### CLAMAV CMAKE BUILD #####' %if "%{_clam_make_type}" == "ninja" _this_verbosity="--quiet" #_this_verbosity="--verbose" ninja -C "%{_clam_build_dir_r}" -j${RPM_BUILD_NCPUS} ${_this_verbosity} %else cmake --build "%{_clam_build_dir_r}" -j${RPM_BUILD_NCPUS} --verbose %endif %install echo '##### STARTING INSTALL #####' cd %{_builddir} ## modify rpmbuild rpath check criteria # cref: /usr/lib/rpm/check-rpaths-worker # _this_QA_RPATHS=$(( 0x0001|0x0002|0x0004|0x0008|0x0010|0x0020 )) # allow 'invalid' RPATHs _this_QA_RPATHS=$(( 0x0002 )) export _this_QA_RPATHS export QA_RPATHS=${_this_QA_RPATHS} echo %{_builddir} echo ${RPM_BUILD_ROOT} mkdir -p ${RPM_BUILD_ROOT}/%{_clam_db_dir} mkdir -p ${RPM_BUILD_ROOT}/%{_clam_log_dir} mkdir -p ${RPM_BUILD_ROOT}/%{_clam_log_dir_milter} mkdir -p ${RPM_BUILD_ROOT}/%{_clam_run_dir} mkdir -p ${RPM_BUILD_ROOT}/%{_clam_run_dir_milter} mkdir -p ${RPM_BUILD_ROOT}/%{_clam_unit_dir} %if "%{_clam_make_type}" == "ninja" #_this_verbosity="--quiet" _this_verbosity="--verbose" DESTDIR="${RPM_BUILD_ROOT}" ninja install -C "%{_clam_build_dir_r}" ${_this_verbosity} %else _this_verbosity="" _this_verbosity="--verbose" DESTDIR="${RPM_BUILD_ROOT}" cmake --install "%{_clam_build_dir_r}" ${_this_verbosity} %endif # GENERATE .service FILES sed -i \ -e 's|__CLAM_CONFDIR__|%{_clam_conf_dir}|g' \ -e 's|__CLAM_CONFFILE__|%{_clam_conf_file}|g' \ -e 's|__CLAM_DBDIR__|%{_clam_db_dir}|g' \ -e 's|__CLAM_EXEC__|%{_clam_exec}|g' \ -e 's|__CLAM_GRP__|%{_clam_grp_daemon}|g' \ -e 's|__CLAM_LIBDIR__|%{_clam_lib_dir}|g' \ -e 's|__CLAM_LOGDIR__|%{_clam_log_dir}|g' \ -e 's|__CLAM_PIDFILE__|%{_clam_pid_file}|g' \ -e 's|__CLAM_RUNDIR__|%{_clam_run_dir}|g' \ -e 's|__CLAM_USR__|%{_clam_usr_daemon}|g' \ -e 's|__FRESH_CONFFILE__|%{_clam_conf_file_fresh}|g' \ -e 's|__FRESH_EXEC__|%{_clam_exec_fresh}|g' \ -e 's|__FRESH_GRP__|%{_clam_grp_fresh}|g' \ -e 's|__FRESH_PIDFILE__|%{_clam_pid_file_fresh}|g' \ -e 's|__FRESH_USR__|%{_clam_usr_fresh}|g' \ -e 's|__MILTER_CONFDIR__|%{_clam_conf_dir_milter}|g' \ -e 's|__MILTER_CONFFILE__|%{_clam_conf_file_milter}|g' \ -e 's|__MILTER_EXEC__|%{_clam_exec_milter}|g' \ -e 's|__MILTER_GRP__|%{_clam_grp_milter}|g' \ -e 's|__MILTER_GRP_PFX__|%{_clam_grp_milter_pfx}|g' \ -e 's|__MILTER_LOGDIR__|%{_clam_log_dir_milter}|g' \ -e 's|__MILTER_PIDFILE__|%{_clam_pid_file_milter}|g' \ -e 's|__MILTER_RUNDIR__|%{_clam_run_dir_milter}|g' \ -e 's|__MILTER_USR__|%{_clam_usr_milter}|g' \ -e 's|__UDPATE_USR__|%{_clam_usr_update}|g' \ %{SOURCE100} %{SOURCE200} %{SOURCE300} install -D --preserve-timestamps --mode=644 --verbose \ %{SOURCE100} \ ${RPM_BUILD_ROOT}/%{_clam_unit_dir}/%{_clam_unitnm_daemon}.service install -D --preserve-timestamps --mode=644 --verbose \ %{SOURCE101} \ ${RPM_BUILD_ROOT}/%{_clam_unit_dir}/%{_clam_unitnm_daemon}.target install -D --preserve-timestamps --mode=644 --verbose \ %{SOURCE200} \ ${RPM_BUILD_ROOT}/%{_clam_unit_dir}/%{_clam_unitnm_fresh}.service install -D --preserve-timestamps --mode=644 --verbose \ %{SOURCE201} \ ${RPM_BUILD_ROOT}/%{_clam_unit_dir}/%{_clam_unitnm_fresh}.target install -D --preserve-timestamps --mode=644 --verbose \ %{SOURCE300} \ ${RPM_BUILD_ROOT}/%{_clam_unit_dir}/%{_clam_unitnm_milter}.service install -D --preserve-timestamps --mode=644 --verbose \ %{SOURCE301} \ ${RPM_BUILD_ROOT}/%{_clam_unit_dir}/%{_clam_unitnm_milter}.target # 'mask' DISTRO SVC FILES ln -sf /dev/null ${RPM_BUILD_ROOT}/%{_clam_unit_dir}/clamav.socket ln -sf /dev/null ${RPM_BUILD_ROOT}/%{_clam_unit_dir}/clamd@.service %check %pre %post %systemd_post %{_clam_unitnm_daemon}.service %systemd_post %{_clam_unitnm_fresh}.service %systemd_post %{_clam_unitnm_milter}.service %preun %systemd_preun %{_clam_unitnm_daemon}.service %systemd_preun %{_clam_unitnm_fresh}.service %systemd_preun %{_clam_unitnm_milter}.service %postun %systemd_postun_with_restart %{_clam_unitnm_daemon}.service %systemd_postun_with_restart %{_clam_unitnm_fresh}.service %systemd_postun_with_restart %{_clam_unitnm_milter}.service %files # http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html %doc %license %dir %{_clam_install_dir} %{_clam_install_dir}/* %attr(0644,root,root) %{_clam_unit_dir}/%{_clam_name}-*.service %attr(0644,root,root) %{_clam_unit_dir}/%{_clam_name}-*.target # Explicit attr() mode not applicable to symlinks %{_clam_unit_dir}/clamav.socket %{_clam_unit_dir}/clamd@.service %dir %attr(0770,%{_clam_usr_daemon},%{_clam_grp_daemon}) %{_clam_db_dir} %dir %attr(0775,%{_clam_usr_daemon},%{_clam_grp_daemon}) %{_clam_run_dir} %dir %attr(0755,%{_clam_usr_milter},%{_clam_grp_milter_pfx}) %{_clam_run_dir_milter} %dir %attr(0750,%{_clam_usr_daemon},%{_clam_grp_daemon}) %{_clam_log_dir} %dir %attr(0750,%{_clam_usr_milter},%{_clam_grp_milter_pfx}) %{_clam_log_dir_milter} # track; delete on uninstall if exists; no error if !exists %ghost %attr(0660,%{_clam_usr_daemon},%{_clam_grp_daemon}) %{_clam_run_dir}/%{_clam_pid_file} %ghost %attr(0660,%{_clam_usr_daemon},%{_clam_grp_daemon}) %{_clam_run_dir}/%{_clam_pid_file_fresh} %ghost %attr(0660,%{_clam_usr_milter},%{_clam_grp_milter_pfx}) %{_clam_run_dir_milter}/%{_clam_pid_file_milter} # track; do not delete on uninstall %ghost %attr(0640,%{_clam_usr_daemon},%{_clam_grp_daemon}) %config(noreplace) %{_clam_log_dir}/%{_clam_pkgnm_daemon}.log %ghost %attr(0640,%{_clam_usr_daemon},%{_clam_grp_daemon}) %config(noreplace) %{_clam_log_dir}/%{_clam_pkgnm_fresh}.log %ghost %attr(0640,%{_clam_usr_milter},%{_clam_grp_milter_pfx}) %config(noreplace) %{_clam_log_dir_milter}/%{_clam_pkgnm_milter}.log %changelog * Wed Sep 18 2024 pgnd _ - bump 1726677190