diff options
author | Roger Leigh <rleigh@debian.org> | 2008-01-27 17:59:20 +0000 |
---|---|---|
committer | Roger Leigh <rleigh@debian.org> | 2008-01-27 17:59:20 +0000 |
commit | 7fabc6cd312d9f4776d75b8df685d28f5f17a051 (patch) | |
tree | fa7e8367f8335703caeca15dc097816c83dccd44 /bin | |
parent | d5ff3b6f2f9907f6d57fce77452c2b97157562b7 (diff) | |
download | schroot-7fabc6cd312d9f4776d75b8df685d28f5f17a051.tar.gz |
* bin/schroot/setup/*, bin/schroot/exec/*: All scripts check if
$CHROOT_SCRIPT_CONFIG exists, and exit with an error if not (but
only if status=ok, in order that the setup-stop task succeeds on
failure). Scripts using values from the $CHROOT_SCRIPT_CONFIG
check that they are defined and valid before using them, and exit
with an error if they are invalid.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/schroot/exec/00check | 5 | ||||
-rwxr-xr-x | bin/schroot/setup/00check | 5 | ||||
-rwxr-xr-x | bin/schroot/setup/05file | 5 | ||||
-rwxr-xr-x | bin/schroot/setup/05lvm | 5 | ||||
-rwxr-xr-x | bin/schroot/setup/10mount | 35 | ||||
-rwxr-xr-x | bin/schroot/setup/15killprocs | 5 | ||||
-rwxr-xr-x | bin/schroot/setup/20copyfiles | 24 | ||||
-rwxr-xr-x | bin/schroot/setup/50chrootname | 5 | ||||
-rwxr-xr-x | bin/schroot/setup/50sbuild | 5 |
9 files changed, 70 insertions, 24 deletions
diff --git a/bin/schroot/exec/00check b/bin/schroot/exec/00check index c6ac95ca..91dcdfa5 100755 --- a/bin/schroot/exec/00check +++ b/bin/schroot/exec/00check @@ -20,7 +20,10 @@ set -e if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" + . "$CHROOT_SCRIPT_CONFIG" +elif [ "$2" = "ok" ]; then + echo "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" + exit 1 fi if [ $1 = "exec-start" ]; then diff --git a/bin/schroot/setup/00check b/bin/schroot/setup/00check index c76ee011..77271be1 100755 --- a/bin/schroot/setup/00check +++ b/bin/schroot/setup/00check @@ -20,7 +20,10 @@ set -e if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" + . "$CHROOT_SCRIPT_CONFIG" +elif [ "$2" = "ok" ]; then + echo "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" + exit 1 fi if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then diff --git a/bin/schroot/setup/05file b/bin/schroot/setup/05file index d29defdd..def9bab0 100755 --- a/bin/schroot/setup/05file +++ b/bin/schroot/setup/05file @@ -20,7 +20,10 @@ set -e if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" + . "$CHROOT_SCRIPT_CONFIG" +elif [ "$2" = "ok" ]; then + echo "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" + exit 1 fi # Check file type diff --git a/bin/schroot/setup/05lvm b/bin/schroot/setup/05lvm index 1453a0eb..46c61af8 100755 --- a/bin/schroot/setup/05lvm +++ b/bin/schroot/setup/05lvm @@ -20,7 +20,10 @@ set -e if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" + . "$CHROOT_SCRIPT_CONFIG" +elif [ "$2" = "ok" ]; then + echo "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" + exit 1 fi if [ "$AUTH_VERBOSITY" = "verbose" ]; then diff --git a/bin/schroot/setup/10mount b/bin/schroot/setup/10mount index 1b349dd2..84c5240b 100755 --- a/bin/schroot/setup/10mount +++ b/bin/schroot/setup/10mount @@ -20,7 +20,10 @@ set -e if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" + . "$CHROOT_SCRIPT_CONFIG" +elif [ "$2" = "ok" ]; then + echo "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" + exit 1 fi # Mount a filesystem @@ -48,15 +51,17 @@ do_mount() # $1: mount base location do_umount_all() { - mounts="$("$LIBEXEC_DIR/schroot-listmounts" -m "$1")" - if [ "x$mounts" != 'x' ]; then - echo "$mounts" | - while read mountloc; do - if [ "$AUTH_VERBOSITY" = "verbose" ]; then - echo "Unmounting $mountloc" - fi - umount "$mountloc" || exit 1 - done || exit 1 + if [ -d "$1" ]; then + mounts="$("$LIBEXEC_DIR/schroot-listmounts" -m "$1")" + if [ "x$mounts" != 'x' ]; then + echo "$mounts" | + while read mountloc; do + if [ "$AUTH_VERBOSITY" = "verbose" ]; then + echo "Unmounting $mountloc" + fi + umount "$mountloc" || exit 1 + done || exit 1 + fi fi } @@ -102,7 +107,15 @@ if [ "$CHROOT_TYPE" = "plain" ] || [ "$CHROOT_TYPE" = "directory" ] || [ "$CHROO fi if [ "$CHROOT_TYPE" != "plain" ]; then - $LIBEXEC_DIR/schroot-mount $VERBOSE -f "$FSTAB" -m "$CHROOT_PATH" + if [ -n "$FSTAB" ]; then + if [ -f "$FSTAB" ]; then + "$LIBEXEC_DIR/schroot-mount" $VERBOSE \ + -f "$FSTAB" -m "$CHROOT_PATH" + else + echo "fstab file '$FSTAB' does not exist" + exit 1 + fi + fi fi elif [ $1 = "setup-stop" ]; then diff --git a/bin/schroot/setup/15killprocs b/bin/schroot/setup/15killprocs index 044eaa7e..bb1147f0 100755 --- a/bin/schroot/setup/15killprocs +++ b/bin/schroot/setup/15killprocs @@ -21,7 +21,10 @@ set -e if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" + . "$CHROOT_SCRIPT_CONFIG" +elif [ "$2" = "ok" ]; then + echo "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" + exit 1 fi # Kill all processes that were run from within the chroot environment diff --git a/bin/schroot/setup/20copyfiles b/bin/schroot/setup/20copyfiles index 0103721d..b52a7ec7 100755 --- a/bin/schroot/setup/20copyfiles +++ b/bin/schroot/setup/20copyfiles @@ -20,7 +20,10 @@ set -e if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" + . "$CHROOT_SCRIPT_CONFIG" +elif [ "$2" = "ok" ]; then + echo "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" + exit 1 fi if [ "$AUTH_VERBOSITY" = "verbose" ]; then @@ -63,12 +66,21 @@ copy_file() } if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then - while read file ; do - if echo "$file" | grep -q '^/'; then - copy_file "$file" "${CHROOT_PATH}$file" + + if [ -n "$COPYFILES" ]; then + if [ -f "$COPYFILES" ]; then + while read file; do + if echo "$file" | grep -q '^/'; then + copy_file "$file" "${CHROOT_PATH}$file" + else + echo "W: Not copying file with relative path: $file" + fi + done < "$COPYFILES" else - echo "W: Not copying file with relative path: $file" + echo "copyfiles file '$COPYFILES' does not exist" + exit 1 fi - done < "$COPYFILES" + fi + fi diff --git a/bin/schroot/setup/50chrootname b/bin/schroot/setup/50chrootname index 8b8355f2..6b571de0 100755 --- a/bin/schroot/setup/50chrootname +++ b/bin/schroot/setup/50chrootname @@ -20,7 +20,10 @@ set -e if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" + . "$CHROOT_SCRIPT_CONFIG" +elif [ "$2" = "ok" ]; then + echo "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" + exit 1 fi if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then diff --git a/bin/schroot/setup/50sbuild b/bin/schroot/setup/50sbuild index be3d39d9..8c2d484b 100755 --- a/bin/schroot/setup/50sbuild +++ b/bin/schroot/setup/50sbuild @@ -20,7 +20,10 @@ set -e if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then - . "$CHROOT_SCRIPT_CONFIG" + . "$CHROOT_SCRIPT_CONFIG" +elif [ "$2" = "ok" ]; then + echo "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist" + exit 1 fi if [ $1 = "setup-start" ] && [ "$SBUILD" = "true" ]; then |