290.1. ripgrep-all-0.10.10
ripgrep that also searches inside PDFs, archives and spreadsheets
| Version | 0.10.10, release 1 |
| Shelf | cli — Command-line productivity utilities: search, view, navigation and text wrangling in the terminal |
| Phase | 44_apps (Applications), 37 of 422 in build order |
| Licence | AGPL-3.0-or-later |
| Homepage | https://github.com/phiresky/ripgrep-all |
| Build time | 2.2 SBU |
| Installed size | 18.0 MiB in 5 files |
| Recipe | ports/core/cli/ripgrep-all/kpkgbuild |
About
ripgrep-all (rga) runs ripgrep over files ripgrep cannot read as text: PDFs, e-books and office documents, archives and compressed files, SQLite databases, mailboxes, and the subtitles and metadata of media files. rga-preproc turns each file into text and caches the result; rga-fzf and rga-fzf-open are an interactive search through fzf. It is a Rust program built with cargo from its vendor bundle, the second sha256 = line (see Vendoring).
Why it is in KDOS
The comment above it in script/phases/44_apps/packages.d/cli.txt:
rga is an adapter layer over ripgrep and its dependencies are PROGRAMS: each missing helper is a file type it silently declines to search.
Sources
ripgrep-all-0.10.10.tar.gz(9.1 MiB)
sha25617fadc7b73a51608d57f82b4a11f3edc0da87716cc4b302103eed9d4b9010fe5
upstream: https://github.com/phiresky/ripgrep-all/archive/refs/tags/v0.10.10.tar.gz
archive copy: sources-1/cli--ripgrep-all-0.10.10.tar.gzripgrep-all-vendor-0.10.10.tar.xz(20.8 MiB)
sha2569ee1fcafba597a3e8902e7139e21a2693412ce80d03c3c91bfe09886a6c50ac5
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-1/cli--ripgrep-all-vendor-0.10.10.tar.xz
Dependencies
Depends on: rust, ripgrep, fzf, poppler, ffmpeg, pandoc, xz, bzip2, zstd, sqlite.
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/44_apps/phase.env && kpkg install ripgrep-all'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/cli/ripgrep-all.
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/ripgrep-all
echo '17fadc7b73a51608d57f82b4a11f3edc0da87716cc4b302103eed9d4b9010fe5 ripgrep-all-0.10.10.tar.gz' | sha256sum -c -
echo '9ee1fcafba597a3e8902e7139e21a2693412ce80d03c3c91bfe09886a6c50ac5 ripgrep-all-vendor-0.10.10.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/ripgrep-all
SRC=$SRC_ROOT/ripgrep-all-0.10.10
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf ripgrep-all-0.10.10.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 CARGO_HOME="$SRC_ROOT/.cargo"
export CARGO_NET_OFFLINE=true
export RUSTFLAGS="-C target-feature=-crt-static"
export ZSTD_SYS_USE_PKG_CONFIG=1
export LIBSQLITE3_SYS_USE_PKG_CONFIG=1
cargo build --release --frozen --offline
install -Dm755 target/release/rga $PKG/usr/bin/rga
install -Dm755 target/release/rga-preproc $PKG/usr/bin/rga-preproc
install -Dm755 target/release/rga-fzf $PKG/usr/bin/rga-fzf
install -Dm755 target/release/rga-fzf-open $PKG/usr/bin/rga-fzf-open
The switches, and why each is set:
ZSTD_SYS_USE_PKG_CONFIG=1— make thezstd-syscrate link the zstd port through pkg-config instead of compiling its own copy.LIBSQLITE3_SYS_USE_PKG_CONFIG=1— makelibsqlite3-syslink the sqlite port, even though the program’sCargo.tomlasksrusqlitefor itsbundledfeature, which would otherwise compile SQLite into the binary. rga uses SQLite for its cache and for searching inside database files.
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/ripgrep-all, 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 ripgrep-all-0.10.10-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/ripgrep-all, and runs the triggers its paths call for.
Contents
Installed programs: rga, rga-fzf, rga-fzf-open, rga-preproc.
Installed directories: /usr/share/licenses/ripgrep-all.
Notes
Both variables are among those script/env/chroot.env exports from 40_lang on (see rust); the recipe names them again for itself. Nothing after cargo build checks the binary’s NEEDED entries, so a crate that fell back to compiling its bundled library would not stop the build; readelf -d /usr/bin/rga-preproc, the program that does the extraction and caching, shows whether libzstd and libsqlite3 are linked.
Many file types are read by running another program, not by a crate: pdftotext from poppler for PDFs, pandoc for e-books and office documents, and ffprobe and ffmpeg from ffmpeg for media. With one missing, rga reports Could not find executable for every file of that type instead of searching it, so every such program is in depends although none is linked.