Merge pull request #491 from mwhudson/_can_MAKE_BOOT-UEFI
Fix Disk._can_MAKE_BOOT on a UEFI system
This commit is contained in:
commit
ddaf916ea6
|
@ -22,6 +22,9 @@ from subiquity.controllers.filesystem import (
|
||||||
from subiquity.models.tests.test_filesystem import (
|
from subiquity.models.tests.test_filesystem import (
|
||||||
make_model_and_disk,
|
make_model_and_disk,
|
||||||
)
|
)
|
||||||
|
from subiquity.models.filesystem import (
|
||||||
|
Bootloader,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Thing:
|
class Thing:
|
||||||
|
@ -57,3 +60,17 @@ class TestFilesystemController(unittest.TestCase):
|
||||||
dm_crypts = [
|
dm_crypts = [
|
||||||
a for a in controller.model._actions if a.type == 'dm_crypt']
|
a for a in controller.model._actions if a.type == 'dm_crypt']
|
||||||
self.assertEqual(dm_crypts, [])
|
self.assertEqual(dm_crypts, [])
|
||||||
|
|
||||||
|
def test_can_only_make_boot_once(self):
|
||||||
|
# This is really testing model code but it's much easier to test with a
|
||||||
|
# controller around.
|
||||||
|
for bl in Bootloader:
|
||||||
|
if bl == Bootloader.NONE:
|
||||||
|
continue
|
||||||
|
controller, disk = make_controller_and_disk()
|
||||||
|
controller.model.bootloader = bl
|
||||||
|
controller.make_boot_disk(disk)
|
||||||
|
self.assertFalse(
|
||||||
|
disk._can_MAKE_BOOT,
|
||||||
|
"make_boot_disk(disk) did not make _can_MAKE_BOOT false with "
|
||||||
|
"bootloader {}".format(bl))
|
||||||
|
|
|
@ -593,12 +593,17 @@ class Disk(_Device):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _can_MAKE_BOOT(self):
|
def _can_MAKE_BOOT(self):
|
||||||
install_dev = self._m.grub_install_device
|
bl = self._m.bootloader
|
||||||
if install_dev:
|
if bl == Bootloader.BIOS:
|
||||||
# For the PReP case, the install_device is the prep partition.
|
if self._m.grub_install_device is self:
|
||||||
if install_dev.type == "partition":
|
return False
|
||||||
install_dev = install_dev.device
|
elif bl == Bootloader.UEFI:
|
||||||
if install_dev is self:
|
m = self._m._mount_for_path('/boot/efi')
|
||||||
|
if m and m.device.volume.device is self:
|
||||||
|
return False
|
||||||
|
elif bl == Bootloader.PREP:
|
||||||
|
install_dev = self._m.grub_install_device
|
||||||
|
if install_dev.device is self:
|
||||||
return False
|
return False
|
||||||
return self._fs is None and self._constructed_device is None
|
return self._fs is None and self._constructed_device is None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue