Stages should be as stateless as possible. Don't provide an easy way out of that. Only the dnf stage used stage to save the dnf cache. That's only useful during development and can be solved by pointing to a local repo mirror.
117 lines
2.6 KiB
Python
Executable file
117 lines
2.6 KiB
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
config = """
|
|
[Anaconda]
|
|
addons_enabled = True
|
|
debug = False
|
|
kickstart_modules =
|
|
org.fedoraproject.Anaconda.Modules.Timezone
|
|
org.fedoraproject.Anaconda.Modules.Network
|
|
org.fedoraproject.Anaconda.Modules.Localization
|
|
org.fedoraproject.Anaconda.Modules.Security
|
|
org.fedoraproject.Anaconda.Modules.Users
|
|
org.fedoraproject.Anaconda.Modules.Payload
|
|
org.fedoraproject.Anaconda.Modules.Storage
|
|
org.fedoraproject.Anaconda.Modules.Services
|
|
|
|
[Installation System]
|
|
type = UNKNOWN
|
|
can_detect_unsupported_hardware = False
|
|
can_detect_support_removed = False
|
|
|
|
[Installation Target]
|
|
type = HARDWARE
|
|
physical_root = /mnt/sysimage
|
|
|
|
[Network]
|
|
default_on_boot = NONE
|
|
|
|
[Payload]
|
|
default_environment =
|
|
ignored_packages =
|
|
enable_updates = True
|
|
enable_closest_mirror = True
|
|
check_supported_locales = False
|
|
|
|
[Security]
|
|
selinux = -1
|
|
|
|
[Bootloader]
|
|
efi_dir = default
|
|
menu_auto_hide = False
|
|
nonibft_iscsi_boot = False
|
|
|
|
[Storage]
|
|
dmraid = True
|
|
ibft = True
|
|
gpt = False
|
|
multipath_friendly_names = True
|
|
allow_imperfect_devices = False
|
|
file_system_type =
|
|
default_partitioning = WORKSTATION
|
|
luks_version = luks2
|
|
|
|
[User Interface]
|
|
custom_stylesheet =
|
|
default_help_pages =
|
|
blivet_gui_supported = True
|
|
|
|
[License]
|
|
eula =
|
|
"""
|
|
|
|
product = """
|
|
[Product]
|
|
product_name = Fedora
|
|
"""
|
|
|
|
def main(tree, kickstart, skip_package_install=False):
|
|
with open("/tmp/kickstart.ks", "w") as f:
|
|
if skip_package_install:
|
|
subprocess.run(["tar", "cvf", "/tmp/empty.tar", "--files-from", "/dev/null"])
|
|
f.write(f"liveimg --url=file:///tmp/empty.tar\n")
|
|
f.write(kickstart)
|
|
|
|
|
|
# Anaconda cannot start without the config existing
|
|
os.makedirs("/etc/anaconda/conf.d", exist_ok=True)
|
|
os.makedirs("/etc/anaconda/product.d", exist_ok=True)
|
|
|
|
with open("/etc/anaconda/anaconda.conf", "w") as f:
|
|
f.write(config)
|
|
|
|
with open("/etc/anaconda/product.d/fedora.conf", "w") as f:
|
|
f.write(product)
|
|
|
|
cmd = [
|
|
"anaconda",
|
|
"--cmdline",
|
|
"--loglevel", "debug",
|
|
"--kickstart", "/tmp/kickstart.ks",
|
|
"--dirinstall", tree
|
|
]
|
|
print(" ".join(cmd), flush=True)
|
|
returncode = subprocess.run(cmd).returncode
|
|
|
|
if returncode != 0:
|
|
try:
|
|
with open("/tmp/anaconda.log") as f:
|
|
print("\n=== anaconda.log" + "=" * 50)
|
|
print(f.read())
|
|
except FileNotFoundError:
|
|
pass
|
|
|
|
if skip_package_install:
|
|
os.unlink("/tmp/empty.tar")
|
|
os.unlink("/tmp/kickstart.ks")
|
|
|
|
return returncode
|
|
|
|
if __name__ == '__main__':
|
|
options = json.load(sys.stdin)
|
|
sys.exit(main(**options))
|