Create all fstab entries one way instead of having special handling

This commit is contained in:
Chrysostomus 2021-01-27 15:41:01 +02:00
parent 14fbbd92dc
commit 8c0c84f162

View File

@ -183,39 +183,19 @@ class FstabGenerator(object):
print(FSTAB_HEADER, file=fstab_file) print(FSTAB_HEADER, file=fstab_file)
for partition in self.partitions: for partition in self.partitions:
# Special treatment for a btrfs root with @, @home and @swap # Special treatment for a btrfs subvolumes
# subvolumes
if (partition["fs"] == "btrfs" if (partition["fs"] == "btrfs"
and partition["mountPoint"] == "/"): and partition["mountPoint"] == "/"):
output = subprocess.check_output(['btrfs', # Subvolume list has been created in mount.conf and curated in mount module,
'subvolume', # so all subvolumes here should be safe to add to fstab
'list',
self.root_mount_point])
output_lines = output.splitlines()
btrfs_subvolumes = libcalamares.globalstorage.value("btrfsSubvolumes") btrfs_subvolumes = libcalamares.globalstorage.value("btrfsSubvolumes")
for line in output_lines: for s in btrfs_subvolumes:
# This is where changes need to go mount_entry = partition
if line.endswith(b'path @'): mount_entry["mountPoint"] = s["mountPoint"]
root_entry = partition home_entry["subvol"] = s["subvolume"]
root_entry["subvol"] = "@" dct = self.generate_fstab_line_info(mount_entry)
dct = self.generate_fstab_line_info(root_entry) if dct:
if dct:
self.print_fstab_line(dct, file=fstab_file) self.print_fstab_line(dct, file=fstab_file)
elif line.endswith(b'path @home'):
home_entry = partition
home_entry["mountPoint"] = "/home"
home_entry["subvol"] = "@home"
dct = self.generate_fstab_line_info(home_entry)
if dct:
self.print_fstab_line(dct, file=fstab_file)
elif line.endswith(b'path @swap'):
swap_part_entry = partition
swap_part_entry["mountPoint"] = "/swap"
swap_part_entry["subvol"] = "@swap"
dct = self.generate_fstab_line_info(swap_part_entry)
if dct:
self.print_fstab_line(dct, file=fstab_file)
else: else:
dct = self.generate_fstab_line_info(partition) dct = self.generate_fstab_line_info(partition)
if dct: if dct: