+def handle_iso(iso, device):
+ """TODO
+ """
+
+ logging.info("Using ISO %s" % iso)
+
+ if os.path.isdir(iso):
+ logging.critical("TODO: /live/image handling not yet implemented") # TODO
+ else:
+ iso_mountpoint = tempfile.mkdtemp()
+ register_tmpfile(iso_mountpoint)
+ remove_iso_mountpoint = True
+
+ mount(iso, iso_mountpoint, ["-o", "loop", "-t", "iso9660"])
+
+ if os.path.isdir(device):
+ logging.info("Specified target is a directory, not mounting therefore.")
+ device_mountpoint = device
+ remove_device_mountpoint = False
+ skip_mbr = True
+
+ else:
+ device_mountpoint = tempfile.mkdtemp()
+ register_tmpfile(device_mountpoint)
+ remove_device_mountpoint = True
+ try:
+ mount(device, device_mountpoint, "")
+ except Exception, error:
+ logging.critical("Fatal: %s" % error)
+ cleanup()
+
+ try:
+ grml_flavour = identify_grml_flavour(iso_mountpoint)
+ logging.info("Identified grml flavour \"%s\"." % grml_flavour)
+ copy_grml_files(grml_flavour, iso_mountpoint, device_mountpoint, dry_run=options.dryrun)
+ except TypeError:
+ logging.critical("Fatal: a critical error happend during execution, giving up")
+ sys.exit(1)
+ finally:
+ if os.path.isdir(iso_mountpoint) and remove_iso_mountpoint:
+ unmount(iso_mountpoint, "")
+
+ os.rmdir(iso_mountpoint)
+ unregister_tmpfile(iso_mountpoint)
+
+ if remove_device_mountpoint:
+ unmount(device_mountpoint, "")
+
+ if os.path.isdir(device_mountpoint):
+ os.rmdir(device_mountpoint)
+ unregister_tmpfile(device_mountpoint)
+
+ # grml_flavour_short = grml_flavour.replace('-','')
+ # logging.debug("grml_flavour_short = %s" % grml_flavour_short)
+