Compare commits

49 Commits

Author SHA1 Message Date
5df00a5814 Further improvements to dnf robustness and repo discovery for offline installs 2026-02-05 19:39:54 +01:00
951a1b7fdc Fix dnf failure by adding /run mount, removing --cacheonly, and ensuring host-config usage 2026-02-05 19:32:56 +01:00
297f2cd3c2 Improve offline repository discovery and dnf configuration for ISO installs 2026-02-05 19:28:41 +01:00
ce2c242454 revert 4278a3198d
revert Add minimal-linux-installer skill with proven installation patterns
2026-02-05 18:32:01 +01:00
4278a3198d Add minimal-linux-installer skill with proven installation patterns 2026-02-05 18:30:55 +01:00
943cfee8bb IT ACTUALLY INSTALLS 2026-02-05 18:16:08 +01:00
9cfd6ad2e0 Use robust usermod -p method for setting passwords 2026-02-05 17:54:14 +01:00
23b5f017d4 Fix password setting using chpasswd -R and improve screen wake lock 2026-02-05 17:39:01 +01:00
ee83411333 Fix password setting by using passwd --stdin and sync 2026-02-05 17:25:00 +01:00
7613bdf8d5 Fix password setting and inhibit system sleep during install 2026-02-05 17:03:36 +01:00
400235067d Fix bootctl unrecognized option and improve repo discovery 2026-02-05 16:46:59 +01:00
f3e7122d02 Fix dnf5 deferred transaction and add shadow-utils for user creation 2026-02-05 16:27:57 +01:00
afe18c1eee Fix dnf error by removing localpkg_only and improve repo search 2026-02-05 15:40:42 +01:00
76c638de8e Improve offline installation by searching for repo in multiple paths 2026-02-05 15:37:18 +01:00
1238dcdabd Remove accidental log file 2026-02-05 15:17:53 +01:00
f7fc354f3f Fix UEFI boot by mounting efivarfs and forcing systemd-boot install 2026-02-05 15:17:48 +01:00
3a226108ec Fix: ensure disk is unmounted before partitioning and use sudo for reboot 2026-02-05 14:55:18 +01:00
45b0fa5a84 . 2026-02-05 14:54:15 +01:00
6b7c7debff Increase VM memory allocation to 8GB 2026-02-05 14:49:59 +01:00
9fcbf6f204 Add automatic dependency installation to run.sh 2026-02-05 14:34:35 +01:00
e5f46324e4 Fix UEFI snapshot support and ensure sudo privileges 2026-02-05 14:23:44 +01:00
4eff9d7e22 Update UEFI VM script with correct paths and add snapshot script 2026-02-05 14:18:39 +01:00
7bfab2ac5b Update window.py 2026-02-05 14:00:49 +01:00
8bac02357c Send logs as file, create sudoer user, and improve bootloader reliability 2026-02-05 13:22:34 +01:00
bba28a6f77 Remove accidental log file 2026-02-05 12:59:54 +01:00
be674e89e0 Switch to systemd-boot, full log sending, and offline install fix 2026-02-05 12:59:24 +01:00
e99290eebe . 2026-02-05 12:48:36 +01:00
eb03edb050 . 2026-02-05 12:39:41 +01:00
f7bebc7f88 Add network logging to Discord webhook for testing branch
- Add network_logging.py module with Discord webhook integration
- Log session start with unique session ID and mode (MOCK/PRODUCTION)
- Log all page navigations when clicking Next
- Log all user selections (disk, install mode, modules, user info)
- Log installation progress through each step
- Send install completion/failure logs
- Auto-flush logs every 2 seconds and immediately on critical events

TESTING BRANCH ONLY - Remove before merging to main
2026-02-04 21:18:18 +01:00
e611f174be Update os_install.py 2026-02-03 21:32:51 +01:00
b70ff549a7 Update partitioning.py 2026-02-03 21:31:17 +01:00
bb31814233 Update partitioning.py 2026-02-03 21:30:27 +01:00
00ba6e5c89 feat: verbose installation logs, improved auto-partitioning logic, and UI tweaks 2026-02-03 21:24:31 +01:00
7d43b82ce1 fix(ui): reorder partition dialog, fix mount point selection, add threaded install with logs 2026-02-03 21:06:16 +01:00
af86d357a4 fix(ui): correct mount point selection pre-fill and simplify partition creation dialog 2026-02-03 20:57:29 +01:00
848b2e7e74 fix: mount pseudo-fs during install, simplify partitioning, and add mount point config 2026-02-03 20:49:41 +01:00
dc417d15d3 fix(backend): use host config for dnf install to resolve repos 2026-02-03 20:29:03 +01:00
7a8e8ccbed fix(partitioning): avoid alignment errors by using fill-gap logic for full space 2026-02-03 20:19:25 +01:00
7371da2451 fix(backend): improve partition creation robustness and formatting 2026-02-03 20:03:24 +01:00
9f5bade34c feat(partitioning): support fat32 and add validation for system partition name 2026-02-03 19:53:51 +01:00
11fca148be fix(ui): handle NoneType fstype and remove duplicate code in partitioning page 2026-02-03 19:49:52 +01:00
b7a049d86f fix(ui): correct Gtk.Button instantiation in partitioning page 2026-02-03 18:13:04 +01:00
2676da751b Fix PartitioningPage being stuck on detecting due to duplicate function 2026-02-03 17:23:19 +01:00
22e1fa8f62 Implement manual partition management (create/delete/mountpoints) 2026-02-03 17:07:45 +01:00
efe25f3e11 Ensure disk device path has /dev/ prefix 2026-02-03 17:01:36 +01:00
2f9338af0a Fix logic error in page transitions 2026-02-03 16:43:19 +01:00
33d989cfad Hook up GUI Install button to backend logic 2026-02-03 16:34:36 +01:00
2377b0269a Implement minimal OS and Bootloader installation logic 2026-02-03 16:28:55 +01:00
3c4870b104 Implement basic partitioning backend and CLI interface 2026-02-03 16:20:59 +01:00
11 changed files with 1555 additions and 76 deletions

View File

View File

@@ -0,0 +1,355 @@
import subprocess
import logging
import os
logger = logging.getLogger(__name__)
# Import network logging for critical disk operations
from .network_logging import log_to_discord
def log_disk_operation(operation, status="start", details=""):
log_to_discord("INFO", f"DISK_{operation}_{status}: {details}", module="disk")
class CommandResult:
def __init__(self, stdout, stderr, returncode):
self.stdout = stdout
self.stderr = stderr
self.returncode = returncode
def run_command(cmd, check=True):
logger.info(f"Running command: {' '.join(cmd)}")
process = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1
)
stdout_lines = []
stderr_lines = []
def read_stream(stream, line_list, log_level):
for line in stream:
line_clean = line.strip()
if line_clean:
log_level(line_clean)
line_list.append(line)
import threading
t1 = threading.Thread(
target=read_stream, args=(process.stdout, stdout_lines, logger.info)
)
t2 = threading.Thread(
target=read_stream, args=(process.stderr, stderr_lines, logger.error)
)
t1.start()
t2.start()
t1.join()
t2.join()
returncode = process.wait()
stdout_str = "".join(stdout_lines)
stderr_str = "".join(stderr_lines)
if check and returncode != 0:
raise subprocess.CalledProcessError(
returncode, cmd, output=stdout_str, stderr=stderr_str
)
return CommandResult(stdout_str, stderr_str, returncode)
def get_partition_device(disk_device, partition_number):
"""
Returns the partition device path.
Handles NVMe style (p1) vs sd style (1).
"""
if disk_device[-1].isdigit():
return f"{disk_device}p{partition_number}"
return f"{disk_device}{partition_number}"
def get_total_memory():
"""Returns total system memory in bytes."""
try:
return os.sysconf("SC_PAGE_SIZE") * os.sysconf("SC_PHYS_PAGES")
except (ValueError, OSError):
with open("/proc/meminfo", "r") as f:
for line in f:
if line.startswith("MemTotal:"):
parts = line.split()
return int(parts[1]) * 1024
return 0
def get_disk_size(disk_device):
"""Returns disk size in bytes using blockdev."""
try:
res = run_command(["blockdev", "--getsize64", disk_device])
return int(res.stdout.strip())
except Exception as e:
logger.error(f"Failed to get disk size: {e}")
return 0
def ensure_unmounted(disk_device):
"""
Finds all mounted partitions belonging to disk_device and unmounts them.
"""
logger.info(f"Ensuring all partitions on {disk_device} are unmounted...")
try:
# Get all partitions for this disk from lsblk
res = run_command(["lsblk", "-nlo", "NAME,MOUNTPOINT", disk_device])
for line in res.stdout.splitlines():
parts = line.split()
if len(parts) >= 2:
# NAME is usually the leaf name (e.g. vda1), we need full path
# But lsblk -lp gives full paths
pass
# Simpler approach: findmnt or just look at /proc/mounts
# Let's use lsblk -lp to get full paths
res = run_command(["lsblk", "-lpno", "NAME,MOUNTPOINT", disk_device])
for line in res.stdout.splitlines():
# line looks like "/dev/vda1 /mnt/boot" or "/dev/vda1"
parts = line.split()
if len(parts) >= 2:
dev_path = parts[0]
mount_point = parts[1]
if mount_point and mount_point != "None":
logger.info(f"Unmounting {dev_path} from {mount_point}...")
run_command(["umount", "-l", dev_path])
except Exception as e:
logger.warning(f"Error during pre-partition unmount: {e}")
def auto_partition_disk(disk_device):
"""
Automatically partitions the disk:
1. EFI System Partition (2GB standard, 1GB small)
2. Root (Remaining)
3. Swap (RAM + 2GB, or 0 if small)
Layout: P1=EFI, P3=Swap (End), P2=Root (Middle)
"""
logger.info(f"Starting auto-partitioning on {disk_device}")
log_disk_operation("PARTITION", "start", f"Disk: {disk_device}")
# 0. Ensure unmounted
ensure_unmounted(disk_device)
# Calculate sizes
disk_size = get_disk_size(disk_device)
ram_size = get_total_memory()
# Defaults
efi_mb = 2048
swap_mb = int((ram_size / (1024 * 1024)) + 2048)
min_root_mb = 10240 # 10GB
total_required_mb = efi_mb + swap_mb + min_root_mb
disk_mb = disk_size / (1024 * 1024)
use_swap = True
if disk_mb < total_required_mb:
logger.warning("Disk too small for standard layout. Adjusting...")
efi_mb = 1024
use_swap = False
# Check minimal viability
if disk_mb < (efi_mb + min_root_mb):
raise Exception("Disk too small for installation (Need ~11GB)")
# 1. Zap the disk (destroy all data)
run_command(["sgdisk", "-Z", disk_device])
# 2. Create new GPT table
run_command(["sgdisk", "-o", disk_device])
# 3. Create EFI Partition (Part 1, Start)
run_command(
[
"sgdisk",
"-n",
f"1:0:+{efi_mb}M",
"-t",
"1:ef00",
"-c",
"1:EFI System",
disk_device,
]
)
# 4. Create Swap Partition (Part 3, End) - If enabled
if use_swap:
# sgdisk negative start is from end of disk
# We use partition 3 for Swap
run_command(
[
"sgdisk",
"-n",
f"3:-{swap_mb}M:0",
"-t",
"3:8200",
"-c",
"3:Swap",
disk_device,
]
)
# 5. Create Root Partition (Part 2, Fill Gap)
# This fills the space between P1 and P3 (or end if no swap)
run_command(["sgdisk", "-n", "2:0:0", "-t", "2:8300", "-c", "2:Root", disk_device])
# Inform kernel of changes
run_command(["partprobe", disk_device])
import time
time.sleep(1)
# 6. Format Partitions
efi_part = get_partition_device(disk_device, 1)
root_part = get_partition_device(disk_device, 2)
swap_part = get_partition_device(disk_device, 3) if use_swap else None
logger.info("Formatting EFI partition...")
run_command(["mkfs.vfat", "-F32", efi_part])
if use_swap:
logger.info("Formatting Swap partition...")
run_command(["mkswap", swap_part])
logger.info("Formatting Root partition...")
run_command(["mkfs.ext4", "-F", root_part])
logger.info("Partitioning and formatting complete.")
log_disk_operation(
"PARTITION",
"complete",
f"EFI: {efi_part}, Root: {root_part}, Swap: {swap_part or 'none'}",
)
result = {"efi": efi_part, "root": root_part}
if use_swap:
result["swap"] = swap_part
else:
# If no swap, we should probably return None or handle it in fstab generation
# backend/os_install.py expects "swap" key for UUID.
# We should probably pass a dummy or None, and update os_install to handle it.
result["swap"] = None
return result
def mount_partitions(partition_info, mount_root="/mnt"):
"""
Mounts the partitions into mount_root.
"""
import os
log_disk_operation("MOUNT", "start", f"Mounting to {mount_root}")
# 1. Mount Root
if not os.path.exists(mount_root):
os.makedirs(mount_root)
run_command(["mount", partition_info["root"], mount_root])
# 2. Mount EFI
efi_mount = os.path.join(mount_root, "boot")
if not os.path.exists(efi_mount):
os.makedirs(efi_mount, exist_ok=True)
run_command(["mount", partition_info["efi"], efi_mount])
# 3. Enable Swap
if partition_info.get("swap"):
run_command(["swapon", partition_info["swap"]])
logger.info(f"Partitions mounted at {mount_root}")
log_disk_operation(
"MOUNT",
"complete",
f"Root: {partition_info['root']}, EFI: {partition_info['efi']}",
)
def create_partition(
disk_device, size_mb, type_code="8300", name="Linux filesystem", fstype=None
):
"""
Creates a new partition on the disk and formats it.
type_code: ef00 (EFI), 8200 (Swap), 8300 (Linux)
fstype: ext4, fat32, swap
"""
# Find next available partition number
res = run_command(["sgdisk", "-p", disk_device])
# Very basic parsing to find the next number
existing_nums = []
for line in res.stdout.splitlines():
parts = line.split()
if parts and parts[0].isdigit():
existing_nums.append(int(parts[0]))
next_num = 1
while next_num in existing_nums:
next_num += 1
# Use -g (mbrtogpt) to ensure we can work on the disk if it was MBR
# size_mb=0 means use all available space in the gap
size_spec = f"+{size_mb}M" if size_mb > 0 else "0"
run_command(
[
"sgdisk",
"-g",
"-n",
f"{next_num}:0:{size_spec}",
"-t",
f"{next_num}:{type_code}",
"-c",
f"{next_num}:{name}",
disk_device,
]
)
run_command(["partprobe", disk_device])
# Wait for partition node to appear
try:
run_command(["udevadm", "settle", "--timeout=5"])
except Exception:
import time
time.sleep(2)
part_dev = get_partition_device(disk_device, next_num)
if fstype == "fat32":
run_command(["mkfs.vfat", "-F32", part_dev])
elif fstype == "ext4":
run_command(["mkfs.ext4", "-F", part_dev])
elif fstype == "swap":
run_command(["mkswap", part_dev])
return next_num
def delete_partition(disk_device, part_num):
"""Deletes a partition by number."""
run_command(["sgdisk", "-d", str(part_num), disk_device])
run_command(["partprobe", disk_device])
def wipe_disk(disk_device):
"""Zaps the disk and creates a new GPT table."""
run_command(["sgdisk", "-Z", disk_device])
run_command(["sgdisk", "-o", disk_device])
run_command(["partprobe", disk_device])

View File

@@ -0,0 +1,120 @@
import logging
import requests
import threading
import time
import os
from datetime import datetime
logger = logging.getLogger(__name__ + ".network_logging")
DISCORD_WEBHOOK_URL = "https://discord.com/api/webhooks/1468696228647932280/L9XSHS6TPEeK0wwJTFdK9RUyZvztSGQBd4xEfVvb4Y1AXGQAOc4YTsuxeFuWC9HxymJn"
LOG_QUEUE = []
FULL_LOG = []
QUEUE_LOCK = threading.Lock()
ENABLED = True
def init_network_logging(enabled: bool = True):
global ENABLED
ENABLED = enabled
def log_to_discord(level: str, message: str, module: str = "general"):
if not ENABLED:
return
timestamp = datetime.utcnow().isoformat()
log_entry = {
"timestamp": timestamp,
"level": level.upper(),
"module": module,
"message": message,
}
with QUEUE_LOCK:
FULL_LOG.append(log_entry)
def flush_logs():
# Deprecated: No partial flushing anymore
pass
def send_full_log():
"""Sends the entire session log as a text file attachment at the end."""
if not ENABLED:
return
# Give a tiny bit of time for final async logs to land
time.sleep(0.5)
with QUEUE_LOCK:
logs_to_send = FULL_LOG.copy()
if not logs_to_send:
return
def send_sync():
temp_file = "/tmp/iridium_install_log.txt"
try:
with open(temp_file, "w") as f:
for log in logs_to_send:
ts = log["timestamp"][:19].replace("T", " ")
line = f"[{ts}] [{log['level']}] [{log['module']}] {log['message']}\n"
f.write(line)
with open(temp_file, "rb") as f:
files = {"file": ("iridium_install_log.txt", f)}
requests.post(DISCORD_WEBHOOK_URL, files=files, timeout=30)
except Exception as e:
print(f"Failed to send full log file to Discord: {e}")
finally:
if os.path.exists(temp_file):
os.remove(temp_file)
# For full log, we run it in a thread but wait for it
t = threading.Thread(target=send_sync)
t.start()
t.join(timeout=30)
def send_discord_message(content: str):
try:
payload = {"content": content}
requests.post(DISCORD_WEBHOOK_URL, json=payload, timeout=5)
except Exception as e:
print(f"Discord webhook error: {e}")
class DiscordLogHandler(logging.Handler):
def __init__(self, module_name: str = "general"):
super().__init__()
self.module_name = module_name
def emit(self, record: logging.LogRecord):
if record.levelno < logging.INFO:
return
level_map = {
logging.INFO: "INFO",
logging.WARNING: "WARN",
logging.ERROR: "ERROR",
logging.CRITICAL: "CRITICAL",
}
level = level_map.get(record.levelno, "INFO")
message = self.format(record)
module_name = (
self.module_name
if self.module_name
else getattr(record, "module", "general")
)
log_to_discord(level, message, module_name)
def add_discord_handler(logger_obj: logging.Logger, module: str = None):
module_name = (
module if module else (logger_obj.name if logger_obj.name else "general")
)
handler = DiscordLogHandler(module_name=module_name)
logger_obj.addHandler(handler)

View File

@@ -0,0 +1,421 @@
import logging
import os
import subprocess
import sys
from contextlib import contextmanager
logger = logging.getLogger(__name__)
# Import network logging for critical operations
from .network_logging import log_to_discord
def log_os_install(operation, status="start", details=""):
log_to_discord(
"INFO", f"OSINSTALL_{operation}_{status}: {details}", module="os_install"
)
class CommandResult:
def __init__(self, stdout, stderr, returncode):
self.stdout = stdout
self.stderr = stderr
self.returncode = returncode
def run_command(cmd, check=True):
logger.info(f"Running command: {' '.join(cmd)}")
process = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
bufsize=1, # Line buffered
)
stdout_lines = []
stderr_lines = []
# Helper to read stream
def read_stream(stream, line_list, log_level):
for line in stream:
line_clean = line.strip()
if line_clean:
log_level(line_clean)
line_list.append(line)
import threading
t1 = threading.Thread(
target=read_stream, args=(process.stdout, stdout_lines, logger.info)
)
t2 = threading.Thread(
target=read_stream, args=(process.stderr, stderr_lines, logger.error)
)
t1.start()
t2.start()
t1.join()
t2.join()
returncode = process.wait()
stdout_str = "".join(stdout_lines)
stderr_str = "".join(stderr_lines)
if check and returncode != 0:
raise subprocess.CalledProcessError(
returncode, cmd, output=stdout_str, stderr=stderr_str
)
return CommandResult(stdout_str, stderr_str, returncode)
@contextmanager
def mount_pseudo_fs(mount_root):
"""
Context manager to bind mount /dev, /proc, /sys, /run, and efivarfs into mount_root.
"""
logger.info(f"Mounting pseudo-filesystems to {mount_root}...")
# dev/pts and dev/shm are often needed by scriptlets
mounts = ["dev", "proc", "sys", "run", "dev/pts", "dev/shm"]
mounted_paths = []
try:
for fs in mounts:
target = os.path.join(mount_root, fs)
os.makedirs(target, exist_ok=True)
run_command(["mount", "--bind", f"/{fs}", target])
mounted_paths.append(target)
# Bind mount RPM GPG keys from host
gpg_keys_host = "/etc/pki/rpm-gpg"
if os.path.exists(gpg_keys_host):
gpg_keys_target = os.path.join(mount_root, "etc/pki/rpm-gpg")
os.makedirs(gpg_keys_target, exist_ok=True)
run_command(["mount", "--bind", gpg_keys_host, gpg_keys_target])
mounted_paths.append(gpg_keys_target)
# Mount efivarfs if it exists on the host
efivars_path = "/sys/firmware/efi/efivars"
if os.path.exists(efivars_path):
target = os.path.join(mount_root, "sys/firmware/efi/efivars")
os.makedirs(target, exist_ok=True)
try:
run_command(["mount", "-t", "efivarfs", "efivarfs", target])
mounted_paths.append(target)
except Exception as e:
logger.warning(f"Failed to mount efivarfs: {e}")
yield
finally:
logger.info(f"Unmounting pseudo-filesystems from {mount_root}...")
for path in reversed(mounted_paths):
try:
run_command(["umount", "-l", path])
except Exception as e:
logger.warning(f"Failed to unmount {path}: {e}")
def has_rpms(path):
"""Checks if a directory contains any .rpm files."""
if not os.path.isdir(path):
return False
try:
for f in os.listdir(path):
if f.endswith(".rpm"):
return True
except Exception:
pass
return False
def find_iso_repo():
"""
Attempts to find a local repository on the ISO or other mounted media.
"""
possible_paths = [
"/run/install/repo",
"/run/install/source",
"/mnt/install/repo",
"/run/initramfs/live",
"/run/initramfs/isoscan",
]
def check_path(p):
if os.path.exists(os.path.join(p, "repodata")) or os.path.exists(os.path.join(p, "media.repo")):
return p
for sub in ["os", "Packages", "BaseOS", "AppStream"]:
sub_p = os.path.join(p, sub)
if os.path.exists(os.path.join(sub_p, "repodata")) or os.path.exists(os.path.join(sub_p, "media.repo")):
return sub_p
return None
# 1. Check known paths
for path in possible_paths:
res = check_path(path)
if res: return res
# 2. Check all mounted filesystems
try:
res = subprocess.run(["findmnt", "-nlo", "TARGET"], capture_output=True, text=True)
if res.returncode == 0:
for mount in res.stdout.splitlines():
if mount.startswith("/proc") or mount.startswith("/sys") or mount.startswith("/dev"):
continue
res = check_path(mount)
if res: return res
except Exception as e:
logger.debug(f"Error searching mount points: {e}")
# 3. Try to mount /dev/sr0 or /dev/cdrom
for dev in ["/dev/sr0", "/dev/cdrom"]:
try:
if os.path.exists(dev):
res = subprocess.run(["findmnt", "-n", dev], capture_output=True)
if res.returncode != 0:
try:
os.makedirs("/mnt/iso", exist_ok=True)
subprocess.run(["mount", "-o", "ro", dev, "/mnt/iso"], check=True)
res = check_path("/mnt/iso")
if res: return res
except Exception: pass
except Exception: pass
# 4. Check /run/media deeper
if os.path.exists("/run/media"):
try:
for root, dirs, files in os.walk("/run/media"):
if "repodata" in dirs or "media.repo" in files:
return root
# Limit depth for performance
if root.count(os.sep) > 5:
del dirs[:]
except Exception: pass
# 5. Last resort: any directory with .rpm files
for path in possible_paths:
if has_rpms(path): return path
for sub in ["os", "Packages", "BaseOS", "AppStream"]:
if has_rpms(os.path.join(path, sub)): return os.path.join(path, sub)
return None
def install_minimal_os(mount_root, releasever=None):
"""
Installs minimal Fedora packages to mount_root.
"""
if not releasever:
# Try to detect from host
try:
with open("/etc/os-release", "r") as f:
for line in f:
if line.startswith("VERSION_ID="):
releasever = line.split("=")[1].strip().strip('"')
break
except Exception:
pass
if not releasever:
releasever = "43" # Fallback
logger.info(f"Installing minimal Fedora {releasever} to {mount_root}...")
log_os_install("INSTALL", "start", f"Target: {mount_root}, Release: {releasever}")
packages = [
"basesystem",
"bash",
"coreutils",
"kernel",
"systemd",
"systemd-boot",
"dnf",
"shadow-utils",
"util-linux",
"efibootmgr",
"passwd",
"rootfiles",
"vim-minimal",
]
# Offline installation logic
iso_repo = find_iso_repo()
# Create a temporary dnf.conf to be strictly local if repo found
dnf_conf_path = "/tmp/iridium_dnf.conf"
with open(dnf_conf_path, "w") as f:
f.write("[main]\ngpgcheck=0\ninstallroot_managed_by_dnf=True\n")
dnf_args = [
f"--config={dnf_conf_path}",
"--setopt=cachedir=/tmp/dnf-cache",
"--setopt=install_weak_deps=False",
"--nodocs",
]
if iso_repo:
logger.info(f"Found ISO repository at {iso_repo}. Using strictly offline mode.")
dnf_args += [
"--disablerepo=*",
f"--repofrompath=iridium-iso,{iso_repo}",
"--enablerepo=iridium-iso",
"--nogpgcheck",
"--offline", # Supported by dnf5
"--setopt=iridium-iso.gpgcheck=0",
"--setopt=metadata_expire=-1",
]
else:
# Check if we are on a Live ISO but no repo found
if os.path.exists("/run/initramfs/live/LiveOS/squashfs.img"):
logger.warning("Detected Fedora Live environment, but no RPM repository was found on the media.")
logger.warning("Workstation Live ISOs usually do not contain a DNF repository for offline installation.")
logger.warning("ISO repository not found. DNF will attempt to use network.")
dnf_args.append("--use-host-config")
cmd = [
"dnf",
"install",
"-y",
f"--installroot={mount_root}",
f"--releasever={releasever}",
]
cmd += dnf_args + packages
# Copy resolv.conf if it exists (some scriptlets might need it for UID/GID lookups)
try:
os.makedirs(os.path.join(mount_root, "etc"), exist_ok=True)
if os.path.exists("/etc/resolv.conf"):
subprocess.run(["cp", "/etc/resolv.conf", os.path.join(mount_root, "etc/resolv.conf")])
except Exception: pass
with mount_pseudo_fs(mount_root):
run_command(cmd)
logger.info("Base system installation complete.")
log_os_install("INSTALL", "complete", f"Installed to {mount_root}")
def configure_system(mount_root, partition_info, user_info=None):
"""
Basic configuration: fstab, systemd-boot, and user creation.
"""
logger.info("Configuring system...")
log_os_install("CONFIGURE", "start", f"Configuring system in {mount_root}")
# 1. Generate fstab
def get_uuid(dev):
res = run_command(["blkid", "-s", "UUID", "-o", "value", dev])
return res.stdout.strip()
root_uuid = get_uuid(partition_info["root"])
efi_uuid = get_uuid(partition_info["efi"])
swap_entry = ""
if partition_info.get("swap"):
swap_uuid = get_uuid(partition_info["swap"])
swap_entry = f"UUID={swap_uuid} none swap defaults 0 0\n"
fstab_content = f"""
UUID={root_uuid} / ext4 defaults 1 1
UUID={efi_uuid} /boot vfat defaults 0 2
{swap_entry}
"""
os.makedirs(os.path.join(mount_root, "etc"), exist_ok=True)
with open(os.path.join(mount_root, "etc/fstab"), "w") as f:
f.write(fstab_content)
with mount_pseudo_fs(mount_root):
# 2. Configure User
if user_info:
logger.info(f"Creating user {user_info['username']}...")
# Create user and add to wheel group (sudoer)
run_command(["chroot", mount_root, "useradd", "-m", "-G", "wheel", user_info["username"]])
# Ensure changes to /etc/passwd and /etc/shadow are flushed
run_command(["sync"])
# Ensure wheel group has sudo privileges
sudoers_dir = os.path.join(mount_root, "etc/sudoers.d")
os.makedirs(sudoers_dir, exist_ok=True)
with open(os.path.join(sudoers_dir, "wheel"), "w") as f:
f.write("%wheel ALL=(ALL) ALL\n")
os.chmod(os.path.join(sudoers_dir, "wheel"), 0o440)
# Set user and root password using hashed passwords and usermod
try:
logger.info(f"Setting hashed passwords for {user_info['username']} and root...")
# Generate SHA512 hash using openssl on the host
res = subprocess.run(
["openssl", "passwd", "-6", user_info["password"]],
capture_output=True,
text=True,
check=True
)
hashed_pass = res.stdout.strip()
# Apply hash to user and root using usermod -p (takes encrypted password)
run_command(["chroot", mount_root, "usermod", "-p", hashed_pass, user_info["username"]])
run_command(["chroot", mount_root, "usermod", "-p", hashed_pass, "root"])
run_command(["sync"])
except Exception as e:
logger.error(f"Failed to set passwords: {e}")
raise e
# Set hostname
with open(os.path.join(mount_root, "etc/hostname"), "w") as f:
f.write(user_info["hostname"] + "\n")
# 3. Configure systemd-boot
# Ensure machine-id exists for kernel-install
if not os.path.exists(os.path.join(mount_root, "etc/machine-id")):
run_command(["chroot", mount_root, "systemd-machine-id-setup"])
# Set kernel command line
os.makedirs(os.path.join(mount_root, "etc/kernel"), exist_ok=True)
with open(os.path.join(mount_root, "etc/kernel/cmdline"), "w") as f:
f.write(f"root=UUID={root_uuid} rw quiet\n")
# Set kernel layout to BLS for systemd-boot
with open(os.path.join(mount_root, "etc/kernel/layout"), "w") as f:
f.write("bls\n")
# Install systemd-boot to the ESP (mounted at /boot)
# Note: removed --force as it's not supported by all bootctl versions
run_command(["chroot", mount_root, "bootctl", "install", "--path=/boot"])
# Add kernel entries
modules_dir = os.path.join(mount_root, "lib/modules")
if os.path.exists(modules_dir):
kvers = [d for d in os.listdir(modules_dir) if os.path.isdir(os.path.join(modules_dir, d))]
for kver in kvers:
logger.info(f"Adding kernel entry for {kver}...")
# Ensure initramfs exists. If not, generate it.
initrd_path_rel = f"boot/initramfs-{kver}.img"
initrd_full_path = os.path.join(mount_root, initrd_path_rel)
if not os.path.exists(initrd_full_path):
logger.info(f"Generating initramfs for {kver}...")
run_command(["chroot", mount_root, "dracut", "--force", f"/boot/initramfs-{kver}.img", kver])
kernel_image = f"/lib/modules/{kver}/vmlinuz"
initrd_arg = f"/boot/initramfs-{kver}.img"
# kernel-install add <version> <image> [initrd]
cmd = ["chroot", mount_root, "kernel-install", "add", kver, kernel_image]
if os.path.exists(os.path.join(mount_root, initrd_arg.lstrip("/"))):
cmd.append(initrd_arg)
run_command(cmd)
# Ensure all data is synced to disk
run_command(["sync"])
logger.info("System configuration complete.")
log_os_install("CONFIGURE", "complete", "systemd-boot and user configured successfully")

View File

@@ -1,29 +1,16 @@
import argparse
import sys
import logging
import gi
# Configure logging
logging.basicConfig(level=logging.INFO)
gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")
# Initialize network logging (TESTING BRANCH ONLY)
from .backend.network_logging import init_network_logging, add_discord_handler, send_full_log
from gi.repository import Adw, Gio, Gtk
from .ui.window import InstallerWindow
class IridiumInstallerApp(Adw.Application):
def __init__(self, mock_mode=False):
super().__init__(
application_id="org.iridium.Installer",
flags=Gio.ApplicationFlags.FLAGS_NONE,
)
self.mock_mode = mock_mode
def do_activate(self):
win = self.props.active_window
if not win:
win = InstallerWindow(application=self, mock_mode=self.mock_mode)
win.present()
init_network_logging(enabled=True)
add_discord_handler(logging.getLogger("iridium_installer"))
logger = logging.getLogger(__name__)
def main():
@@ -33,8 +20,98 @@ def main():
action="store_true",
help="Run in mock mode (no actual changes to disk)",
)
parser.add_argument(
"--partition-disk",
help="Automatically partition the specified disk (WARNING: DESTROYS DATA)",
)
parser.add_argument(
"--full-install",
help="Run a full minimal installation on the specified disk (WARNING: DESTROYS DATA)",
)
args = parser.parse_args()
if args.partition_disk or args.full_install:
from .backend.disk import auto_partition_disk, mount_partitions
from .backend.os_install import install_minimal_os, configure_system
target = args.partition_disk or args.full_install
logger.info(f"INSTALLER_START: Starting installation on {target}")
try:
print(f"Starting installation on {target}...")
print("Step 1: Partitioning...")
logger.info(f"INSTALLER_PARTITION: Partitioning disk {target}")
parts = auto_partition_disk(target)
logger.info(f"INSTALLER_PARTITION_COMPLETE: Created partitions {parts}")
if args.full_install:
print("Step 2: Mounting...")
logger.info("INSTALLER_MOUNT: Mounting partitions")
mount_root = "/mnt"
mount_partitions(parts, mount_root)
print("Step 3: Installing OS (this may take a while)...")
logger.info("INSTALLER_OS_INSTALL: Installing minimal OS")
install_minimal_os(mount_root)
logger.info("INSTALLER_OS_INSTALL_COMPLETE: OS installed successfully")
print("Step 4: Configuring Bootloader...")
logger.info("INSTALLER_BOOTLOADER: Configuring bootloader")
# Default user for CLI install (since we don't have user input in CLI args yet)
user_info = {
"username": "admin",
"password": "password", # Insecure default for CLI dev testing
"hostname": "iridium-cli"
}
configure_system(mount_root, parts, user_info)
logger.info("INSTALLER_BOOTLOADER_COMPLETE: Bootloader configured")
print("Installation complete! You can now reboot.")
logger.info(
"INSTALLER_COMPLETE: Full installation finished successfully"
)
else:
print("Partitioning successful!")
print(f"EFI: {parts['efi']}")
print(f"Swap: {parts['swap']}")
print(f"Root: {parts['root']}")
send_full_log()
return 0
except Exception as e:
error_msg = str(e)
print(f"Installation failed: {e}", file=sys.stderr)
logger.error(f"INSTALLER_ERROR: {error_msg}")
import traceback
traceback.print_exc()
logger.error(f"INSTALLER_TRACEBACK: {traceback.format_exc()}")
send_full_log()
return 1
import gi
gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")
from gi.repository import Adw, Gio
from .ui.window import InstallerWindow
class IridiumInstallerApp(Adw.Application):
def __init__(self, mock_mode=False):
super().__init__(
application_id="org.iridium.Installer",
flags=Gio.ApplicationFlags.FLAGS_NONE,
)
self.mock_mode = mock_mode
def do_activate(self):
win = self.props.active_window
if not win:
win = InstallerWindow(application=self, mock_mode=self.mock_mode)
win.present()
app = IridiumInstallerApp(mock_mode=args.mock)
return app.run(sys.argv)

View File

@@ -43,7 +43,6 @@ CSS = """
def get_total_memory() -> int:
"""Returns total system memory in bytes."""
try:
return os.sysconf("SC_PAGE_SIZE") * os.sysconf("SC_PHYS_PAGES")
except (ValueError, OSError):
@@ -56,12 +55,6 @@ def get_total_memory() -> int:
def calculate_auto_partitions(disk_device):
"""
Generates an automatic partition layout.
- 2GB EFI
- RAM + 2GB Swap
- Rest Root (ext4)
"""
disk_size = 0
try:
# Get disk size in bytes
@@ -87,16 +80,24 @@ def calculate_auto_partitions(disk_device):
return []
ram_size = get_total_memory()
disk_mb = disk_size / (1024 * 1024)
# Sizes in bytes
# Defaults
efi_size = 2 * 1024 * 1024 * 1024
swap_size = ram_size + (2 * 1024 * 1024 * 1024)
min_root_size = 10 * 1024 * 1024 * 1024 # 10GB
# Check if disk is large enough
min_root = 10 * 1024 * 1024 * 1024 # minimum 10GB for root
if disk_size < (efi_size + swap_size + min_root):
print("Disk too small for automatic partitioning scheme.")
return []
total_required = efi_size + swap_size + min_root_size
use_swap = True
if disk_size < total_required:
efi_size = 1 * 1024 * 1024 * 1024
use_swap = False
swap_size = 0
if disk_size < (efi_size + min_root_size):
print("Disk too small for automatic partitioning scheme.")
return []
root_size = disk_size - efi_size - swap_size
@@ -105,20 +106,11 @@ def calculate_auto_partitions(disk_device):
"type": "partition",
"name": "EFI System",
"filesystem": "vfat",
"mount_point": "/boot/efi",
"mount_point": "/boot",
"size": f"{efi_size / (1024**3):.1f} GB",
"bytes": efi_size,
"style_class": "part-efi",
},
{
"type": "partition",
"name": "Swap",
"filesystem": "swap",
"mount_point": "[SWAP]",
"size": f"{swap_size / (1024**3):.1f} GB",
"bytes": swap_size,
"style_class": "part-swap",
},
{
"type": "partition",
"name": "Root",
@@ -130,6 +122,19 @@ def calculate_auto_partitions(disk_device):
},
]
if use_swap:
partitions.append(
{
"type": "partition",
"name": "Swap",
"filesystem": "swap",
"mount_point": "[SWAP]",
"size": f"{swap_size / (1024**3):.1f} GB",
"bytes": swap_size,
"style_class": "part-swap",
}
)
return partitions
@@ -236,6 +241,7 @@ class PartitioningPage(Adw.Bin):
# Initially empty until loaded with a specific disk
def load_partitions(self, disk_device=None):
self.current_disk_path = disk_device
target_disk = None
try:
@@ -290,7 +296,7 @@ class PartitioningPage(Adw.Bin):
p_size = int(p.get("size", 0))
covered_size += p_size
fstype = p.get("fstype", "").lower()
fstype = (p.get("fstype") or "").lower()
style = "part-root"
if "fat" in fstype or "efi" in fstype:
style = "part-efi"
@@ -301,7 +307,7 @@ class PartitioningPage(Adw.Bin):
{
"type": "partition",
"name": p.get("name"),
"filesystem": p.get("fstype", "Unknown"),
"filesystem": p.get("fstype") or "Unknown",
"label": p.get("name"),
"mount_point": p.get("mountpoint", ""),
"size": self.format_size(p_size),
@@ -428,46 +434,184 @@ class PartitioningPage(Adw.Bin):
def show_context_menu(self, widget, x, y):
data = widget.part_data
self.selected_disk_path = self.current_disk_path # Assumes we store this
popover = Gtk.Popover()
popover.set_parent(widget)
menu_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
menu_box.set_spacing(0)
popover.set_child(menu_box)
def add_menu_item(label, icon_name=None, destructive=False):
def add_menu_item(label, icon_name, callback, destructive=False):
btn = Gtk.Button(label=label)
btn.add_css_class("flat")
btn.set_halign(Gtk.Align.FILL)
if destructive:
btn.add_css_class("destructive-action")
if icon_name:
content = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
content.set_spacing(12)
icon = Gtk.Image.new_from_icon_name(icon_name)
lbl = Gtk.Label(label=label)
content.append(icon)
content.append(lbl)
btn.set_child(content)
content = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12)
icon = Gtk.Image.new_from_icon_name(icon_name)
lbl = Gtk.Label(label=label)
content.append(icon)
content.append(lbl)
btn.set_child(content)
btn.connect("clicked", lambda b: [popover.popdown(), callback()])
menu_box.append(btn)
return btn
if data.get("type") == "partition":
add_menu_item("Select Mount Point", "folder-open-symbolic")
add_menu_item("Format", "drive-harddisk-symbolic")
add_menu_item("Resize", "object-resize-symbolic")
add_menu_item(
"Select Mount Point",
"folder-open-symbolic",
lambda: self.select_mount_point(data),
)
separator = Gtk.Separator()
menu_box.append(separator)
btn_del = add_menu_item("Delete", "user-trash-symbolic", destructive=True)
btn_del.add_css_class("error")
add_menu_item(
"Delete",
"user-trash-symbolic",
lambda: self.delete_part(data),
destructive=True,
)
elif data.get("type") == "empty":
add_menu_item("Create Partition", "list-add-symbolic")
add_menu_item(
"Create Partition",
"list-add-symbolic",
lambda: self.create_part_dialog(data),
)
popover.popup()
def select_mount_point(self, data):
win = Adw.Window(
title="Select Mount Point", modal=True, transient_for=self.get_root()
)
box = Gtk.Box(
orientation=Gtk.Orientation.VERTICAL,
spacing=12,
margin_top=24,
margin_bottom=24,
margin_start=24,
margin_end=24,
)
win.set_content(box)
options = ["/", "/boot", "[SWAP]", "None"]
dropdown = Gtk.DropDown.new_from_strings(options)
current_mp = data.get("mount_point")
# Ensure we have a valid string comparison
if not current_mp:
current_mp = "None"
if current_mp in options:
dropdown.set_selected(options.index(current_mp))
else:
dropdown.set_selected(options.index("None"))
box.append(Gtk.Label(label=f"Mount point for {data['name']}:"))
box.append(dropdown)
def on_apply(b):
selected = options[dropdown.get_selected()]
data["mount_point"] = selected if selected != "None" else ""
win.close()
self.refresh_bar()
btn = Gtk.Button(label="Apply")
btn.add_css_class("suggested-action")
btn.connect("clicked", on_apply)
box.append(btn)
win.present()
def delete_part(self, data):
# Extract partition number from name (e.g., nvme0n1p3 -> 3)
import re
from ...backend.disk import delete_partition
match = re.search(r"(\d+)$", data["name"])
if match:
part_num = int(match.group(1))
delete_partition(self.current_disk_path, part_num)
self.load_partitions(self.current_disk_path)
def create_part_dialog(self, data):
win = Adw.Window(
title="Create Partition", modal=True, transient_for=self.get_root()
)
box = Gtk.Box(
orientation=Gtk.Orientation.VERTICAL,
spacing=12,
margin_top=24,
margin_bottom=24,
margin_start=24,
margin_end=24,
)
win.set_content(box)
# Type dropdown
types = {"Root (Linux)": "8300", "EFI System": "ef00", "Swap": "8200"}
type_names = list(types.keys())
type_dropdown = Gtk.DropDown.new_from_strings(type_names)
box.append(Gtk.Label(label="Partition Type:"))
box.append(type_dropdown)
# Size entry
size_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12)
size_entry = Gtk.Entry(text=str(int(data["bytes"] / (1024 * 1024))))
size_entry.set_width_chars(15)
size_box.append(size_entry)
size_box.append(Gtk.Label(label="MB"))
box.append(Gtk.Label(label="Size:"))
box.append(size_box)
error_label = Gtk.Label(label="")
error_label.add_css_class("error")
box.append(error_label)
def on_create(b):
from ...backend.disk import create_partition
selected_type = type_names[type_dropdown.get_selected()]
# Default name and fstype based on type
if selected_type == "EFI System":
name = "EFI System"
fstype = "fat32"
elif selected_type == "Swap":
name = "Swap"
fstype = "swap"
else:
name = "Linux filesystem"
fstype = "ext4"
size_text = size_entry.get_text()
try:
size_mb = int(size_text)
max_mb = int(data["bytes"] / (1024 * 1024))
if size_mb >= max_mb:
size_mb = 0
except ValueError:
error_label.set_text("Invalid size value")
return
type_code = types[selected_type]
try:
create_partition(
self.current_disk_path, size_mb, type_code, name, fstype
)
win.close()
self.load_partitions(self.current_disk_path)
except Exception as e:
error_label.set_text(f"Error: {str(e)}")
btn = Gtk.Button(label="Create")
btn.add_css_class("suggested-action")
btn.connect("clicked", on_create)
box.append(btn)
win.present()
def get_config(self):
return {"partitions": self.partitions}

View File

@@ -89,8 +89,13 @@ class StoragePage(Adw.Bin):
def on_disk_toggled(self, button, device_name):
if button.get_active():
self.selected_disk = device_name
self.emit("disk-selected", device_name)
# Prepend /dev/ if it's just the name
full_path = device_name
if not device_name.startswith("/dev/"):
full_path = f"/dev/{device_name}"
self.selected_disk = full_path
self.emit("disk-selected", full_path)
def get_selected_disk(self):
return self.selected_disk

View File

@@ -1,8 +1,12 @@
import gi
import threading
import logging
import uuid
from datetime import datetime
gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")
from gi.repository import Adw, Gtk
from gi.repository import Adw, Gtk, GLib
from .pages.additional_modules import ModulesPage
from .pages.install_mode import InstallModePage
@@ -11,6 +15,17 @@ from .pages.storage import StoragePage
from .pages.summary import SummaryPage
from .pages.user import UserPage
from .pages.welcome import WelcomePage
from ..backend.network_logging import log_to_discord, flush_logs, send_full_log
class LogHandler(logging.Handler):
def __init__(self, callback):
super().__init__()
self.callback = callback
def emit(self, record):
msg = self.format(record)
GLib.idle_add(self.callback, msg)
class InstallerWindow(Adw.ApplicationWindow):
@@ -18,6 +33,15 @@ class InstallerWindow(Adw.ApplicationWindow):
super().__init__(*args, **kwargs)
self.mock_mode = mock_mode
self.session_id = str(uuid.uuid4())[:8]
# Send session start ping
mode_str = "MOCK" if mock_mode else "PRODUCTION"
log_to_discord(
"SESSION_START",
f"Iridium Installer started - Session: {self.session_id} - Mode: {mode_str}",
"installer",
)
self.set_default_size(900, 650)
self.set_title("Iridium Installer" + (" (MOCK MODE)" if mock_mode else ""))
@@ -91,6 +115,8 @@ class InstallerWindow(Adw.ApplicationWindow):
self.stack.set_visible_child_name(self.page_ids[0])
self.update_buttons()
self.log_handler = None
def add_page(self, widget, name):
self.stack.add_named(widget, name)
self.page_ids.append(name)
@@ -145,18 +171,229 @@ class InstallerWindow(Adw.ApplicationWindow):
self.stack.set_visible_child_name(self.page_ids[self.current_page_index])
self.update_buttons()
def show_progress_page(self, message):
prog_page = Adw.StatusPage()
prog_page.set_title(message)
prog_page.set_description("Please wait while we set up your system.")
spinner = Gtk.Spinner()
spinner.set_size_request(32, 32)
spinner.set_halign(Gtk.Align.CENTER)
spinner.start()
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
box.append(spinner)
# Log view
self.log_buffer = Gtk.TextBuffer()
self.log_view = Gtk.TextView(buffer=self.log_buffer)
self.log_view.set_editable(False)
self.log_view.set_monospace(True)
self.log_view.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
scrolled = Gtk.ScrolledWindow()
scrolled.set_child(self.log_view)
scrolled.set_vexpand(True)
scrolled.set_size_request(-1, 200)
# Style the log view background
# css_provider = Gtk.CssProvider()
# css_provider.load_from_data(b"textview { background-color: #1e1e1e; color: #ffffff; }")
# self.log_view.get_style_context().add_provider(css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
expander = Gtk.Expander(label="Detailed Logs")
expander.set_child(scrolled)
box.append(expander)
prog_page.set_child(box)
name = "progress_install"
self.stack.add_named(prog_page, name)
self.stack.set_visible_child_name(name)
# Hide navigation buttons during install
self.bottom_bar.set_visible(False)
# Attach log handler
self.log_handler = LogHandler(self.append_log)
logging.getLogger().addHandler(self.log_handler)
logging.getLogger().setLevel(logging.INFO)
def append_log(self, msg):
end_iter = self.log_buffer.get_end_iter()
self.log_buffer.insert(end_iter, msg + "\n")
# Auto-scroll
mark = self.log_buffer.create_mark("end", end_iter, False)
self.log_view.scroll_to_mark(mark, 0.0, True, 0.0, 1.0)
def show_finish_page(self, message, success=True):
if self.log_handler:
logging.getLogger().removeHandler(self.log_handler)
self.log_handler = None
# Release wake lock if held
if hasattr(self, "inhibit_cookie") and self.inhibit_cookie:
app = self.get_application()
app.uninhibit(self.inhibit_cookie)
self.inhibit_cookie = None
finish_page = Adw.StatusPage()
finish_page.set_title(message)
btn = Gtk.Button()
btn.set_halign(Gtk.Align.CENTER)
if success:
finish_page.set_icon_name("emblem-ok-symbolic")
finish_page.set_description("You can now restart your computer.")
btn.set_label("Restart System")
btn.add_css_class("suggested-action")
btn.add_css_class("pill")
def on_restart(b):
import subprocess
try:
# Use sudo since we might be running as liveuser
subprocess.run(["sudo", "systemctl", "reboot"])
except Exception as e:
print(f"Failed to reboot: {e}")
self.close()
btn.connect("clicked", on_restart)
else:
finish_page.set_icon_name("dialog-error-symbolic")
finish_page.set_description("An error occurred during installation.")
btn.set_label("Close Installer")
btn.connect("clicked", lambda b: self.close())
finish_page.set_child(btn)
name = "finish_install"
self.stack.add_named(finish_page, name)
self.stack.set_visible_child_name(name)
def run_installation(self, disk, mode, modules, user_info):
try:
from ..backend.disk import auto_partition_disk, mount_partitions
from ..backend.os_install import install_minimal_os, configure_system
from ..backend.network_logging import log_to_discord as nlog
# Step 1: Partitioning
logging.info("Step 1: Partitioning...")
nlog(
"INSTALL_PROGRESS",
f"Session: {self.session_id} - Starting partitioning on {disk}",
"installer",
)
parts = auto_partition_disk(disk)
nlog(
"INSTALL_PROGRESS",
f"Session: {self.session_id} - Partitioning complete",
"installer",
)
# Step 2: Mounting
logging.info("Step 2: Mounting...")
nlog(
"INSTALL_PROGRESS",
f"Session: {self.session_id} - Mounting partitions",
"installer",
)
mount_root = "/mnt"
mount_partitions(parts, mount_root)
nlog(
"INSTALL_PROGRESS",
f"Session: {self.session_id} - Mounting complete",
"installer",
)
# Step 3: OS Installation
logging.info("Step 3: OS Installation...")
nlog(
"INSTALL_PROGRESS",
f"Session: {self.session_id} - Installing OS (this may take a while)",
"installer",
)
install_minimal_os(mount_root)
nlog(
"INSTALL_PROGRESS",
f"Session: {self.session_id} - OS installation complete",
"installer",
)
# Step 4: Configure
logging.info("Step 4: Configuration...")
nlog(
"INSTALL_PROGRESS",
f"Session: {self.session_id} - Configuring bootloader and user",
"installer",
)
configure_system(mount_root, parts, user_info)
nlog(
"INSTALL_PROGRESS",
f"Session: {self.session_id} - Configuration complete",
"installer",
)
# Install complete
nlog(
"INSTALL_COMPLETE",
f"Session: {self.session_id} - Installation completed successfully!",
"installer",
)
flush_logs()
send_full_log()
GLib.idle_add(self.show_finish_page, "Installation Successful!", True)
except Exception as e:
error_msg = str(e)
logging.error(f"Installation failed: {e}")
nlog(
"INSTALL_ERROR",
f"Session: {self.session_id} - Installation failed: {error_msg}",
"installer",
)
import traceback
traceback.print_exc()
nlog(
"INSTALL_ERROR",
f"Session: {self.session_id} - Traceback: {traceback.format_exc()}",
"installer",
)
flush_logs()
send_full_log()
GLib.idle_add(self.show_finish_page, f"Installation Failed: {e}", False)
def on_next_clicked(self, button):
# Logic before transition
# Log navigation
current_page_name = self.page_ids[self.current_page_index]
mode_str = "MOCK" if self.mock_mode else "PRODUCTION"
log_to_discord(
"NAVIGATION_NEXT",
f"Session: {self.session_id} - Page: {current_page_name} - Mode: {mode_str}",
"installer",
)
# Logic before transition
if current_page_name == "storage":
selected_disk = self.storage_page.get_selected_disk()
log_to_discord(
"SELECTION",
f"Session: {self.session_id} - Selected disk: {selected_disk}",
"installer",
)
self.partitioning_page.load_partitions(selected_disk)
next_index = self.current_page_index + 1
if current_page_name == "install_mode":
mode = self.install_mode_page.get_mode()
log_to_discord(
"SELECTION",
f"Session: {self.session_id} - Install mode: {mode}",
"installer",
)
if mode == "automatic":
# Skip partitioning page
next_index = self.page_ids.index("modules")
@@ -164,6 +401,14 @@ class InstallerWindow(Adw.ApplicationWindow):
# Go to partitioning page
next_index = self.page_ids.index("partitioning")
if current_page_name == "modules":
modules = self.modules_page.get_modules()
log_to_discord(
"SELECTION",
f"Session: {self.session_id} - Selected modules: {modules}",
"installer",
)
if current_page_name == "user":
# Prepare summary instead of installing immediately
disk = self.storage_page.get_selected_disk()
@@ -171,6 +416,13 @@ class InstallerWindow(Adw.ApplicationWindow):
modules = self.modules_page.get_modules()
user_info = self.user_page.get_user_info()
# Log user info (without password for security)
log_to_discord(
"SELECTION",
f"Session: {self.session_id} - User: {user_info.get('username', 'N/A')}, Hostname: {user_info.get('hostname', 'N/A')}, Sudo: {user_info.get('allow_sudo', False)}",
"installer",
)
partitions_config = {}
if mode == "manual":
partitions_config = self.partitioning_page.get_config()
@@ -196,12 +448,12 @@ class InstallerWindow(Adw.ApplicationWindow):
modules = self.modules_page.get_modules()
user_info = self.user_page.get_user_info()
partitions_config = {}
if mode == "manual":
partitions_config = self.partitioning_page.get_config()
elif mode == "automatic":
partitions = calculate_auto_partitions(disk)
partitions_config = {"partitions": partitions}
# Log the install trigger with full config
log_to_discord(
"INSTALL_START",
f"Session: {self.session_id} - Disk: {disk} - Mode: {mode} - Modules: {modules} - Mock: {self.mock_mode}",
"installer",
)
if self.mock_mode:
print("!!! MOCK MODE ENABLED - NO CHANGES WILL BE MADE !!!")
@@ -209,10 +461,31 @@ class InstallerWindow(Adw.ApplicationWindow):
print(f"Mode: {mode}")
print(f"Modules: {modules}")
print(f"User: {user_info}")
print(f"Partition Config: {partitions_config}")
print("Simulation complete.")
log_to_discord(
"INSTALL_COMPLETE",
f"Session: {self.session_id} - Mock installation complete",
"installer",
)
flush_logs()
# Show success in UI even in mock
self.show_finish_page("Mock Installation Complete!")
else:
print("NOT IMPLEMENTED")
# Inhibit logout/suspend/idle
app = self.get_application()
self.inhibit_cookie = app.inhibit(
self,
Gtk.ApplicationInhibitFlags.LOGOUT | Gtk.ApplicationInhibitFlags.SUSPEND | Gtk.ApplicationInhibitFlags.IDLE,
"Installing Operating System"
)
self.show_progress_page("Installing Iridium OS...")
thread = threading.Thread(
target=self.run_installation,
args=(disk, mode, modules, user_info),
daemon=True,
)
thread.start()
return

21
run.sh
View File

@@ -27,6 +27,27 @@ if command -v gtk-update-icon-cache &> /dev/null; then
gtk-update-icon-cache -f -t "$HOME/.local/share/icons/hicolor" 2>/dev/null || true
fi
# Check and install dependencies (Fedora/DNF)
if command -v dnf &> /dev/null; then
DEPENDENCIES="python3-gobject gtk4 libadwaita python3-requests gdisk dosfstools e2fsprogs"
MISSING_DEPS=""
for dep in $DEPENDENCIES; do
if ! rpm -q $dep &> /dev/null; then
MISSING_DEPS="$MISSING_DEPS $dep"
fi
done
if [ -n "$MISSING_DEPS" ]; then
echo "Missing dependencies found:$MISSING_DEPS"
echo "Installing..."
sudo dnf install -y $MISSING_DEPS
fi
else
echo "Warning: 'dnf' not found. Automatic dependency installation skipped."
echo "Please ensure you have: python3-gobject gtk4 libadwaita python3-requests gdisk dosfstools e2fsprogs"
fi
export GSETTINGS_SCHEMA_DIR=.
python3 -m iridium_installer.main "$@"

44
run_vm_uefi.sh Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/bash
# Configuration
ISO_PATH="${1:-/home/n0va/Downloads/Fedora-Workstation-Live-43-1.6.x86_64.iso}"
DISK_PATH="${2:-/home/n0va/.local/share/iridium-installer-vm/test-disk.qcow2}"
OVMF_CODE="/usr/share/edk2/x64/OVMF_CODE.4m.fd"
OVMF_VARS_TEMPLATE="/usr/share/edk2/x64/OVMF_VARS.4m.fd"
OVMF_VARS_LOCAL="/tmp/iridium_vm_vars.qcow2"
# Ensure OVMF vars exist in qcow2 format for snapshot support
if [ ! -f "$OVMF_VARS_LOCAL" ]; then
if [ -f "$OVMF_VARS_TEMPLATE" ]; then
echo "Creating UEFI vars file from template..."
qemu-img convert -f raw -O qcow2 "$OVMF_VARS_TEMPLATE" "$OVMF_VARS_LOCAL"
else
echo "Warning: OVMF VARS template not found at $OVMF_VARS_TEMPLATE"
# Fallback to creating an empty qcow2 if template is missing (not ideal but avoids crash)
qemu-img create -f qcow2 "$OVMF_VARS_LOCAL" 528K
fi
fi
echo "Starting Iridium VM with UEFI support..."
echo "ISO: $ISO_PATH"
echo "Disk: $DISK_PATH"
# QEMU Command with UEFI (OVMF) enabled
# We use format=qcow2 for pflash1 to allow snapshots (savevm)
qemu-system-x86_64 \
-enable-kvm \
-m 8G \
-smp 2 \
-cpu host \
-drive if=pflash,format=raw,readonly=on,file="$OVMF_CODE" \
-drive if=pflash,format=qcow2,file="$OVMF_VARS_LOCAL" \
-drive file="$DISK_PATH",format=qcow2,if=virtio \
-cdrom "$ISO_PATH" \
-boot once=d \
-netdev user,id=net0 \
-device virtio-net-pci,netdev=net0 \
-vga virtio \
-display gtk,gl=on \
-monitor unix:$HOME/.local/share/iridium-installer-vm/monitor.sock,server,nowait \
-name "Iridium Installer Test VM (UEFI)" \
-loadvm clean-state

19
take_snapshot.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
SOCKET="$HOME/.local/share/iridium-installer-vm/monitor.sock"
SNAPSHOT_NAME="${1:-clean-state}"
if [ ! -S "$SOCKET" ]; then
echo "Error: QEMU monitor socket not found at $SOCKET"
echo "Is the VM running?"
exit 1
fi
echo "Taking snapshot: $SNAPSHOT_NAME"
echo "savevm $SNAPSHOT_NAME" | nc -U "$SOCKET"
if [ $? -eq 0 ]; then
echo "Snapshot command sent successfully."
else
echo "Failed to send snapshot command. Ensure 'nc' (netcat) with -U support is installed."
fi