119.2. oxipng-10.2.1
Lossless PNG optimiser
| Version | 10.2.1, release 1 |
| Shelf | graphics — Graphics applications: painting, vector, photo development and management, image viewers, screenshot and image optimisers |
| Phase | 41_system (System), 617 of 1047 in build order |
| Licence | MIT |
| Homepage | https://github.com/oxipng/oxipng |
| Build time | 1.6 SBU |
| Installed size | 1.3 MiB in 3 files |
| Recipe | ports/core/graphics/oxipng/kpkgbuild |
About
oxipng is a lossless PNG optimiser written in Rust: it re-encodes the same pixels with better filter choices and better deflate compression, and the result decodes to exactly the same image. Because nothing is lost, it is safe to point at a whole archive of screenshots or scanned pages: nobody has to judge an acceptable loss of quality, as with the lossy pngquant on the same shelf.
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/graphics.txt:
Lossless, which is the only reason it is safe to point at an archive: the output decodes bit-identical, so nobody has to judge acceptable quality loss.
Sources
oxipng-10.2.1.tar.gz(17.6 MiB)
sha256460ccfcdcc9c3877b9f7fae1dfd4f2a3f93d3b2a2af3e3b62ca32b163f923cca
upstream: https://github.com/oxipng/oxipng/archive/refs/tags/v10.2.1.tar.gz
archive copy: sources-2/graphics--oxipng-10.2.1.tar.gzoxipng-vendor-10.2.1.tar.xz(6.4 MiB)
sha2561aaa46c49e9e05f68b42fedc1b18a8396914d5dfc6da362601fc584d20cd91f7
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-2/graphics--oxipng-vendor-10.2.1.tar.xz
Dependencies
Depends on: rust.
Required by: no port names it.
Patches
build.sh applies these; kpkg applies nothing by itself.
source-date-epoch.patch— Inxtask/src/main.rs, dates the manual page fromSOURCE_DATE_EPOCHwhen it is set, and from the current time only when it is not. Without it the page carries the day it was built, and the package’s bytes differ on every rebuild.
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 oxipng'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/graphics/oxipng.
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/graphics/oxipng
echo '460ccfcdcc9c3877b9f7fae1dfd4f2a3f93d3b2a2af3e3b62ca32b163f923cca oxipng-10.2.1.tar.gz' | sha256sum -c -
echo '1aaa46c49e9e05f68b42fedc1b18a8396914d5dfc6da362601fc584d20cd91f7 oxipng-vendor-10.2.1.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/oxipng
SRC=$SRC_ROOT/oxipng-10.2.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf oxipng-10.2.1.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 vendorsync and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
tar xf $PORT_SRC/${name}-vendor-${version}.tar.xz
export RUSTFLAGS="-C target-feature=-crt-static"
cargo build --release --frozen --offline --bin oxipng
install -Dm755 target/release/oxipng $PKG/usr/bin/oxipng
patch -p1 -i "$PORT_SRC/source-date-epoch.patch"
cargo run --frozen --offline --manifest-path xtask/Cargo.toml -- mangen
install -Dm644 target/xtask/mangen/manpages/oxipng.1 -t "$PKG/usr/share/man/man1"
The switches, and why each is set:
--bin oxipng— Build only the crate’soxipngbinary target.--manifest-path xtask/Cargo.toml— Run thextaskhelper crate, whosemangentask renders the manual page,oxipng.1, from the sameclapdefinition of the options that the program parses, so the page and the options cannot disagree.
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/oxipng, 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 oxipng-10.2.1-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/oxipng, and runs the triggers its paths call for.
Contents
Installed programs: oxipng.
Installed directories: /usr/share/licenses/oxipng.
Short descriptions
oxipng |
A lossless PNG compression optimizer |
Notes
The crates are not downloaded at build time. ports/fetch runs cargo vendor against the release and packs the result into oxipng-vendor-<version>.tar.xz, held by its sha256 = line like any other source (see Vendoring). xtask is a crate of its own beside the main one and resolves against its own lock file, so the recipe’s vendorsync = xtask/Cargo.toml makes ports/fetch pass that manifest to cargo vendor --sync too, and the one bundle serves both cargo runs. Without it the offline cargo run fails on the first crate only the xtask needs. oxipng is the example the vendoring section uses for vendorsync.