1 #!/bin/sh 2 3 # Configuration: 4 if [ -e userinstall-defaults ]; then 5 . "$PWD/userinstall-defaults" 6 elif [ -e /etc/default/userinstall ]; then 7 . /etc/default/userinstall 8 else 9 echo "No defaults found for userinstall." 1>&2 10 exit 1 11 fi 12 13 # Root installations benefit from having the proc and sys filesystems mounted. 14 15 mount -o bind /proc "$PACKAGEROOT/proc" 16 mount -o bind /sys "$PACKAGEROOT/sys" 17 18 if [ "$1" = '--dev' ]; then 19 DEV=$1 20 shift 1 21 22 # Backup any existing device directory. 23 24 if [ ! -e "$PACKAGEROOT/dev.orig" ] && [ -e "$PACKAGEROOT/dev" ]; then 25 mv "$PACKAGEROOT/dev" "$PACKAGEROOT/dev.orig" 26 fi 27 28 # Make an empty device directory if appropriate. 29 30 if [ ! -e "$PACKAGEROOT/dev" ] || rmdir "$PACKAGEROOT/dev" ; then 31 mkdir "$PACKAGEROOT/dev" 32 mount -o bind /dev "$PACKAGEROOT/dev" 33 else 34 echo "Devices may already be defined for the installation." 1>&2 35 fi 36 elif [ ! -e "$PACKAGEROOT/dev" ]; then 37 echo 1>&2 <<EOF 38 Devices are not defined for the installation. 39 To mount the host system's devices, use the --dev option. 40 EOF 41 exit 1 42 fi 43 44 # Enter the installation. 45 46 chroot "$PACKAGEROOT" $* 47 48 # Unmount the filesystems. 49 50 umount "$PACKAGEROOT/proc" 51 umount "$PACKAGEROOT/sys" 52 53 if [ "$DEV" ]; then 54 umount "$PACKAGEROOT/dev" && rmdir "$PACKAGEROOT/dev" 55 if [ -e "$PACKAGEROOT/dev.orig" ] && [ ! -e "$PACKAGEROOT/dev" ]; then 56 mv "$PACKAGEROOT/dev.orig" "$PACKAGEROOT/dev" 57 fi 58 fi