create mounts for swap when the fs gets created
This commit is contained in:
parent
3eff761284
commit
f115a32edd
|
@ -18,7 +18,11 @@ import os
|
|||
|
||||
from subiquitycore.controller import BaseController
|
||||
|
||||
from subiquity.models.filesystem import align_up, DeviceAction
|
||||
from subiquity.models.filesystem import (
|
||||
align_up,
|
||||
DeviceAction,
|
||||
Partition,
|
||||
)
|
||||
from subiquity.ui.views import (
|
||||
FilesystemView,
|
||||
GuidedDiskSelectionView,
|
||||
|
@ -92,6 +96,13 @@ class FilesystemController(BaseController):
|
|||
if spec['fstype'] is None or spec['fstype'].label is None:
|
||||
return
|
||||
fs = self.model.add_filesystem(volume, spec['fstype'].label)
|
||||
if isinstance(volume, Partition):
|
||||
if spec['fstype'].label == "swap":
|
||||
volume.flag = "swap"
|
||||
elif volume.flag == "swap":
|
||||
volume.flag = ""
|
||||
if spec['fstype'].label == "swap":
|
||||
self.model.add_mount(fs, "")
|
||||
self.create_mount(fs, spec)
|
||||
return fs
|
||||
|
||||
|
|
|
@ -379,7 +379,10 @@ class Mount:
|
|||
path = attr.ib(default=None)
|
||||
|
||||
def can_delete(self):
|
||||
# Can't delete /boot/efi mount, anything else is fine.
|
||||
# Can't delete mount of /boot/efi or swap, anything else is fine.
|
||||
if not self.path:
|
||||
# swap mount
|
||||
return False
|
||||
if not isinstance(self.device.volume, Partition):
|
||||
# Can't be /boot/efi if volume is not a partition
|
||||
return True
|
||||
|
@ -438,12 +441,6 @@ class FilesystemModel(object):
|
|||
|
||||
def render(self):
|
||||
r = []
|
||||
for f in self._filesystems:
|
||||
if f.fstype == 'swap':
|
||||
if isinstance(f.volume, Partition):
|
||||
f.volume.flag = "swap"
|
||||
if f.mount() is None:
|
||||
self.add_mount(f, "")
|
||||
for d in self._disks.values():
|
||||
r.append(asdict(d))
|
||||
for p in self._partitions:
|
||||
|
|
|
@ -197,7 +197,8 @@ class MountList(WidgetWrap):
|
|||
mountinfos = [
|
||||
MountInfo(mount=m)
|
||||
for m in sorted(
|
||||
self.parent.model.all_mounts(), key=lambda m: m.path)
|
||||
self.parent.model.all_mounts(),
|
||||
key=lambda m: (m.path == "", m.path))
|
||||
]
|
||||
if len(mountinfos) == 0:
|
||||
self.table.set_contents([])
|
||||
|
@ -215,19 +216,22 @@ class MountList(WidgetWrap):
|
|||
|
||||
for i, mi in enumerate(mountinfos):
|
||||
path_markup = mi.path
|
||||
for j in range(i-1, -1, -1):
|
||||
mi2 = mountinfos[j]
|
||||
if mi.startswith(mi2):
|
||||
part1 = "/".join(mi.split_path[:len(mi2.split_path)])
|
||||
part2 = "/".join(
|
||||
[''] + mi.split_path[len(mi2.split_path):])
|
||||
path_markup = [('info_minor', part1), part2]
|
||||
break
|
||||
if j == 0 and mi2.split_path == ['', '']:
|
||||
path_markup = [
|
||||
('info_minor', "/"),
|
||||
"/".join(mi.split_path[1:]),
|
||||
]
|
||||
if path_markup == "":
|
||||
path_markup = ('info_minor', "SWAP")
|
||||
else:
|
||||
for j in range(i-1, -1, -1):
|
||||
mi2 = mountinfos[j]
|
||||
if mi.startswith(mi2):
|
||||
part1 = "/".join(mi.split_path[:len(mi2.split_path)])
|
||||
part2 = "/".join(
|
||||
[''] + mi.split_path[len(mi2.split_path):])
|
||||
path_markup = [('info_minor', part1), part2]
|
||||
break
|
||||
if j == 0 and mi2.split_path == ['', '']:
|
||||
path_markup = [
|
||||
('info_minor', "/"),
|
||||
"/".join(mi.split_path[1:]),
|
||||
]
|
||||
actions = [(_("Unmount"), mi.mount.can_delete(), 'unmount')]
|
||||
menu = ActionMenu(actions)
|
||||
connect_signal(menu, 'action', self._mount_action, mi.mount)
|
||||
|
|
Loading…
Reference in New Issue