X-Git-Url: https://git.grml.org/?p=grml2usb.git;a=blobdiff_plain;f=grml2usb;h=ab0ad63189e31299bc785be9269fdcaacf3a0651;hp=b0a1fc231504bccc6b6fc591aeb11fc0f84e61f3;hb=360c9e5b51ef3d640ed6343da2babbe646415465;hpb=a06f95e130756c62301da0ef35c133e78c82ce2f diff --git a/grml2usb b/grml2usb index b0a1fc2..ab0ad63 100755 --- a/grml2usb +++ b/grml2usb @@ -40,6 +40,7 @@ GRML_FLAVOURS = set() # which flavours are being installed? GRML_DEFAULT = None UUID = None SYSLINUX_LIBS = "/usr/lib/syslinux/" +GPT_HEADER = "\x55\xaa\x45\x46\x49\x20\x50\x41\x52\x54" # original GPT header RE_PARTITION = re.compile(r'([a-z/]*?)(\d+)$') RE_P_PARTITION = re.compile(r'(.*?\d+)p(\d+)$') @@ -311,16 +312,20 @@ def search_file(filename, search_path='/bin' + os.pathsep + '/usr/bin', lst_retu def check_uid_root(): """Check for root permissions""" if not os.geteuid() == 0: - sys.exit("Error: please run this script with uid 0 (root).") + raise CriticalException("please run this script with uid 0 (root).") def check_boot_flag(device): boot_dev, x = get_device_from_partition(device) with open(boot_dev, 'r') as image: - data = image.read(512) + data = image.read(520) bootcode = data[440:] - if bootcode[6] == '\x80': + gpt_data = bootcode[70:80] + + if gpt_data == GPT_HEADER: + logging.info("GPT detected, skipping bootflag check") + elif bootcode[6] == '\x80': logging.debug("bootflag is enabled") else: logging.debug("bootflag is NOT enabled") @@ -540,7 +545,7 @@ def install_mbr(mbrtemplate, device, partition, ismirbsdmbr=True): if not os.path.isfile(mbrtemplate): logging.error('Error installing MBR (either try --syslinux-mbr or ' 'install missing file "%s"?)', mbrtemplate) - raise CriticalException("Error: %s can not be read.", mbrtemplate) + raise CriticalException("%s can not be read." % mbrtemplate) if partition is not None and ((partition < 0) or (partition > 3)): logging.warn("Cannot activate partition %d", partition) @@ -1379,7 +1384,7 @@ def handle_syslinux_config(grml_flavour, target): # install main configuration only *once*, no matter how many ISOs we have: syslinux_config_file = open(syslinux_cfg, 'w') - syslinux_config_file.write("TIMEOUT 300\n") + syslinux_config_file.write("timeout 300\n") syslinux_config_file.write("include vesamenu.cfg\n") syslinux_config_file.close() @@ -1674,8 +1679,7 @@ def check_options(opts): @opts option dict from OptionParser """ if opts.grubmbr and not opts.grub: - logging.critical("Error: --grub-mbr requires --grub option.") - sys.exit(1) + raise CriticalException("--grub-mbr requires --grub option.") def check_programs():