Skip to content

Commit 37159dc

Browse files
authored
Add LPath execute permissions methods (#4378)
1 parent e2bd7b3 commit 37159dc

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

archinstall/lib/installer.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import re
55
import shlex
66
import shutil
7-
import stat
87
import subprocess
98
import textwrap
109
import time
@@ -29,6 +28,7 @@
2928
)
3029
from archinstall.lib.exceptions import DiskError, HardwareIncompatibilityError, RequirementError, ServiceException, SysCallError
3130
from archinstall.lib.hardware import SysInfo
31+
from archinstall.lib.linux_path import LPath
3232
from archinstall.lib.locale.utils import verify_keyboard_layout, verify_x11_keyboard_layout
3333
from archinstall.lib.mirror.mirror_handler import MirrorListHandler
3434
from archinstall.lib.models.application import ZramAlgorithm
@@ -1386,7 +1386,7 @@ def _add_grub_bootloader(
13861386
raise DiskError(f'Failed to install GRUB boot on {boot_partition.dev_path}: {err}')
13871387

13881388
if SysInfo.has_uefi() and uki_enabled:
1389-
grub_d = self.target / 'etc/grub.d'
1389+
grub_d = LPath(self.target) / 'etc/grub.d'
13901390
linux_file = grub_d / '10_linux'
13911391
uki_file = grub_d / '15_uki'
13921392

@@ -1406,10 +1406,9 @@ def _add_grub_bootloader(
14061406
)
14071407

14081408
try:
1409-
mode = linux_file.stat().st_mode
1410-
linux_file.chmod(mode & ~(stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH))
14111409
uki_file.write_text(content)
1412-
uki_file.chmod(mode)
1410+
uki_file.add_exec()
1411+
linux_file.remove_exec()
14131412
except OSError:
14141413
error('Failed to enable UKI menu entries')
14151414
else:

archinstall/lib/linux_path.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import stat
12
from pathlib import Path
23
from typing import Self
34

@@ -9,3 +10,13 @@ def fs_root(cls) -> Self:
910

1011
def relative_to_root(self) -> Self:
1112
return self.relative_to(self.fs_root())
13+
14+
def add_exec(self) -> None:
15+
"""Add execute permissions (mirrors `chmod +x`)."""
16+
mode = self.stat().st_mode
17+
self.chmod(mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
18+
19+
def remove_exec(self) -> None:
20+
"""Remove execute permissions (mirrors `chmod -x`)."""
21+
mode = self.stat().st_mode
22+
self.chmod(mode & ~(stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH))

0 commit comments

Comments
 (0)