Chunk 1 of the C3 refactor: replace the two-pass install model (archinstall CLI + custom shell dance + chroot bash installer) with a single Python orchestrator that owns phase ordering, using archinstall as a library subsystem. Splits the bash entry point into two: - install.sh: online entry point. Ensures omarchy runtime + base.packages are installed/up to date, then exec's finalize.sh. - finalize.sh: the in-target portion (preflight + packaging + config + login + post-install). Called by install.sh (online) AND by the orchestrator after arch-chroot -u $USER (offline). Adds the orchestrator skeleton under install/orchestrator/: - main.py: entry point, builds + runs the phase list - context.py: InstallContext (parsed configurator JSON + invocation paths) - phases.py: phase state machine (logging + state.json + error wrapping) - phases_impl.py: stubbed phase implementations (filled in by chunks 2-6) - archinstall_adapter.py: thin compat wall around archinstall lib imports (only this module imports from archinstall.*) - ui.py: gum subprocess wrappers so the orchestrator keeps the same styled-terminal UX as the bash installer Updates bin/omarchy-install to dispatch: - --config <json> in args → python -m orchestrator.main (ISO install) - anything else → bash install.sh (online rerun on installed system) Concrete phase logic lands in subsequent chunks. All phases currently raise NotImplementedError; the orchestrator imports cleanly and --help works as a smoke check.
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
"""Install context: parsed configurator output + invocation paths."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from dataclasses import dataclass
|
|
from pathlib import Path
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class InstallContext:
|
|
config_path: Path
|
|
creds_path: Path
|
|
full_name: str
|
|
email: str
|
|
encrypt: bool
|
|
|
|
user_configuration: dict
|
|
user_credentials: dict
|
|
|
|
target: Path = Path("/mnt")
|
|
omarchy_path: Path = Path("/usr/share/omarchy")
|
|
state_dir: Path = Path("/run/omarchy-install")
|
|
log_path: Path = Path("/var/log/omarchy-install.log")
|
|
target_log_path: Path = Path("/mnt/var/log/omarchy-install.log")
|
|
|
|
@classmethod
|
|
def from_args(cls, args) -> "InstallContext":
|
|
config_path = Path(args.config)
|
|
creds_path = Path(args.creds)
|
|
return cls(
|
|
config_path=config_path,
|
|
creds_path=creds_path,
|
|
full_name=_read_text(args.full_name_file),
|
|
email=_read_text(args.email_file),
|
|
encrypt=_read_text(args.encrypt_file).lower() in ("true", "yes", "1"),
|
|
user_configuration=json.loads(config_path.read_text()),
|
|
user_credentials=json.loads(creds_path.read_text()),
|
|
)
|
|
|
|
@property
|
|
def username(self) -> str:
|
|
return self.user_credentials["users"][0]["username"]
|
|
|
|
|
|
def _read_text(path: str | None) -> str:
|
|
if not path:
|
|
return ""
|
|
p = Path(path)
|
|
if not p.exists():
|
|
return ""
|
|
return p.read_text().strip()
|