Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

102.16. clamav-1.5.4

Anti-virus toolkit — clamscan, the clamd daemon, sigtool and the libclamav scanning engine

Version 1.5.4, release 2
Shelf security — Security applications: GnuPG and front-ends, password and secret managers, certificates, scanners, forensics and audit
Phase 41_system (System), 940 of 1047 in build order
Licence GPL-2.0-only
Homepage https://www.clamav.net/
Build time 6.9 SBU
Installed size 101.3 MiB in 58 files
Recipe ports/core/security/clamav/kpkgbuild

About

ClamAV is an open-source anti-virus engine. The package holds the scanning library libclamav, clamscan for scanning on demand, the clamd daemon with its client clamdscan, clamonacc for scanning files as they are opened, freshclam to download the signature databases, and sigtool, clambc, clamdtop and clamconf. Part of libclamav is written in Rust; its crates come vendored in upstream’s own release tarball, under .cargo/vendor.

The package ships no signature database. clamscan and clamd refuse to scan without one, and freshclam, run once as root on a machine with a network, fetches it into /var/lib/clamav.

Sources

Dependencies

Depends on: cmake, ninja, pkgconf, rust, python3, openssl, zlib, bzip2, libxml2, pcre2, json-c, curl, ncurses, libmspack, musl-fts.

Required by: no port names it.

Patches

build.sh applies these; kpkg applies nothing by itself.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install clamav'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/security/clamav.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/security/clamav
echo '1af1117a228f1b5bc7fa91a0dabc37848a99e7d25188e9be8043332ce721dfd3  clamav-1.5.4.tar.gz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/clamav
SRC=$SRC_ROOT/clamav-1.5.4
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf clamav-1.5.4.tar.gz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

patch -p1 -i "$PORT_SRC/link-fts.patch"

patch -p1 -i "$PORT_SRC/openssl4.patch"

export CARGO_HOME="$SRC_ROOT/.cargo"
export RUSTFLAGS="-C target-feature=-crt-static"
export CARGO_NET_OFFLINE=true
cmake -S . -B build -G Ninja \
	-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DCMAKE_INSTALL_LIBDIR=lib \
	-DCMAKE_SKIP_INSTALL_RPATH=ON \
	-DAPP_CONFIG_DIRECTORY=/etc/clamav \
	-DDATABASE_DIRECTORY=/var/lib/clamav \
	-DBYTECODE_RUNTIME=interpreter \
	-DENABLE_APP=ON \
	-DENABLE_CLAMONACC=ON \
	-DENABLE_MILTER=OFF \
	-DENABLE_SYSTEMD=OFF \
	-DENABLE_UNRAR=ON \
	-DENABLE_EXTERNAL_MSPACK=ON \
	-DENABLE_JSON_SHARED=ON \
	-DHAVE_SYSTEM_LFS_FTS=ON \
	-DENABLE_MAN_PAGES=ON \
	-DENABLE_DOXYGEN=OFF \
	-DENABLE_EXAMPLES=OFF \
	-DENABLE_TESTS=OFF \
	-DENABLE_STATIC_LIB=OFF \
	-DENABLE_SHARED_LIB=ON
cmake --build build
DESTDIR=$PKG cmake --install build

rm -f "$PKG/usr/bin/clamsubmit" "$PKG/usr/share/man/man1/clamsubmit.1"

install -d "$PKG/var/lib/clamav"

install -Dm644 /dev/stdin "$PKG/etc/clamav/freshclam.conf" <<'CONF'
DatabaseDirectory /var/lib/clamav
DatabaseOwner clamav
DatabaseMirror database.clamav.net
CONF

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

postinstall.sh runs on the installed system after the package is adopted:

# Everything is written under PKG_ROOT, the root kpkgadd is installing into:
# --root and an A/B update install into a tree that is not the running one.
#
# freshclam run as root switches to the clamav account (DatabaseOwner) and
# exits if it is missing; the database directory is that account's to write.
root="${PKG_ROOT:-/}"
grep -q '^clamav:' "$root/etc/group" 2>/dev/null || groupadd -R "$root" -r clamav
grep -q '^clamav:' "$root/etc/passwd" 2>/dev/null || \
	useradd -R "$root" -r -g clamav -d /var/lib/clamav -s /sbin/nologin clamav
uid=$(awk -F: '$1 == "clamav" { print $3 }' "$root/etc/passwd")
gid=$(awk -F: '$1 == "clamav" { print $3 }' "$root/etc/group")
[ -n "$uid" ] && [ -n "$gid" ] && chown "$uid:$gid" "$root/var/lib/clamav"

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/clamav, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf clamav-1.5.4-2.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/clamav, and runs the triggers its paths call for.

Contents

Installed programs: clamav-config, clambc, clamconf, clamd, clamdscan, clamdtop, clamonacc, clamscan, freshclam, sigtool.

Installed libraries: libclamav.so, libclamav_rust.a, libclamunrar.so, libclamunrar_iface.so, libfreshclam.so.

Installed directories: /etc/clamav, /usr/share/licenses/clamav, /var/lib/clamav.

Short descriptions

clambc Bytecode Analysis and Testing Tool
clamconf Clam AntiVirus configuration utility
clamd an anti-virus daemon
clamdscan scan files and directories for viruses using Clam AntiVirus Daemon
clamdtop monitor the Clam AntiVirus Daemon
clamonacc an anti-virus on-access scanning daemon and clamd client
clamscan scan files and directories for viruses
freshclam update virus databases
sigtool signature and database management tool
libclamav.pc A GPL virus scanner

Notes

build.sh deletes clamsubmit and its manual page: the program does nothing but upload a sample to Cisco’s servers.

Upstream installs only .sample configuration files, which are never read, and freshclam refuses to start without a configuration. build.sh therefore writes a three-line /etc/clamav/freshclam.conf: the database directory, the clamav account as DatabaseOwner, and database.clamav.net as the mirror.

postinstall.sh creates the clamav group and system account (home /var/lib/clamav, no login shell) unless they exist, and gives it the database directory. freshclam run as root switches to that account and exits if it is missing. The script writes under PKG_ROOT, so it also works when kpkgadd installs into a root that is not the running one.