Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions archinstall/lib/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@
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()
Expand Down Expand Up @@ -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)
22 changes: 18 additions & 4 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@
__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,
Expand Down Expand Up @@ -1711,3 +1707,21 @@ def _service_state(self, service_name: str) -> str:
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)
3 changes: 1 addition & 2 deletions archinstall/scripts/guided.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
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 (
Expand Down
3 changes: 1 addition & 2 deletions examples/interactive_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
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 (
Expand Down