bootstrap rootfs on any architecture

This commit is contained in:
alexander stefanov 2024-11-14 00:34:01 +03:00
parent d6c3da6a4f
commit b33981b433
3 changed files with 14 additions and 14 deletions

View file

@ -69,9 +69,7 @@ def main():
sys.exit(1) sys.exit(1)
config = load_config(config_path) config = load_config(config_path)
if config["ARCH"] != "aarch64": arch = config["ARCH"]
print("Unsupported architecture.")
sys.exit(1)
print(f"Building for {vendor}/{device} with distro {distro}...") print(f"Building for {vendor}/{device} with distro {distro}...")
@ -86,17 +84,17 @@ def main():
print("Skipping U-Boot build.") print("Skipping U-Boot build.")
if not skip_rootfs: if not skip_rootfs:
setup_bootstrap("bootstrap", TMP_DIR, vendor, device, distro) disk_image_path = create_disk_image(TMP_DIR, config, vendor, device)
if disk_image_path:
loop_device = setup_loop_device(disk_image_path)
print(f"Loop device setup at {loop_device}")
create_partitions(loop_device, config)
mount_partitions(config, loop_device, TMP_DIR, vendor, device)
setup_bootstrap("bootstrap", TMP_DIR, vendor, device, distro, arch)
else: else:
print("Skipping rootfs bootstrap") print("Skipping rootfs bootstrap")
disk_image_path = create_disk_image(TMP_DIR, config, vendor, device)
if disk_image_path:
loop_device = setup_loop_device(disk_image_path)
print(f"Loop device setup at {loop_device}")
create_partitions(loop_device, config)
mount_partitions(config, loop_device, TMP_DIR, vendor, device)
print(f"Build completed for {vendor}/{device} with distro {distro}") print(f"Build completed for {vendor}/{device} with distro {distro}")

View file

@ -50,16 +50,18 @@ enabled=1
f.write(dnf_conf_content) f.write(dnf_conf_content)
def run_dnf_install(config, dnf_conf_path, rootfs_dir): def run_dnf_install(config, dnf_conf_path, rootfs_dir, arch):
"""Run dnf command to install packages based on the bootstrap configuration.""" """Run dnf command to install packages based on the bootstrap configuration."""
pkgs = config["PKGS"] pkgs = config["PKGS"]
weak_deps = config["WEAK_DEPS"].lower() weak_deps = config["WEAK_DEPS"].lower()
print(f"Bootstrapping '{arch}' rootfs...")
dnf_command = [ dnf_command = [
"sudo", "sudo",
"dnf", "dnf",
"--setopt=install_weak_deps=" + str(weak_deps), "--setopt=install_weak_deps=" + str(weak_deps),
"--config", dnf_conf_path, "--config", dnf_conf_path,
"--forcearch", arch,
"--installroot", rootfs_dir, "--installroot", rootfs_dir,
"install" "install"
] + pkgs.split() ] + pkgs.split()
@ -67,7 +69,7 @@ def run_dnf_install(config, dnf_conf_path, rootfs_dir):
subprocess.run(dnf_command, check=True) subprocess.run(dnf_command, check=True)
def setup_bootstrap(bootstrap_dir, tmp_dir, vendor, device, distro): def setup_bootstrap(bootstrap_dir, tmp_dir, vendor, device, distro, arch):
# load distro config # load distro config
# bootstrap/DISTRO_NAME # bootstrap/DISTRO_NAME
distro_config_path = os.path.join(bootstrap_dir, distro) distro_config_path = os.path.join(bootstrap_dir, distro)
@ -81,6 +83,6 @@ def setup_bootstrap(bootstrap_dir, tmp_dir, vendor, device, distro):
rootfs_dir = os.path.join(tmp_dir, vendor, device, "rootfs") rootfs_dir = os.path.join(tmp_dir, vendor, device, "rootfs")
generate_dnf_conf(dnf_conf_path, config["ABF_DOWNLOADS"], config["RELEASE"]) generate_dnf_conf(dnf_conf_path, config["ABF_DOWNLOADS"], config["RELEASE"])
run_dnf_install(config, dnf_conf_path, rootfs_dir) run_dnf_install(config, dnf_conf_path, rootfs_dir, arch)
#setup_user(rootfs_dir, config["DEFAULT_USER"], config["DEFAULT_USER_PASSWORD"], config["PASSWD_ROOT"]) #setup_user(rootfs_dir, config["DEFAULT_USER"], config["DEFAULT_USER_PASSWORD"], config["PASSWD_ROOT"])