Signed-off-by: Mathieu Parent <math.parent@gmail.com>
| ... | ... |
@@ -1,7 +1,21 @@ |
| 1 | 1 |
#!/usr/bin/env bash |
| 2 | 2 |
set -e |
| 3 | 3 |
|
| 4 |
+mkimgdeb="$(basename "$0")" |
|
| 5 |
+mkimg="$(dirname "$0").sh" |
|
| 6 |
+ |
|
| 7 |
+usage() {
|
|
| 8 |
+ echo >&2 "usage: $mkimgdeb rootfsDir suite [debootstrap-args]" |
|
| 9 |
+ echo >&2 " note: $mkimgdeb meant to be used from $mkimg" |
|
| 10 |
+ exit 1 |
|
| 11 |
+} |
|
| 12 |
+ |
|
| 4 | 13 |
rootfsDir="$1" |
| 14 |
+if [ -z "$rootfsDir" ]; then |
|
| 15 |
+ echo >&2 "error: rootfsDir is missing" |
|
| 16 |
+ echo >&2 |
|
| 17 |
+ usage |
|
| 18 |
+fi |
|
| 5 | 19 |
shift |
| 6 | 20 |
|
| 7 | 21 |
# we have to do a little fancy footwork to make sure "rootfsDir" becomes the second non-option argument to debootstrap |
| ... | ... |
@@ -13,10 +27,21 @@ while [ $# -gt 0 ] && [[ "$1" == -* ]]; do |
| 13 | 13 |
done |
| 14 | 14 |
|
| 15 | 15 |
suite="$1" |
| 16 |
+if [ -z "$suite" ]; then |
|
| 17 |
+ echo >&2 "error: suite is missing" |
|
| 18 |
+ echo >&2 |
|
| 19 |
+ usage |
|
| 20 |
+fi |
|
| 16 | 21 |
shift |
| 17 | 22 |
|
| 18 | 23 |
# get path to "chroot" in our current PATH |
| 19 |
-chrootPath="$(type -P chroot)" |
|
| 24 |
+chrootPath="$(type -P chroot || :)" |
|
| 25 |
+if [ -z "$chrootPath" ]; then |
|
| 26 |
+ echo >&2 "error: chroot not found. Are you root?" |
|
| 27 |
+ echo >&2 |
|
| 28 |
+ usage |
|
| 29 |
+fi |
|
| 30 |
+ |
|
| 20 | 31 |
rootfs_chroot() {
|
| 21 | 32 |
# "chroot" doesn't set PATH, so we need to set it explicitly to something our new debootstrap chroot can use appropriately! |
| 22 | 33 |
|