File clamav.spec of Package clamav

#
# spec file for package clamav
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%global name_version	%{name}-%{version}

%bcond_with	clammspack
%bcond_without	unrar
%bcond_with	valgrind

Name:           clamav
Version:        1.4.2
Release:        0
Summary:        Antivirus Toolkit
License:        GPL-2.0-only
Group:          Productivity/Security
URL:            https://www.clamav.net
Source0:        https://github.com/Cisco-Talos/clamav/releases/download/%{name_version}/%{name_version}.tar.gz
Source1:        https://github.com/Cisco-Talos/clamav/releases/download/%{name_version}/%{name_version}.tar.gz.sig
Source2:        clamav.keyring
Source3:        clamav-rpmlintrc
Source4:        clamav-tmpfiles.conf
Source5:        clamav-milter.service
Patch1:         clamav-conf.patch
Patch2:         clamav-obsolete-config.patch
Patch3:         clamav-fips.patch
Patch4:         clamav-daemon.patch
Patch5:         clamav-timer.patch
Patch100:       clamav-disable_test_pe_cert_trust.patch
BuildRequires:  cargo
BuildRequires:  cmake
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  pkgconfig
BuildRequires:  python3-pytest
BuildRequires:  rust >= 1.56
BuildRequires:  rust-bindgen
BuildRequires:  sendmail-devel
BuildRequires:  pkgconfig(bzip2)
BuildRequires:  pkgconfig(check)
BuildRequires:  pkgconfig(json-c)
BuildRequires:  pkgconfig(libcurl) >= 7.45
BuildRequires:  pkgconfig(libpcre2-8) >= 10.30
BuildRequires:  pkgconfig(libsystemd)
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(ncurses)
BuildRequires:  pkgconfig(openssl) >= 1.0.2
BuildRequires:  pkgconfig(systemd)
BuildRequires:  pkgconfig(zlib)
Requires(pre):  group(vscan)
Requires(pre):  user(vscan)
Requires:       libclamav12 = %{version}
Requires:       libfreshclam3 = %{version}
Obsoletes:      clamav-db < 0.88.3
Provides:       clamav-nodb = %{version}
Obsoletes:      clamav-nodb < %{version}
%{?systemd_ordering}
%if %{without clammspack}
BuildRequires:  pkgconfig(libmspack)
%endif
%if %{with valgrind}
BuildRequires:  valgrind
%endif

%description
ClamAV is an antivirus engine designed for detecting trojans,
viruses, malware and other malicious threats. It is the de-facto
standard for mail gateway scanning. It provides a multi-threaded
scanning daemon, command line utilities for on-demand file scanning,
and a tool for automatic signature updates. The core ClamAV library
provides numerous file format detection mechanisms, file unpacking
support, archive support, and multiple signature languages for
detecting threats.

%package docs-html
Summary:        Documentation for ClamAV in HTML format
License:        GPL-2.0-only
Group:          Productivity/Security
BuildArch:      noarch

%description docs-html
Optional HTML documentation for ClamAV antivirus engine

%package milter
Summary:        ClamAV Milter compatible mail scanner
License:        GPL-2.0-only
Group:          Productivity/Security
Requires:       %{name} = %{version}
Provides:       %{name}:%{_sbindir}/clamav-milter

%description milter
ClamAV-milter is a filter for sendmail(1) mail server. It uses a
mail scanning engine built into clamd(8). ClamAV-milter can use
load balancing and fault tolerant techniques to connect to more
than one clamd(8) server and seamlessly hot-swap to even the load
between different machines and to keep scanning for viruses even
when a server goes down.

%package -n libclamav12
Summary:        ClamAV antivirus engine runtime
License:        GPL-2.0-only
Group:          System/Libraries

%description -n libclamav12
ClamAV is an antivirus engine designed for detecting trojans,
viruses, malware and other malicious threats.

%package -n libfreshclam3
Summary:        ClamAV updater library
License:        GPL-2.0-only
Group:          System/Libraries

%description -n libfreshclam3
ClamAV is an antivirus engine designed for detecting trojans,
viruses, malware and other malicious threats.

%package -n libclammspack0
Summary:        ClamAV antivirus engine runtime
License:        GPL-2.0-only
Group:          System/Libraries

%description -n libclammspack0
ClamAV is an antivirus engine designed for detecting trojans,
viruses, malware and other malicious threats.

%package devel
Summary:        Development files for libclamav, an antivirus engine
License:        GPL-2.0-only
Group:          Development/Libraries/C and C++
Requires:       libclamav12 = %{version}
Requires:       libfreshclam3 = %{version}

%description devel
ClamAV is an antivirus engine designed for detecting trojans,
viruses, malware and other malicious threats.

This subpackage contains header files for developing applications
that want to make use of libclamav.

%prep
%autosetup -p1 -n %{name_version}
%if %{without unrar}
rm COPYING/COPYING.unrar
%endif

%build
%cmake \
	-D CMAKE_BUILD_TYPE="Release" \
	-D CMAKE_INSTALL_DOCDIR=%{_docdir}/clamav \
	-D CMAKE_SKIP_RPATH=ON \
	-D APP_CONFIG_DIRECTORY=%{_sysconfdir} \
	-D DATABASE_DIRECTORY=%{_localstatedir}/lib/clamav \
%if %{without clammspack}
	-D ENABLE_EXTERNAL_MSPACK=ON \
%endif
%if %{without unrar}
	-D ENABLE_UNRAR=OFF \
%endif
	-D CLAMAV_USER=vscan \
	-D CLAMAV_GROUP=vscan
%cmake_build

%install
%cmake_install
install -d -m755 %{buildroot}%{_localstatedir}/lib/clamav
install -d -m755 %{buildroot}%{_tmpfilesdir}
install -m644 %{SOURCE4} %{buildroot}%{_tmpfilesdir}/clamav.conf
mkdir -p -m 0755 %{buildroot}/run/clamav
find %{buildroot} -type f -name "*.a" -delete -print

# fix the new config file names
mv %{buildroot}%{_sysconfdir}/clamd.conf{.sample,}
mv %{buildroot}%{_sysconfdir}/clamav-milter.conf{.sample,}
mv %{buildroot}%{_sysconfdir}/freshclam.conf{.sample,}

# rename clamav-daemon to clamd
mv %{buildroot}%{_unitdir}/clam{av-daemon,d}.service
mv %{buildroot}%{_unitdir}/clam{av-daemon,d}.socket

# Systemd...
install -d -m 0755 %{buildroot}%{_unitdir}
rm -f %{buildroot}%{_unitdir}/clamav-clamonacc.service
install -m 0644 %{SOURCE5} %{buildroot}%{_unitdir}/clamav-milter.service
# this is broken if system does not have systemd so don't
# use it at all on systems without mandatory systemd
for srvname in clamd clamav-freshclam clamav-milter; do
	ln -s service %{buildroot}%{_sbindir}/rc${srvname}
done

# Remove duplicate files
%fdupes %{buildroot}%{_docdir}

%check
# regression tests
%if !0%{?qemu_user_space_build:1}
%ctest
%endif

%pre
%service_add_pre clamd.service clamd.socket clamav-freshclam.service

%post
%service_add_post clamd.service clamd.socket clamav-freshclam.service
%tmpfiles_create %{_tmpfilesdir}/clamav.conf

%preun
if [ $1 -eq 0 ]; then
	# package will be uninstalled
	rm -f %{_localstatedir}/lib/clamav/*
fi
%service_del_preun clamd.service clamd.socket clamav-freshclam.service

%postun
%service_del_postun clamd.service clamd.socket clamav-freshclam.service

%pre milter
%service_add_pre clamav-milter.service

%post milter
%service_add_post clamav-milter.service

%preun milter
%service_del_preun clamav-milter.service

%postun milter
%service_del_postun clamav-milter.service

%ldconfig_scriptlets -n libclamav12
%ldconfig_scriptlets -n libfreshclam3

%if %{with clammspack}
%ldconfig_scriptlets -n libclammspack0
%endif

%files
%license COPYING.txt COPYING/*
%config(noreplace) %{_sysconfdir}/clamd.conf
%config(noreplace) %{_sysconfdir}/freshclam.conf
%ghost %{_rundir}/clamav
%{_bindir}/clamav-config
%{_bindir}/clambc
%{_bindir}/clamconf
%{_bindir}/clamdscan
%{_bindir}/clamdtop
%{_bindir}/clamscan
%{_bindir}/clamsubmit
%{_bindir}/freshclam
%{_bindir}/sigtool
%{_sbindir}/clamd
%{_sbindir}/clamonacc
%{_sbindir}/rcclamd
%{_sbindir}/rcclamav-freshclam
%{_mandir}/man1/clambc.1%{?ext_man}
%{_mandir}/man1/clamconf.1%{?ext_man}
%{_mandir}/man1/clamdscan.1%{?ext_man}
%{_mandir}/man1/clamdtop.1%{?ext_man}
%{_mandir}/man1/clamscan.1%{?ext_man}
%{_mandir}/man1/clamsubmit.1%{?ext_man}
%{_mandir}/man1/freshclam.1%{?ext_man}
%{_mandir}/man1/sigtool.1%{?ext_man}
%{_mandir}/man5/clamd.conf.5%{?ext_man}
%{_mandir}/man5/freshclam.conf.5%{?ext_man}
%{_mandir}/man8/clamd.8%{?ext_man}
%{_mandir}/man8/clamonacc.8%{?ext_man}
%{_tmpfilesdir}/*
%{_unitdir}/clamd.service
%{_unitdir}/clamd.socket
%{_unitdir}/clamav-freshclam.service
%{_unitdir}/clamav-freshclam-once.service
%{_unitdir}/clamav-freshclam-once.timer
%defattr(-,vscan,vscan)
%dir %{_localstatedir}/lib/clamav

%files docs-html
%defattr(644,root,root)
%{_docdir}/clamav

%files milter
%config(noreplace) %{_sysconfdir}/clamav-milter.conf
%{_unitdir}/clamav-milter.service
%{_sbindir}/clamav-milter
%{_sbindir}/rcclamav-milter
%{_mandir}/man5/clamav-milter.conf.5%{?ext_man}
%{_mandir}/man8/clamav-milter.8%{?ext_man}

%files -n libclamav12
%{_libdir}/libclamav.so.12*
%if %{with unrar}
%{_libdir}/libclamunrar.so.12*
%{_libdir}/libclamunrar_iface.so.12*
%endif

%files -n libfreshclam3
%{_libdir}/libfreshclam.so.3*

%if %{with clammspack}
%files -n libclammspack0
%{_libdir}/libclammspack.so.0*
%endif

%files devel
%{_includedir}/*
%{_libdir}/pkgconfig/*
%{_libdir}/libclam*.so
%{_libdir}/libfreshclam*.so

%changelog
openSUSE Build Service is sponsored by