Switch to rsync-based offline installation from live system
This commit is contained in:
@@ -126,96 +126,46 @@ def is_uefi():
|
|||||||
|
|
||||||
def install_minimal_os(mount_root, releasever="43"):
|
def install_minimal_os(mount_root, releasever="43"):
|
||||||
"""
|
"""
|
||||||
Installs minimal Fedora packages to mount_root.
|
Installs the OS by rsyncing from the live environment (fully offline).
|
||||||
"""
|
"""
|
||||||
logger.info(f"Installing minimal Fedora {releasever} to {mount_root}...")
|
logger.info(f"Installing Iridium OS to {mount_root} via rsync...")
|
||||||
log_os_install("INSTALL", "start", f"Target: {mount_root}, Release: {releasever}")
|
log_os_install("INSTALL", "start", f"Target: {mount_root}")
|
||||||
|
|
||||||
uefi = is_uefi()
|
# Exclude list for rsync to avoid copying pseudo-filesystems and temporary data
|
||||||
|
excludes = [
|
||||||
packages = [
|
"/dev/*",
|
||||||
"basesystem",
|
"/proc/*",
|
||||||
"bash",
|
"/sys/*",
|
||||||
"coreutils",
|
"/tmp/*",
|
||||||
"kernel",
|
"/run/*",
|
||||||
"systemd",
|
"/mnt/*",
|
||||||
"dnf",
|
"/media/*",
|
||||||
"shadow-utils",
|
"/lost+found",
|
||||||
"util-linux",
|
"/home/*/.gvfs",
|
||||||
"passwd",
|
"/home/*/.cache",
|
||||||
"rootfiles",
|
"/home/*/.local/share/Trash",
|
||||||
"vim-minimal",
|
"/var/lib/dnf/*",
|
||||||
|
"/var/cache/dnf/*",
|
||||||
|
"/etc/fstab",
|
||||||
|
"/etc/hostname",
|
||||||
|
# Avoid copying the installer data itself if it's in home
|
||||||
|
"domek_na_skale",
|
||||||
]
|
]
|
||||||
|
|
||||||
if uefi:
|
exclude_args = [f"--exclude={ex}" for ex in excludes]
|
||||||
packages += ["systemd-boot-unsigned", "efibootmgr"]
|
|
||||||
else:
|
|
||||||
packages += ["grub2-pc", "grub2-tools", "grubby"]
|
|
||||||
|
|
||||||
# Offline installation logic
|
# We use -a (archive), -H (hard links), -A (acls), -X (xattrs), -v (verbose), -x (one file system)
|
||||||
possible_repos = [
|
# --info=progress2 gives a nice summary for logging
|
||||||
"/run/install/repo",
|
cmd = ["rsync", "-aHAXvx", "--info=progress2"] + exclude_args + ["/", mount_root]
|
||||||
"/run/install/source",
|
|
||||||
"/mnt/install/repo",
|
|
||||||
"/run/initramfs/live",
|
|
||||||
"/run/initramfs/isoscan",
|
|
||||||
]
|
|
||||||
|
|
||||||
iso_repo = None
|
logger.info("Starting rsync operation...")
|
||||||
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"):
|
|
||||||
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:
|
|
||||||
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",
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
logger.warning("ISO repository not found. DNF might try to use network.")
|
|
||||||
dnf_args = []
|
|
||||||
|
|
||||||
cmd = [
|
|
||||||
"dnf",
|
|
||||||
"install",
|
|
||||||
"-y",
|
|
||||||
f"--installroot={mount_root}",
|
|
||||||
f"--releasever={releasever}",
|
|
||||||
"--setopt=install_weak_deps=False",
|
|
||||||
"--nodocs",
|
|
||||||
]
|
|
||||||
|
|
||||||
if not iso_repo:
|
|
||||||
cmd.append("--use-host-config")
|
|
||||||
|
|
||||||
cmd += dnf_args + packages
|
|
||||||
|
|
||||||
with mount_pseudo_fs(mount_root):
|
|
||||||
run_command(cmd)
|
run_command(cmd)
|
||||||
|
|
||||||
logger.info("Base system installation complete.")
|
# Ensure essential directories exist
|
||||||
|
for d in ["dev", "proc", "sys", "run", "mnt", "tmp"]:
|
||||||
|
os.makedirs(os.path.join(mount_root, d), exist_ok=True)
|
||||||
|
|
||||||
|
logger.info("Base system rsync complete.")
|
||||||
log_os_install("INSTALL", "complete", f"Installed to {mount_root}")
|
log_os_install("INSTALL", "complete", f"Installed to {mount_root}")
|
||||||
|
|
||||||
|
|
||||||
@@ -263,6 +213,15 @@ def configure_system(mount_root, partition_info, user_info=None, disk_device=Non
|
|||||||
# 2. Configure User
|
# 2. Configure User
|
||||||
if user_info:
|
if user_info:
|
||||||
logger.info(f"Creating user {user_info['username']}...")
|
logger.info(f"Creating user {user_info['username']}...")
|
||||||
|
|
||||||
|
# Since we rsync from live, we might have a 'liveuser' or similar.
|
||||||
|
# We should probably clear /home and /etc/passwd entries that are non-system
|
||||||
|
# but for now, let's just make sure we can create the new one.
|
||||||
|
try:
|
||||||
|
# Remove liveuser if it exists (common in Fedora live)
|
||||||
|
run_command(["chroot", mount_root, "userdel", "-r", "liveuser"], check=False)
|
||||||
|
except: pass
|
||||||
|
|
||||||
run_command(["chroot", mount_root, "useradd", "-m", "-G", "wheel", user_info["username"]])
|
run_command(["chroot", mount_root, "useradd", "-m", "-G", "wheel", user_info["username"]])
|
||||||
|
|
||||||
# Set hostname
|
# Set hostname
|
||||||
|
|||||||
Reference in New Issue
Block a user