1.1 --- a/user-do-root Fri Apr 13 00:16:46 2012 +0200
1.2 +++ b/user-do-root Mon May 07 00:32:42 2012 +0200
1.3 @@ -10,26 +10,46 @@
1.4 exit 1
1.5 fi
1.6
1.7 +# Root installations benefit from having the proc and sys filesystems mounted.
1.8 +
1.9 mount -o bind /proc "$PACKAGEROOT/proc"
1.10 mount -o bind /sys "$PACKAGEROOT/sys"
1.11 +
1.12 if [ "$1" = '--dev' ]; then
1.13 DEV=$1
1.14 shift 1
1.15 - if [ -e "$PACKAGEROOT/dev.orig" ]; then
1.16 - echo "Devices may already be defined for the installation." 1>&2
1.17 +
1.18 + # Backup any existing device directory.
1.19 +
1.20 + if [ ! -e "$PACKAGEROOT/dev.orig" ] && [ -e "$PACKAGEROOT/dev" ]; then
1.21 + mv "$PACKAGEROOT/dev" "$PACKAGEROOT/dev.orig"
1.22 + fi
1.23 +
1.24 + # Make an empty device directory if appropriate.
1.25 +
1.26 + if [ ! -e "$PACKAGEROOT/dev" ] || rmdir "$PACKAGEROOT/dev" ; then
1.27 + mkdir "$PACKAGEROOT/dev"
1.28 + mount -o bind /dev "$PACKAGEROOT/dev"
1.29 else
1.30 - if [ -e "$PACKAGEROOT/dev" ]; then
1.31 - mv "$PACKAGEROOT/dev" "$PACKAGEROOT/dev.orig"
1.32 - fi
1.33 - if [ ! -e "$PACKAGEROOT/dev" ]; then
1.34 - mkdir "$PACKAGEROOT/dev"
1.35 - fi
1.36 - mount -o bind /dev "$PACKAGEROOT/dev"
1.37 + echo "Devices may already be defined for the installation." 1>&2
1.38 fi
1.39 +elif [ ! -e "$PACKAGEROOT/dev" ]; then
1.40 + echo 1>&2 <<EOF
1.41 +Devices are not defined for the installation.
1.42 +To mount the host system's devices, use the --dev option.
1.43 +EOF
1.44 + exit 1
1.45 fi
1.46 +
1.47 +# Enter the installation.
1.48 +
1.49 chroot "$PACKAGEROOT" $*
1.50 +
1.51 +# Unmount the filesystems.
1.52 +
1.53 umount "$PACKAGEROOT/proc"
1.54 umount "$PACKAGEROOT/sys"
1.55 +
1.56 if [ "$DEV" ]; then
1.57 umount "$PACKAGEROOT/dev" && rmdir "$PACKAGEROOT/dev"
1.58 if [ -e "$PACKAGEROOT/dev.orig" ] && [ ! -e "$PACKAGEROOT/dev" ]; then