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

90.4. unzip-6.0

ZIP extraction utilities

Version 6.0, release 2
Shelf archiver — Compression libraries and archive tools
Phase 41_system (System), 59 of 1047 in build order
Licence Info-ZIP
Homepage https://infozip.sourceforge.net/UnZip.html
Build time 0.1 SBU
Installed size 663.7 KiB in 12 files
Recipe ports/core/archiver/unzip/kpkgbuild

About

UnZip is Info-ZIP’s extractor: unzip, unzipsfx, funzip, zipinfo and the zipgrep script. It is the command a user extracts a ZIP archive with, and many ports name it in depends; noto-fonts and josm, for example, unpack ZIP archives with it in their build.sh.

Info-ZIP has made no release since this version, so every fix since exists only as a distribution’s patch. The numbered series beside the recipe is Alpine’s, applied in Alpine’s order, which the numbers keep: each patch is a diff from the top of the tree and may depend on the ones before it. It carries the CVE fixes for heap and buffer overflows and the check that refuses a “zip bomb” built from overlapping entries.

Sources

Dependencies

Depends on: bzip2.

Required by (24): antlr2, ark, convertlit, digital, docx2txt, firefox-esr, josm, libreoffice, librepcb, librewolf, logisim-evolution, meshtastic-firmware, noto-cjk, noto-fonts, noto-fonts-extra, openjdk, openrct2, polyclipping, srb2, thunderbird, ttf-jetbrains-mono, wine-gecko, xonotic, xonotic-data.

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 unzip'

What kpkg does

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

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/unzip
echo '036d96991646d0449ed0aa952e4fbe21b476ce994abc276e49d30e686708bd37  unzip-6.0.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/unzip
SRC=$SRC_ROOT/unzip-6.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf unzip-6.0.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 recipe’s helpers _version and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

for p in "$PORT_SRC"/[0-9][0-9]-*.patch; do
	patch -p1 -i "$p"
done

make -f unix/Makefile unzips CC="$CC" LD="$CC" \
	CFLAGS="$CFLAGS" LF2="$LDFLAGS" \
	D_USE_BZ2=-DUSE_BZIP2 L_BZ2=-lbz2 \
	LOCAL_UNZIP="-DBSD -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DLARGE_FILE_SUPPORT -DUNICODE_SUPPORT -DUNICODE_WCHAR -DUTF8_MAYBE_NATIVE -include time.h" \
	prefix=$PKG/usr

make prefix=$PKG/usr MANDIR=$PKG/usr/share/man/man1 -f unix/Makefile 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/unzip, 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 unzip-6.0-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/unzip, and runs the triggers its paths call for.

Contents

Installed programs: funzip, unzip, unzipsfx, zipgrep, zipinfo.

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

Short descriptions

funzip filter for extracting from a ZIP archive in a pipe
unzip list, test and extract compressed files in a ZIP archive
unzipsfx self-extracting stub for prepending to ZIP archives
zipgrep search files in a ZIP archive for lines matching a pattern
zipinfo list detailed information about a ZIP archive

Notes

29-zipbomb-switch.patch makes the zip-bomb check switchable: with UNZIP_DISABLE_ZIPBOMB_DETECTION=TRUE in the environment, unzip extracts an archive with overlapping entries instead of refusing it.