X-Git-Url: https://git.grml.org/?p=grml2usb.git;a=blobdiff_plain;f=grml2usb;fp=grml2usb;h=2f58d011e7bd98b9dbfd2f90eea70b4a0ba6f5d6;hp=4e958b580efced1c3d032748c9368a71b3ef3cce;hb=360632e096cbcd38d025d610cd64ce3fbb45c131;hpb=bb8723484d9384bc2e4095340be9ce7f9e58d802 diff --git a/grml2usb b/grml2usb index 4e958b5..2f58d01 100755 --- a/grml2usb +++ b/grml2usb @@ -317,9 +317,29 @@ def check_uid_root(): raise CriticalException("please run this script with uid 0 (root).") +# for usage inside check_boot_flag +def get_partition_for_path(path): + import parted + + boot_dev, x = get_device_from_partition(path) + + d = parted.getDevice(boot_dev) + disk = parted.Disk(d) + return disk.getPartitionByPath(path) + + def check_boot_flag(device): boot_dev, x = get_device_from_partition(device) + try: + import parted + part = get_partition_for_path(device) + if part.getFlag(parted.PARTITION_BOOT): + logging.debug("bootflag is enabled on %s" % device) + return + except ImportError, e: + pass + with open(boot_dev, 'r') as image: data = image.read(520) bootcode = data[440:] @@ -332,7 +352,7 @@ def check_boot_flag(device): else: logging.debug("bootflag is NOT enabled") raise VerifyException("Device %s does not have the bootflag set. " - "Please enable it to be able to boot." % boot_dev) + "Please enable it to be able to boot." % device) def mkfs_fat16(device):