feat: Introduce check_dependencies to verify required system tools before installation.

This commit is contained in:
Zeev Diukman 2026-01-19 08:46:50 +02:00
parent 0f87ed3896
commit 56dddd6a2c

25
z.py
View file

@ -5,6 +5,7 @@ import sys
import os
import shlex
import getpass
import shutil
from dataclasses import dataclass, field
from typing import List, Optional
@ -127,12 +128,36 @@ def run_live_command(command, log_func=None, check=True, shell=False, dry_run=Fa
# Mimic subprocess.CalledProcessError
raise subprocess.CalledProcessError(return_code, command)
def check_dependencies(log_func=print):
"""Checks if required system tools are available."""
required_tools = [
"lsblk", "btrfs", "mkfs.btrfs", "mkfs.fat",
"pacstrap", "genfstab", "arch-chroot"
]
missing = []
for tool in required_tools:
if not shutil.which(tool):
missing.append(tool)
if missing:
msg = f"Error: Missing required tools: {', '.join(missing)}\nPlease install: btrfs-progs, dosfstools, arch-install-scripts"
log_func(msg)
raise RuntimeError(msg)
def perform_installation(config: InstallConfig, log_func=print):
"""
Executes the installation process based on the provided configuration.
log_func is a function to display messages (defaults to print).
"""
try:
check_dependencies(log_func)
except RuntimeError:
# If check fails, we stop. In TUI this will define the error.
return
# helper for dry_run propagation
# helper for dry_run propagation
def run(cmd, **kwargs):
# Merge dry_run into kwargs if not explicitly set