From 78fd7dacc31d47fc120edfcb195cd99d4e5d0cc2 Mon Sep 17 00:00:00 2001 From: Marc Brakels Date: Sun, 27 Feb 2022 13:07:53 +0100 Subject: [PATCH 1/2] Added command line option to skip GRUB legacy bootloader --- WoeUSB/core.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/WoeUSB/core.py b/WoeUSB/core.py index b23c506..1392b2f 100644 --- a/WoeUSB/core.py +++ b/WoeUSB/core.py @@ -89,6 +89,8 @@ def init(from_cli=True, install_mode=None, source_media=None, target_media=None, target_media = args.target workaround_bios_boot_flag = args.workaround_bios_boot_flag + + skip_legacy_bootloader = args.workaround_skip_grub target_filesystem_type = args.target_filesystem @@ -106,13 +108,13 @@ def init(from_cli=True, install_mode=None, source_media=None, target_media=None, if from_cli: return [source_fs_mountpoint, target_fs_mountpoint, temp_directory, install_mode, source_media, target_media, - workaround_bios_boot_flag, target_filesystem_type, filesystem_label, verbose, debug, parser] + workaround_bios_boot_flag, skip_legacy_bootloader, target_filesystem_type, filesystem_label, verbose, debug, parser] else: return [source_fs_mountpoint, target_fs_mountpoint, temp_directory, target_media] def main(source_fs_mountpoint, target_fs_mountpoint, source_media, target_media, install_mode, temp_directory, - target_filesystem_type, workaround_bios_boot_flag, parser=None): + target_filesystem_type, workaround_bios_boot_flag, parser=None, skip_legacy_bootloader=False): """ :param parser: :param source_fs_mountpoint: @@ -192,10 +194,10 @@ def main(source_fs_mountpoint, target_fs_mountpoint, source_media, target_media, copy_filesystem_files(source_fs_mountpoint, target_fs_mountpoint) workaround.support_windows_7_uefi_boot(source_fs_mountpoint, target_fs_mountpoint) + if not skip_legacy_bootloader: + install_legacy_pc_bootloader_grub(target_fs_mountpoint, target_device, command_grubinstall) - install_legacy_pc_bootloader_grub(target_fs_mountpoint, target_device, command_grubinstall) - - install_legacy_pc_bootloader_grub_config(target_fs_mountpoint, target_device, command_grubinstall, name_grub_prefix) + install_legacy_pc_bootloader_grub_config(target_fs_mountpoint, target_device, command_grubinstall, name_grub_prefix) if workaround_bios_boot_flag: workaround.buggy_motherboards_that_ignore_disks_without_boot_flag_toggled(target_device) @@ -642,6 +644,8 @@ def setup_arguments(): help="Specify label for the newly created file system in --device creation method") parser.add_argument("--workaround-bios-boot-flag", action="store_true", help="Workaround BIOS bug that won't include the device in boot menu if non of the partition's boot flag is toggled") + parser.add_argument("--workaround-skip-grub", action="store_true", + help="This will skip the legacy grub bootloader creation step.") parser.add_argument("--target-filesystem", "--tgt-fs", choices=["FAT", "NTFS"], default="FAT", type=str.upper, help="Specify the filesystem to use as the target partition's filesystem.") parser.add_argument('--for-gui', action="store_true", help=argparse.SUPPRESS) @@ -707,12 +711,12 @@ def run(): source_fs_mountpoint, target_fs_mountpoint, temp_directory, \ install_mode, source_media, target_media, \ - workaround_bios_boot_flag, target_filesystem_type, new_file_system_label, \ - verbose, debug, parser = result + workaround_bios_boot_flag, skip_legacy_bootloader, target_filesystem_type, \ + new_file_system_label, verbose, debug, parser = result try: main(source_fs_mountpoint, target_fs_mountpoint, source_media, target_media, install_mode, temp_directory, - target_filesystem_type, workaround_bios_boot_flag, parser) + target_filesystem_type, workaround_bios_boot_flag, parser, skip_legacy_bootloader) except KeyboardInterrupt: pass except Exception as error: From 7259cae76dbd92603d00dd4ad1ba222443fc512d Mon Sep 17 00:00:00 2001 From: Marc Brakels Date: Sun, 27 Feb 2022 18:16:30 +0100 Subject: [PATCH 2/2] GUI option: legacy grub bootloader --- WoeUSB/gui.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/WoeUSB/gui.py b/WoeUSB/gui.py index 0a3b7a7..f6593e7 100644 --- a/WoeUSB/gui.py +++ b/WoeUSB/gui.py @@ -49,8 +49,12 @@ def __init__(self, title, pos, size, style=wx.DEFAULT_FRAME_STYLE): self.options_filesystem = wx.MenuItem(options_menu, wx.ID_ANY, _("Use NTFS"), _("Use NTFS instead of FAT. NOTE: NTFS seems to be slower than FAT."), wx.ITEM_CHECK) + self.options_skip_grub = wx.MenuItem(options_menu, wx.ID_ANY, _("Skip legacy grub bootloader"), + _("No legacy grub bootloader will be created. NOTE: It will only boot on system with UEFI support."), + wx.ITEM_CHECK) options_menu.Append(self.options_boot) options_menu.Append(self.options_filesystem) + options_menu.Append(self.options_skip_grub) self.__MenuBar = wx.MenuBar() self.__MenuBar.Append(file_menu, _("&File")) @@ -242,8 +246,8 @@ def on_install(self, __): filesystem = "NTFS" else: filesystem = "FAT" - - woe = WoeUSB_handler(iso, device, boot_flag=self.__parent.options_boot.IsChecked(), filesystem=filesystem) + + woe = WoeUSB_handler(iso, device, boot_flag=self.__parent.options_boot.IsChecked(), filesystem=filesystem, skip_grub=self.__parent.options_skip_grub.IsChecked()) woe.start() dialog = wx.ProgressDialog(_("Installing"), _("Please wait..."), 101, self.GetParent(), @@ -383,7 +387,7 @@ class WoeUSB_handler(threading.Thread): error = "" kill = False - def __init__(self, source, target, boot_flag, filesystem): + def __init__(self, source, target, boot_flag, filesystem, skip_grub=False): threading.Thread.__init__(self) core.gui = self @@ -391,6 +395,7 @@ def __init__(self, source, target, boot_flag, filesystem): self.target = target self.boot_flag = boot_flag self.filesystem = filesystem + self.skip_grub = skip_grub def run(self): source_fs_mountpoint, target_fs_mountpoint, temp_directory, target_media = core.init( @@ -401,7 +406,7 @@ def run(self): ) try: core.main(source_fs_mountpoint, target_fs_mountpoint, self.source, self.target, "device", temp_directory, - self.filesystem, self.boot_flag) + self.filesystem, self.boot_flag , None, self.skip_grub) except SystemExit: pass