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
libarchive-3.8.10.tar.xz(6.4 MiB)
sha25656cad765459d5ee25a3b761f90c47d99379d28297fbfb72d908880d6b875fb96
upstream: https://libarchive.org/downloads/libarchive-3.8.10.tar.xz
archive copy: sources-1/archiver--libarchive-3.8.10.tar.xz
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.
--without-xml2, line 28: libxml2 (explained with the switches below)--without-nettle, line 31: nettle (explained with the switches below)--without-mbedtls, line 32: mbedtls
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:
--enable-bsdtar,--enable-bsdcpio,--enable-bsdcat,--enable-bsdunzip— Build and install the four command-line programs. Each is upstream’s default; the switches name what the package installs. With the bare valueyesand the static library still built (--disable-staticis not passed), configure links libarchive into each program statically, sobsdtarand the others carry their own copy and do not loadlibarchive.so;readelf -d /usr/bin/bsdtarnames the compression libraries but not libarchive.--enable-acl— Read and restore POSIX ACLs when archiving and extracting, through acl.--enable-xattr— Read and restore extended attributes. configure looks forsetxattr()in the C library first, and musl has it, so nothing from attr is linked.--enable-posix-regex-lib=libc— Take the POSIX regular expressions ofbsdtar -s(the path-rewriting option) from musl’sregcomp, and never look for the PCRE or PCRE2 POSIX libraries. configure falls back to a separatelibregexonly when the C library has noregcomp, which musl has.--with-zlib,--with-bz2lib,--with-lzma,--with-zstd,--with-lz4— gzip, bzip2, xz and lzma, zstd and lz4 filters, through zlib, bzip2, xz, zstd and lz4.--with-lzo2— Thelzopfilter, through lzo. Unlike the others this one is off unless asked for.--with-openssl— Take MD5, SHA and RIPEMD-160 for mtree and xar checksums, and the ciphers for encrypted zip archives, from OpenSSL’slibcrypto.--without-nettle,--without-mbedtls— Do not take those hashes from Nettle or Mbed TLS. Both are off by upstream’s default, and both libraries are ports here; with the switches stated, OpenSSL is the only crypto library libarchive links.--with-expat— Parse xar archives’ XML table of contents with expat.--without-xml2— Do not use libxml2 for xar. configure prefers libxml2 when it finds it, and only libxml2 provides the XML writer, so with this switch libarchive reads xar archives (through expat) and refuses to write them with “Xar not supported on this platform”.--without-libb2— No external BLAKE2 library; RAR 5 checksums use the copy of BLAKE2 libarchive carries in its own source. No libb2 port exists.
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.