revert Enhance offline installation logic: better repo detection and --offline flag
This commit is contained in:
2026-02-10 13:58:45 +01:00
parent 8f7eb17d3c
commit c92e0bb1f9

View File

@@ -152,48 +152,50 @@ def install_minimal_os(mount_root, releasever="43"):
else: else:
packages += ["grub2-pc", "grub2-tools", "grubby"] packages += ["grub2-pc", "grub2-tools", "grubby"]
# Offline installation logic: Search for repodata or Packages # Offline installation logic
possible_repos = [ possible_repos = [
"/run/install/repo", "/run/install/repo",
"/run/install/source", "/run/install/source",
"/mnt/install/repo", "/mnt/install/repo",
"/run/initramfs/live", "/run/initramfs/live",
"/run/initramfs/isoscan", "/run/initramfs/isoscan",
"/run/media/liveuser/Fedora-WS-Live-43", # Example Fedora ISO mount
] ]
# Also check all mounts in /run/media
if os.path.exists("/run/media"):
try:
for root, dirs, files in os.walk("/run/media", topdown=True):
if "repodata" in dirs or "Packages" in dirs:
possible_repos.append(root)
if len(possible_repos) > 20: break # Safety limit
except Exception: pass
iso_repo = None iso_repo = None
for path in possible_repos: for path in possible_repos:
if os.path.isdir(path) and (os.path.exists(os.path.join(path, "repodata")) or os.path.exists(os.path.join(path, "Packages"))): if os.path.exists(os.path.join(path, "repodata")):
iso_repo = path iso_repo = path
logger.info(f"Detected potential offline repository at: {iso_repo}")
break break
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 = ["--offline"] # DNF4/DNF5 support this to prevent network use dnf_args = []
if iso_repo: if iso_repo:
logger.info(f"Using strictly offline mode with repo: {iso_repo}") logger.info(f"Found ISO repository at {iso_repo}. Using strictly offline mode.")
dnf_args += [ dnf_args = [
"--disablerepo=*", "--disablerepo=*",
f"--repofrompath=iridium-iso,{iso_repo}", f"--repofrompath=iridium-iso,{iso_repo}",
"--enablerepo=iridium-iso", "--enablerepo=iridium-iso",
"--cacheonly", "--cacheonly",
"--setopt=localpkg_gpgcheck=False",
"--setopt=gpgcheck=False",
] ]
else: else:
logger.error("NO OFFLINE REPOSITORY FOUND! Installation will likely fail if network is unavailable.") logger.warning("ISO repository not found. DNF might try to use network.")
# If we are in "testing" and really want to force offline, we should maybe exit here dnf_args = []
# but for now we'll let it try with host config if not found.
dnf_args.append("--use-host-config")
cmd = [ cmd = [
"dnf", "dnf",
@@ -205,6 +207,9 @@ def install_minimal_os(mount_root, releasever="43"):
"--nodocs", "--nodocs",
] ]
if not iso_repo:
cmd.append("--use-host-config")
cmd += dnf_args + packages cmd += dnf_args + packages
with mount_pseudo_fs(mount_root): with mount_pseudo_fs(mount_root):