diff options
author | Andrew Cady <d@jerkface.net> | 2018-07-09 17:46:51 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2018-07-09 17:46:51 -0400 |
commit | 2702e09259bd66b85c6d3a4c0753ed1120d714df (patch) | |
tree | 576a3b500bff0d3fa4618c1e4d305d2de7911acf /debootstrap.sh | |
parent | 6815ac19bfd8e945894d6d37ef5f0d51523aa8d4 (diff) |
get build-rootfs.sh working adequately to build some truly useful images
Diffstat (limited to 'debootstrap.sh')
-rwxr-xr-x | debootstrap.sh | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/debootstrap.sh b/debootstrap.sh index 0971c0c..2ef288b 100755 --- a/debootstrap.sh +++ b/debootstrap.sh | |||
@@ -12,11 +12,21 @@ usage() | |||
12 | { | 12 | { |
13 | cat <<EOF >&2 | 13 | cat <<EOF >&2 |
14 | Usage: | 14 | Usage: |
15 | |||
16 | # creation & deletion | ||
15 | $0 init <suite> | 17 | $0 init <suite> |
16 | $0 new <suite> <new-name> | 18 | $0 new <suite> <new-name> |
17 | $0 clone <suite> <source-name> <new-name> | 19 | $0 clone <suite> <source-name> <new-name> |
18 | $0 chroot <suite> <name> | 20 | $0 rm <suite> <source-name> |
19 | $0 add <suite> <name> <package> [packages...] | 21 | |
22 | # modification | ||
23 | $0 add <suite> <name> <package> [packages...] | ||
24 | $0 chroot <suite> <name> [command] [args...] | ||
25 | $0 sh <suite> <name> [command] [args...] | ||
26 | $0 with_mp <suite> <name> <command> [args...] | ||
27 | $0 with_img <suite> <name> <command> [args...] | ||
28 | |||
29 | # inspection | ||
20 | $0 list | 30 | $0 list |
21 | $0 show unpackaged <suite> <name> | 31 | $0 show unpackaged <suite> <name> |
22 | $0 show unpackaged-du <suite> <name> ["filtered"] | 32 | $0 show unpackaged-du <suite> <name> ["filtered"] |
@@ -46,7 +56,7 @@ list() | |||
46 | f=${f##*/} | 56 | f=${f##*/} |
47 | f=${f%.btrfs} | 57 | f=${f%.btrfs} |
48 | suite=${f%%-*} | 58 | suite=${f%%-*} |
49 | name=${f##*.} | 59 | name=${f#*.} |
50 | [ "$header_printed" ] || echo 'Existing images:' | 60 | [ "$header_printed" ] || echo 'Existing images:' |
51 | printf ' %s %s\n' "$suite" "$name" | 61 | printf ' %s %s\n' "$suite" "$name" |
52 | header_printed=y | 62 | header_printed=y |
@@ -139,6 +149,17 @@ show_unpackaged_du() | |||
139 | fi | 149 | fi |
140 | } | 150 | } |
141 | 151 | ||
152 | with_img() | ||
153 | { | ||
154 | local suite="$1" name="$2" command="$3" | ||
155 | shift 3 | ||
156 | [ "$suite" -a "$name" ] || usage | ||
157 | imagename=$(suite_name_to_imagename "$suite" "$name") | ||
158 | [ -e "$imagename" ] || die "no such file: $imagename" | ||
159 | |||
160 | "$command" "$@" "$imagename" | ||
161 | } | ||
162 | |||
142 | run_command_with_mountpoint() | 163 | run_command_with_mountpoint() |
143 | { | 164 | { |
144 | local suite="$1" name="$2" command="$3" | 165 | local suite="$1" name="$2" command="$3" |
@@ -172,13 +193,13 @@ add() | |||
172 | shift 2 | 193 | shift 2 |
173 | running_suite=$(lsb_release -cs) || die 'lsb_release failed' | 194 | running_suite=$(lsb_release -cs) || die 'lsb_release failed' |
174 | if [ "$suite" = "$running_suite" -a -x ./src/selfstrap ]; then | 195 | if [ "$suite" = "$running_suite" -a -x ./src/selfstrap ]; then |
175 | run_mp "$suite" "$name" ./src/selfstrap "$@" -t | 196 | with_mp "$suite" "$name" ./src/selfstrap "$@" -t |
176 | else | 197 | else |
177 | exit 1 | 198 | exit 1 |
178 | fi | 199 | fi |
179 | } | 200 | } |
180 | 201 | ||
181 | run_mp() | 202 | with_mp() |
182 | { | 203 | { |
183 | suite=$1 | 204 | suite=$1 |
184 | name=$2 | 205 | name=$2 |
@@ -363,7 +384,7 @@ show() | |||
363 | } | 384 | } |
364 | 385 | ||
365 | case "$1" in | 386 | case "$1" in |
366 | init|new|clone|list|show|add|run_mp) cmd=$1; shift; $cmd "$@" ;; | 387 | init|new|clone|list|show|add|with_mp|with_img) cmd=$1; shift; $cmd "$@" ;; |
367 | chroot|sh|rm) cmd=${1}_image; shift; $cmd "$@" ;; | 388 | chroot|sh|rm) cmd=${1}_image; shift; $cmd "$@" ;; |
368 | *) usage ;; | 389 | *) usage ;; |
369 | esac | 390 | esac |