add flash uboot device and add --nodocs globally

This commit is contained in:
alexander stefanov 2024-12-21 14:37:17 +03:00
parent bc7a1aa0bb
commit 8ff48f62a2
4 changed files with 45 additions and 7 deletions

View file

@ -10,7 +10,7 @@ from utils.make_disk import create_disk_image, setup_loop_device
from utils.make_disk import create_partitions, mount_partitions
from utils.generate_spec import generate_spec_file
from utils.kernel import clone_kernel, make_kernel_tar
from utils.uboot import build_uboot
from utils.uboot import build_uboot, flash_uboot
from utils.patch import apply_uboot_patches, apply_kernel_patches
from utils.rpmbuild import run_rpmbuild
@ -75,6 +75,8 @@ def main():
print(f"Loop device setup at {loop_device}")
# fdisk, mkfs here
create_partitions(loop_device, config)
if not skip_uboot:
flash_uboot(loop_device, TMP_DIR, config, vendor, device)
mount_partitions(config, loop_device, TMP_DIR, vendor, device)
# dnf install rootfs here
setup_bootstrap("bootstrap", TMP_DIR, vendor, device, distro, arch)

View file

@ -63,6 +63,7 @@ def run_dnf_install(config, dnf_conf_path, rootfs_dir, arch, extra_pkgs=""):
"dnf",
"--setopt=install_weak_deps=" + str(weak_deps),
"--config", dnf_conf_path,
"--nodocs",
"--forcearch", arch,
"--installroot", rootfs_dir,
"install"

View file

@ -3,7 +3,6 @@
import os
import subprocess
def create_disk_image(tmp_dir, config, vendor, device):
boot_size = config.get("BOOT_SIZE", "").rstrip("MB")

View file

@ -9,19 +9,19 @@ from utils.common import download_blob
from utils.patch import apply_uboot_patches
def build_uboot(TMP_DIR, BASE_DIR, config, vendor, device):
if "UBOOT" not in config or "UBOOT_VERSION" not in config:
print("U-Boot configuration not found. Skipping U-Boot build.")
return
uboot_git = config.get("UBOOT")
uboot_branch = config.get("UBOOT_VERSION")
uboot_config = config.get("UBOOT_CONFIG")
uboot_build_cmd = config.get("UBOOT_BUILD")
mkimage_cmd = config.get("MKIMAGE_CMD")
blobs_url = config.get("BLOBS_URL", "")
uboot_dir = os.path.join(TMP_DIR, vendor, device, "u-boot")
if "UBOOT" not in config or "UBOOT_VERSION" not in config:
print("U-Boot configuration not found. Skipping U-Boot build.")
return
# Clone U-Boot repository
uboot_dir = os.path.join(TMP_DIR, vendor, device, "u-boot")
clone_repo(uboot_git, uboot_branch, uboot_dir, "u-boot")
apply_uboot_patches(BASE_DIR, vendor, device, uboot_dir)
@ -68,3 +68,39 @@ def build_uboot(TMP_DIR, BASE_DIR, config, vendor, device):
except subprocess.CalledProcessError as e:
print(f"Error during U-Boot build: {e}")
os.chdir(BASE_DIR)
def flash_uboot(loop_device, TMP_DIR, config, vendor, device):
"""
Flash U-Boot components to the disk image.
Parameters:
loop_device (str): The loop device path (e.g., /dev/loop0).
uboot_dir (str): Directory where U-Boot artifacts are located.
config (dict): Configuration dictionary.
"""
uboot_dir = os.path.join(TMP_DIR, vendor, device, "u-boot")
idbloader_path = os.path.join(uboot_dir, config.get("BOOT_IDB", "idbloader.img"))
uboot_itb_path = os.path.join(uboot_dir, config.get("BOOT_ITB", "u-boot.itb"))
if not os.path.isfile(idbloader_path) or not os.path.isfile(uboot_itb_path):
print(f"Error: Required U-Boot files not found: {idbloader_path}, {uboot_itb_path}")
return False
try:
print(f"Flashing {idbloader_path} to {loop_device}...")
subprocess.run([
"dd", f"if={idbloader_path}", f"of={loop_device}", "seek=64",
"conv=notrunc", "status=none"
], check=True)
print(f"Flashing {uboot_itb_path} to {loop_device}...")
subprocess.run([
"dd", f"if={uboot_itb_path}", f"of={loop_device}", "seek=16384",
"conv=notrunc", "status=none"
], check=True)
print("U-Boot flashing completed successfully.")
except subprocess.CalledProcessError as e:
print(f"Error flashing U-Boot files: {e}")
return False
return True