chroot_sandboxes/debian/get_debootstrap
Jarvis Carroll 4f6ee7cc88 Fix get_debootstrap script
Now it extracts and calls the program properly, if it isn't already
installed.

Also, the script `debian/cleanup_everything` removes debootstrap and
both of the created Debian roots, returning the repository to the same
state it clones in as.
2025-05-23 15:20:59 +10:00

34 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# Finds debootstrap in $PATH, or download some version of it if not found.
# This script prefers to use local copies that are already downloaded, over
# system-wide installations, in case you want to test on some specific
# outdated version of debootstrap.
download_it() {
curl http://deb.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.128+nmu2+deb12u2.tar.gz --output debootstrap.tar.gz
tar xf debootstrap.tar.gz && rm debootstrap.tar.gz
}
LOCALDIR=`pwd`/debootstrap
if test -e "$LOCALDIR/debootstrap"
then
echo "Found $LOCALDIR/debootstrap in current directory"
# Run debootstrap without installing it to the system.
DEBOOTSTRAP_DIR="$LOCALDIR" "$LOCALDIR/debootstrap" "$@"
elif IT=`command -v debootstrap`
then
echo "Found $IT in PATH"
# Use the version of debootstrap that was already installed.
debootstrap "$@"
else
echo "debootstrap not found. Downloading to $LOCALDIR."
download_it
# Run debootstrap without installing it to the system.
DEBOOTSTRAP_DIR="$LOCALDIR" "$LOCALDIR/debootstrap" "$@"
fi