1.1 --- a/user-do-root Mon May 07 00:32:42 2012 +0200
1.2 +++ b/user-do-root Mon Sep 10 00:31:02 2012 +0200
1.3 @@ -33,8 +33,13 @@
1.4 else
1.5 echo "Devices may already be defined for the installation." 1>&2
1.6 fi
1.7 +
1.8 + # Record this process's usage of the devices.
1.9 +
1.10 + touch "$PACKAGEROOT/dev.userinstall.$$"
1.11 +
1.12 elif [ ! -e "$PACKAGEROOT/dev" ]; then
1.13 - echo 1>&2 <<EOF
1.14 + cat 1>&2 <<EOF
1.15 Devices are not defined for the installation.
1.16 To mount the host system's devices, use the --dev option.
1.17 EOF
1.18 @@ -50,9 +55,20 @@
1.19 umount "$PACKAGEROOT/proc"
1.20 umount "$PACKAGEROOT/sys"
1.21
1.22 -if [ "$DEV" ]; then
1.23 - umount "$PACKAGEROOT/dev" && rmdir "$PACKAGEROOT/dev"
1.24 - if [ -e "$PACKAGEROOT/dev.orig" ] && [ ! -e "$PACKAGEROOT/dev" ]; then
1.25 - mv "$PACKAGEROOT/dev.orig" "$PACKAGEROOT/dev"
1.26 - fi
1.27 +rm "$PACKAGEROOT/dev.userinstall.$$"
1.28 +
1.29 +if [ "$DEV" ] ; then
1.30 + for FILENAME in "$PACKAGEROOT/dev.userinstall."* ; do
1.31 +
1.32 + # If the pattern does not expand to produce filenames, no such
1.33 + # files are present.
1.34 +
1.35 + if [ "$FILENAME" = "$PACKAGEROOT/dev.userinstall.*" ]; then
1.36 + umount "$PACKAGEROOT/dev" && rmdir "$PACKAGEROOT/dev"
1.37 + if [ -e "$PACKAGEROOT/dev.orig" ] && [ ! -e "$PACKAGEROOT/dev" ]; then
1.38 + mv "$PACKAGEROOT/dev.orig" "$PACKAGEROOT/dev"
1.39 + fi
1.40 + fi
1.41 + break
1.42 + done
1.43 fi