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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Lint Python and Find Syntax Errors](https://github.com/archlinux/archinstall/actions/workflows/flake8.yaml/badge.svg)](https://github.com/archlinux/archinstall/actions/workflows/flake8.yaml)

Just another guided/automated [Arch Linux](https://wiki.archlinux.org/index.php/Arch_Linux) installer with a twist.
The installer also doubles as a python library to install Arch Linux and manage services, packages, and other things inside the installed system *(Usually from a live medium)*.
The installer also doubles as a python library to install Arch Linux and manage services, packages, and other things inside the installed system *(Usually from a live medium or from an existing installation)*.

* archinstall [discord](https://discord.gg/aDeMffrxNg) server
* archinstall [#archinstall:matrix.org](https://matrix.to/#/#archinstall:matrix.org) Matrix channel
Expand Down
7 changes: 7 additions & 0 deletions archinstall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from archinstall.lib.packages.packages import check_package_upgrade
from archinstall.tui.ui.components import tui as ttui

from .lib.general import running_from_host
from .lib.hardware import SysInfo
from .lib.output import FormattedOutput, debug, error, info, log, warn
from .lib.pacman import Pacman
Expand Down Expand Up @@ -110,6 +111,12 @@ def main() -> int:
info(new_version)
time.sleep(3)

if running_from_host():
# log which mode we are using
debug('Running from Host (H2T Mode)...')
else:
debug('Running from ISO (Live Mode)...')

script = arch_config_handler.get_script()

mod_name = f'archinstall.scripts.{script}'
Expand Down
17 changes: 14 additions & 3 deletions archinstall/lib/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
_VT100_ESCAPE_REGEX_BYTES = _VT100_ESCAPE_REGEX.encode()


def running_from_host() -> bool:
"""
Check if running from an installed system.

Returns True if running from installed system (host mode) for host-to-target install.
Returns False if /run/archiso exists (ISO mode).
"""
is_host = not Path('/run/archiso').exists()
return is_host


def generate_password(length: int = 64) -> str:
haystack = string.printable # digits, ascii_letters, punctuation (!"#$[] etc) and whitespace
return ''.join(secrets.choice(haystack) for _ in range(length))
Expand All @@ -46,7 +57,7 @@ def clear_vt100_escape_codes_from_str(data: str) -> str:
return re.sub(_VT100_ESCAPE_REGEX, '', data)


def jsonify(obj: object, safe: bool = True) -> object:
def jsonify(obj: Any, safe: bool = True) -> Any:
"""
Converts objects into json.dumps() compatible nested dictionaries.
Setting safe to True skips dictionary keys starting with a bang (!)
Expand Down Expand Up @@ -84,7 +95,7 @@ class JSON(json.JSONEncoder, json.JSONDecoder):
"""

@override
def encode(self, o: object) -> str:
def encode(self, o: Any) -> str:
return super().encode(jsonify(o))


Expand All @@ -94,7 +105,7 @@ class UNSAFE_JSON(json.JSONEncoder, json.JSONDecoder):
"""

@override
def encode(self, o: object) -> str:
def encode(self, o: Any) -> str:
return super().encode(jsonify(o, safe=False))


Expand Down
7 changes: 6 additions & 1 deletion archinstall/lib/locale/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ..exceptions import ServiceException, SysCallError
from ..general import SysCommand
from ..general import SysCommand, running_from_host
from ..output import error


Expand Down Expand Up @@ -79,6 +79,11 @@ def get_kb_layout() -> str:


def set_kb_layout(locale: str) -> bool:
if running_from_host():
# Skip when running from host - no need to change host keymap
# The target installation keymap is set via installer.set_keyboard_language()
return True

if len(locale.strip()):
if not verify_keyboard_layout(locale):
error(f'Invalid keyboard locale specified: {locale}')
Expand Down