Move run_custom_user_commands to fix an import cycle (#3254)
This commit is contained in:
parent
cb42003b2b
commit
d43482e585
|
|
@ -16,15 +16,12 @@ from enum import Enum
|
|||
from pathlib import Path
|
||||
from select import EPOLLHUP, EPOLLIN, epoll
|
||||
from shutil import which
|
||||
from typing import TYPE_CHECKING, Any, override
|
||||
from typing import Any, override
|
||||
|
||||
from .exceptions import RequirementError, SysCallError
|
||||
from .output import debug, error, info
|
||||
from .output import debug, error
|
||||
from .storage import storage
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .installer import Installer
|
||||
|
||||
# https://stackoverflow.com/a/43627833/929999
|
||||
_VT100_ESCAPE_REGEX = r'\x1B\[[?0-9;]*[a-zA-Z]'
|
||||
_VT100_ESCAPE_REGEX_BYTES = _VT100_ESCAPE_REGEX.encode()
|
||||
|
|
@ -479,20 +476,6 @@ def _pid_exists(pid: int) -> bool:
|
|||
return False
|
||||
|
||||
|
||||
def run_custom_user_commands(commands: list[str], installation: Installer) -> None:
|
||||
for index, command in enumerate(commands):
|
||||
script_path = f"/var/tmp/user-command.{index}.sh"
|
||||
chroot_path = f"{installation.target}/{script_path}"
|
||||
|
||||
info(f'Executing custom command "{command}" ...')
|
||||
with open(chroot_path, "w") as user_script:
|
||||
user_script.write(command)
|
||||
|
||||
SysCommand(f"arch-chroot {installation.target} bash {script_path}")
|
||||
|
||||
os.unlink(chroot_path)
|
||||
|
||||
|
||||
def secret(x: str) -> str:
|
||||
""" return * with len equal to to the input string """
|
||||
return '*' * len(x)
|
||||
|
|
|
|||
|
|
@ -59,10 +59,6 @@ __packages__ = ["base", "base-devel", "linux-firmware", "linux", "linux-lts", "l
|
|||
__accessibility_packages__ = ["brltty", "espeakup", "alsa-utils"]
|
||||
|
||||
|
||||
def accessibility_tools_in_use() -> bool:
|
||||
return os.system('systemctl is-active --quiet espeakup.service') == 0
|
||||
|
||||
|
||||
class Installer:
|
||||
def __init__(
|
||||
self,
|
||||
|
|
@ -1711,3 +1707,21 @@ class Installer:
|
|||
f'systemctl show --no-pager -p SubState --value {service_name}',
|
||||
environment_vars={'SYSTEMD_COLORS': '0'}
|
||||
).decode()
|
||||
|
||||
|
||||
def accessibility_tools_in_use() -> bool:
|
||||
return os.system('systemctl is-active --quiet espeakup.service') == 0
|
||||
|
||||
|
||||
def run_custom_user_commands(commands: list[str], installation: Installer) -> None:
|
||||
for index, command in enumerate(commands):
|
||||
script_path = f"/var/tmp/user-command.{index}.sh"
|
||||
chroot_path = f"{installation.target}/{script_path}"
|
||||
|
||||
info(f'Executing custom command "{command}" ...')
|
||||
with open(chroot_path, "w") as user_script:
|
||||
user_script.write(command)
|
||||
|
||||
SysCommand(f"arch-chroot {installation.target} bash {script_path}")
|
||||
|
||||
os.unlink(chroot_path)
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@ from archinstall.lib.args import ArchConfig, arch_config_handler
|
|||
from archinstall.lib.configuration import ConfigurationOutput
|
||||
from archinstall.lib.disk.filesystem import FilesystemHandler
|
||||
from archinstall.lib.disk.utils import disk_layouts
|
||||
from archinstall.lib.general import run_custom_user_commands
|
||||
from archinstall.lib.global_menu import GlobalMenu
|
||||
from archinstall.lib.installer import Installer, accessibility_tools_in_use
|
||||
from archinstall.lib.installer import Installer, accessibility_tools_in_use, run_custom_user_commands
|
||||
from archinstall.lib.interactions.general_conf import ask_chroot
|
||||
from archinstall.lib.models import AudioConfiguration, Bootloader
|
||||
from archinstall.lib.models.device_model import (
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@ from archinstall.lib.args import ArchConfig, arch_config_handler
|
|||
from archinstall.lib.configuration import ConfigurationOutput
|
||||
from archinstall.lib.disk.filesystem import FilesystemHandler
|
||||
from archinstall.lib.disk.utils import disk_layouts
|
||||
from archinstall.lib.general import run_custom_user_commands
|
||||
from archinstall.lib.global_menu import GlobalMenu
|
||||
from archinstall.lib.installer import Installer, accessibility_tools_in_use
|
||||
from archinstall.lib.installer import Installer, accessibility_tools_in_use, run_custom_user_commands
|
||||
from archinstall.lib.interactions.general_conf import ask_chroot
|
||||
from archinstall.lib.models import AudioConfiguration, Bootloader
|
||||
from archinstall.lib.models.device_model import (
|
||||
|
|
|
|||
Loading…
Reference in New Issue