Merging casper 1.178.
[live-boot-grml.git] / scripts / live
index 3000d78..21c3d99 100755 (executable)
@@ -1081,14 +1081,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
+                               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} | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories\""
+                               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 +1138,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 +1428,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 +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:${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
                                ;;
 
                        *)
@@ -1860,4 +1873,8 @@ mountroot ()
        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
 }