90.6. ouch-0.8.3
Compresses and decompresses many archive formats with one command
| Version | 0.8.3, release 1 |
| Shelf | archiver — Compression libraries and archive tools |
| Phase | 41_system (System), 61 of 1047 in build order |
| Licence | MIT |
| Homepage | https://github.com/ouch-org/ouch |
| Build time | 3.6 SBU |
| Installed size | 5.7 MiB in 9 files |
| Recipe | ports/core/archiver/ouch/kpkgbuild |
About
ouch compresses and decompresses with one command whatever the format: ouch compress, ouch decompress and ouch list choose the format from the file name, for tar, zip, 7z, gzip, bzip2, bzip3, xz, lzma, lzip, lz4, zstd, brotli and snappy; rar it only decompresses and lists, since RAR’s licence allows no more. It is a Rust program built with cargo from its vendor bundle, the second sha256 = line (see Vendoring).
It is built with upstream’s default features, which include unrar and bzip3. Each of those compiles a C or C++ library carried inside its crate, so both formats are part of the binary, which is why it links libstdc++; neither library is a port of its own.
Sources
ouch-0.8.3.tar.gz(101.2 KiB)
sha256f695393cbbd89cf5a2095c32235e585a85432ccfb902c78d2a2e9787abbb439c
upstream: https://github.com/ouch-org/ouch/archive/0.8.3.tar.gz
archive copy: sources-1/archiver--ouch-0.8.3.tar.gzouch-vendor-0.8.3.tar.xz(20.1 MiB)
sha256013355b46504de190aafa8f6d2934f64e37f359f592df836ca093a5a0cdaf147
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-1/archiver--ouch-vendor-0.8.3.tar.xz
Dependencies
Depends on: rust, clang, zstd.
Required by: no port names it.
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 ouch'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/archiver/ouch.
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/ouch
echo 'f695393cbbd89cf5a2095c32235e585a85432ccfb902c78d2a2e9787abbb439c ouch-0.8.3.tar.gz' | sha256sum -c -
echo '013355b46504de190aafa8f6d2934f64e37f359f592df836ca093a5a0cdaf147 ouch-vendor-0.8.3.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/ouch
SRC=$SRC_ROOT/ouch-0.8.3
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf ouch-0.8.3.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:
tar xf $PORT_SRC/${name}-vendor-${version}.tar.xz
export RUSTFLAGS="-C target-feature=-crt-static"
export LIBCLANG_PATH=/usr/lib
export OUCH_ARTIFACTS_FOLDER="$PWD/artifacts"
cargo build --release --frozen --offline
readelf -d target/release/ouch | grep -q 'NEEDED.*\[libzstd\.so\.1\]'
install -Dm755 target/release/ouch $PKG/usr/bin/ouch
install -Dm644 artifacts/*.1 -t $PKG/usr/share/man/man1
install -Dm644 artifacts/ouch.bash "$PKG/usr/share/bash-completion/completions/ouch"
install -Dm644 artifacts/_ouch "$PKG/usr/share/zsh/site-functions/_ouch"
install -Dm644 artifacts/ouch.fish "$PKG/usr/share/fish/vendor_completions.d/ouch.fish"
The switches, and why each is set:
-C target-feature=-crt-static— link against musl dynamically, the rule for every cargo build in the tree (see rust). Here it is also what lets the build run at all: thelibbzip3-syscrate’s build script generates its bindings with bindgen, which loadslibclangat build time, and a statically linked musl program cannot load a shared library. clang is independsfor the same reason.LIBCLANG_PATH=/usr/lib— where bindgen’sclang-syslooks forlibclang.so, so it does not have to search.OUCH_ARTIFACTS_FOLDER="$PWD/artifacts"— read by ouch’sbuild.rs: when set, it writes the manual pages and the shell completions into that directory, whichbuild.shthen installs. Unset, the build writes neither.
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/ouch, 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 ouch-0.8.3-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/ouch, and runs the triggers its paths call for.
Contents
Installed programs: ouch.
Installed directories: /usr/share/licenses/ouch.
Short descriptions
ouch |
A command-line utility for easily compressing and decompressing files and directories. |
Notes
The zstd format links the system library: from 40_lang on the tree exports ZSTD_SYS_USE_PKG_CONFIG=1, which makes the zstd-sys crate find zstd through pkg-config instead of compiling its own copy (see rust). The readelf line after cargo build checks that the binary needs libzstd.so.1, so a crate that falls back to its copy fails the build instead of shipping one.