From 8f7eb17d3c2c9d614f6cd20ccf526b41c728f048 Mon Sep 17 00:00:00 2001 From: N0VA Date: Tue, 10 Feb 2026 13:56:33 +0100 Subject: [PATCH] Enhance offline installation logic: better repo detection and --offline flag --- iridium_installer/backend/os_install.py | 53 +++++++++++-------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/iridium_installer/backend/os_install.py b/iridium_installer/backend/os_install.py index 12140c5..00418c2 100644 --- a/iridium_installer/backend/os_install.py +++ b/iridium_installer/backend/os_install.py @@ -152,50 +152,48 @@ def install_minimal_os(mount_root, releasever="43"): else: packages += ["grub2-pc", "grub2-tools", "grubby"] - # Offline installation logic + # Offline installation logic: Search for repodata or Packages possible_repos = [ "/run/install/repo", "/run/install/source", "/mnt/install/repo", "/run/initramfs/live", "/run/initramfs/isoscan", + "/run/media/liveuser/Fedora-WS-Live-43", # Example Fedora ISO mount ] - iso_repo = None - for path in possible_repos: - if os.path.exists(os.path.join(path, "repodata")): - iso_repo = path - 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"): + # Also check all mounts in /run/media + if 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 + 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 - dnf_args = [] + iso_repo = None + 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"))): + iso_repo = path + logger.info(f"Detected potential offline repository at: {iso_repo}") + break + + dnf_args = ["--offline"] # DNF4/DNF5 support this to prevent network use if iso_repo: - logger.info(f"Found ISO repository at {iso_repo}. Using strictly offline mode.") - dnf_args = [ + logger.info(f"Using strictly offline mode with repo: {iso_repo}") + dnf_args += [ "--disablerepo=*", f"--repofrompath=iridium-iso,{iso_repo}", "--enablerepo=iridium-iso", "--cacheonly", + "--setopt=localpkg_gpgcheck=False", + "--setopt=gpgcheck=False", ] else: - logger.warning("ISO repository not found. DNF might try to use network.") - dnf_args = [] + logger.error("NO OFFLINE REPOSITORY FOUND! Installation will likely fail if network is unavailable.") + # If we are in "testing" and really want to force offline, we should maybe exit here + # but for now we'll let it try with host config if not found. + dnf_args.append("--use-host-config") cmd = [ "dnf", @@ -207,9 +205,6 @@ def install_minimal_os(mount_root, releasever="43"): "--nodocs", ] - if not iso_repo: - cmd.append("--use-host-config") - cmd += dnf_args + packages with mount_pseudo_fs(mount_root):