Fix bootctl unrecognized option and improve repo discovery
This commit is contained in:
@@ -150,6 +150,20 @@ def install_minimal_os(mount_root, releasever="43"):
|
||||
elif os.path.exists(os.path.join(path, "Packages")):
|
||||
iso_repo = path
|
||||
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 = []
|
||||
if iso_repo:
|
||||
@@ -162,7 +176,6 @@ def install_minimal_os(mount_root, releasever="43"):
|
||||
]
|
||||
else:
|
||||
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 = []
|
||||
|
||||
cmd = [
|
||||
@@ -175,7 +188,6 @@ def install_minimal_os(mount_root, releasever="43"):
|
||||
"--nodocs",
|
||||
]
|
||||
|
||||
# Only use host config if we didn't find an ISO repo
|
||||
if not iso_repo:
|
||||
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:
|
||||
f.write(fstab_content)
|
||||
|
||||
# 2. Configure User
|
||||
if user_info:
|
||||
logger.info(f"Creating user {user_info['username']}...")
|
||||
with mount_pseudo_fs(mount_root):
|
||||
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"]])
|
||||
|
||||
@@ -239,8 +251,7 @@ UUID={efi_uuid} /boot vfat defaults 0 2
|
||||
with open(os.path.join(mount_root, "etc/hostname"), "w") as f:
|
||||
f.write(user_info["hostname"] + "\n")
|
||||
|
||||
# 3. Configure systemd-boot
|
||||
with mount_pseudo_fs(mount_root):
|
||||
# 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"])
|
||||
@@ -255,7 +266,8 @@ UUID={efi_uuid} /boot vfat defaults 0 2
|
||||
f.write("bls\n")
|
||||
|
||||
# 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
|
||||
modules_dir = os.path.join(mount_root, "lib/modules")
|
||||
|
||||
Reference in New Issue
Block a user