From 05f9b10974e0b5ed96a389df81728d417a453f8a Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Wed, 8 May 2019 23:25:30 +1200 Subject: [PATCH] Replace --uefi with --bootloader to select any bootloader style for dry-run Relatedly, make 'MAKE_BOOT in disk.supported_actions' depend on bootloader style not architecture. --- Makefile | 2 +- subiquity/cmd/tui.py | 6 +++--- subiquity/controllers/filesystem.py | 5 +++-- .../controllers/tests/test_filesystem.py | 2 +- subiquity/models/filesystem.py | 20 +++++++++++-------- .../views/filesystem/tests/test_filesystem.py | 2 ++ 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 6910c65c..b2926540 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ i18n: $(PYTHON) setup.py build dryrun: probert i18n - $(MAKE) ui-view DRYRUN="--dry-run --uefi" + $(MAKE) ui-view DRYRUN="--dry-run --bootloader uefi" ui-view: $(PYTHON) -m subiquity $(DRYRUN) $(MACHARGS) diff --git a/subiquity/cmd/tui.py b/subiquity/cmd/tui.py index 04d6333c..dc3060d2 100755 --- a/subiquity/cmd/tui.py +++ b/subiquity/cmd/tui.py @@ -63,9 +63,9 @@ def parse_options(argv): parser.add_argument('--machine-config', metavar='CONFIG', dest='machine_config', help="Don't Probe. Use probe data file") - parser.add_argument('--uefi', action='store_true', - dest='uefi', - help='run in uefi support mode') + parser.add_argument('--bootloader', + choices=['none', 'bios', 'prep', 'uefi'], + help='Override style of bootloader to use') parser.add_argument('--screens', action='append', dest='screens', default=[]) parser.add_argument('--script', metavar="SCRIPT", action='append', diff --git a/subiquity/controllers/filesystem.py b/subiquity/controllers/filesystem.py index 92da5b5e..cefa9478 100644 --- a/subiquity/controllers/filesystem.py +++ b/subiquity/controllers/filesystem.py @@ -58,8 +58,9 @@ class FilesystemController(BaseController): def __init__(self, common): super().__init__(common) self.model = self.base_model.filesystem - if self.opts.dry_run and self.opts.uefi: - self.model.bootloader = Bootloader.UEFI + if self.opts.dry_run and self.opts.bootloader: + name = self.opts.bootloader.upper() + self.model.bootloader = getattr(Bootloader, name) self.answers = self.all_answers.get("Filesystem", {}) self.answers.setdefault('guided', False) self.answers.setdefault('guided-index', 0) diff --git a/subiquity/controllers/tests/test_filesystem.py b/subiquity/controllers/tests/test_filesystem.py index 302e2ede..9435821c 100644 --- a/subiquity/controllers/tests/test_filesystem.py +++ b/subiquity/controllers/tests/test_filesystem.py @@ -37,7 +37,7 @@ def make_controller_and_disk(): common['answers'] = {} opts = Thing() opts.dry_run = True - opts.uefi = True + opts.bootloader = "UEFI" common['opts'] = opts controller = FilesystemController(common) return controller, disk diff --git a/subiquity/models/filesystem.py b/subiquity/models/filesystem.py index 38f5cdf3..f2dc1479 100644 --- a/subiquity/models/filesystem.py +++ b/subiquity/models/filesystem.py @@ -541,14 +541,18 @@ class Disk(_Device): return self.serial return self.path - supported_actions = [ - DeviceAction.INFO, - DeviceAction.PARTITION, - DeviceAction.FORMAT, - DeviceAction.REMOVE, - ] - if platform.machine() != 's390x': - supported_actions.append(DeviceAction.MAKE_BOOT) + @property + def supported_actions(self): + actions = [ + DeviceAction.INFO, + DeviceAction.PARTITION, + DeviceAction.FORMAT, + DeviceAction.REMOVE, + ] + if self._m.bootloader != Bootloader.NONE: + actions.append(DeviceAction.MAKE_BOOT) + return actions + _can_INFO = True _can_PARTITION = property(lambda self: self.free_for_partitions > 0) _can_FORMAT = property( diff --git a/subiquity/ui/views/filesystem/tests/test_filesystem.py b/subiquity/ui/views/filesystem/tests/test_filesystem.py index 5232acdd..b97b09dc 100644 --- a/subiquity/ui/views/filesystem/tests/test_filesystem.py +++ b/subiquity/ui/views/filesystem/tests/test_filesystem.py @@ -8,6 +8,7 @@ from subiquitycore.testing import view_helpers from subiquity.controllers.filesystem import FilesystemController from subiquity.models.filesystem import ( + Bootloader, Disk, FilesystemModel, ) @@ -24,6 +25,7 @@ class FilesystemViewTests(unittest.TestCase): def make_view(self, model, devices=[]): controller = mock.create_autospec(spec=FilesystemController) controller.ui = mock.Mock() + model.bootloader = Bootloader.NONE model.all_devices.return_value = devices model.grub_install_device = None return FilesystemView(model, controller)