92.3. ripgrep-15.2.0
Recursively search directories for a regex pattern
| Version | 15.2.0, release 1 |
| Shelf | cli — Command-line productivity utilities: search, view, navigation and text wrangling in the terminal |
| Phase | 41_system (System), 281 of 1047 in build order |
| Licence | Unlicense OR MIT |
| Homepage | https://github.com/BurntSushi/ripgrep |
| Build time | 5.5 SBU |
| Installed size | 7.1 MiB in 7 files |
| Recipe | ports/core/cli/ripgrep/kpkgbuild |
About
ripgrep, rg, searches a directory tree for a regular expression, line by line, skipping what .gitignore and .ignore files exclude and hidden and binary files by default. The port builds it with PCRE2 support, so rg -P takes Perl-compatible patterns with look-around and backreferences, and generates its manual page and its bash, zsh and fish completions from the built binary.
Sources
ripgrep-15.2.0.tar.gz(592.3 KiB)
sha2567605249d3eb0d5f170e3414498e3344e26b1e7a147aec518b57090b80036a562
upstream: https://github.com/BurntSushi/ripgrep/archive/15.2.0.tar.gz
archive copy: sources-1/cli--ripgrep-15.2.0.tar.gzripgrep-vendor-15.2.0.tar.xz(5.9 MiB)
sha256422e95e9aad0cffa1b887292aaa6e3eff7b397a50f48e474bbf092943c144820
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-1/cli--ripgrep-vendor-15.2.0.tar.xz
Dependencies
Required by (2): ripgrep-all, 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 ripgrep'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/cli/ripgrep.
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
echo '7605249d3eb0d5f170e3414498e3344e26b1e7a147aec518b57090b80036a562 ripgrep-15.2.0.tar.gz' | sha256sum -c -
echo '422e95e9aad0cffa1b887292aaa6e3eff7b397a50f48e474bbf092943c144820 ripgrep-vendor-15.2.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/ripgrep
SRC=$SRC_ROOT/ripgrep-15.2.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf ripgrep-15.2.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 CARGO_HOME="$SRC_ROOT/.cargo"
export CARGO_NET_OFFLINE=true
export PCRE2_SYS_STATIC=0
export RUSTFLAGS="-C target-feature=-crt-static"
cargo build --release --frozen --offline --features 'pcre2'
install -Dm755 target/release/rg $PKG/usr/bin/rg
target/release/rg --generate man > rg.1
target/release/rg --generate complete-bash > rg.bash
target/release/rg --generate complete-zsh > _rg
target/release/rg --generate complete-fish > rg.fish
install -Dm644 rg.1 $PKG/usr/share/man/man1/rg.1
install -Dm644 rg.bash $PKG/usr/share/bash-completion/completions/rg
install -Dm644 _rg $PKG/usr/share/zsh/site-functions/_rg
install -Dm644 rg.fish $PKG/usr/share/fish/vendor_completions.d/rg.fish
The switches, and why each is set:
--features 'pcre2'— Build in the PCRE2 engine behind-P/--pcre2. ripgrep’s default build has only its own regex engine.PCRE2_SYS_STATIC=0— Tell thepcre2-syscrate to link the system’slibpcre2-8through pkg-config. Its build script otherwise assumes a static build on any musl target and compiles the PCRE2 copy it carries into the binary, where the pcre2 port’s updates never reach it.
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, 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-15.2.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/ripgrep, and runs the triggers its paths call for.
Contents
Installed programs: rg.
Installed directories: /usr/share/licenses/ripgrep.
Short descriptions
rg |
recursively search the current directory for lines matching a pattern |
Notes
rg is built from a vendor bundle, ripgrep-vendor-<version>.tar.xz, which ports/fetch makes with cargo vendor; see Vendoring. The installed binary NEEDs libpcre2-8.so.0; one that does not has fallen back to the bundled copy.