From c92e0bb1f988ee849e38bd8bf251be81581f2f3b Mon Sep 17 00:00:00 2001 From: N0VA Date: Tue, 10 Feb 2026 13:58:45 +0100 Subject: [PATCH] revert 8f7eb17d3c2c9d614f6cd20ccf526b41c728f048 revert Enhance offline installation logic: better repo detection and --offline flag --- iridium_installer/backend/os_install.py | 49 ++++++++++++++----------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/iridium_installer/backend/os_install.py b/iridium_installer/backend/os_install.py index 00418c2..12140c5 100644 --- a/iridium_installer/backend/os_install.py +++ b/iridium_installer/backend/os_install.py @@ -152,48 +152,50 @@ def install_minimal_os(mount_root, releasever="43"): else: packages += ["grub2-pc", "grub2-tools", "grubby"] - # Offline installation logic: Search for repodata or Packages + # Offline installation logic 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 ] - # 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 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 - logger.info(f"Detected potential offline repository at: {iso_repo}") 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: - logger.info(f"Using strictly offline mode with repo: {iso_repo}") - dnf_args += [ + 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", "--cacheonly", - "--setopt=localpkg_gpgcheck=False", - "--setopt=gpgcheck=False", ] else: - 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") + logger.warning("ISO repository not found. DNF might try to use network.") + dnf_args = [] cmd = [ "dnf", @@ -205,6 +207,9 @@ 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):