minimal-bootstrap: trim bzip2-static output

Install the single bzip2 binary with bunzip2 and bzcat symlinks instead of duplicate binaries, and skip unused recovery tools, headers, libraries, scripts, and man pages. The smoke test covers compression plus both decompression entry points.

Size impact against upstream/staging:

- bzip2-static closure: 0.665 MiB -> 0.159 MiB (-0.505 MiB)

Assisted-by: codex with gpt-5.5-high
This commit is contained in:
Aliaksandr 2026-05-22 05:43:00 +03:00
commit 0bc798232d
No known key found for this signature in database
GPG key ID: CACB28BA93CE71A2
2 changed files with 29 additions and 9 deletions

View file

@ -33,12 +33,28 @@ bash.runCommand "${pname}-${version}"
gzip
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/bzip2 --help
mkdir $out
'';
passthru.tests = {
get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/bzip2 --help
mkdir $out
'';
compress =
result:
bash.runCommand "${pname}-compress-${version}" { } ''
printf 'bootstrap\n' > input
${result}/bin/bzip2 -k input
${result}/bin/bunzip2 -c input.bz2 > bunzip2-output
read -r bunzip2Output < bunzip2-output
test "$bunzip2Output" = bootstrap
${result}/bin/bzcat input.bz2 > bzcat-output
read -r bzcatOutput < bzcat-output
test "$bzcatOutput" = bootstrap
mkdir $out
'';
};
meta = {
description = "High-quality data compression program";
@ -58,12 +74,15 @@ bash.runCommand "${pname}-${version}"
-j $NIX_BUILD_CORES \
CC=musl-gcc \
CFLAGS=-static \
bzip2 bzip2recover
bzip2
# Install
make install -j $NIX_BUILD_CORES PREFIX=$out
mkdir -p $out/bin
cp bzip2 $out/bin/bzip2
ln -s bzip2 $out/bin/bunzip2
ln -s bzip2 $out/bin/bzcat
# Strip
# Ignore failures, because strip may fail on non-elf files.
find $out/{bin,lib} -type f -exec strip --strip-debug {} + || true
strip --strip-debug $out/bin/bzip2 || true
''

View file

@ -402,6 +402,7 @@ lib.makeScope
echo ${bash-static.tests.get-version}
echo ${binutils-static.tests.get-version}
echo ${bzip2-static.tests.get-version}
echo ${bzip2-static.tests.compress}
echo ${coreutils-static.tests.get-version}
echo ${diffutils-static.tests.get-version}
echo ${findutils-static.tests.get-version}