X-Git-Url: http://git.grml.org/?p=grml2usb.git;a=blobdiff_plain;f=grml2usb;h=9ac698833849c855c54dcbc2a1c514fd9c7ca465;hp=13c8249bf77af252fa18427a879c2c9397969ec5;hb=875b62bab2a04d2f105f28a5692edc514de04390;hpb=e86ad0fb7af950b56ecc47f393a1c812b0b37c07 diff --git a/grml2usb b/grml2usb index 13c8249..9ac6988 100755 --- a/grml2usb +++ b/grml2usb @@ -22,7 +22,7 @@ import uuid import struct # global variables -PROG_VERSION = "0.9.27" +PROG_VERSION = "0.9.28~git" MOUNTED = set() # register mountpoints TMPFILES = set() # register tmpfiles DATESTAMP = time.mktime(datetime.datetime.now().timetuple()) # unique identifier for syslinux.cfg @@ -1116,26 +1116,26 @@ def update_grml_versions(iso_mount, target): @target: path of the target mount point """ grml_target = target + '/grml/' - new_grml_version = search_file('grml-version', grml_target) - if new_grml_version: - orig_grml_version = search_file('grml-version', iso_mount) - if not orig_grml_version: - logging.warn("Warning: %s could not be found - can not install it", orig_grml_version) + target_grml_version_file = search_file('grml-version', grml_target) + if target_grml_version_file: + iso_grml_version_file = search_file('grml-version', iso_mount) + if not iso_grml_version_file: + logging.warn("Warning: %s could not be found - can not install it", iso_grml_version_file) return False try: - new_file = open(new_grml_version, 'a+') - new_flavours = [ get_flavour(l) for l in new_file.readlines() ] - - old_file = open(orig_grml_version, 'r') - old_lines = old_file.readlines() - for line in old_lines: - if not get_flavour(line) in new_flavours: - new_file.write(line) + target_file = open(target_grml_version_file, 'a+') + target_flavours = [ get_flavour(l) for l in target_file.readlines() ] + + iso_file = open(iso_grml_version_file, 'r') + iso_lines = iso_file.readlines() + for line in iso_lines: + if not get_flavour(line) in target_flavours: + target_file.write(line) except IOError: logging.warn("Warning: Could not write file") finally: - new_file.close() - old_file.close() + target_file.close() + iso_file.close() return True else: return False @@ -1868,7 +1868,6 @@ def install_grml(mountpoint, device): except CriticalException, error: logging.critical("Fatal: %s", error) raise - global GRML_FLAVOURS try: grml_flavours = identify_grml_flavour(mountpoint) for flavour in set(grml_flavours): @@ -2032,6 +2031,24 @@ def check_options(opts): sys.exit(1) +def check_programs(): + """check if all needed programs are installed""" + if options.grub: + if not which("grub-install"): + logging.critical("Fatal: grub-install not available (please install the " + + "grub package or drop the --grub option)") + sys.exit(1) + + if options.syslinux: + if not which("syslinux"): + logging.critical("Fatal: syslinux not available (please install the " + + "syslinux package or use the --grub option)") + sys.exit(1) + + if not which("rsync"): + logging.critical("Fatal: rsync not available, can not continue - sorry.") + sys.exit(1) + def main(): """Main function [make pylint happy :)]""" @@ -2055,6 +2072,8 @@ def main(): if options.dryrun: logging.info("Running in simulation mode as requested via option dry-run.") + check_programs() + # specified arguments device = args[len(args) - 1] isos = args[0:len(args) - 1] @@ -2068,21 +2087,6 @@ def main(): logging.critical("Fatal: installation on raw device not supported. (BIOS won't support it.)") sys.exit(1) - if options.grub: - if not which("grub-install"): - logging.critical("Fatal: grub-install not available (please install the " - + "grub package or drop the --grub option)") - sys.exit(1) - - if options.syslinux: - if not which("syslinux"): - logging.critical("Fatal: syslinux not available (please install the " - + "syslinux package or use the --grub option)") - sys.exit(1) - - if not which("rsync"): - logging.critical("Fatal: rsync not available, can not continue - sorry.") - sys.exit(1) # provide upgrade path handle_compat_warning(device)