Fix bootctl unrecognized option and improve repo discovery

This commit is contained in:
2026-02-05 16:46:59 +01:00
parent f3e7122d02
commit 400235067d

View File

@@ -150,6 +150,20 @@ def install_minimal_os(mount_root, releasever="43"):
elif os.path.exists(os.path.join(path, "Packages")): elif os.path.exists(os.path.join(path, "Packages")):
iso_repo = path iso_repo = path
break break
# Try searching in /run/media if not found
if not iso_repo and os.path.exists("/run/media"):
try:
for user in os.listdir("/run/media"):
user_path = os.path.join("/run/media", user)
if os.path.isdir(user_path):
for label in os.listdir(user_path):
label_path = os.path.join(user_path, label)
if os.path.exists(os.path.join(label_path, "repodata")):
iso_repo = label_path
break
if iso_repo: break
except Exception: pass
dnf_args = [] dnf_args = []
if iso_repo: if iso_repo:
@@ -162,7 +176,6 @@ def install_minimal_os(mount_root, releasever="43"):
] ]
else: else:
logger.warning("ISO repository not found in common locations. DNF might try to use network.") logger.warning("ISO repository not found in common locations. DNF might try to use network.")
# Note: Avoid --offline in dnf5 as it defers the transaction to next boot.
dnf_args = [] dnf_args = []
cmd = [ cmd = [
@@ -175,7 +188,6 @@ def install_minimal_os(mount_root, releasever="43"):
"--nodocs", "--nodocs",
] ]
# Only use host config if we didn't find an ISO repo
if not iso_repo: if not iso_repo:
cmd.append("--use-host-config") cmd.append("--use-host-config")
@@ -217,10 +229,10 @@ UUID={efi_uuid} /boot vfat defaults 0 2
with open(os.path.join(mount_root, "etc/fstab"), "w") as f: with open(os.path.join(mount_root, "etc/fstab"), "w") as f:
f.write(fstab_content) f.write(fstab_content)
# 2. Configure User with mount_pseudo_fs(mount_root):
if user_info: # 2. Configure User
logger.info(f"Creating user {user_info['username']}...") if user_info:
with mount_pseudo_fs(mount_root): logger.info(f"Creating user {user_info['username']}...")
# Create user and add to wheel group (sudoer) # Create user and add to wheel group (sudoer)
run_command(["chroot", mount_root, "useradd", "-m", "-G", "wheel", user_info["username"]]) run_command(["chroot", mount_root, "useradd", "-m", "-G", "wheel", user_info["username"]])
@@ -239,8 +251,7 @@ UUID={efi_uuid} /boot vfat defaults 0 2
with open(os.path.join(mount_root, "etc/hostname"), "w") as f: with open(os.path.join(mount_root, "etc/hostname"), "w") as f:
f.write(user_info["hostname"] + "\n") f.write(user_info["hostname"] + "\n")
# 3. Configure systemd-boot # 3. Configure systemd-boot
with mount_pseudo_fs(mount_root):
# Ensure machine-id exists for kernel-install # Ensure machine-id exists for kernel-install
if not os.path.exists(os.path.join(mount_root, "etc/machine-id")): if not os.path.exists(os.path.join(mount_root, "etc/machine-id")):
run_command(["chroot", mount_root, "systemd-machine-id-setup"]) run_command(["chroot", mount_root, "systemd-machine-id-setup"])
@@ -255,7 +266,8 @@ UUID={efi_uuid} /boot vfat defaults 0 2
f.write("bls\n") f.write("bls\n")
# Install systemd-boot to the ESP (mounted at /boot) # Install systemd-boot to the ESP (mounted at /boot)
run_command(["chroot", mount_root, "bootctl", "install", "--path=/boot", "--force"]) # Note: removed --force as it's not supported by all bootctl versions
run_command(["chroot", mount_root, "bootctl", "install", "--path=/boot"])
# Add kernel entries # Add kernel entries
modules_dir = os.path.join(mount_root, "lib/modules") modules_dir = os.path.join(mount_root, "lib/modules")