summaryrefslogtreecommitdiffstats
path: root/src/utils/postinstall.py
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-07-02 15:40:31 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-08-30 12:19:48 +0200
commitf7b37ba0100b7366c65100ca8f3b6788eb68d7c5 (patch)
tree036c464ab730ce5f2070e8ce1be3b5d730b0bed6 /src/utils/postinstall.py
parentc09c064f28594a1850dae595b20af9ba165692df (diff)
utils: replace the legacy function ogConfigureFstab
Implement configure_fstab() as a replacement of ogConfigureFstab. Create src/utils/fstab.py to implement the main fstab configuration functions. Define two fstab helper classes, FstabBuilder and FstabEntry. FstabEntry Represents each line in the fstab file. Has the values: device, mountpoint, fstype, options, dump_code and pass_code. FstabBuilder Contains a list of FstabEntry. Handles loading of a preexisting fstab file and the serialization of multiple FstabEntry into a file. The fstab configuration has 3 main steps: Root partition: - Update the device field with the device where the new system is installed. Swap partition: - Preserve all the swapfile entries in every case. - If the filesystem has a swap partition: update the device field in the first fstab swap entry and remove the rest swap entries pointing to a swap partition. Only one swap partition is supported. Create a new fstab entry if no preexisting swap entry exists. - If the system has no swap partition remove every swap partition entry. EFI partition: - Update the device field of the EFI fstab entry if it exists. Create a new fstab entry if no preexisting EFI entry exists. Add get_filesystem_id to disk.py to obtain the UUID. Define every device field as a UUID. That method is more robust than a plain device path as it works after disks being added or removed.
Diffstat (limited to 'src/utils/postinstall.py')
-rw-r--r--src/utils/postinstall.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/utils/postinstall.py b/src/utils/postinstall.py
index 7e21e67..94a7e4b 100644
--- a/src/utils/postinstall.py
+++ b/src/utils/postinstall.py
@@ -18,6 +18,7 @@ from src.utils.disk import *
from src.utils.winreg import *
from src.utils.fs import *
from src.utils.uefi import *
+from src.utils.fstab import *
from socket import gethostname
CONFIGUREOS_LEGACY_ENABLED = False
@@ -148,16 +149,17 @@ def configure_grub_in_mbr(disk, partition):
def configure_fstab(disk, partition):
- cmd_configure = f"ogConfigureFstab {disk} {partition}"
+ logging.info(f'Configuring /etc/fstab')
+ device = get_partition_device(disk, partition)
+ mountpoint = device.replace('dev', 'mnt')
- proc = subprocess.run(cmd_configure,
- stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL,
- encoding='utf-8',
- shell=True,
- check=True)
- if proc.returncode != 0:
- logging.warning(f'{cmd_configure} returned non-zero exit status {proc.returncode}')
+ if not mount_mkdir(device, mountpoint):
+ raise OgError(f'Unable to mount {device} into {mountpoint}')
+
+ try:
+ update_fstab(disk, partition, mountpoint)
+ finally:
+ umount(mountpoint)
def install_grub(disk, partition):