small hacks to only allow one prep partition at a time
This commit is contained in:
parent
5524197837
commit
69775133cf
|
@ -679,6 +679,10 @@ class FilesystemController(SubiquityController):
|
|||
|
||||
def add_boot_disk(self, new_boot_disk):
|
||||
bootloader = self.model.bootloader
|
||||
if bootloader == Bootloader.PREP:
|
||||
for disk in self.model.all_disks():
|
||||
if disk._is_boot_device():
|
||||
self.remove_boot_disk(disk)
|
||||
if new_boot_disk._has_preexisting_partition():
|
||||
if bootloader == Bootloader.BIOS:
|
||||
new_boot_disk.grub_device = True
|
||||
|
|
|
@ -215,7 +215,7 @@ class TestFilesystemController(unittest.TestCase):
|
|||
|
||||
size_before = disk2p1.size
|
||||
controller.add_boot_disk(disk2)
|
||||
self.assertEqual(len(disk1.partitions()), 1)
|
||||
self.assertEqual(len(disk1.partitions()), 0)
|
||||
self.assertEqual(len(disk2.partitions()), 2)
|
||||
self.assertEqual(disk2.partitions()[1], disk2p1)
|
||||
self.assertEqual(
|
||||
|
@ -223,11 +223,6 @@ class TestFilesystemController(unittest.TestCase):
|
|||
self.assertEqual(disk2.partitions()[0].flag, "prep")
|
||||
self.assertEqual(disk2.partitions()[0].wipe, "zero")
|
||||
|
||||
controller.remove_boot_disk(disk2)
|
||||
self.assertEqual(len(disk2.partitions()), 1)
|
||||
self.assertEqual(disk2.partitions()[0], disk2p1)
|
||||
self.assertEqual(disk2p1.size, size_before)
|
||||
|
||||
def test_make_boot_disk_PREP_existing(self):
|
||||
controller = make_controller(Bootloader.PREP)
|
||||
disk1 = make_disk(controller.model, preserve=True)
|
||||
|
|
|
@ -61,6 +61,7 @@ from subiquitycore.ui.utils import (
|
|||
from subiquitycore.view import BaseView
|
||||
|
||||
from subiquity.models.filesystem import (
|
||||
Bootloader,
|
||||
DeviceAction,
|
||||
humanize_size,
|
||||
)
|
||||
|
@ -329,9 +330,10 @@ class DeviceList(WidgetWrap):
|
|||
if device._is_boot_device():
|
||||
return _("Stop Using As Boot Device")
|
||||
else:
|
||||
for other in self.parent.model.all_disks():
|
||||
if other._is_boot_device():
|
||||
return _("Add As Another Boot Device")
|
||||
if self.parent.model.bootloader != Bootloader.PREP:
|
||||
for other in self.parent.model.all_disks():
|
||||
if other._is_boot_device():
|
||||
return _("Add As Another Boot Device")
|
||||
return _("Use As Boot Device")
|
||||
|
||||
def _action_menu_for_device(self, device):
|
||||
|
|
Loading…
Reference in New Issue