Improve offline installation by searching for repo in multiple paths
This commit is contained in:
@@ -132,18 +132,35 @@ def install_minimal_os(mount_root, releasever="43"):
|
|||||||
]
|
]
|
||||||
|
|
||||||
# Offline installation logic
|
# Offline installation logic
|
||||||
iso_repo = "/run/install/repo"
|
possible_repos = [
|
||||||
dnf_args = []
|
"/run/install/repo",
|
||||||
|
"/run/install/source",
|
||||||
|
"/mnt/install/repo",
|
||||||
|
"/run/initramfs/live",
|
||||||
|
]
|
||||||
|
|
||||||
if os.path.exists(iso_repo):
|
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
|
||||||
|
|
||||||
|
dnf_args = []
|
||||||
|
if iso_repo:
|
||||||
logger.info(f"Found ISO repository at {iso_repo}. Using strictly offline mode.")
|
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",
|
||||||
|
"--offline",
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
logger.warning(f"ISO repository not found at {iso_repo}. Trying to use host config (may require network).")
|
logger.warning("ISO repository not found in common locations. DNF might try to use network.")
|
||||||
|
# Try to at least prevent some network usage
|
||||||
|
dnf_args = ["--setopt=localpkg_only=1", "--offline"]
|
||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
"dnf",
|
"dnf",
|
||||||
@@ -151,10 +168,15 @@ def install_minimal_os(mount_root, releasever="43"):
|
|||||||
"-y",
|
"-y",
|
||||||
f"--installroot={mount_root}",
|
f"--installroot={mount_root}",
|
||||||
f"--releasever={releasever}",
|
f"--releasever={releasever}",
|
||||||
"--use-host-config",
|
|
||||||
"--setopt=install_weak_deps=False",
|
"--setopt=install_weak_deps=False",
|
||||||
"--nodocs",
|
"--nodocs",
|
||||||
] + dnf_args + packages
|
]
|
||||||
|
|
||||||
|
# Only use host config if we didn't find an ISO repo
|
||||||
|
if not iso_repo:
|
||||||
|
cmd.append("--use-host-config")
|
||||||
|
|
||||||
|
cmd += dnf_args + packages
|
||||||
|
|
||||||
with mount_pseudo_fs(mount_root):
|
with mount_pseudo_fs(mount_root):
|
||||||
run_command(cmd)
|
run_command(cmd)
|
||||||
|
|||||||
Reference in New Issue
Block a user