84.2. xh-0.26.2
Command-line HTTP client
| Version | 0.26.2, release 1 |
| Shelf | devtools — Debuggers, tracers, profilers, analysers, linters, language servers and developer utilities |
| Phase | 41_system (System), 372 of 1047 in build order |
| Licence | MIT |
| Homepage | https://github.com/ducaale/xh |
| Build time | 2.6 SBU |
| Installed size | 10.9 MiB in 8 files |
| Recipe | ports/core/devtools/xh/kpkgbuild |
About
xh is a command-line HTTP client in the style of HTTPie: xh POST example.org name=value builds a JSON body from its arguments, and the response is printed with its headers and a highlighted, indented body. Invoked as xhs it assumes https:// when the URL names no scheme, so the package installs xhs as a link to xh, with a matching manual page link. It is a Rust program built from a vendored crate bundle, against the system’s OpenSSL and oniguruma.
Sources
xh-0.26.2.tar.gz(325.9 KiB)
sha25661a88a5b3beac225b75a11d6ed32659af78db7ff29c825def0ab7f4a2906cbd7
upstream: https://github.com/ducaale/xh/archive/refs/tags/v0.26.2.tar.gz
archive copy: sources-1/devtools--xh-0.26.2.tar.gzxh-vendor-0.26.2.tar.xz(29.2 MiB)
sha256f438568ab4ead8b94c48900f389ea6e8d9c7a96c83cebd83b335ee94fcbd4c20
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-1/devtools--xh-vendor-0.26.2.tar.xz
Dependencies
Depends on: rust, pkgconf, openssl, oniguruma.
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 xh'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/devtools/xh.
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/devtools/xh
echo '61a88a5b3beac225b75a11d6ed32659af78db7ff29c825def0ab7f4a2906cbd7 xh-0.26.2.tar.gz' | sha256sum -c -
echo 'f438568ab4ead8b94c48900f389ea6e8d9c7a96c83cebd83b335ee94fcbd4c20 xh-vendor-0.26.2.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/xh
SRC=$SRC_ROOT/xh-0.26.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf xh-0.26.2.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"
cargo build --release --frozen --offline --no-default-features \
--features native-tls,http-message-signatures
readelf -d target/release/xh | grep -q 'NEEDED.*\[libssl\.so'
readelf -d target/release/xh | grep -q 'NEEDED.*\[libonig\.so\.5\]'
install -Dm755 target/release/xh $PKG/usr/bin/xh
ln -s xh $PKG/usr/bin/xhs
install -Dm644 doc/xh.1 $PKG/usr/share/man/man1/xh.1
ln -s xh.1 $PKG/usr/share/man/man1/xhs.1
install -Dm644 completions/xh.bash $PKG/usr/share/bash-completion/completions/xh
install -Dm644 completions/_xh $PKG/usr/share/zsh/site-functions/_xh
install -Dm644 completions/xh.fish $PKG/usr/share/fish/vendor_completions.d/xh.fish
The switches, and why each is set:
--no-default-features— Turns off upstream’s default feature set:rustls,online-testsandnetwork-interface.rustlswould compile its TLS stack, and with it AWS-LC, into the binary, where no package database sees its version.online-testsonly gates tests that reach the network.network-interfaceserves--interfaceon systems withoutSO_BINDTODEVICE; on Linux xh binds through the socket option and does not use it.--features native-tls,http-message-signatures—native-tlsmakes reqwest speak TLS through the system openssl, which is whyopensslandpkgconfare independs.http-message-signaturesadds xh’s support for signing requests (RFC 9421) through thehttpsig-hypercrate, a feature upstream leaves off by default. The TLS rule for every Rust port is in rust.
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/xh, 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 xh-0.26.2-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/xh, and runs the triggers its paths call for.
Contents
Installed programs: xh, xhs.
Installed directories: /usr/share/licenses/xh.
Short descriptions
xh |
Friendly and fast tool for sending HTTP requests |
Notes
The two readelf -d lines after cargo build stop the build unless the binary NEEDs libssl.so and libonig.so.5. The second holds because the tree’s environment sets RUSTONIG_SYSTEM_LIBONIG=1 for every Rust build from 40_lang on, which makes syntect’s onig_sys link oniguruma instead of compiling its own copy. Either check failing means a copy of the library was compiled into xh.