def check_boot_flag(device):
+ if os.path.isdir(device):
+ logging.debug(
+ "Device %s is a directory, skipping check for boot flag." % device
+ )
+ return
+
boot_dev, x = get_device_from_partition(device)
logging.info("Checking for boot flag")
"mbrtemplate" file, set the "partition" (0..3) active, and install the
result back to "device".
- @mbrtemplate: default MBR file
+ @mbrtemplate: default MBR file (must be a valid MBR file of at least 440
+ (or 439 if ismirbsdmbr) bytes)
@device: name of a file assumed to be a hard disc (or USB stick) image, or
something like "/dev/sdb"
@partition: must be a number between 0 and 3, inclusive
- @mbrtemplate: must be a valid MBR file of at least 440 (or 439 if
- ismirbsdmbr) bytes.
-
@ismirbsdmbr: if true then ignore the active flag, set the mirbsdmbr
specific flag to 0/1/2/3 and set the MBR's default value accordingly. If
false then leave the mirbsdmbr specific flag set to FFh, set all
proc = subprocess.Popen(["sync"])
proc.wait()
+ logging.debug("Probing device via 'blockdev --rereadpt %s'", device)
+ proc = subprocess.Popen(["blockdev", "--rereadpt", device])
+ proc.wait()
+ if proc.returncode != 0:
+ raise Exception(
+ "Couldn't execute blockdev on '%s' (install util-linux?)", device
+ )
+
set_rw(device)
if x.startswith(source):
raise CriticalException(
(
- "Error executing mount: %s already mounted - "
+ "Error executing mount: {0} already mounted - "
"please unmount before invoking grml2usb"
).format(source)
)
exec_rsync(efi_img, target + "/boot/efi.img")
handle_secure_boot(target, efi_img)
+ execute(mkdir, target + "/conf/")
+ glob_and_copy(iso_mount + "/conf/bootfile_*", target + "/conf/")
+
for ffile in ["f%d" % number for number in range(1, 11)]:
search_and_copy(ffile, iso_mount, syslinux_target + ffile)
logging.debug("Updating grub configuration")
grub_target = target + "/boot/grub/"
- secureboot_target = target + "/EFI/ubuntu/"
bootid_re = re.compile(r"bootid=[\w_-]+")
live_media_path_re = re.compile(r"live-media-path=[\w_/-]+")
remove_regexes.append(re.compile(regex))
shortname = get_shortname(grml_flavour)
- for filename in glob.glob(grub_target + "*.cfg") + glob.glob(
- secureboot_target + "*.cfg"
- ):
+ for filename in glob.glob(grub_target + "*.cfg"):
for line in fileinput.input(filename, inplace=1):
line = line.rstrip("\r\n")
if option_re.search(line):
logging.critical("Fatal: %s", error)
sys.exit(1)
- ubuntu_cfg = search_file("grub.cfg", efi_mountpoint + "/EFI/ubuntu")
- logging.debug("ubuntu_cfg = %s" % ubuntu_cfg)
- if not ubuntu_cfg:
+ grub_cfg = search_file("grub.cfg", efi_mountpoint + "/boot/grub/")
+ logging.debug("grub_cfg = %s" % grub_cfg)
+ if not grub_cfg:
logging.info(
- "No /EFI/ubuntu/grub.cfg found inside EFI image, looks like Secure Boot support is missing."
+ "No /boot/grub/grub.cfg found inside EFI image, looks like Secure Boot support is missing."
)
else:
- mkdir(target + "/efi/ubuntu")
+ mkdir(target + "/boot/grub/x86_64-efi/")
logging.debug(
- "exec_rsync(%s, %s + '/efi/ubuntu/grub.cfg')" % (ubuntu_cfg, target)
+ "exec_rsync(%s, %s + '/boot/grub/x86_64-efi/grub.cfg')" % (grub_cfg, target)
)
- exec_rsync(ubuntu_cfg, target + "/efi/ubuntu/grub.cfg")
+ exec_rsync(grub_cfg, target + "/boot/grub/x86_64-efi/grub.cfg")
logging.debug(
"exec_rsync(%s + '/EFI/BOOT/grubx64.efi', %s + '/efi/boot/grubx64.efi')'"
break
if not mbrcode:
- str_locations = " or ".join(['"%s"' % l for l in mbr_locations])
+ str_locations = " or ".join(['"%s"' % x for x 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