File 3.3.1-fstab.patch of Package calamares

diff -ruN a/src/modules/fstab/main.py b/src/modules/fstab/main.py
--- a/src/modules/fstab/main.py	2024-03-20 10:16:59.213328651 -0600
+++ b/src/modules/fstab/main.py	2023-06-02 08:08:11.000000000 -0600
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/python3
 # -*- coding: utf-8 -*-
 #
 # === This file is part of Calamares - <https://calamares.io> ===
@@ -99,11 +99,21 @@
 
 
 class FstabGenerator(object):
-    def __init__(self, partitions, root_mount_point, mount_options_list,
-                 crypttab_options, tmp_options):
+    """ Class header
+
+    :param partitions:
+    :param root_mount_point:
+    :param mount_options:
+    :param ssd_extra_mount_options:
+    :param crypttab_options:
+    :param tmp_options:
+    """
+    def __init__(self, partitions, root_mount_point, mount_options,
+                 ssd_extra_mount_options, crypttab_options, tmp_options):
         self.partitions = partitions
         self.root_mount_point = root_mount_point
-        self.mount_options_list = mount_options_list
+        self.mount_options = mount_options
+        self.ssd_extra_mount_options = ssd_extra_mount_options
         self.crypttab_options = crypttab_options
         self.tmp_options = tmp_options
         self.ssd_disks = set()
@@ -258,7 +268,17 @@
             libcalamares.utils.debug("Ignoring foreign swap {!s} {!s}".format(disk_name, partition.get("uuid", None)))
             return None
 
-        options = self.get_mount_options(mount_point)
+        # If this is btrfs subvol a dedicated to a swapfile, use different options than a normal btrfs subvol
+        if filesystem == "btrfs" and partition.get("subvol", None) == "/@swap":
+            options = self.get_mount_options("btrfs_swap", mount_point)
+        else:
+            options = self.get_mount_options(filesystem, mount_point)
+
+        if is_ssd:
+            extra = self.ssd_extra_mount_options.get(filesystem)
+
+            if extra:
+                options += "," + extra
 
         if mount_point == "/" and filesystem != "btrfs":
             check = 1
@@ -310,18 +330,15 @@
             if partition["mountPoint"]:
                 mkdir_p(self.root_mount_point + partition["mountPoint"])
 
-    def get_mount_options(self, mountpoint):
-        """
-        Returns the mount options for a given mountpoint
+    def get_mount_options(self, filesystem, mount_point):
+        efiMountPoint = libcalamares.globalstorage.value("efiSystemPartition")
+        job_config = libcalamares.job.configuration
 
-        :param mountpoint: A string containing the mountpoint for the fstab entry
-        :return: A string containing the mount options for the entry or "defaults" if nothing is found
-        """
-        mount_options_item = next((x for x in self.mount_options_list if x.get("mountpoint") == mountpoint), None)
-        if mount_options_item:
-            return mount_options_item.get("option_string", "defaults")
-        else:
-            return "defaults"
+        if (mount_point == efiMountPoint and "efiMountOptions" in job_config):
+            return job_config["efiMountOptions"]
+
+        return self.mount_options.get(filesystem,
+                                      self.mount_options["default"])
 
 
 def create_swapfile(root_mount_point, root_btrfs):
@@ -400,13 +417,14 @@
             swap_choice = None
 
     libcalamares.job.setprogress(0.1)
-    mount_options_list = global_storage.value("mountOptionsList")
+    mount_options = conf.get("mountOptions", {})
+    ssd_extra_mount_options = conf.get("ssdExtraMountOptions", {})
     crypttab_options = conf.get("crypttabOptions", "luks")
     tmp_options = conf.get("tmpOptions", {})
 
     # We rely on mount_options having a default; if there wasn't one,
     # bail out with a meaningful error.
-    if not mount_options_list:
+    if not mount_options:
         libcalamares.utils.warning("No mount options defined, {!s} partitions".format(len(partitions)))
         return (_("Configuration Error"),
                 _("No <pre>{!s}</pre> configuration is given for <pre>{!s}</pre> to use.")
@@ -414,7 +432,8 @@
 
     generator = FstabGenerator(partitions,
                                root_mount_point,
-                               mount_options_list,
+                               mount_options,
+                               ssd_extra_mount_options,
                                crypttab_options,
                                tmp_options)
 
openSUSE Build Service is sponsored by