+ try:
+ handle_syslinux_config(grml_flavour, target)
+ except CriticalException, error:
+ logging.critical("Fatal: %s", error)
+ sys.exit(1)
+
+ if options.skipgrubconfig:
+ logging.info("Skipping generation of grub configuration as requested.")
+ else:
+ try:
+ handle_grub_config(grml_flavour, device, target)
+ except CriticalException, error:
+ logging.critical("Fatal: %s", error)
+ sys.exit(1)
+
+def handle_dir(live_image, device):
+ """Main logic for copying files of the currently running grml system.
+
+ @live_image: directory where currently running live system resides (usually /live/image)
+ @device: partition where the specified ISO should be installed to"""
+
+ logging.info("Using %s as install base", live_image)
+
+ if os.path.isdir(device):
+ logging.info("Specified target is a directory, therefore not mounting.")
+ device_mountpoint = device
+ remove_device_mountpoint = False
+ else:
+ device_mountpoint = tempfile.mkdtemp(prefix="grml2usb")
+ register_tmpfile(device_mountpoint)
+ remove_device_mountpoint = True
+ try:
+ mount(device, device_mountpoint, "")
+ except CriticalException, error:
+ logging.critical("Fatal: %s", error)
+ cleanup()
+ sys.exit(1)
+
+ try:
+ 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:
+ unmount(device_mountpoint, "")
+ if os.path.isdir(device_mountpoint):
+ os.rmdir(device_mountpoint)
+ unregister_tmpfile(device_mountpoint)
+ except CriticalException, error:
+ logging.critical("Fatal: %s", error)
+ cleanup()