From 2702e09259bd66b85c6d3a4c0753ed1120d714df Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Mon, 9 Jul 2018 17:46:51 -0400 Subject: get build-rootfs.sh working adequately to build some truly useful images --- debootstrap.sh | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'debootstrap.sh') diff --git a/debootstrap.sh b/debootstrap.sh index 0971c0c..2ef288b 100755 --- a/debootstrap.sh +++ b/debootstrap.sh @@ -12,11 +12,21 @@ usage() { cat <&2 Usage: + +# creation & deletion $0 init $0 new $0 clone - $0 chroot - $0 add [packages...] + $0 rm + +# modification + $0 add [packages...] + $0 chroot [command] [args...] + $0 sh [command] [args...] + $0 with_mp [args...] + $0 with_img [args...] + +# inspection $0 list $0 show unpackaged $0 show unpackaged-du ["filtered"] @@ -46,7 +56,7 @@ list() f=${f##*/} f=${f%.btrfs} suite=${f%%-*} - name=${f##*.} + name=${f#*.} [ "$header_printed" ] || echo 'Existing images:' printf ' %s %s\n' "$suite" "$name" header_printed=y @@ -139,6 +149,17 @@ show_unpackaged_du() fi } +with_img() +{ + local suite="$1" name="$2" command="$3" + shift 3 + [ "$suite" -a "$name" ] || usage + imagename=$(suite_name_to_imagename "$suite" "$name") + [ -e "$imagename" ] || die "no such file: $imagename" + + "$command" "$@" "$imagename" +} + run_command_with_mountpoint() { local suite="$1" name="$2" command="$3" @@ -172,13 +193,13 @@ add() shift 2 running_suite=$(lsb_release -cs) || die 'lsb_release failed' if [ "$suite" = "$running_suite" -a -x ./src/selfstrap ]; then - run_mp "$suite" "$name" ./src/selfstrap "$@" -t + with_mp "$suite" "$name" ./src/selfstrap "$@" -t else exit 1 fi } -run_mp() +with_mp() { suite=$1 name=$2 @@ -363,7 +384,7 @@ show() } case "$1" in - init|new|clone|list|show|add|run_mp) cmd=$1; shift; $cmd "$@" ;; + init|new|clone|list|show|add|with_mp|with_img) cmd=$1; shift; $cmd "$@" ;; chroot|sh|rm) cmd=${1}_image; shift; $cmd "$@" ;; *) usage ;; esac -- cgit v1.2.3