Add LPath execute permissions methods (#4378)

This commit is contained in:
codefiles 2026-04-06 03:16:21 -04:00 committed by GitHub
parent e2bd7b3405
commit 37159dcb6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 5 deletions

View File

@ -4,7 +4,6 @@ import platform
import re import re
import shlex import shlex
import shutil import shutil
import stat
import subprocess import subprocess
import textwrap import textwrap
import time import time
@ -29,6 +28,7 @@ from archinstall.lib.disk.utils import (
) )
from archinstall.lib.exceptions import DiskError, HardwareIncompatibilityError, RequirementError, ServiceException, SysCallError from archinstall.lib.exceptions import DiskError, HardwareIncompatibilityError, RequirementError, ServiceException, SysCallError
from archinstall.lib.hardware import SysInfo from archinstall.lib.hardware import SysInfo
from archinstall.lib.linux_path import LPath
from archinstall.lib.locale.utils import verify_keyboard_layout, verify_x11_keyboard_layout from archinstall.lib.locale.utils import verify_keyboard_layout, verify_x11_keyboard_layout
from archinstall.lib.mirror.mirror_handler import MirrorListHandler from archinstall.lib.mirror.mirror_handler import MirrorListHandler
from archinstall.lib.models.application import ZramAlgorithm from archinstall.lib.models.application import ZramAlgorithm
@ -1386,7 +1386,7 @@ class Installer:
raise DiskError(f'Failed to install GRUB boot on {boot_partition.dev_path}: {err}') raise DiskError(f'Failed to install GRUB boot on {boot_partition.dev_path}: {err}')
if SysInfo.has_uefi() and uki_enabled: if SysInfo.has_uefi() and uki_enabled:
grub_d = self.target / 'etc/grub.d' grub_d = LPath(self.target) / 'etc/grub.d'
linux_file = grub_d / '10_linux' linux_file = grub_d / '10_linux'
uki_file = grub_d / '15_uki' uki_file = grub_d / '15_uki'
@ -1406,10 +1406,9 @@ class Installer:
) )
try: try:
mode = linux_file.stat().st_mode
linux_file.chmod(mode & ~(stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH))
uki_file.write_text(content) uki_file.write_text(content)
uki_file.chmod(mode) uki_file.add_exec()
linux_file.remove_exec()
except OSError: except OSError:
error('Failed to enable UKI menu entries') error('Failed to enable UKI menu entries')
else: else:

View File

@ -1,3 +1,4 @@
import stat
from pathlib import Path from pathlib import Path
from typing import Self from typing import Self
@ -9,3 +10,13 @@ class LPath(Path):
def relative_to_root(self) -> Self: def relative_to_root(self) -> Self:
return self.relative_to(self.fs_root()) return self.relative_to(self.fs_root())
def add_exec(self) -> None:
"""Add execute permissions (mirrors `chmod +x`)."""
mode = self.stat().st_mode
self.chmod(mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
def remove_exec(self) -> None:
"""Remove execute permissions (mirrors `chmod -x`)."""
mode = self.stat().st_mode
self.chmod(mode & ~(stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH))