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

50.6. libarchive-3.8.10

Multi-format archive and compression library, with bsdtar, bsdcpio, bsdcat and bsdunzip

Version 3.8.10, release 1
Shelf archiver — Compression libraries and archive tools
Phase 30_foundation (Build Foundation), 27 of 127 in build order
Licence BSD-2-Clause
Homepage https://libarchive.org/
Build time 0.7 SBU
Installed size 5.4 MiB in 57 files
Recipe ports/core/archiver/libarchive/kpkgbuild

About

libarchive reads and writes tar, cpio, zip, 7-Zip, ISO 9660, xar and many other archive formats, through any of the common compression filters, and installs four programs built on it: bsdtar, bsdcpio, bsdcat and bsdunzip. The system tar stays GNU tar; the BSD programs sit beside it under their own names.

Two things in KDOS lean on it directly. cmake links the shared library for cmake -E tar and its packaging, so libarchive and every library it depends on are installed early in 30_foundation, ahead of cmake in the order run at the head of the phase’s list, well before the archiver shelf’s section. Desktop programs such as ark, gvfs and mpv use it too.

Sources

Dependencies

Depends on: acl, attr, xz, zstd, lz4, lzo, bzip2, zlib, openssl, expat.

Required by (31): ardour, ark, audacious, cmake, docbook-xml, e2fsprogs, elfutils, font-manager, gdal, gimp, glaxnimate, gvfs, horizon-eda, hydrogen, kbackup, libvips, lnav, mpv, mupdf, opencpn, openttd-opengfx, openttd-openmsx, openttd-opensfx, osinfo-db-tools, qt-creator, samba, tesseract, totem-pl-parser, translatelocally, vlc, zeal.

Optional, off in KDOS

These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.

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/30_foundation/phase.env && kpkg install libarchive'

What kpkg does

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

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/archiver/libarchive
echo '56cad765459d5ee25a3b761f90c47d99379d28297fbfb72d908880d6b875fb96  libarchive-3.8.10.tar.xz' | 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/libarchive
SRC=$SRC_ROOT/libarchive-3.8.10
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libarchive-3.8.10.tar.xz -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:

./configure \
	--prefix=/usr \
	--enable-bsdtar \
	--enable-bsdcpio \
	--enable-bsdcat \
	--enable-bsdunzip \
	--enable-acl \
	--enable-xattr \
	--enable-posix-regex-lib=libc \
	--with-zlib \
	--with-bz2lib \
	--with-lzma \
	--with-zstd \
	--with-lz4 \
	--with-openssl \
	--with-expat \
	--without-xml2 \
	--without-libb2 \
	--with-lzo2 \
	--without-nettle \
	--without-mbedtls
make
make DESTDIR=$PKG install

The switches, and why each is set:

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

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/libarchive, 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 libarchive-3.8.10-1.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/libarchive, and runs the triggers its paths call for.

Contents

Installed programs: bsdcat, bsdcpio, bsdtar, bsdunzip.

Installed libraries: libarchive.a, libarchive.so.

Installed directories: /usr/share/licenses/libarchive.

Short descriptions

bsdcat expand files to standard output
bsdcpio copy files to and from archives
bsdtar manipulate tape archives
bsdunzip extract files from a ZIP archive
libarchive.pc library that can create and read several streaming archive formats

Notes

configure looks for zlib, bzip2, xz, zstd, lz4 and OpenSSL whether or not they are named (LZO only when asked), and when one is missing it builds without it and says so only in its output: --with-zstd and the rest do not make a missing library fatal. What guarantees them is the recipe’s depends line, which installs every one of them first. A library dropped from depends would leave a libarchive.so with no built-in support for that filter, and no failed build to show for it; libarchive would then run the external program instead (zstd, xz and the like), with a warning. readelf -d /usr/lib/libarchive.so lists the libraries a build really linked.