8.37. red 1.0.2
Build and install red as the final Rust sed-compatible stream editor.
Input assumption: red-v1.0.2.tar.gz is already present in /sources from the chapter 4 source staging step.
Source URL: https://github.com/vyavdoshenko/red/archive/refs/tags/v1.0.2.tar.gz
Upstream compatibility note: upstream describes red as an experimental drop-in replacement for GNU sed and says it currently achieves full functional compatibility with GNU sed behavior. This section installs it as the final sed command after the Rust toolchain is available.
Licenses:
- MIT
Dependencies:
- musl (libc)
- clang
- ca-certificates
- rustc
- cargo
red is a Rust implementation of a GNU sed-compatible stream editor. we need it to provide the final target sed command for source edits, package build scripts, and routine text-processing work after the Rust toolchain is installed.
Extract and Enter the Source Tree
cd /sources
rm -rf red-1.0.2
tar -xf red-v1.0.2.tar.gz
cd red-1.0.2/red
Build red
red is a Cargo project and does not ship a Makefile, configure script, or install target. Build the locked release crate directly.
SSL_CERT_FILE=/system/configuration/ssl/cert.pem \
CARGO_HTTP_CAINFO=/system/configuration/ssl/cert.pem \
cargo build \
--release \
--locked \
--no-default-features \
--target "$LBI_ARCH-unknown-linux-musl"
Install red
Install the binary as red, remove the earlier sed implementation, then replace it with a symlink to red.
install -Dm755 "target/$LBI_ARCH-unknown-linux-musl/release/red" \
/system/binaries/red
rm -f /system/binaries/sed
rm -f /system/documentation/man-pages/sed.1
ln -sf red /system/binaries/sed
Verify red
red --version
sed --version
printf 'one two\n' | sed 's/two/three/'
The final command should print:
one three
bsdsed package remains part of the bootstrap path, but /system/binaries/sed now resolves to red.
Command Explanations
rm -rf red-...andtar -xf: Recreate a clean red source tree.SSL_CERT_FILEandCARGO_HTTP_CAINFO: Point Cargo's TLS stack at the installed CA bundle.cargo build --release --locked --no-default-features: Builds a reproducible release binary without default optional features.--target "$LBI_ARCH-unknown-linux-musl": Builds for the selected musl architecture target.install -Dm755 ... /system/binaries/red: Installs the red binary into the target command directory.rm -f /system/binaries/sedandln -sf red /system/binaries/sed: Replaces the earlier sed provider with red.red --version,sed --version, and the substitution pipeline: Verify both command names and basic sed behavior.