X-Git-Url: https://git.grml.org/?p=grml2usb.git;a=blobdiff_plain;f=grml2usb;h=fd6dc17865327fb987d146ebb1aab7d38edb1b44;hp=fd03ef9c5594763368e21f79255a16e84d1c3cf3;hb=5296685e8dc17decbbd1f163bc06c25f336e313c;hpb=f5b6d9662dadabbaa7221d3f33a8fea906db4b54 diff --git a/grml2usb b/grml2usb index fd03ef9..fd6dc17 100755 --- a/grml2usb +++ b/grml2usb @@ -12,7 +12,7 @@ This script installs a grml system (either a running system or ISO[s]) to a USB """ -from __future__ import with_statement +# from __future__ import with_statement from optparse import OptionParser from inspect import isroutine, isclass import datetime, logging, os, re, subprocess, sys, tempfile, time @@ -612,20 +612,21 @@ def install_grub(device): device_mountpoint = tempfile.mkdtemp(prefix="grml2usb") register_tmpfile(device_mountpoint) try: - mount(device, device_mountpoint, "") - logging.debug("grub-install --recheck --no-floppy --root-directory=%s %s", device_mountpoint, device) - proc = subprocess.Popen(["grub-install", "--recheck", "--no-floppy", - "--root-directory=%s" % device_mountpoint, device], stdout=file(os.devnull, "r+")) - proc.wait() - if proc.returncode != 0: - # raise Exception("error executing grub-install") - logging.critical("Fatal: error executing grub-install (please check the grml2usb FAQ)") + try: + mount(device, device_mountpoint, "") + logging.debug("grub-install --recheck --no-floppy --root-directory=%s %s", device_mountpoint, device) + proc = subprocess.Popen(["grub-install", "--recheck", "--no-floppy", + "--root-directory=%s" % device_mountpoint, device], stdout=file(os.devnull, "r+")) + proc.wait() + if proc.returncode != 0: + # raise Exception("error executing grub-install") + logging.critical("Fatal: error executing grub-install (please check the grml2usb FAQ)") + cleanup() + sys.exit(1) + except CriticalException, error: + logging.critical("Fatal: %s" % error) cleanup() sys.exit(1) - except CriticalException, error: - logging.critical("Fatal: %s" % error) - cleanup() - sys.exit(1) finally: unmount(device_mountpoint, "") @@ -1479,12 +1480,13 @@ def handle_dir(live_image, device): sys.exit(1) try: - grml_flavour = identify_grml_flavour(live_image) - logging.info("Identified grml flavour \"%s\"." % grml_flavour) - install_iso_files(grml_flavour, live_image, device, device_mountpoint) - except TypeError: - logging.critical("Fatal: a critical error happend during execution (not a grml ISO?), giving up") - sys.exit(1) + try: + grml_flavour = identify_grml_flavour(live_image) + logging.info("Identified grml flavour \"%s\"." % grml_flavour) + install_iso_files(grml_flavour, live_image, device, device_mountpoint) + except TypeError: + logging.critical("Fatal: a critical error happend during execution (not a grml ISO?), giving up") + sys.exit(1) finally: if remove_device_mountpoint: try: @@ -1537,12 +1539,13 @@ def handle_iso(iso, device): sys.exit(1) try: - grml_flavour = identify_grml_flavour(iso_mountpoint) - logging.info("Identified grml flavour \"%s\"." % grml_flavour) - install_iso_files(grml_flavour, iso_mountpoint, device, device_mountpoint) - except TypeError: - logging.critical("Fatal: a critical error happend during execution (not a grml ISO?), giving up") - sys.exit(1) + try: + grml_flavour = identify_grml_flavour(iso_mountpoint) + logging.info("Identified grml flavour \"%s\"." % grml_flavour) + install_iso_files(grml_flavour, iso_mountpoint, device, device_mountpoint) + except TypeError: + logging.critical("Fatal: a critical error happend during execution (not a grml ISO?), giving up") + sys.exit(1) finally: if os.path.isdir(iso_mountpoint) and remove_iso_mountpoint: unmount(iso_mountpoint, "")