summaryrefslogtreecommitdiffstats
path: root/iso2usb.sh
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2016-04-13 23:19:05 +0200
committer Eric Hameleers <alien@slackware.com>2016-04-13 23:19:05 +0200
commitd0f3ed8fe2e08ecb1cf38f4e896086a2ea41e13f (patch)
tree78532646ccae99c14bd378906f702e6e51f75b72 /iso2usb.sh
parent7af741640c38d865d91a9adb884e713b84af6ca5 (diff)
downloadliveslak-d0f3ed8fe2e08ecb1cf38f4e896086a2ea41e13f.tar.gz
liveslak-d0f3ed8fe2e08ecb1cf38f4e896086a2ea41e13f.tar.xz
iso2usb.sh: use XZ for compressing/decompressing the initrd.
Diffstat (limited to 'iso2usb.sh')
-rw-r--r--iso2usb.sh19
1 files changed, 16 insertions, 3 deletions
diff --git a/iso2usb.sh b/iso2usb.sh
index c519035..5a3d87d 100644
--- a/iso2usb.sh
+++ b/iso2usb.sh
@@ -59,6 +59,10 @@ ISOMNT=""
CNTMNT=""
USBMNT=""
+# Compressor used on the initrd ("gzip" or "xz --check=crc32");
+# Note that the kernel's XZ decompressor does not understand CRC64:
+COMPR="xz --check=crc32"
+
#
# -- function definitions --
#
@@ -124,13 +128,22 @@ cat <<EOT
EOT
}
+# Uncompress the initrd based on the compression algorithm used:
+uncompressfs () {
+ if $(file "${1}" | grep -qi ": gzip"); then
+ gzip -cd "${1}"
+ elif $(file "${1}" | grep -qi ": XZ"); then
+ xz -cd "${1}"
+ fi
+}
+
# Add longer USB WAIT to the initrd:
update_initrd() {
IMGFILE="$1"
# USB boot medium needs a few seconds boot delay else the overlay will fail.
# Check if we need to update the wait-for-root file in the initrd:
- OLDWAIT=$(gunzip -cd ${IMGFILE} |cpio -i --to-stdout wait-for-root 2>/dev/null)
+ OLDWAIT=$(uncompressfs ${IMGFILE} |cpio -i --to-stdout wait-for-root 2>/dev/null)
if [ "$OLDWAIT" = "$WAIT" -a $DOLUKS -eq 0 ]; then
return
fi
@@ -148,7 +161,7 @@ update_initrd() {
echo "--- Extracting Slackware initrd and adding rootdelay for USB..."
cd ${IMGDIR}
- gunzip -cd ${IMGFILE} \
+ uncompressfs ${IMGFILE} \
| cpio -i -d -H newc --no-absolute-filenames
echo "--- Updating 'waitforroot' time from '$OLDWAIT' to '$WAIT':"
echo ${WAIT} > wait-for-root
@@ -162,7 +175,7 @@ update_initrd() {
echo "--- Compressing the initrd image again:"
chmod 0755 ${IMGDIR}
- find . |cpio -o -H newc |gzip > ${IMGFILE}
+ find . |cpio -o -H newc |$COMPR > ${IMGFILE}
cd - 2>/dev/null
rm -rf $IMGDIR/*
} # End of update_initrd()