92.4. fd-10.5.0
File finder, an alternative to find
| Version | 10.5.0, release 1 |
| Shelf | cli — Command-line productivity utilities: search, view, navigation and text wrangling in the terminal |
| Phase | 41_system (System), 282 of 1047 in build order |
| Licence | MIT OR Apache-2.0 |
| Homepage | https://github.com/sharkdp/fd |
| Build time | 6.7 SBU |
| Installed size | 4.0 MiB in 7 files |
| Recipe | ports/core/cli/fd/kpkgbuild |
About
fd finds files by name, a simpler and faster find for the common case: a regular expression or glob against the name, a parallel walk of the tree, and .gitignore rules and hidden files honoured by default. The port installs fd, its manual page and completions for bash, zsh and fish.
Sources
fd-10.5.0.tar.gz(134.2 KiB)
sha256e6d9e90730bf316101691e49d59cc02565278dc3779d33a77423801569484851
upstream: https://github.com/sharkdp/fd/archive/v10.5.0.tar.gz
archive copy: sources-1/cli--fd-10.5.0.tar.gzfd-vendor-10.5.0.tar.xz(14.2 MiB)
sha256ead8cd2694a63b2e416b3dd0a0330683ed358c99cea7eeee613486307fa7c397
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-1/cli--fd-vendor-10.5.0.tar.xz
Dependencies
Depends on: rust.
Required by (1): yazi.
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 fd'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/cli/fd.
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/cli/fd
echo 'e6d9e90730bf316101691e49d59cc02565278dc3779d33a77423801569484851 fd-10.5.0.tar.gz' | sha256sum -c -
echo 'ead8cd2694a63b2e416b3dd0a0330683ed358c99cea7eeee613486307fa7c397 fd-vendor-10.5.0.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/fd
SRC=$SRC_ROOT/fd-10.5.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf fd-10.5.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 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 --features use-jemalloc
install -Dm755 target/release/fd $PKG/usr/bin/fd
target/release/fd --gen-completions bash > fd.bash
target/release/fd --gen-completions fish > fd.fish
install -Dm644 fd.bash $PKG/usr/share/bash-completion/completions/fd
install -Dm644 fd.fish $PKG/usr/share/fish/vendor_completions.d/fd.fish
install -Dm644 contrib/completion/_fd $PKG/usr/share/zsh/site-functions/_fd
install -Dm644 doc/fd.1 $PKG/usr/share/man/man1/fd.1
The switches, and why each is set:
--features use-jemalloc— Make jemalloc, compiled from the vendoredtikv-jemalloc-syscrate, the program’s allocator, in place of musl’smalloc, which takes one global lock for every allocation while fd’s parallel walker allocates from many threads. The feature is added to upstream’s defaults, which build the completion generator.
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/fd, 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 fd-10.5.0-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/fd, and runs the triggers its paths call for.
Contents
Installed programs: fd.
Installed directories: /usr/share/licenses/fd.
Short descriptions
fd |
find entries in the filesystem |
Notes
fd is built from a vendor bundle, fd-vendor-<version>.tar.xz, made by ports/fetch with cargo vendor; see Vendoring. The jemalloc inside the binary is that crate’s copy, not the jemalloc port’s library.