Releasing debian version 4.0~a4-1.
[live-boot-grml.git] / scripts / boot / 9990-misc-helpers.sh
index 6b385cd..356fe6d 100755 (executable)
@@ -100,16 +100,7 @@ is_nice_device ()
 {
        sysfs_path="${1#/sys}"
 
-       if [ -e /lib/udev/path_id ]
-       then
-               # squeeze
-               PATH_ID="/lib/udev/path_id"
-       else
-               # wheezy/sid (udev >= 174)
-               PATH_ID="/sbin/udevadm test-builtin path_id"
-       fi
-
-       if ${PATH_ID} "${sysfs_path}" | egrep -q "ID_PATH=(usb|pci-[^-]*-(ide|sas|scsi|usb|virtio)|platform-sata_mv|platform-orion-ehci|platform-mmc|platform-mxsdhci)"
+       if /sbin/udevadm test-builtin path_id "${sysfs_path}" | egrep -q "ID_PATH=(usb|pci-[^-]*-(ide|sas|scsi|usb|virtio)|platform-sata_mv|platform-orion-ehci|platform-mmc|platform-mxsdhci)"
        then
                return 0
        elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
@@ -600,7 +591,7 @@ fs_size ()
                size=$(expr ${size} + ${size} / 20 ) # FIXME: 5% more to be sure
        else
                # free space
-               size="$(df -kP | grep -s ${mountp} | awk '{print $4}')"
+               size="$(df -k | grep -s ${mountp} | awk '{print $4}')"
        fi
 
        if [ -n "${doumount}" ]
@@ -1197,12 +1188,11 @@ link_files ()
 
 do_union ()
 {
-       local unionmountpoint unionrw unionro
+       local unionmountpoint unionrw unionro1 unionro2
        unionmountpoint="${1}"  # directory where the union is mounted
-       shift
-       unionrw="${1}"          # branch where the union changes are stored
-       shift
-       unionro="${*}"          # space separated list of read-only branches (optional)
+       unionrw="${2}"          # branch where the union changes are stored
+       unionro1="${3}"         # first underlying read-only branch (optional)
+       unionro2="${4}"         # second underlying read-only branch (optional)
 
        case "${UNIONTYPE}" in
                aufs)
@@ -1226,12 +1216,13 @@ do_union ()
                unionfs-fuse)
                        unionmountopts="-o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid"
                        unionmountopts="${unionmountopts} ${unionrw}=${rw_opt}"
-                       if [ -n "${unionro}" ]
+                       if [ -n "${unionro1}" ]
                        then
-                               for rofs in ${unionro}
-                               do
-                                       unionmountopts="${unionmountopts}:${rofs}=${ro_opt}"
-                               done
+                               unionmountopts="${unionmountopts}:${unionro1}=${ro_opt}"
+                       fi
+                       if [ -n "${unionro2}" ]
+                       then
+                               unionmountopts="${unionmountopts}:${unionro2}=${ro_opt}"
                        fi
                        ( sysctl -w fs.file-max=391524 ; ulimit -HSn 16384
                        unionfs-fuse ${unionmountopts} "${unionmountpoint}" ) && \
@@ -1240,27 +1231,21 @@ do_union ()
                        ;;
 
                overlayfs)
-                       # XXX: can multiple unionro be used? (overlayfs only handles two dirs, but perhaps they can be chained?)
-                       # XXX: and can unionro be optional? i.e. can overlayfs skip lowerdir?
-                       if echo ${unionro} | grep -q " "
-                       then
-                               panic "Multiple lower filesystems are currently not supported with overlayfs (unionro = ${unionro})."
-                       elif [ -z "${unionro}"  ]
-                       then
-                               panic "Overlayfs needs at least one lower filesystem (read-only branch)."
-                       fi
-                       unionmountopts="-o noatime,lowerdir=${unionro},upperdir=${unionrw}"
+                       # XXX: can unionro2 be used? (overlayfs only handles two dirs, but perhaps they can be chained?)
+                       # XXX: and can unionro1 be optional? i.e. can overlayfs skip lowerdir?
+                       unionmountopts="-o noatime,lowerdir=${unionro1},upperdir=${unionrw}"
                        mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}"
                        ;;
 
                *)
                        unionmountopts="-o noatime,${noxino_opt},dirs=${unionrw}=${rw_opt}"
-                       if [ -n "${unionro}" ]
+                       if [ -n "${unionro1}" ]
                        then
-                               for rofs in ${unionro}
-                               do
-                                       unionmountopts="${unionmountopts}:${rofs}=${ro_opt}"
-                               done
+                               unionmountopts="${unionmountopts}:${unionro1}=${ro_opt}"
+                       fi
+                       if [ -n "${unionro2}" ]
+                       then
+                               unionmountopts="${unionmountopts}:${unionro2}=${ro_opt}"
                        fi
                        mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}"
                        ;;
@@ -1497,13 +1482,15 @@ activate_custom_mounts ()
                        do
                                if [ -n "${rootmnt}" ]
                                then
-                                       fs="${d}/$(echo ${dest} | sed -e "s|${rootmnt}||")"
+                                       rootfs_dest_backing="${d}/$(echo ${dest} | sed -e "s|${rootmnt}||")"
                                else
-                                       fs="${d}/${dest}"
+                                       rootfs_dest_backing="${d}/${dest}"
                                fi
-                               if [ -d "${fs}" ]
+                               if [ -d "${rootfs_dest_backing}" ]
                                then
-                                       rootfs_dest_backing="${rootfs_dest_backing} ${fs}"
+                                       break
+                               else
+                                       rootfs_dest_backing=""
                                fi
                        done
                fi
@@ -1566,32 +1553,6 @@ activate_custom_mounts ()
        echo ${used_devices}
 }
 
-fix_backwards_compatibility ()
-{
-       local device dir opt backing include_list
-       device=${1}
-       dir=${2}
-       opt=${3}
-
-       if [ -n "${PERSISTENCE_READONLY}" ]
-       then
-               return
-       fi
-
-       backing="$(mount_persistence_media ${device})"
-       if [ -z "${backing}" ]
-       then
-               return
-       fi
-
-       include_list="${backing}/${persistence_list}"
-       if [ ! -r "${include_list}" ] && [ ! -r "${backing}/${old_persistence_list}" ]
-       then
-               echo "# persistence backwards compatibility:
-${dir} ${opt},source=." > "${include_list}"
-       fi
-}
-
 is_mountpoint ()
 {
        directory="$1"