+
+def install_mbr(target):
+ """Install a default master boot record on given target"""
+ print("TODO")
+
+
+def loopback_mount(iso, target):
+ """Loopback mount specified ISO on given target"""
+ print("mount -o loop %s %s") % (iso, target)
+
+
+def check_for_vat(partition):
+ """Check whether specified partition is VFAT/FAT16 filesystem"""
+ try:
+ udev_info = subprocess.Popen(["/lib/udev/vol_id", "-t",
+ partition],stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ filesystem = udev_info.communicate()[0].rstrip()
+
+ if udev_info.returncode == 2:
+ print("failed to read device %s - wrong UID / permissions?") % partition
+ return 1
+
+ if filesystem != "vfat":
+ return(1)
+
+ # TODO: check for ID_FS_VERSION=FAT16?
+
+ except OSError:
+ print("Sorry, /lib/udev/vol_id not available.")
+ return 1
+
+def copy_grml_files(grml_flavour, iso_mount, target):
+ """Copy files from ISO on given target"""
+
+ # TODO: provide alternative search_file() if file information is stored in
+ # a config.ini file?
+ squashfs = search_file(grml_flavour + '.squashfs', iso_mount)
+ print("debug: copy squashfs to %s") % target + '/live/' + grml_flavour + '.squashfs'
+
+ filesystem_module = search_file('filesystem.module', iso_mount)
+ print("debug: copy filesystem.module to %s") % target + '/live/' + grml_flavour + '.module'
+
+ kernel = search_file('linux26', iso_mount)
+ print("debug: copy kernel to %s") % target + '/boot/release/' + grml_flavour + '/linux26'
+
+ initrd = search_file('initrd.gz', iso_mount)
+ print("debug: copy initrd to %s") % target + '/boot/release/' + grml_flavour + '/initrd.gz'
+
+ logo = search_file('logo.16', iso_mount)
+ print("debug: copy logo.16 to %s") % target + '/boot/isolinux/' + 'logo.16'
+
+ for file in 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10':
+ bootsplash = search_file(file, iso_mount)
+ print("debug: copy %s to %s") % (bootsplash, target + '/boot/isolinux/' + file)
+
+
+def uninstall_files(device):
+ print("TODO")
+
+
+def identify_grml_flavour(mountpath):
+ version_file = search_file('grml-version', mountpath)
+ file = open(version_file, 'r')
+ grml_info = file.readline()
+ file.close
+ grml_flavour = re.match(r'[\w-]*', grml_info).group()
+ return grml_flavour
+