From 8c3f10ba402e7535529decf008cfd3dbd39d9d7e Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 25 May 2025 03:09:29 +0100 Subject: rom.sh: simplify u-boot payload handling define it with a single variable, rather than several. this allows several checks to be greatly simplified. Signed-off-by: Leah Rowe --- include/rom.sh | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'include') diff --git a/include/rom.sh b/include/rom.sh index 1c39979d..eedd05d3 100644 --- a/include/rom.sh +++ b/include/rom.sh @@ -94,21 +94,16 @@ mkcorebootbin() initmode="${initmode%%_*}" cbfstool="elf/cbfstool/$tree/cbfstool" - [ "$payload_uboot_i386" = "y" ] && \ - [ "$payload_uboot_amd64" = "y" ] && \ - err "'$target' enables 32- and 64-bit x86 U-Boot" + [ -z "$payload_uboot" ] || [ "$payload_uboot" = "amd64" ] || \ + [ "$payload_uboot" = "i386" ] || [ "$payload_uboot" = "arm64" ] \ + || err "'$target' defines bad u-boot type '$payload_uboot'" - if [ "$payload_uboot_i386" = "y" ] || \ - [ "$payload_uboot_amd64" = "y" ]; then - printf "'%s' has x86 U-Boot; assuming SeaBIOS=y\n" \ - "$target" 1>&2 + [ -z "$payload_uboot" ] || [ "$payload_uboot" = "arm64" ] || \ payload_seabios="y" - fi [ -n "$uboot_config" ] || uboot_config="default" - [ "$payload_uboot" = "y" ] || payload_seabios="y" [ "$payload_grub" = "y" ] && payload_seabios="y" - [ "$payload_seabios" = "y" ] && [ "$payload_uboot" = "y" ] && \ + [ "$payload_seabios" = "y" ] && [ "$payload_uboot" = "arm64" ] && \ $dry err "$target: U-Boot(arm64) and SeaBIOS/GRUB both enabled." [ -z "$grub_scan_disk" ] && grub_scan_disk="nvme ahci ata" @@ -126,7 +121,8 @@ mkcorebootbin() if $dry grep "CONFIG_PAYLOAD_NONE=y" "$defconfig"; then [ "$payload_seabios" = "y" ] && pname="seabios" && \ $dry add_seabios - [ "$payload_uboot" = "y" ] && pname="uboot" && $dry add_uboot + [ "$payload_uboot" = "arm64" ] && pname="uboot" && \ + $dry add_uboot; : else pname="custom" $dry cprom @@ -135,10 +131,8 @@ mkcorebootbin() add_seabios() { - if [ "$payload_uboot_i386" = "y" ] || \ - [ "$payload_uboot_amd64" = "y" ]; then - $dry add_uboot - fi + [ -z "$payload_uboot" ] || [ "$payload_uboot" = "arm64" ] || \ + $dry add_uboot _seabioself="elf/seabios/default/$initmode/bios.bin.elf" _seaname="fallback/payload" && [ "$payload_grubsea" = "y" ] && \ @@ -159,7 +153,7 @@ add_seabios() [ "$payload_grub" = "y" ] && add_grub [ "$payload_grubsea" != "y" ] && cprom - [ "$payload_uboot_amd64" = "y" ] && [ "$displaymode" != "txtmode" ] && \ + [ "$payload_uboot" = "amd64" ] && [ "$displaymode" != "txtmode" ] && \ [ "$initmode" != "normal" ] && [ "$payload_grubsea" != "y" ] && \ pname="seauboot" && cprom "seauboot" [ "$payload_grub" = "y" ] && pname="seagrub" && mkseagrub; : @@ -206,14 +200,13 @@ add_uboot() ubpath="fallback/payload" ubtarget="$target" # override for x86/x86_64 targets: - if [ "$payload_uboot_i386" = "y" ] || \ - [ "$payload_uboot_amd64" = "y" ]; then + if [ -n "$payload_uboot" ] && [ "$payload_uboot" != "arm64" ]; then ubcbfsargs="-l 0x1110000 -e 0x1110000" # 64-bit and 32-bit # on 64-bit, 0x1120000 is the SPL, and stub before that ubpath="img/u-boot" # 64-bit ubtarget="amd64coreboot" - [ "$payload_uboot_i386" = "y" ] && ubpath="u-boot" # 32-bit - [ "$payload_uboot_i386" = "y" ] && ubtarget="i386coreboot"; : + [ "$payload_uboot" = "i386" ] && ubpath="u-boot" # 32-bit + [ "$payload_uboot" = "i386" ] && ubtarget="i386coreboot"; : fi ubdir="elf/u-boot/$ubtarget/$uboot_config" @@ -222,8 +215,8 @@ add_uboot() ubootelf="$ubdir/u-boot.elf" && [ ! -f "$ubootelf" ] && \ ubootelf="$ubdir/u-boot" # override for x86/x86_64 targets: - [ "$payload_uboot_i386" = "y" ] && ubootelf="$ubdir/u-boot-dtb.bin" - [ "$payload_uboot_amd64" = "y" ] && \ + [ "$payload_uboot" = "i386" ] && ubootelf="$ubdir/u-boot-dtb.bin" + [ "$payload_uboot" = "amd64" ] && \ ubootelf="$ubdir/u-boot-x86-with-spl.bin" # EFI-compatible cbfs "$tmprom" "$ubootelf" "$ubpath" $ubcbfsargs -- cgit v1.2.1 From d2e148fdd9d3f341940c22c241d219a0372f8f57 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 25 May 2025 04:40:30 +0100 Subject: rom.sh: simplify ccache handling for coreboot we simply do not need to run the make-oldconfig command at all, and after removing it, the "cook" function seemed quite redundant so i merged it with mkvendorfiles() Signed-off-by: Leah Rowe --- include/rom.sh | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/rom.sh b/include/rom.sh index eedd05d3..4a3503f4 100644 --- a/include/rom.sh +++ b/include/rom.sh @@ -45,7 +45,8 @@ mkpayload_grub() mkvendorfiles() { - [ -z "$mode" ] && $dry cook_coreboot_config + [ -n "$mode" ] || [ ! -f "$srcdir/.config" ] || $dry printf \ + "CONFIG_CCACHE=y\n" >> "$srcdir/.config" || err "$srcdir: !cook"; : fx_ check_coreboot_util printf "cbfstool\nifdtool\n" printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \ err "!mk $srcdir .coreboot-version" @@ -53,14 +54,6 @@ mkvendorfiles() x_ ./mk download "$target"; : } -cook_coreboot_config() -{ - [ -f "$srcdir/.config" ] || return 0 - printf "CONFIG_CCACHE=y\n" >> "$srcdir/.config" || \ - err "$srcdir/.config: Could not enable ccache" - make -C "$srcdir" oldconfig || err "Could not cook $srcdir/.config"; : -} - check_coreboot_util() { [ "$badhash" = "y" ] && x_ rm -f "elf/$1/$tree/$1" -- cgit v1.2.1 From a47e98117235682e9d1744ddbf1d16523532d96a Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 25 May 2025 04:45:23 +0100 Subject: rom.sh: rename mkvendorfiles it mainly does general tasks, like handling utils and enabling ccache. the vfiles are a small part. rename the function accordingly. it is called by premake, so let's call it corebootpremake. this change will also make sense when cherry-picked into cbmk, which does not handle vfiles at all. Signed-off-by: Leah Rowe --- include/rom.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/rom.sh b/include/rom.sh index 4a3503f4..632ecca3 100644 --- a/include/rom.sh +++ b/include/rom.sh @@ -43,7 +43,7 @@ mkpayload_grub() "/boot/grub/grub.cfg=$grubdata/memdisk.cfg"; : } -mkvendorfiles() +corebootpremake() { [ -n "$mode" ] || [ ! -f "$srcdir/.config" ] || $dry printf \ "CONFIG_CCACHE=y\n" >> "$srcdir/.config" || err "$srcdir: !cook"; : -- cgit v1.2.1 From 97ce531c341f36b1496729e4a0f882b4ad9621b7 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 25 May 2025 05:03:03 +0100 Subject: rom.sh: simplify mkcoreboottar() Signed-off-by: Leah Rowe --- include/rom.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/rom.sh b/include/rom.sh index 632ecca3..4ac4c5de 100644 --- a/include/rom.sh +++ b/include/rom.sh @@ -253,10 +253,7 @@ cbfs() mkcoreboottar() { - [ "$target" = "$tree" ] && return 0 - [ "$XBMK_RELEASE" = "y" ] || return 0 - [ "$release" != "n" ] || return 0 - - $dry mkrom_tarball "bin/$target" - $dry x_ ./mk inject "bin/${relname}_${target}.tar.xz" nuke; : + [ "$target" != "$tree" ] && [ "$XBMK_RELEASE" = "y" ] && \ + [ "$release" != "n" ] && $dry mkrom_tarball "bin/$target" && \ + $dry x_ ./mk inject "bin/${relname}_${target}.tar.xz" nuke; : } -- cgit v1.2.1 From ad333ae24810dcb762d5561d0b7d7dabec7c0eac Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 25 May 2025 14:35:02 +0100 Subject: tree.sh: Don't auto-run make-oldconfig This code was introduced to provide fault tolerance, so that if I forgot to manually update the configs myself, builds would still succeed, e.g. coreboot builds. However, there have been cases in the past where this introduces settings we don't want, and in general we do want to know when there is an error in the configs. The policy should always be: fail early, fail hard. This also mitigates bugs in U-Boot's build system; for example, when I last attempted to update the U-Boot tree for x86, make-oldconfig introduced a lot of junk settings unrelated, which then introduced code that would brick the board if you tried it on one, e.g. it broke booting most Linux kernels via bootflow. With this change, U-Boot will be easier to handle, which normally requires manual configuration; the automated make-oldconfig reconfiguration feature breaks U-Boot. This will no longer occur, since we no longer run it manually. On the other hand, this feature has also prevented other disastrous bugs in the past, such as when I forgot to properly set the SPD size on T480; it was set to 256 bytes, not 512 as is correct. Therefore, this new design change means I must also be more vigilant about config changes in project trees. Signed-off-by: Leah Rowe --- include/tree.sh | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/tree.sh b/include/tree.sh index 83887864..8aaadd57 100644 --- a/include/tree.sh +++ b/include/tree.sh @@ -279,8 +279,6 @@ handle_makefile() $dry x_ make -C "$srcdir" $cleanargs clean [ -f "$defconfig" ] && x_ cp "$defconfig" "$srcdir/.config" - [ -n "$mode" ] || [ -n "$btype" ] || $dry make -C \ - "$srcdir" silentoldconfig || make -C "$srcdir" oldconfig || : run_make_command || err "handle_makefile $srcdir: no makefile!" -- cgit v1.2.1 From 2493203ee53befbf46de0ff7908214b5e64033a8 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 25 May 2025 14:46:33 +0100 Subject: get.sh: Properly error out if tmpclone fails We rely on a non-zero exit on other try_ commands, which works fine there because we then check the file afterward and error out accordingly. For git repositories, we assume that both mirrors are identical and therefore once we get to the first clone attempt, we assume that it must succeed. Therefore, if it does not succeed, we must fail. This fixes a regression I found in testing, where sometimes a failed patching attempt would not result in an error exit, and would therefore result in broken sources being present. In practise, I always very closely watch the terminal when testing xbmk, especially when updating project patches, so we probably didn't introduce any broken sources in practice. Signed-off-by: Leah Rowe --- include/get.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/get.sh b/include/get.sh index 6f1b5f1d..3d06eb4a 100644 --- a/include/get.sh +++ b/include/get.sh @@ -111,7 +111,8 @@ try_file() eval "[ -$echk \"$cached\" ] || return 1" if [ "$2" = "git" ]; then - [ -d "$5" ] || tmpclone "$cached" "$5" "$6" "$7" || return 1 + [ -d "$5" ] || tmpclone "$cached" "$5" "$6" "$7" || \ + err "Can't clone final repo in command: try_file $*"; : else bad_checksum "$6" "$cached" && x_ rm -f "$cached" && return 1 [ "$cached" != "$5" ] && x_ cp "$cached" "$5" -- cgit v1.2.1 From 30bc3732c39cbb14faa8f7caf0c9206f6a401008 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 25 May 2025 17:01:10 +0100 Subject: init.sh: error out if .git/ is a symlink the current behaviour is a relic from the older lbmk design, before recent auditing. the current logic would cause xbmk to continue execution, going into a child process with .git/ being a symlink. The .git/ directory should never be a symlink, because it is extremely error-prone. Signed-off-by: Leah Rowe --- include/init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/init.sh b/include/init.sh index 38eb1c81..9265bf45 100644 --- a/include/init.sh +++ b/include/init.sh @@ -195,7 +195,7 @@ xbmk_git_init() || err "Run this first: $gitcmd \"your ${gitcmd##*.}\"" done - [ -L ".git" ] && return 1 + [ -L ".git" ] && err "'$xbmkpwd/.git' is a symlink" [ -e ".git" ] && return 0 eval "`setvars "$(date -Rud @$versiondate)" cdate _nogit`" -- cgit v1.2.1