extract ISO feature: make sure *.squashfs files exist + support older ISOs too
authorMichael Prokop <mika@grml.org>
Fri, 25 May 2012 11:17:14 +0000 (13:17 +0200)
committerMichael Prokop <mika@grml.org>
Fri, 25 May 2012 11:17:14 +0000 (13:17 +0200)
ISOs before release 2011.12 used /live/ for storing squashfs files,
releases starting with 2011.12 use /live/*/ (where "*" corresponds
to the release name). Test whether such files exist before accessing
them and while adding the check also add support for releases older
than 2011.12.

Thanks: Charles A. Hewson <cahewson@eskimo.com> for the bugreport

grml-live

index aedf4a6..b62e89b 100755 (executable)
--- a/grml-live
+++ b/grml-live
@@ -553,7 +553,20 @@ if [ -n "$EXTRACT_ISO_NAME" ]; then
     eend 1
     bailout 1
   fi
-  unsquashfs -d "${CHROOT_OUTPUT}" "${mountpoint}"/live/*/*.squashfs ; rc=$?
+
+  if ls "${mountpoint}"/live/*/*.squashfs 2>/dev/null | grep -q . ; then # ISOs >=2011.12
+    log "Using ${mountpoint}/live/*/*.squashfs for unsquashfs"
+    unsquashfs -d "${CHROOT_OUTPUT}" "${mountpoint}"/live/*/*.squashfs ; rc=$?
+  elif ls "${mountpoint}"/live/*.squashfs 2>/dev/null | grep -q . ; then # ISOs before 2011.12
+    log "Using ${mountpoint}/live/*.squashfs for unsquashfs"
+    unsquashfs -d "${CHROOT_OUTPUT}" "${mountpoint}"/live/*.squashfs ; rc=$?
+  else
+    log "Error: Could not find any *.squashfs files on the ISO"
+    eerror "Error: Could not find any *.squashfs files on the ISO"
+    eend 1
+    bailout 1
+  fi
+
   umount "$mountpoint"
   rmdir "$mountpoint"
   if [ "$rc" != 0 ]; then