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
+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+)$')
RE_LOOP_DEVICE = re.compile(r'/dev/loop\d+$')
+
def syslinux_warning(option, opt, value, opt_parser):
"""A helper function for printing a warning about deprecated option
"""
@Exception: message"""
pass
+
class VerifyException(Exception):
"""Throw critical exception if there is an fatal error when verifying something.
@cwd: current working directory
"""
- return os.path.exists(os.path.join(cwd, filename))
+ return os.path.exists(os.path.join(cwd, filename))
for path in paths:
current_dir = path
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:]
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):
squashfs = search_file(grml_flavour + '.squashfs', iso_mount)
if squashfs is None:
logging.error("error locating squashfs file")
- raise CriticalException("squashfs file not found"
- ", please check that your iso is not corrupt")
+ raise CriticalException("squashfs file not found, please check that your iso is not corrupt")
else:
squashfs_target = target + '/live/' + grml_flavour + '/'
execute(mkdir, squashfs_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()
mbrcode = GRML2USB_BASE + '/mbr/mbrldr'
if options.syslinuxmbr:
- mbrcode = '/usr/lib/syslinux/mbr.bin'
+ mbrcode = ""
+ mbr_locations = ('/usr/lib/syslinux/mbr.bin',
+ '/usr/share/syslinux/mbr.bin')
+ for mbrpath in mbr_locations:
+ if os.path.isfile(mbrpath):
+ mbrcode = mbrpath
+ break
+
+ if mbrcode is "":
+ str_locations = " or ".join(['"%s"' % l for l in mbr_locations])
+ logging.error('Cannot find syslinux MBR, install it at %s)',
+ str_locations)
+ raise CriticalException("syslinux MBR can not be found at %s."
+ % str_locations)
elif options.mbrmenu:
mbrcode = GRML2USB_BASE + '/mbr/mbrldr'