Merging casper 1.216.
[live-boot-grml.git] / scripts / live
index 3000d78..26a6a46 100755 (executable)
@@ -20,6 +20,7 @@ USERFULLNAME="Live user"
 HOSTNAME="host"
 
 mkdir -p "${mountpoint}"
+tried="/tmp/tried"
 
 # Create /etc/mtab for debug purpose and future syncs
 if [ ! -d /etc ]
@@ -45,6 +46,7 @@ fi
 Arguments ()
 {
        PRESEEDS=""
+       LOCATIONS=""
 
        for ARGUMENT in $(cat /proc/cmdline)
        do
@@ -417,8 +419,8 @@ Arguments ()
                                ;;
 
                        preseed/file=*|file=*)
-                               LOCATION="${ARGUMENT#*=}"
-                               export LOCATION
+                               LOCATIONS="${ARGUMENT#*=} ${LOCATIONS}"
+                               export LOCATIONS
                                ;;
 
                        nopreseed)
@@ -427,7 +429,7 @@ Arguments ()
                                ;;
 
                        url=*)
-                               location="${ARGUMENT#url=}"
+                               URL_LOCATION="${ARGUMENT#url=}"
 
                                mount -o bind /sys /root/sys
                                mount -o bind /proc /root/proc
@@ -435,14 +437,14 @@ Arguments ()
 
                                mkdir -p /root/var/run/network
                                [ "${NETBOOT}" ] || chroot /root dhclient eth0
-                               chroot /root wget -P /tmp "${location}"
+                               chroot /root wget -P /tmp "${URL_LOCATION}"
                                [ "${NETBOOT}" ] || chroot /root ifconfig eth0 down
 
                                umount /root/sys
                                umount /root/proc
                                umount /root/dev
 
-                               LOCATION="/tmp/$(basename "${location}")"
+                               LOCATIONS="/tmp/$(basename ${URL_LOCATION}) ${LOCATIONS}"
                                ;;
 
                        */*=*)
@@ -665,12 +667,15 @@ is_nice_device ()
 {
        sysfs_path="${1#/sys}"
 
-       if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-|platform-mmc)"
+       if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-|platform-orion-ehci|platform-mmc|platform-mxsdhci|)"
        then
                return 0
        elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
        then
                return 0
+       elif echo ${sysfs_path} | grep -q "^/block/dm-"
+       then
+               return 0
        fi
 
        return 1
@@ -775,6 +780,10 @@ do_netmount ()
        udevadm trigger
        udevadm settle
 
+       if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && \
+          [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
+       then
+
        # if ethdevice was not specified on the kernel command line
        # make sure we try to get a working network configuration
        # for *every* present network device (except for loopback of course)
@@ -818,6 +827,10 @@ do_netmount ()
                fi
        done
 
+       else
+       ipconfig ${DEVICE} | tee /netboot.config
+       fi
+
        # source relevant ipconfig output
        OLDHOSTNAME=${HOSTNAME}
        . /tmp/net-${DEVICE}.conf
@@ -1081,14 +1094,23 @@ try_snap ()
                        RES=$?
                else
                        # cpio.gz snapshot
-                       cd "${snap_mount}"
-                       zcat "${snapback}/${snapfile}" | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1
-                       RES=$?
-                       if [ "${RES}" != "0" ]
+
+                       # Unfortunately klibc's cpio is incompatible with the
+                       # rest of the world; everything else requires -u -d,
+                       # while klibc doesn't implement them. Try to detect
+                       # whether it's in use.
+                       cpiopath="$(which cpio)" || true
+                       if [ "$cpiopath" ] && grep -aq /lib/klibc "$cpiopath"
                        then
-                               log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories\""
+                               cpioargs=
+                       else
+                               cpioargs='--unconditional --make-directories'
+                       fi
+
+                       if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse 2>/dev/null)
+                       then
+                               log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | cpio $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse\""
                        fi
-                       cd "${OLDPWD}"
                fi
 
                umount "${snapback}" ||  log_warning_msg "failure to \"umount ${snapback}\""
@@ -1129,7 +1151,7 @@ try_snap ()
                return 1
        fi
 
-       echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
+       echo "export ${snap_type}SNAP="/cow${snap_mount#$rootmnt}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
        return 0
 }
 
@@ -1419,6 +1441,8 @@ setup_unionfs ()
                        case "${UNIONTYPE}" in
                                unionfs-fuse)
                                        (ulimit -n 16384; unionfs-fuse -o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid /cow=RW:${exposedrootfs}${dir} "${rootmnt}${dir}" || panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option cow,noinitgroups,default_permissions,allow_other,use_ino,suid=/cow=RW:${exposedrootfs}${dir}")
+                                       mkdir -p /dev/.initramfs/varrun
+                                       pidof unionfs-fuse >> /dev/.initramfs/varrun/sendsigs.omit || true
                                        ;;
 
                                *)
@@ -1430,6 +1454,8 @@ setup_unionfs ()
                case "${UNIONTYPE}" in
                        unionfs-fuse)
                                (ulimit -n 16384; unionfs-fuse -o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid /cow=RW:${rofsstring} "${rootmnt}" || panic "mount ${UNIONTYPE} on ${rootmnt} failed with option cow,noinitgroups,default_permissions,allow_other,use_ino,suid=/cow:RW:${rofsstring}")
+                               mkdir -p /dev/.initramfs/varrun
+                               pidof unionfs-fuse >> /dev/.initramfs/varrun/sendsigs.omit || true
                                ;;
 
                        *)
@@ -1550,6 +1576,7 @@ check_dev ()
                        umount $mountpoint
                fi
        fi
+       [ -e "$devname" ] || continue
 
        if [ -n "${LIVE_MEDIA_OFFSET}" ]
        then
@@ -1561,7 +1588,10 @@ check_dev ()
 
        if is_supported_fs ${fstype}
        then
+               devuid=$(blkid -o value -s UUID "$devname")
+               [ -n "$devuid" ] && grep -qs "\<$devuid\>" $tried && continue
                mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
+               [ -n "$devuid" ] && echo "$devuid" >> $tried
 
                if is_live_path ${mountpoint} && \
                        ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
@@ -1661,6 +1691,7 @@ find_livefs ()
        for sysblock in $devices_to_scan
        do
                devname=$(sys2dev "${sysblock}")
+               [ -e "$devname" ] || continue
                fstype=$(get_fstype "${devname}")
 
                if /lib/udev/cdrom_id ${devname} > /dev/null
@@ -1732,6 +1763,14 @@ integrity_check ()
        fi
 }
 
+start_usplash_pulse ()
+{
+       if [ -x /sbin/usplash_write ]
+       then
+               /sbin/usplash_write "PULSELOGO"
+       fi
+}
+
 mountroot ()
 {
         if [ -x /scripts/local-top/cryptroot ]; then
@@ -1751,6 +1790,7 @@ mountroot ()
        Arguments
 
        set_usplash_timeout
+       start_usplash_pulse
 
        maybe_break live-premount
        log_begin_msg "Running /scripts/live-premount"
@@ -1845,6 +1885,28 @@ mountroot ()
                mount -n -o bind /dev "${rootmnt}/dev"
        fi
 
+       # Open up two fifo's fd's for debconf-communicate to use. Speeds up
+       # the live-initramfs process considerably.
+       log_begin_msg "Creating debconf-communicate fifo mechanism"
+       mkfifo /tmp/debconf-in.fifo
+       mkfifo /tmp/debconf-out.fifo
+
+       chroot /root debconf-communicate -fnoninteractive live-initramfs > /tmp/debconf-out.fifo < /tmp/debconf-in.fifo &
+
+       # Save the PID so it can be killed later.
+       DEBCONF_COMMUNICATE_PID="$!"
+
+       if [ ! -p /tmp/debconf-in.fifo ] || [ ! -p /tmp/debconf-out.fifo ]
+       then
+               log_warning_msg "failed to setup debconf-communicate channel"
+       fi
+       log_end_msg
+
+       # Order matters!
+       # These file descriptors must stay open until we're finished with
+       # debconf-communicate.
+       exec 4</tmp/debconf-out.fifo 3>/tmp/debconf-in.fifo
+
        maybe_break live-bottom
        log_begin_msg "Running /scripts/live-bottom\n"
 
@@ -1856,8 +1918,19 @@ mountroot ()
                umount "${rootmnt}/dev"
        fi
 
+       # Kill the debconf-communicate instance and close fd's associated with·
+       # debconf-communicate.
+       kill $DEBCONF_COMMUNICATE_PID
+       exec 3>&- 4<&-
+       rm -f /tmp/debconf-in.fifo
+       rm -f /tmp/debconf-out.fifo
+
        exec 1>&6 6>&-
        exec 2>&7 7>&-
        kill ${tailpid}
        [ -w "${rootmnt}/var/log/" ] && cp live.log "${rootmnt}/var/log/" 2>/dev/null
+       if [ -f /etc/live.conf ]
+       then
+               cp /etc/live.conf "${rootmnt}/etc/"
+       fi
 }