From 436c105986e8806d53f723509986cc20564d3c85 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Thu, 21 Jan 2021 10:42:30 -0500 Subject: selfstrap: force-enable --real-apt, force-disabling --unpack --- selfstrap | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/selfstrap b/selfstrap index 441456d..606c65e 100755 --- a/selfstrap +++ b/selfstrap @@ -2,8 +2,10 @@ debian_mirror=http://httpredir.debian.org/debian debian_security_mirror=http://security.debian.org EXTRA_PACKAGES='apt debian-archive-keyring locales' +REAL_APT_INSTALL=y die() { printf 'Error: %s\n' "$*"; exit 1; } +warn() { printf 'Warning: %s\n' "$*"; } usage() { @@ -45,7 +47,11 @@ done [ "$TARGET" ] || usage -! [ "$REAL_APT_INSTALL" -a "$UNPACK_ONLY" ] || die "option --real-apt is incompatible with option --unpack" +if [ "$REAL_APT_INSTALL" -a "$UNPACK_ONLY" ] +then + warn "option --real-apt is incompatible with option --unpack; disabling --unpack" + UNPACK_ONLY= +fi EXTRA_PACKAGES="$EXTRA_PACKAGES $*" @@ -116,7 +122,7 @@ apt_() # Avoid deleting lists on the calling system. set -- "$@" -o APT::Get::List-Cleanup=false - apt-"${apt_cmd}" "$@" + eatmydata -- apt-"${apt_cmd}" "$@" } apt_get() { apt_ get "$@"; } apt_cache() { apt_ cache "$@"; } @@ -462,13 +468,15 @@ if [ "$REAL_APT_INSTALL" ]; then # Unpack required packages. Handles (1) # Note: populate_rootfs() already created a necessary symlink /usr/bin/awk -> /usr/bin/mawk - apt_extract $required_packages + apt_extract $required_packages eatmydata # This handles (2). # An alternative (used by debootstrap) is to configure base-passwd install_etc_passwd + prepare_chroot "$TARGET" apt_get install -y $required_packages $EXTRA_PACKAGES + cleanup_chroot "$TARGET" else apt_extract $required_packages apt_extract $EXTRA_PACKAGES -- cgit v1.2.3