X-Git-Url: https://git.grml.org/?p=grml2usb.git;a=blobdiff_plain;f=grml2usb;h=5ab3bf23cb9381133e50f3caa7a74710791071c7;hp=737c68a9ba376c7aea7e845c2adf5440c486cece;hb=460813178067e6c3e30a041d49f7b44577f77b9f;hpb=100193b24b57c98c475f58484764d1b945666ff4 diff --git a/grml2usb b/grml2usb index 737c68a..5ab3bf2 100755 --- a/grml2usb +++ b/grml2usb @@ -768,19 +768,24 @@ def copy_system_files(grml_flavour, iso_mount, target): else: exec_rsync(filesystem_module, squashfs_target + 'filesystem.module') - kernel = search_file('vmlinuz', iso_mount) - if kernel is None: - # compat for releases < 2011.12 - kernel = search_file('linux26', iso_mount) + cleaned_flavour = re.sub(r'[,._-]', '', grml_flavour) - if kernel is None: - logging.critical("Fatal: kernel not found") - raise CriticalException("error locating kernel file") + if os.path.isdir(iso_mount + '/boot/' + cleaned_flavour): + exec_rsync(iso_mount + '/boot/' + cleaned_flavour, target + '/boot') + else: + kernel = search_file('vmlinuz', iso_mount) + if kernel is None: + # compat for releases < 2011.12 + kernel = search_file('linux26', iso_mount) + + if kernel is None: + logging.critical("Fatal: kernel not found") + raise CriticalException("error locating kernel file") - source = os.path.dirname(kernel) + '/' - dest = target + '/' + os.path.dirname(kernel).replace(iso_mount,'') + '/' - execute(mkdir, dest) - exec_rsync(source, dest) + source = os.path.dirname(kernel) + '/' + dest = target + '/' + os.path.dirname(kernel).replace(iso_mount,'') + '/' + execute(mkdir, dest) + exec_rsync(source, dest) def update_grml_versions(iso_mount, target): @@ -827,46 +832,24 @@ def update_grml_versions(iso_mount, target): else: return False -def copy_grml_files(iso_mount, target): +def copy_grml_files(grml_flavour, iso_mount, target): """copy some minor grml files to a given target + @grml_flavour: the current grml_flavour @iso_mount: path where a grml ISO is mounted on @target: path where grml's main files should be copied to""" grml_target = target + '/grml/' execute(mkdir, grml_target) - copy_files = [ 'grml-cheatcodes.txt', 'LICENSE.txt', 'md5sums', 'README.txt' ] - # handle grml-version - if not update_grml_versions(iso_mount, target): - copy_files.append('grml-version') - - for myfile in copy_files: - grml_file = search_file(myfile, iso_mount) - if grml_file is None: - logging.warn("Warning: file %s could not be found - can not install it", myfile) - else: - exec_rsync(grml_file, grml_target + myfile) - - grml_web_target = grml_target + '/web/' - execute(mkdir, grml_web_target) - - for myfile in 'index.html', 'style.css': - grml_file = search_file(myfile, iso_mount) - if grml_file is None: - logging.warn("Warning: file %s could not be found - can not install it", myfile) - else: - exec_rsync(grml_file, grml_web_target + myfile) - - grml_webimg_target = grml_web_target + '/images/' - execute(mkdir, grml_webimg_target) - - for myfile in 'button.png', 'favicon.png', 'linux.jpg', 'logo.png': - grml_file = search_file(myfile, iso_mount) - if grml_file is None: - logging.warn("Warning: file %s could not be found - can not install it", myfile) - else: - exec_rsync(grml_file, grml_webimg_target + myfile) + grml_prefixe = ["GRML", "grml"] + for prefix in grml_prefixe: + filename = "{0}/{1}/{2}".format(iso_mount, prefix, grml_flavour) + if os.path.exists(filename): + exec_rsync(filename, grml_target) + break + else: + logging.warn("Warning: could not find flavour directory for %s ", grml_flavour) def handle_addon_copy(filename, dst, iso_mount, ignore_errors=False): @@ -1005,6 +988,9 @@ def copy_bootloader_files(iso_mount, target, grml_flavour): logging.critical(" ... either use grml releases >=2009.10 or switch to an older grml2usb version.") raise + if not os.path.exists(iso_mount + '/boot/grub/footer.cfg'): + logging.warning("Warning: Grml releases older than 2011.12 support only one flavour in grub.") + for expr in name, 'distri.cfg', \ defaults_file, 'grml.png', 'hd.cfg', 'isolinux.cfg', 'isolinux.bin', \ 'isoprompt.cfg', 'options.cfg', \ @@ -1039,7 +1025,7 @@ def install_iso_files(grml_flavour, iso_mount, device, target): logging.info("Copying files. This might take a while....") try: copy_system_files(grml_flavour, iso_mount, target) - copy_grml_files(iso_mount, target) + copy_grml_files(grml_flavour, iso_mount, target) except CriticalException, error: logging.critical("Execution failed: %s", error) sys.exit(1) @@ -1135,7 +1121,7 @@ def handle_grub_config(grml_flavour, device, target): for regex in options.removeoption: remove_regexes.append(re.compile(regex)) - for filename in glob.glob(grub_target + '*.cfg'): + for filename in glob.glob(grub_target + grml_flavour + '*.cfg'): for line in fileinput.input(filename, inplace=1): line = line.rstrip("\r\n") if option_re.search(line): @@ -1621,6 +1607,11 @@ def check_programs(): logging.critical("Fatal: rsync not available, can not continue - sorry.") sys.exit(1) +def load_loop(): + """Runs modprobe loop and throws away it's output""" + proc = subprocess.Popen(["modprobe", "loop"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + proc.wait() + def main(): """Main function [make pylint happy :)]""" @@ -1639,6 +1630,8 @@ def main(): check_options(options) + load_loop() + logging.info("Executing grml2usb version %s", PROG_VERSION) if options.dryrun: @@ -1647,7 +1640,7 @@ def main(): check_programs() # specified arguments - device = args[len(args) - 1] + device = os.path.realpath(args[len(args) - 1]) isos = args[0:len(args) - 1] if not os.path.isdir(device):