- Drop perl, perl-io-socket-ssl, tcl-lib, tcl-tls, sqlite-tcl, lua5.4, lua5.4-dev, lua5.5, lua5.5-dev and sqlite (CLI) from the package set and add them to the prune denylist: 13 packages / 49.45 MiB including dependents. sqlite-libs, tcl, and all paramount runtimes stay. - Promote curl to an explicit world entry and pin curl, bc, ed, rlwrap, mandoc, nano, less and frotz as core tools in check-rebuild.sh. - Remove the lua/luac symlink creation and the lua5.5 critical-binary check from the build scripts; apply-bananarchy-overlay.sh deletes stale links. - Drop four legacy pmbootstrap-era so: world constraints (@ entries in the prune list); so:libperl.so was pinning perl and blocking its removal. - Update README.md, MANUAL.md, AGENTS.md, SDK.md section 7 and CHANGELOG.md. - Rebuild images/bananarchy-nokia-argon.img (1.59 GiB, down from 1.66 GiB) and verify with qemu-arm that yabasic, neoui.yab, neonet.yab, curl, bc and ed still work while perl, lua, sqlite3, gcc and janet are gone.
85 lines
3.0 KiB
Bash
Executable File
85 lines
3.0 KiB
Bash
Executable File
#!/bin/sh
|
|
# Remove Wayland-only, Rust-based, and retired packages from a target rootfs.
|
|
# Usage: prune-rootfs-packages.sh <rootfs-dir> world|purge
|
|
# world - drop retired entries from etc/apk/world before apk add, so apk can
|
|
# atomically replace conflicting providers (C sudo replaces sudo-rs),
|
|
# and pin install_if packages with negative constraints
|
|
# purge - apk del the still-installed entries after apk add, then re-pin the
|
|
# constraints and run apk fix so install_if packages stay removed
|
|
# Runs inside the build container, where apk and the repositories are available.
|
|
set -eu
|
|
|
|
ROOTFS="$1"
|
|
PHASE="$2"
|
|
BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
PRUNE_FILE="$BASE_DIR/scripts/rootfs-prune-packages.txt"
|
|
INSTALLED_DB="$ROOTFS/lib/apk/db/installed"
|
|
WORLD_FILE="$ROOTFS/etc/apk/world"
|
|
|
|
if [ ! -f "$PRUNE_FILE" ]; then
|
|
echo "Error: missing $PRUNE_FILE" >&2
|
|
exit 1
|
|
fi
|
|
PRUNE_PKGS="$(grep -v '^[[:space:]]*#' "$PRUNE_FILE" | grep -v '^[[:space:]]*$' | grep -v '^[!@]' | tr '\n' ' ')"
|
|
WORLD_DENY="$(grep '^!' "$PRUNE_FILE" | tr '\n' ' ')"
|
|
WORLD_DROP="$(grep '^@' "$PRUNE_FILE" | sed 's/^@//' | tr '\n' ' ')"
|
|
DENY_NAMES=""
|
|
for deny in $WORLD_DENY; do
|
|
DENY_NAMES="$DENY_NAMES ${deny#!}"
|
|
done
|
|
|
|
pin_world_constraints() {
|
|
if [ -f "$WORLD_FILE" ]; then
|
|
cp "$WORLD_FILE" "$WORLD_FILE.bananarchy-tmp"
|
|
else
|
|
: > "$WORLD_FILE.bananarchy-tmp"
|
|
fi
|
|
for pkg in $PRUNE_PKGS $DENY_NAMES; do
|
|
grep -vxF "$pkg" "$WORLD_FILE.bananarchy-tmp" > "$WORLD_FILE.bananarchy-tmp2" || true
|
|
mv "$WORLD_FILE.bananarchy-tmp2" "$WORLD_FILE.bananarchy-tmp"
|
|
grep -vxF "!$pkg" "$WORLD_FILE.bananarchy-tmp" > "$WORLD_FILE.bananarchy-tmp2" || true
|
|
mv "$WORLD_FILE.bananarchy-tmp2" "$WORLD_FILE.bananarchy-tmp"
|
|
done
|
|
for entry in $WORLD_DROP; do
|
|
grep -vxF "$entry" "$WORLD_FILE.bananarchy-tmp" > "$WORLD_FILE.bananarchy-tmp2" || true
|
|
mv "$WORLD_FILE.bananarchy-tmp2" "$WORLD_FILE.bananarchy-tmp"
|
|
done
|
|
for deny in $WORLD_DENY; do
|
|
printf '%s\n' "$deny" >> "$WORLD_FILE.bananarchy-tmp"
|
|
done
|
|
mv "$WORLD_FILE.bananarchy-tmp" "$WORLD_FILE"
|
|
}
|
|
|
|
case "$PHASE" in
|
|
world)
|
|
pin_world_constraints
|
|
;;
|
|
purge)
|
|
if [ -f "$INSTALLED_DB" ]; then
|
|
PRUNE_INSTALLED=""
|
|
for pkg in $PRUNE_PKGS; do
|
|
if grep -Fxq "P:$pkg" "$INSTALLED_DB"; then
|
|
PRUNE_INSTALLED="$PRUNE_INSTALLED $pkg"
|
|
fi
|
|
done
|
|
if [ -n "$PRUNE_INSTALLED" ]; then
|
|
echo "[prune] Removing:$PRUNE_INSTALLED"
|
|
# shellcheck disable=SC2086
|
|
if ! apk --root "$ROOTFS" --arch armv7 del --no-scripts $PRUNE_INSTALLED; then
|
|
echo " -> Warning: some retired packages could not be purged" >&2
|
|
fi
|
|
fi
|
|
# apk del drops negative constraints, so restore them and let apk fix
|
|
# purge the install_if packages that apk del cannot remove on its own.
|
|
pin_world_constraints
|
|
if ! apk --root "$ROOTFS" --arch armv7 fix --no-scripts; then
|
|
echo " -> Warning: apk fix could not enforce the prune constraints" >&2
|
|
fi
|
|
fi
|
|
;;
|
|
*)
|
|
echo "Usage: $0 <rootfs-dir> world|purge" >&2
|
|
exit 1
|
|
;;
|
|
esac
|