Merge remote-tracking branch 'origin/pr/20'
authorMichael Prokop <mika@grml.org>
Tue, 15 Oct 2019 08:24:47 +0000 (10:24 +0200)
committerMichael Prokop <mika@grml.org>
Tue, 15 Oct 2019 08:24:47 +0000 (10:24 +0200)
debian/control
debian/tests/control [new file with mode: 0644]
debian/tests/smoke-grml2usb-py2 [new file with mode: 0755]
debian/tests/smoke-grml2usb-py3 [new file with mode: 0755]
grml2usb

index 0c5aa38..0382eef 100644 (file)
@@ -17,7 +17,8 @@ Vcs-Browser: https://git.grml.org/?p=grml2usb.git
 
 Package: grml2usb
 Architecture: amd64 i386
-Depends: mtools,
+Depends: kmod,
+         mtools,
          python,
          python-parted,
          rsync,
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644 (file)
index 0000000..c6aeeed
--- /dev/null
@@ -0,0 +1,21 @@
+Tests: smoke-grml2usb-py2
+Depends: dosfstools,
+         kpartx,
+         isolinux,
+         python2,
+         syslinux,
+         syslinux-common,
+         xorriso,
+         @
+Restrictions: needs-root, isolation-machine, breaks-testbed
+
+Tests: smoke-grml2usb-py3
+Depends: dosfstools,
+         kpartx,
+         isolinux,
+         python2,
+         syslinux,
+         syslinux-common,
+         xorriso,
+         @
+Restrictions: needs-root, isolation-machine, breaks-testbed
diff --git a/debian/tests/smoke-grml2usb-py2 b/debian/tests/smoke-grml2usb-py2
new file mode 100755 (executable)
index 0000000..67b45d1
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+exec 2>&1
+set -ex
+
+TMPDIR=$(mktemp -d)
+LODEV=$(losetup -f)
+cleanup() {
+  kpartx -d "$LODEV" || true
+  losetup -d "$LODEV" || true
+  rm -rf "$TMPDIR"
+}
+trap cleanup EXIT
+
+mkdir "$TMPDIR"/isoroot "$TMPDIR"/isoroot/boot "$TMPDIR"/isoroot/boot/isolinux
+cp /usr/lib/ISOLINUX/isolinux.bin "$TMPDIR"/isoroot/boot/isolinux/
+echo 'FAKE' > "$TMPDIR"/isoroot/grml-version
+echo 'LOGO' > "$TMPDIR"/isoroot/boot/logo.16
+touch "$TMPDIR"/isoroot/boot/isolinux/FAKE_default.cfg
+touch "$TMPDIR"/isoroot/boot/isolinux/FAKE_grml.cfg
+touch "$TMPDIR"/isoroot/boot/isolinux/hidden.cfg
+xorriso -as mkisofs -l -r -J -no-pad -no-emul-boot -boot-load-size 4 -boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -o "$TMPDIR"/fake.iso "$TMPDIR"/isoroot
+xorriso -dev "$TMPDIR"/fake.iso -ls
+
+dd if=/dev/zero of="$TMPDIR"/blockdev bs=1M count=50
+
+sfdisk "$TMPDIR"/blockdev <<EOT
+label: dos
+label-id: 0x00000000
+unit: sectors
+
+p1 : start=        2048, size=      100352, type=6, bootable
+EOT
+
+losetup -P "$LODEV" "$TMPDIR"/blockdev
+
+python2 $(which grml2usb) --bootloader-only --verbose --skip-usb-check --force --fat16 "$TMPDIR"/fake.iso "$LODEV"p1
diff --git a/debian/tests/smoke-grml2usb-py3 b/debian/tests/smoke-grml2usb-py3
new file mode 100755 (executable)
index 0000000..d91a60b
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+exec 2>&1
+set -ex
+
+TMPDIR=$(mktemp -d)
+LODEV=$(losetup -f)
+cleanup() {
+  kpartx -d "$LODEV" || true
+  losetup -d "$LODEV" || true
+  rm -rf "$TMPDIR"
+}
+trap cleanup EXIT
+
+mkdir "$TMPDIR"/isoroot "$TMPDIR"/isoroot/boot "$TMPDIR"/isoroot/boot/isolinux
+cp /usr/lib/ISOLINUX/isolinux.bin "$TMPDIR"/isoroot/boot/isolinux/
+echo 'FAKE' > "$TMPDIR"/isoroot/grml-version
+echo 'LOGO' > "$TMPDIR"/isoroot/boot/logo.16
+touch "$TMPDIR"/isoroot/boot/isolinux/FAKE_default.cfg
+touch "$TMPDIR"/isoroot/boot/isolinux/FAKE_grml.cfg
+touch "$TMPDIR"/isoroot/boot/isolinux/hidden.cfg
+xorriso -as mkisofs -l -r -J -no-pad -no-emul-boot -boot-load-size 4 -boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -o "$TMPDIR"/fake.iso "$TMPDIR"/isoroot
+xorriso -dev "$TMPDIR"/fake.iso -ls
+
+dd if=/dev/zero of="$TMPDIR"/blockdev bs=1M count=50
+
+sfdisk "$TMPDIR"/blockdev <<EOT
+label: dos
+label-id: 0x00000000
+unit: sectors
+
+p1 : start=        2048, size=      100352, type=6, bootable
+EOT
+
+losetup -P "$LODEV" "$TMPDIR"/blockdev
+
+python3 $(which grml2usb) --bootloader-only --verbose --skip-usb-check --force --fat16 "$TMPDIR"/fake.iso "$LODEV"p1
index ac700f1..9c6c8c5 100755 (executable)
--- a/grml2usb
+++ b/grml2usb
@@ -315,7 +315,7 @@ def get_defaults_file(iso_mount, flavour, name):
     return ('', '')
 
 
-def search_file(filename, search_path='/bin' + os.pathsep + '/usr/bin', lst_return=False):
+def search_file(filename, search_path='/bin' + os.pathsep + '/usr/bin', lst_return=False, required=False):
     """Given a search path, find file
 
     @filename: name of file to search for
@@ -344,6 +344,10 @@ def search_file(filename, search_path='/bin' + os.pathsep + '/usr/bin', lst_retu
                 retval.append(os.path.abspath(os.path.join(current_dir, filename)))
                 if not lst_return:
                     break
+
+    if required and not retval:
+        raise CriticalException("Required file %s not found in %s" % (filename, search_path))
+
     if lst_return:
         return retval
     elif retval:
@@ -1108,7 +1112,7 @@ def copy_bootloader_files(iso_mount, target, grml_flavour):
     grub_target = target + '/boot/grub/'
     execute(mkdir, grub_target)
 
-    logo = search_file('logo.16', iso_mount)
+    logo = search_file('logo.16', iso_mount, required=True)
     exec_rsync(logo, syslinux_target + 'logo.16')
 
     bootx64_efi = search_file('bootx64.efi', iso_mount)
@@ -1928,6 +1932,8 @@ def main():
 
     except Exception as error:
         logging.critical("Fatal: %s", str(error))
+        if options.verbose:
+            logging.exception("Exception:")
         sys.exit(1)