Skip to content

Commit

Permalink
community/clamav: upgrade to 0.104.1
Browse files Browse the repository at this point in the history
build system is changed to cmake from autotools
  • Loading branch information
Milan P. Stanić authored and ncopa committed Nov 17, 2021
1 parent c012b10 commit d7b9aee
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 38 deletions.
80 changes: 42 additions & 38 deletions community/clamav/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Contributor: Carlo Landmeter <[email protected]>
# Maintainer: Carlo Landmeter <[email protected]>
pkgname=clamav
pkgver=0.103.3
pkgrel=1
pkgver=0.104.1
pkgrel=0
pkgusers="clamav"
pkggroups="clamav"
pkgdesc="An anti-virus toolkit for UNIX eis-ng backport"
Expand All @@ -15,13 +15,30 @@ depends="$pkgname-scanner $pkgname-daemon"
depends_dev="openssl1.1-compat-dev"
install="freshclam.pre-install
clamav-daemon.pre-install clamav-daemon.pre-upgrade"
makedepends="ncurses-dev zlib-dev bzip2-dev pcre-dev linux-headers $depends_dev
libmilter-dev fts-dev curl-dev autoconf automake libtool"
makedepends="$depends_dev
bzip2-dev
check-dev
cmake
curl-dev
fts-dev
json-c-dev
libmspack-dev
libmilter-dev
libxml2-dev
linux-headers
ncurses-dev
pcre2-dev
zlib-dev
"
checkdepends="python3"
subpackages="$pkgname-doc $pkgname-dev $pkgname-libunrar $pkgname-libs
$pkgname-daemon $pkgname-clamdscan $pkgname-scanner $pkgname-db::noarch freshclam
$pkgname-daemon-openrc:daemon_rc:noarch freshclam-openrc:freshclam_rc:noarch
$pkgname-milter"
source="https://www.clamav.net/downloads/production/clamav-$pkgver.tar.gz
link-fts.patch
cmake-fix-race-condition-with-parallel-builds.patch
clamd.initd
clamd.confd
freshclam.initd
Expand All @@ -30,7 +47,6 @@ source="https://www.clamav.net/downloads/production/clamav-$pkgver.tar.gz
freshclam.logrotate
"


# secfixes:
# 0.103.2-r0:
# - CVE-2021-1405
Expand Down Expand Up @@ -76,41 +92,31 @@ source="https://www.clamav.net/downloads/production/clamav-$pkgver.tar.gz
# - CVE-2018-14681
# - CVE-2018-14682

prepare() {
update_config_sub
default_prepare
autoreconf -ifv
}

build() {
LIBS=-lfts ./configure \
--build=$CBUILD \
--host=$CHOST \
--prefix=/usr \
--libdir=/usr/lib \
--sysconfdir=/etc/clamav \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--without-iconv \
--disable-llvm \
--with-user=clamav \
--with-group=clamav \
--with-dbdir=/var/lib/clamav \
--enable-clamdtop \
--enable-bigstack \
--with-pcre \
--enable-milter \
--enable-clamonacc
make
mkdir -p build
cmake -B build \
-D CMAKE_BUILD_TYPE=none \
-D CMAKE_INSTALL_PREFIX=/usr \
-D CMAKE_INSTALL_LIBDIR=/usr/lib \
-D APP_CONFIG_DIRECTORY=/etc/clamav \
-D DATABASE_DIRECTORY=/var/lib/clamav \
-D ENABLE_TESTS=ON \
-D ENABLE_CLAMONACC=ON \
-D ENABLE_MILTER=ON \
-D ENABLE_EXTERNAL_MSPACK=ON \
-D ENABLE_EXAMPLES=ON \
-D ENABLE_EXAMPLES_DEFAULT=ON \
-D HAVE_SYSTEM_LFS_FTS=1 \
-D ENABLE_JSON_SHARED=ON
make -C build
}

check() {
make check
make -C build test
}

package() {
make DESTDIR="$pkgdir" install

make -C build install DESTDIR="$pkgdir"
# set proper defaults
sed -i -e "s:^\(Example\):\# \1:" \
-e "s:.*\(PidFile\) .*:\1 /run/clamav/freshclam.pid:" \
Expand All @@ -132,10 +138,6 @@ package() {
"$pkgdir"/etc/clamav/clamd.conf.sample
}

check() {
make check
}

libunrar() {
pkgdesc="ClamAV unrar libraries"
replaces="clamav"
Expand Down Expand Up @@ -257,7 +259,9 @@ milter() {
}

sha512sums="
c2ee24a6f63735c064140aa5baa347d51e8240b2f7eced3480d05435202aedd481fa7057fd40ecbc2e93a62fe8b0cefb574d8accdf9acede643ffbe0d396686f clamav-0.103.3.tar.gz
2cd4f73de73a2bbc002e1aa85326ea30cce0073fc1a2d5d7d220465217a84eb97fac759010ae0af54d2f0ed725112a51a65a486491fa52388cd7652d7b5cfa5a clamav-0.104.1.tar.gz
20a52291d00e0b8e6e0cd7b31484a577045dfa8e2481fe1e4e1640e6f6d9317114c7fd53211a2bf9edcea4e084789b4820d7ceeaaf17346d581524683289e698 link-fts.patch
8a7e20d83ba004a701f91df94561d5df1ca6819df5bc7d0830279f51ad2e0f14fb003fd22db4a7de784c68ca4af504896b88f189124549a092a0689514456947 cmake-fix-race-condition-with-parallel-builds.patch
d886d810de66e8da800384c1e8192f7da4352402ffc3b33cfbca93d81a2235d8c902ca9d436b9be70f00740b4555e1efbf09bf9f84059095a1a297b27581cd20 clamd.initd
59c561b3dcb0b616b647cd8e4ebc46a2cc5e7144c8c7ea0054cc1c3021d1da8f67e4dad5c083c3fe712ed887aaabfca91b538f4759537e7c4c9ab71ba4fd5794 clamd.confd
6f0c615b89f0f0d2f0e9f965f025b9ac8c81b2168fa6727dc8a47222abd780f9b656732f289d6061a20126b16126a975d50e8b3b8ff131f55dd8803da8be5dec freshclam.initd
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From c5c3b7558e16dabc6d2c7c7876ac8cd2e23f4caf Mon Sep 17 00:00:00 2001
From: Alexander Sulfrian <[email protected]>
Date: Fri, 24 Sep 2021 12:37:43 +0200
Subject: [PATCH] CMake: Fix race condition with parallel builds

If running multiple parallel processes of "xor_testfile.py" there was a
race condition between checking for the existence of the directory and
creating it. Now this is handled as a dependency in CMake.
---
unit_tests/input/CMakeLists.txt | 4 ++++
unit_tests/input/xor_testfile.py | 3 ---
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/unit_tests/input/CMakeLists.txt b/unit_tests/input/CMakeLists.txt
index 3297290d18..7a3ba4bb96 100644
--- a/unit_tests/input/CMakeLists.txt
+++ b/unit_tests/input/CMakeLists.txt
@@ -62,6 +62,9 @@ if(ENABLE_UNRAR)
)
endif()

+add_custom_target(tgt_clamav_hdb_scanfiles ALL
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/clamav_hdb_scanfiles)
+
# Decrypt test file
function(decrypt_testfile test_file)
add_custom_command(OUTPUT clamav_hdb_scanfiles/${test_file}
@@ -71,6 +74,7 @@ function(decrypt_testfile test_file)
--out_file ${CMAKE_CURRENT_BINARY_DIR}/clamav_hdb_scanfiles/${test_file}
COMMENT "Decrypting test file ${test_file}...")
add_custom_target(tgt_${test_file} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clamav_hdb_scanfiles/${test_file})
+ ADD_DEPENDENCIES(tgt_${test_file} tgt_clamav_hdb_scanfiles)
endfunction()

foreach(TESTFILE ${TESTFILES})
diff --git a/unit_tests/input/xor_testfile.py b/unit_tests/input/xor_testfile.py
index bacc971faa..41379621b5 100755
--- a/unit_tests/input/xor_testfile.py
+++ b/unit_tests/input/xor_testfile.py
@@ -53,9 +53,6 @@ def main():

# Write out the result to the destination file.
try:
- if not out_file.parent.exists():
- out_file.parent.mkdir()
-
with out_file.open('w+b') as out_file_fd:
out_file_fd.write(out_file_bytes)

12 changes: 12 additions & 0 deletions community/clamav/link-fts.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/clamonacc/CMakeLists.txt b/clamonacc/CMakeLists.txt
index e95e6d0..928b60a 100644
--- a/clamonacc/CMakeLists.txt
+++ b/clamonacc/CMakeLists.txt
@@ -47,6 +47,7 @@ set_target_properties( clamonacc PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}" )

target_link_libraries( clamonacc
PRIVATE
+ fts
ClamAV::libclamav
ClamAV::common
CURL::libcurl )

0 comments on commit d7b9aee

Please sign in to comment.