Compare commits

..

8 Commits

Author SHA1 Message Date
Leah Rowe 5da5e305a7 Merge branch 'master' into 25.04_branch 2025-05-08 22:19:37 +01:00
Leah Rowe 12920bbd29 Merge branch 'master' into 25.04_branch 2025-05-08 16:10:15 +01:00
Leah Rowe 8cf600eafe Merge branch 'master' into 25.04_branch 2025-05-06 14:50:05 +01:00
Leah Rowe d87a9b78e0 mk: Fix bad error handling for gnu_setver
I mixed logical OR and AND by mistake. Oops!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-05 12:28:32 +01:00
Leah Rowe 5f0c7e30ba lib.sh: set -u -e in err()
Some parts of lbmk set +u +e, to be reset later on
under normal conditions upon exit. We must ensure
such level of integrity in err() as well.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-05 12:28:32 +01:00
Leah Rowe c414eba896 Merge branch 'master' into 25.04_branch 2025-05-05 07:37:02 +01:00
Leah Rowe 9ddb92f1dc Merge branch 'master' into 25.04_branch 2025-05-05 07:29:28 +01:00
Leah Rowe d89ac13056 Canoeboot 25.04 rev1
Rolled back the recent SeaBIOS revision update, which
therefore removes these SeaBIOS patches:

* 9029a010 kconfig: fix the check-lxdialog.sh to work with gcc 14+
* 8863cbbd ahci: add controller reset
* df9dd418 update pci_pad_mem64 handling
* a4fc1845 add romfile_loadbool()
* a2725e28 drop acpi tables and hex includes
* 35aa9a72 drop obsolete acpi table code
* 1b598a1d usb-hid: Support multiple USB HID devices by storing them in a linked list

Technically, I need only revert instead to revision df9dd418, but
that and the other revisions above contain changes that may possibly
cause other breakage.

We know the old revision worked, so roll back these 7 SeaBIOS commits.

Now I will re-compile the 25.04 release and re-upload it as rev1.

This bug was reported on a T420 thinkpad, which Canoeboot doesn't
support, but since that AHCI code is fairly generic, and these
controllers all so similar, it makes sense to just roll back SeaBIOS
on Canoeboot in addition to Libreboot.

Therefore, both Libreboot and Canoeboot will both provide a revision
release for the 25.04 series.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-01 14:57:49 +01:00
43 changed files with 816 additions and 844 deletions

View File

@ -16,7 +16,7 @@ index 04d058f55..b1cc8f236 100644
grub_term_cls (term);
- msg_formatted = grub_xasprintf (_("GNU GRUB version %s"), PACKAGE_VERSION);
+ msg_formatted = grub_xasprintf (_("Canoeboot 25.04 Corny Calamity (GRUB menu): https://canoeboot.org/"));
+ msg_formatted = grub_xasprintf (_("Canoeboot 25.04 rev1 (GRUB menu): https://canoeboot.org/"));
if (!msg_formatted)
return;

View File

@ -16,7 +16,7 @@ index 04d058f55..b1cc8f236 100644
grub_term_cls (term);
- msg_formatted = grub_xasprintf (_("GNU GRUB version %s"), PACKAGE_VERSION);
+ msg_formatted = grub_xasprintf (_("Canoeboot 25.04 Corny Calamity (GRUB menu): https://canoeboot.org/"));
+ msg_formatted = grub_xasprintf (_("Canoeboot 25.04 rev1 (GRUB menu): https://canoeboot.org/"));
if (!msg_formatted)
return;

View File

@ -16,7 +16,7 @@ index 04d058f55..b1cc8f236 100644
grub_term_cls (term);
- msg_formatted = grub_xasprintf (_("GNU GRUB version %s"), PACKAGE_VERSION);
+ msg_formatted = grub_xasprintf (_("Canoeboot 25.04 Corny Calamity (GRUB menu): https://canoeboot.org/"));
+ msg_formatted = grub_xasprintf (_("Canoeboot 25.04 rev1 (GRUB menu): https://canoeboot.org/"));
if (!msg_formatted)
return;

View File

@ -17,7 +17,7 @@ index 538b316d..9eed0b12 100644
// Write to screen.
- printf("SeaBIOS (version %s)\n", VERSION);
+ printf("Canoeboot 25.04 Corny Calamity (SeaBIOS menu): https://canoeboot.org/\n");
+ printf("Canoeboot 25.04 rev1 (SeaBIOS menu): https://canoeboot.org/\n");
display_uuid();
}

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subcurl="https://www.mirrorservice.org/sites/libreboot.org/release/misc/acpica/acpica-unix-20241212.tar.gz"
subcurl_bkup="https://mirror.math.princeton.edu/pub/libreboot/misc/acpica/acpica-unix-20241212.tar.gz"
subfile="https://www.mirrorservice.org/sites/libreboot.org/release/misc/acpica/acpica-unix-20241212.tar.gz"
subfile_bkup="https://mirror.math.princeton.edu/pub/libreboot/misc/acpica/acpica-unix-20241212.tar.gz"
subhash="daa4243f927451ac18c337cf17c27849e68329b3f7eb25b8c3379fda9c6a484201b73d4ffccab89a0ae22cc5e432f141ba149015a003834b0515bdb3d4efe0a8"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subgit="https://review.coreboot.org/arm-trusted-firmware.git"
subgit_bkup="https://github.com/coreboot/arm-trusted-firmware"
subrepo="https://review.coreboot.org/arm-trusted-firmware.git"
subrepo_bkup="https://github.com/coreboot/arm-trusted-firmware"
subhash="57ac3f74b34a3303f03deee264a1f2247c68008d"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/binutils/binutils-2.43.1.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/binutils/binutils-2.43.1.tar.xz"
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/binutils/binutils-2.43.1.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/binutils/binutils-2.43.1.tar.xz"
subhash="20977ad17729141a2c26d358628f44a0944b84dcfefdec2ba029c2d02f40dfc41cc91c0631044560d2bd6f9a51e1f15846b4b311befbe14f1239f14ff7d57824"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.xz"
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.xz"
subhash="932bdef0cda94bacedf452ab17f103c0cb511ff2cec55e9112fc0328cbf1d803b42595728ea7b200e0a057c03e85626f937012e49a7515bc5dd256b2bf4bc396"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/gmp/gmp-6.3.0.tar.xz"
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/gmp/gmp-6.3.0.tar.xz"
subhash="e85a0dab5195889948a3462189f0e0598d331d3457612e2d3350799dba2e244316d256f8161df5219538eb003e4b5343f989aaa00f96321559063ed8c8f29fd2"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subgit="https://review.coreboot.org/libgfxinit.git"
subgit_bkup="https://github.com/coreboot/libgfxinit"
subrepo="https://review.coreboot.org/libgfxinit.git"
subrepo_bkup="https://github.com/coreboot/libgfxinit"
subhash="17cfc92f402493979783585b6581efbd98c0cf07"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subgit="https://review.coreboot.org/libhwbase.git"
subgit_bkup="https://github.com/coreboot/libhwbase"
subrepo="https://review.coreboot.org/libhwbase.git"
subrepo_bkup="https://github.com/coreboot/libhwbase"
subhash="584629b9f4771b7618951cec57df2ca3af9c6981"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/mpc/mpc-1.3.1.tar.gz"
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/mpc/mpc-1.3.1.tar.gz"
subhash="4bab4ef6076f8c5dfdc99d810b51108ced61ea2942ba0c1c932d624360a5473df20d32b300fc76f2ba4aa2a97e1f275c9fd494a1ba9f07c4cb2ad7ceaeb1ae97"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/mpfr/mpfr-4.2.1.tar.xz"
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/mpfr/mpfr-4.2.1.tar.xz"
subhash="bc68c0d755d5446403644833ecbb07e37360beca45f474297b5d5c40926df1efc3e2067eecffdf253f946288bcca39ca89b0613f545d46a9e767d1d4cf358475"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subcurl="https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/nasm-2.16.03.tar.bz2"
subcurl_bkup="https://www.mirrorservice.org/sites/distfiles.macports.org/nasm/nasm-2.16.03.tar.bz2"
subfile="https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/nasm-2.16.03.tar.bz2"
subfile_bkup="https://www.mirrorservice.org/sites/distfiles.macports.org/nasm/nasm-2.16.03.tar.bz2"
subhash="f28445d368debdf44219cc57df33800a8c0e49186cd60836d4adfec7700d53b801d34aa9fc9bfda74169843f33a1e8b465e11292582eb968bb9c3a26f54dd172"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subgit="https://review.coreboot.org/vboot.git"
subgit_bkup="https://github.com/coreboot/vboot"
subrepo="https://review.coreboot.org/vboot.git"
subrepo_bkup="https://github.com/coreboot/vboot"
subhash="3f94e2c7ed58c4e67d6e7dc6052ec615dbbb9bb4"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subcurl="https://www.mirrorservice.org/sites/libreboot.org/release/misc/acpica/acpica-unix2-20190703.tar.gz"
subcurl_bkup="https://mirror.math.princeton.edu/pub/libreboot/misc/acpica/acpica-unix2-20190703.tar.gz"
subfile="https://www.mirrorservice.org/sites/libreboot.org/release/misc/acpica/acpica-unix2-20190703.tar.gz"
subfile_bkup="https://mirror.math.princeton.edu/pub/libreboot/misc/acpica/acpica-unix2-20190703.tar.gz"
subhash="8445a6d354ce3bcbfb5159f4ec0312b1e910c0b1b2033a2300f892e4ac580abab4e3f5b4ded379f0036299359d307330511ab7053678cfd9031d7df4c365f555"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/binutils/binutils-2.32.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/binutils/binutils-2.32.tar.xz"
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/binutils/binutils-2.32.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/binutils/binutils-2.32.tar.xz"
subhash="d326408f12a03d9a61a9de56584c2af12f81c2e50d2d7e835d51565df8314df01575724afa1e43bd0db45cfc9916b41519b67dfce03232aa4978704492a6994a"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gcc/gcc-8.3.0/gcc-8.3.0.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/gcc/gcc-8.3.0/gcc-8.3.0.tar.xz"
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gcc/gcc-8.3.0/gcc-8.3.0.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/gcc/gcc-8.3.0/gcc-8.3.0.tar.xz"
subhash="1811337ae3add9680cec64968a2509d085b6dc5b6783fc1e8c295e3e47416196fd1a3ad8dfe7e10be2276b4f62c357659ce2902f239f60a8648548231b4b5802"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/gmp/gmp-6.1.2.tar.xz"
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/gmp/gmp-6.1.2.tar.xz"
subhash="9f098281c0593b76ee174b722936952671fab1dae353ce3ed436a31fe2bc9d542eca752353f6645b7077c1f395ab4fdd355c58e08e2a801368f1375690eee2c6"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/mpc/mpc-1.1.0.tar.gz"
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/mpc/mpc-1.1.0.tar.gz"
subhash="72d657958b07c7812dc9c7cbae093118ce0e454c68a585bfb0e2fa559f1bf7c5f49b93906f580ab3f1073e5b595d23c6494d4d76b765d16dde857a18dd239628"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/mpfr/mpfr-4.0.2.tar.xz"
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/mpfr/mpfr-4.0.2.tar.xz"
subhash="d583555d08863bf36c89b289ae26bae353d9a31f08ee3894520992d2c26e5683c4c9c193d7ad139632f71c0a476d85ea76182702a98bf08dde7b6f65a54f8b88"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subcurl="https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/nasm-2.16.03.tar.bz2"
subcurl_bkup="https://www.mirrorservice.org/sites/distfiles.macports.org/nasm/nasm-2.16.03.tar.bz2"
subfile="https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/nasm-2.16.03.tar.bz2"
subfile_bkup="https://www.mirrorservice.org/sites/distfiles.macports.org/nasm/nasm-2.16.03.tar.bz2"
subhash="f28445d368debdf44219cc57df33800a8c0e49186cd60836d4adfec7700d53b801d34aa9fc9bfda74169843f33a1e8b465e11292582eb968bb9c3a26f54dd172"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subgit="https://review.coreboot.org/vboot.git"
subgit_bkup="https://github.com/coreboot/vboot"
subrepo="https://review.coreboot.org/vboot.git"
subrepo_bkup="https://github.com/coreboot/vboot"
subhash="ecdca931ae0637d1a9498f64862939bd5bb99e0b"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subhash="5d25331352e7a4ff010096af7dfd1a2d5f74e688"
subgit="https://codeberg.org/canoeboot/cbwww"
subgit_bkup="https://git.disroot.org/canoeboot/cbwww"
subrepo="https://codeberg.org/canoeboot/cbwww"
subrepo_bkup="https://git.disroot.org/canoeboot/cbwww"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subhash="dfab6aea12b770d72cdc69cd9c5eb3e48bc9f679"
subgit="https://codeberg.org/canoeboot/cbwww-img"
subgit_bkup="https://git.disroot.org/canoeboot/cbwww-img"
subrepo="https://codeberg.org/canoeboot/cbwww-img"
subrepo_bkup="https://git.disroot.org/canoeboot/cbwww-img"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subgit="https://codeberg.org/libreboot/gnulib"
subgit_bkup="git://git.sv.gnu.org/gnulib" # ALWAYS slow. only use as backup!
subrepo="https://codeberg.org/libreboot/gnulib"
subrepo_bkup="git://git.sv.gnu.org/gnulib" # ALWAYS slow. only use as backup!
subhash="9f48fb992a3d7e96610c4ce8be969cff2d61a01b"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subgit="https://codeberg.org/libreboot/gnulib"
subgit_bkup="git://git.sv.gnu.org/gnulib" # ALWAYS slow. only use as backup!
subrepo="https://codeberg.org/libreboot/gnulib"
subrepo_bkup="git://git.sv.gnu.org/gnulib" # ALWAYS slow. only use as backup!
subhash="9f48fb992a3d7e96610c4ce8be969cff2d61a01b"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subgit="https://codeberg.org/libreboot/gnulib"
subgit_bkup="git://git.sv.gnu.org/gnulib" # ALWAYS slow. only use as backup!
subrepo="https://codeberg.org/libreboot/gnulib"
subrepo_bkup="git://git.sv.gnu.org/gnulib" # ALWAYS slow. only use as backup!
subhash="9f48fb992a3d7e96610c4ce8be969cff2d61a01b"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subhash="7c6f1973a16893cf1f0868af6f8e60a028b933ad"
subgit="https://github.com/grumpycoders/uC-sdk.git"
subgit_bkup="https://codeberg.org/vimuser/uC-sdk"
subrepo="https://github.com/grumpycoders/uC-sdk.git"
subrepo_bkup="https://codeberg.org/vimuser/uC-sdk"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subhash="86c416d4c0fb38432460b3e11b08b9de76941bf5"
subgit="https://codeberg.org/libreboot/tinyusb"
subgit_bkup="https://github.com/hathach/tinyusb.git"
subrepo="https://codeberg.org/libreboot/tinyusb"
subrepo_bkup="https://github.com/hathach/tinyusb.git"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subhash="458250dc6147dc807eec9e4d5a6caf38a699ecb1"
subgit="https://codeberg.org/libreboot/libopencm3"
subgit_bkup="https://github.com/libopencm3/libopencm3"
subrepo="https://codeberg.org/libreboot/libopencm3"
subrepo_bkup="https://github.com/libopencm3/libopencm3"

View File

@ -18,7 +18,7 @@ index 84831915a2..318dbf8b8b 100644
ret |= scene_obj_set_pos(scn, OBJ_MENU, MARGIN_LEFT, 100);
ret |= scene_txt_str(scn, "title", OBJ_MENU_TITLE, STR_MENU_TITLE,
- "U-Boot - Boot Menu", NULL);
+ "Canoeboot 25.04 Corny Calamity (U-Boot menu): https://canoeboot.org/", NULL);
+ "Canoeboot 25.04 rev1 (U-Boot menu): https://canoeboot.org/", NULL);
ret |= scene_menu_set_title(scn, OBJ_MENU, OBJ_PROMPT);
logo = video_get_u_boot_logo();

View File

@ -18,7 +18,7 @@ index 84831915a2..318dbf8b8b 100644
ret |= scene_obj_set_pos(scn, OBJ_MENU, MARGIN_LEFT, 100);
ret |= scene_txt_str(scn, "title", OBJ_MENU_TITLE, STR_MENU_TITLE,
- "U-Boot - Boot Menu", NULL);
+ "Canoeboot 25.04 Corny Calamity (U-Boot menu): https://canoeboot.org/", NULL);
+ "Canoeboot 25.04 rev1 (U-Boot menu): https://canoeboot.org/", NULL);
ret |= scene_menu_set_title(scn, OBJ_MENU, OBJ_PROMPT);
logo = video_get_u_boot_logo();

View File

@ -18,7 +18,7 @@ index 84831915a2..318dbf8b8b 100644
ret |= scene_obj_set_pos(scn, OBJ_MENU, MARGIN_LEFT, 100);
ret |= scene_txt_str(scn, "title", OBJ_MENU_TITLE, STR_MENU_TITLE,
- "U-Boot - Boot Menu", NULL);
+ "Canoeboot 25.04 Corny Calamity (U-Boot menu): https://Canoeboot.org/", NULL);
+ "Canoeboot 25.04 rev1 (U-Boot menu): https://Canoeboot.org/", NULL);
ret |= scene_menu_set_title(scn, OBJ_MENU, OBJ_PROMPT);
logo = video_get_u_boot_logo();

View File

@ -1,162 +0,0 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (c) 2020-2021,2023-2025 Leah Rowe <leah@libreboot.org>
# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
eval "`setvars "" loc url bkup_url subcurl subhash subgit subgit_bkup \
depend subcurl_bkup repofail`"
tmpgit="$xbmklocal/gitclone"
tmpgitcache="$XBMK_CACHE/tmpgit"
fetch_targets()
{
e "src/$project/$tree" d && return 0
printf "Creating %s tree %s\n" "$project" "$tree"
git_prep "$url" "$bkup_url" "$xbmkpwd/$configdir/$tree/patches" \
"src/$project/$tree" with_submodules
}
fetch_project()
{
eval "`setvars "" xtree`"
eval "`setcfg "config/git/$project/pkg.cfg"`"
chkvars url
[ -n "$xtree" ] && x_ ./mk -f coreboot "$xtree"
[ -z "$depend" ] || for d in $depend ; do
printf "'%s' needs '%s'; grabbing '%s'\n" "$project" "$d" "$d"
x_ ./mk -f $d
done
clone_project
}
clone_project()
{
loc="$XBMK_CACHE/clone/$project" && singletree "$project" && \
loc="src/$project"
printf "Downloading project '%s' to '%s'\n" "$project" "$loc"
e "$loc" d missing && remkdir "${tmpgit%/*}" && git_prep \
"$url" "$bkup_url" "$xbmkpwd/config/$project/patches" "$loc"; :
}
git_prep()
{
_patchdir="$3"
_loc="$4" # $1 and $2 are gitrepo and gitrepo_backup
chkvars rev
xbmkget git "$1" "$2" "$tmpgit" "$rev" "$_patchdir"
if singletree "$project" || [ $# -gt 4 ]; then
dx_ fetch_submodule "$mdir/module.list"
fi
[ "$_loc" = "${_loc%/*}" ] || x_ mkdir -p "${_loc%/*}"
x_ mv "$tmpgit" "$_loc"
}
fetch_submodule()
{
mcfgdir="$mdir/${1##*/}"; eval \
"`setvars "" subhash subgit subgit_bkup subcurl subcurl_bkup st`"
eval "`setcfg "$mcfgdir/module.cfg" 0`"
for xt in git curl; do
_seval="if [ -n \"\$sub$xt\" ] || [ -n \"\$sub${xt}_bkup\" ]"
eval "$_seval; then st=\"\$st \$xt\"; fi"
done
st="${st# }" && [ "$st" = "git curl" ] && err "$mdir: git+curl defined"
[ -z "$st" ] && return 0 # subgit/subcurl not defined
chkvars "sub${st}" "sub${st}_bkup" "subhash"
[ "$st" = "git" ] && x_ rm -Rf "$tmpgit/$1"
eval xbmkget "$st" "\$sub$st" "\$sub${st}_bkup" "$tmpgit/$1" \
"$subhash" "$mdir/${1##*/}/patches"
}
xbmkget()
{
[ "$1" = "curl" ] || [ "$1" = "copy" ] || [ "$1" = "git" ] || \
err "Bad dlop (arg 1): xbmkget $*"
echk="f" && [ "$1" = "git" ] && echk="d"
for url in "$2" "$3"; do
[ -n "$url" ] && try_file "$url" "$@" && \
eval "[ -$echk \"$4\" ] && return 0"
done && err "$1 $2 $3 $4: not downloaded"; :
}
try_file()
{
cached="file/$6" && [ "$2" = "git" ] && cached="clone/${3##*/}" && \
cached="${cached%.git}" # always the main repo as basis for naming,
# in case the backup has another name
cached="$XBMK_CACHE/$cached"
x_ mkdir -p "${5%/*}" "${cached%/*}"
echk="d" && [ "$2" != "git" ] && echk="f" && \
bad_checksum "$6" "$cached" 2>/dev/null && x_ rm -f "$cached"
eval "[ -$echk \"$cached\" ] || try_$2 \"\$cached\" \"\$@\" || return 1"
[ "$2" != "git" ] && [ -f "$5" ] && \
bad_checksum "$6" "$5" 2>/dev/null && x_ cp "$cached" "$5"
eval "[ -$echk \"$cached\" ] || return 1"
if [ "$2" = "git" ]; then
[ -d "$5" ] || tmpclone "$cached" "$5" "$6" "$7" || return 1
else
bad_checksum "$6" "$cached" && x_ rm -f "$cached" && return 1
[ "$cached" != "$5" ] && x_ cp "$cached" "$5"
bad_checksum "$6" "$5" && x_ rm -f "$5" && return 1; :
fi
eval "[ -$echk \"$5\" ] || return 1"
}
try_curl()
{
_ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
( x_ curl --location --retry 3 -A "$_ua" "$2" -o "$1" ) || \
( x_ wget --tries 3 -U "$_ua" "$2" -O "$1" ) || return 1; :
}
try_copy()
{
[ -L "$2" ] && printf "symlink %s (trycp %s)\n" "$2" "$*" && return 1
[ ! -f "$2" ] && printf "%s missing (trycp %s)\n" "$2" "$*" && return 1
( x_ cp "$2" "$1" ) || return 1; :
}
try_git()
{
gitdest="`findpath "$1"`" || err "Can't get readpath for '$1'"
x_ rm -Rf "$tmpgitcache"
[ -d "$gitdest" ] || ( x_ git clone "$2" "$tmpgitcache" ) || return 1
[ -d "$gitdest" ] || x_ mkdir -p "${gitdest%/*}"
[ -d "$gitdest" ] || x_ mv "$tmpgitcache" "$gitdest"
( x_ git -C "$gitdest" remote add main "$4" 2>/dev/null ) || :
( x_ git -C "$gitdest" remote add backup "$5" 2>/dev/null ) || :
( x_ git -C "$gitdest" fetch --all ) || :
( x_ git -C "$gitdest" pull --all ) || :; :
}
bad_checksum()
{
[ ! -f "$2" ] && printf "'%s' missing, %s\n" "$2" "$1" 1>&2 && return 0
csum="$(x_ sha512sum "$2" | awk '{print $1}')" || err "!sha512 '$2' $1"
[ "$csum" != "$1" ] && printf "BAD SHA512, '%s'; need '%s', got %s\n" \
"$2" "$1" "$csum" 1>&2 && x_ rm -f "$2" && return 0; return 1
}
tmpclone()
{
( x_ git clone "$1" "$2" ) || return 1
( x_ git -C "$2" reset --hard "$3" ) || return 1
( fx_ "eval x_ git -C \"$2\" am" find "$4" -type f ) || return 1; :
}

106
include/git.sh Normal file
View File

@ -0,0 +1,106 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (c) 2020-2021,2023-2025 Leah Rowe <leah@libreboot.org>
# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
eval "`setvars "" loc url bkup_url subfile subhash subrepo subrepo_bkup \
depend subfile_bkup repofail`"
tmpgit="$xbmklocal/gitclone"
fetch_targets()
{
e "src/$project/$tree" d && return 0
printf "Creating %s tree %s\n" "$project" "$tree"
git_prep "$loc" "$loc" "$xbmkpwd/$configdir/$tree/patches" \
"src/$project/$tree" with_submodules
nuke "$project/$tree" "$project/$tree"
}
fetch_project()
{
eval "`setvars "" xtree`"
eval "`setcfg "config/git/$project/pkg.cfg"`"
chkvars url
[ -n "$xtree" ] && x_ ./mk -f coreboot "$xtree"
[ -z "$depend" ] || for d in $depend ; do
printf "'%s' needs '%s'; grabbing '%s'\n" "$project" "$d" "$d"
x_ ./mk -f $d
done
clone_project
for x in config/git/*; do
[ -d "$x" ] && nuke "${x##*/}" "src/${x##*/}" 2>/dev/null; :
done; :
}
clone_project()
{
loc="$XBMK_CACHE/repo/$project" && singletree "$project" && \
loc="src/$project"
printf "Downloading project '%s' to '%s'\n" "$project" "$loc"
e "$loc" d missing && remkdir "${tmpgit%/*}" && git_prep \
"$url" "$bkup_url" "$xbmkpwd/config/$project/patches" "$loc"; :
}
git_prep()
{
_patchdir="$3"
_loc="$4" # $1 and $2 are gitrepo and gitrepo_backup
chkvars rev
tmpclone "$1" "$2" "$tmpgit" "$rev" "$_patchdir"
if singletree "$project" || [ $# -gt 4 ]; then
dx_ fetch_submodule "$mdir/module.list"
fi
[ "$_loc" != "$XBMK_CACHE/repo/$project" ] && \
[ "$XBMK_RELEASE" = "y" ] && rmgit "$tmpgit"
[ "$_loc" = "${_loc%/*}" ] || x_ mkdir -p "${_loc%/*}"
mv "$tmpgit" "$_loc" || err "git_prep: !mv $tmpgit $_loc"
}
fetch_submodule()
{
mcfgdir="$mdir/${1##*/}"; eval \
"`setvars "" subhash subrepo subrepo_bkup subfile subfile_bkup st`"
[ ! -f "$mcfgdir/module.cfg" ] || . "$mcfgdir/module.cfg" || \
err "! . $mcfgdir/module.cfg"
for xt in repo file; do
_seval="if [ -n \"\$sub$xt\" ] || [ -n \"\$sub${xt}_bkup\" ]"
eval "$_seval; then st=\"\$st \$xt\"; fi"
done
st="${st# }" && [ "$st" = "repo file" ] && err "$mdir: repo+file"
[ -z "$st" ] && return 0 # subrepo/subfile not defined
chkvars "sub${st}" "sub${st}_bkup" "subhash"
[ "$st" = "file" ] && xbmkget "$subfile" "$subfile_bkup" \
"$tmpgit/$1" "$subhash" && return 0
rm -Rf "$tmpgit/$1" || err "!rm '$mdir' '$1'"
tmpclone "$subrepo" "$subrepo_bkup" "$tmpgit/$1" "$subhash" \
"$mdir/${1##*/}/patches"
}
tmpclone()
{
[ -d "$3" ] && return 0
printf "Creating git clone '%s' from '%s', '%s'\n" "$3" "$1" "$2"
git clone "$1" "$3" || x_ rm -Rf "$3"
[ -d "$3" ] || x_ git clone "$2" "$3"
x_ git -C "$3" reset --hard "$4"
fx_ "eval x_ git -C \"$3\" am" find "$5" -type f
}
nuke()
{
e "config/${1%/}/nuke.list" f missing || while read -r nukefile; do
rmf="src/${2%/}/$nukefile" && [ -L "$rmf" ] && continue
e "$rmf" e missing || rm -Rf "$rmf" || err "!rm $rmf, ${2%/}"
done < "config/${1%/}/nuke.list"; :
}

View File

@ -12,10 +12,11 @@ projectsite="https://canoeboot.org/"
[ -z "${PATH+x}" ] && \
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
xbmkpath="$PATH"
eval "`setvars "" _nogit board reinstall versiondate aur_notice configdir \
datadir version xbmkpwd relname xbmkpwd xbmktmp python pyver xbmklocal \
xbmklock cvxbmk cvchk xbmkpath`"
xbmklock`"
xbmk_init()
{
@ -30,7 +31,8 @@ xbmk_init()
id -u 1>/dev/null 2>/dev/null || err "suid check failed (id -u)"
[ "$(id -u)" != "0" ] || err "this command as root is not permitted"
for init_cmd in get_version set_env git_init child_exec; do
for init_cmd in set_pyver set_version set_env git_init create_tmpdir \
lock create_pathdirs child_exec; do
xbmk_$init_cmd "$@" || break
done
}
@ -43,101 +45,12 @@ xbmkpkg()
eval "`setcfg "config/dependencies/$2"`"
chkvars pkg_add pkglist
x_ $pkg_add $pkglist
$pkg_add $pkglist || err "Cannot install packages"
[ -n "$aur_notice" ] && \
printf "You need AUR packages: %s\n" "$aur_notice" 1>&2; :
}
xbmk_get_version()
{
[ ! -f ".version" ] || read -r version < ".version" || err
[ ! -f ".versiondate" ] || read -r versiondate < ".versiondate" || err
[ ! -f ".version" ] || chkvars version
[ ! -f ".versiondate" ] || chkvars versiondate
[ ! -e ".git" ] && [ ! -f ".version" ] && version="unknown"
[ ! -e ".git" ] && [ ! -f ".versiondate" ] && versiondate="1716415872"
[ -n "$version" ] && relname="$projectname-$version"; :
}
xbmk_set_env()
{
is_child="n"
xbmkpath="$PATH"
# unify all temporary files/directories in a single TMPDIR
[ -z "${TMPDIR+x}" ] || [ "${TMPDIR%_*}" = "/tmp/xbmk" ] || \
unset TMPDIR
[ -n "${TMPDIR+x}" ] && export TMPDIR="$TMPDIR" && xbmktmp="$TMPDIR"
[ -z "${TMPDIR+x}" ] || is_child="y" # child instance, so return
if [ "$is_child" = "y" ]; then
[ -z "${XBMK_CACHE+x}" ] && err "XBMK_CACHE unset on child"
[ -z "${XBMK_THREADS+x}" ] && err "XBMK_THREADS unset on child"
e "lock" f missing && err "lock file absent on child"
return 1
fi
[ -f "$xbmklock" ] && err "'$xbmklock' exists. Is a build running?"
touch "$xbmklock" || err "cannot create '$xbmklock'"; :
# parent instance of xbmk, so don't return. set up TMPDIR
export TMPDIR="/tmp"
export TMPDIR="$(mktemp -d -t xbmk_XXXXXXXX)"
xbmktmp="$TMPDIR"
# XBMK_CACHE is a directory, for caching downloads and git repon
[ -z "${XBMK_CACHE+x}" ] && export XBMK_CACHE="$xbmkpwd/cache"
[ -z "$XBMK_CACHE" ] && export XBMK_CACHE="$xbmkpwd/cache"
[ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$xbmkpwd/cache" ] && \
err "cachedir '$xbmkpwd/cache' is a symlink"
[ -L "$XBMK_CACHE" ] && export XBMK_CACHE="$xbmkpwd/cache"
xbmkcache="`findpath "$XBMK_CACHE"`" || \
err "Can't resolve cachedir: '$XBMK_CACHE'"
export XBMK_CACHE="$xbmkcache"
[ ! -e "$XBMK_CACHE" ] || \
[ -d "$XBMK_CACHE" ] || err "cachedir '$XBMK_CACHE' is a file"; :
export PATH="$XBMK_CACHE/xbmkpath:$XBMK_CACHE/gnupath:$PATH"
xbmkpath="$PATH"
# if "y": a coreboot target won't be built if target.cfg says release="n"
# (this is used to exclude certain build targets from releases)
[ -z "${XBMK_RELEASE+x}" ] && export XBMK_RELEASE="n"
[ "$XBMK_RELEASE" = "Y" ] && export XBMK_RELEASE="y"
[ "$XBMK_RELEASE" = "y" ] || export XBMK_RELEASE="n"
[ -z "${XBMK_THREADS+x}" ] && export XBMK_THREADS=1
expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \
1>/dev/null 2>/dev/null || export XBMK_THREADS=1
xbmk_set_version
export LOCALVERSION="-$projectname-${version%%-*}"
remkdir "$xbmktmp" "$xbmklocal"
remkdir "$XBMK_CACHE/gnupath" "$XBMK_CACHE/xbmkpath"
xbmk_set_pyver
}
xbmk_set_version()
{
version_="$version"
[ ! -e ".git" ] || version="$(git describe --tags HEAD 2>&1)" || \
version="git-$(git rev-parse HEAD 2>&1)" || version="$version_"
versiondate_="$versiondate"
[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
--pretty='%ct' HEAD)" || versiondate="$versiondate_"
chkvars version versiondate
update_xbmkver "."
relname="$projectname-$version"
}
xbmk_set_pyver()
{
pyv="import sys; print(sys.version_info[:])"
@ -150,14 +63,7 @@ xbmk_set_pyver()
[ -n "$pyver" ] && \
pyver="$("$(pybin "$python")" -c "$pyv" | awk '{print $1}')" && \
pyver="${pyver#(}" && pyver="${pyver%,}"
[ "${pyver%%.*}" = "3" ] || err "Bad python version (must by 3.x)"
(
# set up python v3.x in PATH, in case it's not set up correctly.
# see code above that detected the correct python3 command.
x_ cd "$XBMK_CACHE/xbmkpath"
x_ ln -s "`pybin "$python"`" python
) || err "Can't set up python symlink in $XBMK_CACHE/xbmkpath"; :
[ "${pyver%%.*}" = "3" ] || err "Bad python version (must by 3.x)"; :
}
# Use direct path, to prevent a hang if Python is using a virtual environment,
@ -191,6 +97,57 @@ pybin()
command -v "$1" 2>/dev/null || return 1
}
xbmk_set_version()
{
[ ! -f ".version" ] || read -r version < ".version" || :; :
[ ! -f ".versiondate" ] || read -r versiondate < ".versiondate" || :; :
[ -e ".git" ] || [ -f ".version" ] || printf "unknown\n" > ".version" \
|| err "Cannot generate unknown .version file"
[ -e ".git" ] || [ -f ".versiondate" ] || printf "1716415872\n" > \
".versiondate" || err "Can't generate unknown versiondate file"; :
version_="$version"
[ ! -e ".git" ] || version="$(git describe --tags HEAD 2>&1)" || \
version="git-$(git rev-parse HEAD 2>&1)" || version="$version_"
versiondate_="$versiondate"
[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
--pretty='%ct' HEAD)" || versiondate="$versiondate_"
chkvars version versiondate
printf "%s\n" "$version" > ".version" || err "can't save version"
printf "%s\n" "$versiondate" > ".versiondate" || err "can't save date"
relname="$projectname-$version"
}
xbmk_set_env()
{
export LOCALVERSION="-$projectname-${version%%-*}"
# XBMK_CACHE is a directory, for caching downloads and git repon
[ -z "${XBMK_CACHE+x}" ] && export XBMK_CACHE="$xbmkpwd/cache"
[ -z "$XBMK_CACHE" ] && export XBMK_CACHE="$xbmkpwd/cache"
[ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$xbmkpwd/cache" ] && \
err "cachedir '$xbmkpwd/cache' is a symlink"
[ -L "$XBMK_CACHE" ] && export XBMK_CACHE="$xbmkpwd/cache"
xbmkcache="`findpath "$XBMK_CACHE"`" || \
err "Can't resolve cachedir: '$XBMK_CACHE'"
export XBMK_CACHE="$xbmkcache"
[ ! -e "$XBMK_CACHE" ] || \
[ -d "$XBMK_CACHE" ] || err "cachedir '$XBMK_CACHE' is a file"; :
# if "y": a coreboot target won't be built if target.cfg says release="n"
# (this is used to exclude certain build targets from releases)
[ -z "${XBMK_RELEASE+x}" ] && export XBMK_RELEASE="n"
[ "$XBMK_RELEASE" = "Y" ] && export XBMK_RELEASE="y"
[ "$XBMK_RELEASE" = "y" ] || export XBMK_RELEASE="n"
[ -z "${XBMK_THREADS+x}" ] && export XBMK_THREADS=1
expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \
1>/dev/null 2>/dev/null || export XBMK_THREADS=1; :
}
xbmk_git_init()
{
for gitarg in "--global user.name" "--global user.email"; do
@ -210,6 +167,44 @@ xbmk_git_init()
2>/dev/null; :
}
xbmk_create_tmpdir()
{
x_ mkdir -p "$xbmklocal"
# unify all temporary files/directories in a single TMPDIR
[ -z "${TMPDIR+x}" ] || [ "${TMPDIR%_*}" = "/tmp/xbmk" ] || \
unset TMPDIR
[ -n "${TMPDIR+x}" ] && export TMPDIR="$TMPDIR" && xbmktmp="$TMPDIR"
[ -z "${TMPDIR+x}" ] || return 1 # child instance, so return
# parent instance of xbmk, so don't return. set up TMPDIR
export TMPDIR="/tmp"
export TMPDIR="$(mktemp -d -t xbmk_XXXXXXXX)"
xbmktmp="$TMPDIR"
# /tmp might be a tmpfs, so for large files we use ./tmp,
# not to be confused with xbmktmp (xbmktmp points to /tmp)
remkdir "$xbmktmp" "$xbmklocal"
}
xbmk_lock()
{
[ -f "$xbmklock" ] && err "'$xbmklock' exists. Is a build running?"
touch "$xbmklock" || err "cannot create '$xbmklock'"; :
}
xbmk_create_pathdirs()
{
remkdir "$XBMK_CACHE/gnupath" "$XBMK_CACHE/xbmkpath"
export PATH="$XBMK_CACHE/xbmkpath:$XBMK_CACHE/gnupath:$PATH"
(
# set up python v3.x in PATH, in case it's not set up correctly.
# see code above that detected the correct python3 command.
cd "$XBMK_CACHE/xbmkpath" || err "can't cd $XBMK_CACHE/xbmkpath"
x_ ln -s "`pybin "$python"`" python
) || err "Can't set up python symlink in $XBMK_CACHE/xbmkpath"; :
}
xbmk_child_exec()
{
xbmk_rval=0

View File

@ -4,101 +4,83 @@
# Copyright (c) 2023-2025 Leah Rowe <leah@libreboot.org>
cbcfgsdir="config/coreboot"
tmpromdel="$XBMK_CACHE/DO_NOT_FLASH"
hashfiles="vendorhashes blobhashes" # used to detect and error out
# if running on an archive that needs vendor files
dontflash="!!! AN ERROR OCCURED! Do NOT flash these images !!!"
tmpromdel="$xbmklocal/DO_NOT_FLASH"
nvm="util/nvmutil/nvm"
ifdtool="elf/ifdtool/default/ifdtool"
cv="CONFIG_GBE_BIN_PATH"
[ -n "$cvxbmk" ] && cv="$cv $cvxbmk"
[ -n "$cvchk" ] && cv="$cv $cvchk"
eval "`setvars "" archive boarddir IFD_platform ifdprefix tree new_mac \
tmpromdir board xchanged $cv`"
inject()
{
remkdir "$tmpromdel"
set +u +e
[ $# -lt 1 ] && err "No options specified"
eval "`setvars "" nuke new_mac xchanged`"
[ $# -lt 1 ] && err "No options specified. - $dontflash"
eval "`setvars "" new_mac xchanged`"
archive="$1";
new_mac="xx:xx:xx:xx:xx:xx"
[ $# -gt 1 ] && case "$2" in
nuke)
new_mac=""
nuke="nuke" ;;
setmac)
[ $# -gt 2 ] && new_mac="$3" && \
[ -z "$new_mac" ] && err "Empty MAC address specified" ;;
*)
err "Unrecognised inject mode: '$2'"
*) err "Unrecognised inject mode: '$2'"
esac
[ "$new_mac" = "keep" ] && new_mac=""
check_release
check_target && patch_release
[ -n "$new_mac" ] && [ "$new_mac" != "restore" ] && \
x_ make -C util/nvmutil clean && x_ make -C util/nvmutil
[ "$xchanged" = "y" ] && remktar
check_release "$archive" || err "'$archive' is not a release archive"
xnot=" NOT" && [ "$xchanged" = "y" ] && xnot=""
printf "\n'%s' was%s modified\n" "$archive" "$xnot" 1>&2
if readcfg && readkconfig; then
patch_release_roms
fi
x_ rm -Rf "$tmpromdel"
[ "$xchanged" != "y" ] && printf "\n'%s' *NOT* modified.\n" "$archive"
[ "$xchanged" = "y" ] && printf "\n'%s' %s.\n" "$archive" "$xtype"; :
}
check_release()
{
[ -L "$archive" ] && err "'$archive' is a symlink"
e "$archive" f missing && err "'$archive' missing"
[ -L "$archive" ] && err "'$archive' is a symlink. $dontflash"
e "$archive" f missing && return 1
archivename="`basename "$archive"`" || err "Can't get '$archive' name"
[ -z "$archivename" ] && err "Can't determine archive name"
archivename="`basename "$archive"`"
[ -z "$archivename" ] && err "Can't determine archive name. $dontflash"
case "$archivename" in
*_src.tar.xz)
err "'$archive' is a src archive, silly!" ;;
grub_*|seagrub_*|custom_*|seauboot_*|seabios_withgrub_*)
err "'$archive' is a ROM image (it must be a tarball)" ;;
return 1 ;;
*.tar.xz) _stripped_prefix="${archivename#*_}"
board="${_stripped_prefix%.tar.xz}" ;;
*)
err "'$archive': could not detect board type"
*) err "'$archive': could not detect board type - $dontflash"
esac; :
}
check_target()
readcfg()
{
[ "$board" = "${board#serprog_}" ] || return 1
if [ "$board" = "serprog_rp2040" ] || [ "$board" = "serprog_stm32" ] \
|| [ "$board" = "serprog_pico" ]; then
printf "'%s' is a serprog firmware archive.\n" "$archive" 1>&2
return 1
fi
boarddir="$cbcfgsdir/$board"
eval "`setcfg "$boarddir/target.cfg"`"
chkvars tree && x_ ./mk -d coreboot "$tree"
cbdir="src/coreboot/$tree"
cbfstool="elf/cbfstool/$tree/cbfstool"
rmodtool="elf/cbfstool/$tree/rmodtool"
cbfstool="elf/cbfstool/$tree/cbfstool"
ifdtool="elf/ifdtool/$tree/ifdtool"
[ -n "$IFD_platform" ] && ifdprefix="-p $IFD_platform"; :
}
patch_release()
{
has_hashes="n"
tmpromdir="$tmpromdel/bin/$board"
remkdir "${tmpromdir%"/bin/$board"}"
x_ tar -xf "$archive" -C "${tmpromdir%"/bin/$board"}"
for _hashes in "vendorhashes" "blobhashes"; do
e "$tmpromdir/$_hashes" f && err \
"'$archive': vendorfile insertion unsupported"
done
readkconfig || exit 0
[ -n "$new_mac" ] && [ -n "$CONFIG_GBE_BIN_PATH" ] && modify_mac; :
}
readkconfig()
{
x_ rm -f "$xbmktmp/cbcfg"
@ -113,17 +95,38 @@ scankconfig()
done
}
patch_release_roms()
{
tmpromdir="$xbmklocal/DO_NOT_FLASH/bin/$board"
remkdir "${tmpromdir%"/bin/$board"}"
x_ tar -xf "$archive" -C "${tmpromdir%"/bin/$board"}"
for _hashes in $hashfiles; do
e "$tmpromdir/$_hashes" f && err \
"'$archive': vendorfile insertion unsupported; $dontflash"
done
[ -z "$new_mac" ] || [ -z "$CONFIG_GBE_BIN_PATH" ] || modify_mac
[ "$xchanged" = "y" ] || rm -Rf "$tmpromdel" || :
[ "$xchanged" = "y" ] || return 0
(
x_ cd "${tmpromdir%"/bin/$board"}"
mkrom_tarball "bin/$board"
) || err "Cannot re-generate '$archive' - $dontflash"
mv "${tmpromdir%"/bin/$board"}/bin/${relname}_${board}.tar.xz" \
"$archive" || err "'$archive' -> Can't overwrite - $dontflash"; :
}
modify_mac()
{
x_ cp "${CONFIG_GBE_BIN_PATH##*../}" "$xbmklocal/gbe"
[ -n "$new_mac" ] && [ "$new_mac" != "restore" ] && \
x_ make -C util/nvmutil clean && x_ make -C util/nvmutil && \
x_ "$nvm" "$xbmklocal/gbe" setmac "$new_mac"
fx_ newmac x_ find "$tmpromdir" -maxdepth 1 -type f -name "*.rom"
printf "\nThe following GbE NVM data will be written:\n"
x_ "$nvm" "$xbmklocal/gbe" dump | grep -v "bytes read from file" || :
}
newmac()
@ -131,15 +134,3 @@ newmac()
e "$1" f && xchanged="y" && x_ \
"$ifdtool" $ifdprefix -i GbE:"$xbmklocal/gbe" "$1" -O "$1"; :
}
remktar()
{
(
x_ cd "${tmpromdir%"/bin/$board"}"
printf "Re-building tar archive (please wait)\n"
mkrom_tarball "bin/$board" 1>/dev/null
) || err "Cannot re-generate '$archive'"
mv "${tmpromdir%"/bin/$board"}/bin/${relname}_${board}.tar.xz" \
"$archive" || err "'$archive' -> Can't overwrite"; :
}

View File

@ -15,17 +15,13 @@ remkdir()
mkrom_tarball()
{
update_xbmkver "$1"
printf "%s\n" "$version" > "$1/.version" || err "$1 !version"
printf "%s\n" "$versiondate" > "$1/.versiondate" || err "$1 !vdate"
mktarball "$1" "${1%/*}/${relname}_${1##*/}.tar.xz"
x_ rm -Rf "$1"
}
update_xbmkver()
{
printf "%s\n" "$version" > "$1/.version" || err "$1 !version"; :
printf "%s\n" "$versiondate" > "$1/.versiondate" || err "$1 !vdate"; :
}
mktarball()
{
printf "Creating tar archive '%s' from directory '%s'\n" "$2" "$1"
@ -33,6 +29,63 @@ mktarball()
x_ tar -c "$1" | xz -T$XBMK_THREADS -9e > "$2" || err "mktarball2, $1"
}
mksha512sum()
{
(
[ "${1%/*}" != "$1" ] && x_ cd "${1%/*}"
sha512sum ./"${1##*/}" >> "$2" || err "!sha512sum \"$1\" > \"$2\""
) || err "failed to create tarball checksum"
}
rmgit()
{
x_ find "$1" -name ".git" -exec rm -Rf {} +
x_ find "$1" -name ".gitmodules" -exec rm -Rf {} +
}
# can grab from the internet, or copy locally.
# if copying locally, it can only copy a file.
xbmkget()
{
_ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
_dlop="curl" && [ $# -gt 4 ] && _dlop="$5"
cached="$XBMK_CACHE/file/$4"
dl_fail="n" # 1 url, 2 url backup, 3 destination, 4 checksum
bad_checksum "$4" "$cached" 2>/dev/null && dl_fail="y"
[ "$dl_fail" = "n" ] && e "$3" f && return 0
x_ mkdir -p "${3%/*}" "$XBMK_CACHE/file"
for url in "$1" "$2"; do
[ "$dl_fail" = "n" ] && break
[ -z "$url" ] && continue
rm -f "$cached" || err "!rm -f '$cached'"
if [ "$_dlop" = "curl" ]; then
curl --location --retry 3 -A "$_ua" "$url" \
-o "$cached" || wget --tries 3 -U "$_ua" "$url" \
-O "$cached" || continue
elif [ "$_dlop" = "copy" ]; then
[ -L "$url" ] && \
printf "dl %s %s %s %s: '%s' is a symlink\n" \
"$1" "$2" "$3" "$4" "$url" 1>&2 && continue
[ ! -f "$url" ] && \
printf "dl %s %s %s %s: '%s' not a file\n" \
"$1" "$2" "$3" "$4" "$url" 1>&2 && continue
cp "$url" "$cached" || continue
else
err "$1 $2 $3 $4: Unsupported dlop type: '$_dlop'"
fi
bad_checksum "$4" "$cached" || dl_fail="n"
done
[ "$dl_fail" = "y" ] && err "$1 $2 $3 $4: not downloaded"
[ "$cached" = "$3" ] || x_ cp "$cached" "$3"; :
}
bad_checksum()
{
[ "$(sha512sum "$2" | awk '{print $1}')" != "$1" ] || return 1
printf "Bad checksum for file: %s\n" "$2" 1>&2; rm -f "$2" || :; :
}
e()
{
es_t="e" && [ $# -gt 1 ] && es_t="$2"
@ -44,6 +97,14 @@ e()
printf "%s %s\n" "$1" "$es2" 1>&2
}
mk()
{
mk_flag="$1" || err "No argument given"
shift 1 && for mk_arg in "$@"; do
x_ ./mk $mk_flag $mk_arg
done; :
}
setvars()
{
_setvars=""
@ -79,8 +140,8 @@ chkvars()
# e.g. coreboot is multi-tree, so 1
singletree()
{
( fx_ "eval exit 1 && err" find "config/$1/"*/ -type f \
-name "target.cfg" ) || return 1; :
( fx_ "exit 1" find "config/$1/"*/ -type f -name "target.cfg" ) || \
return 1
}
findpath()

View File

@ -1,86 +0,0 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (c) 2023-2025 Leah Rowe <leah@libreboot.org>
eval "`setvars "" reldir reldest vdir rsrc relmode`"
release()
{
export XBMK_RELEASE="y"
reldir="release"
while getopts d:m: option; do
[ -z "$OPTARG" ] && err "empty argument not allowed"
case "$option" in
d) reldir="$OPTARG" ;;
m) relmode="$OPTARG" ;;
*) err "invalid option '-$option'" ;;
esac
done
reldest="$reldir/$version"
[ -e "$reldest" ] && \
err "already exists: \"$reldest\""
vdir="$XBMK_CACHE/relpwd/${xbmktmp##*/}/$version"
rsrc="$vdir/${relname}_src"
remkdir "$vdir"
x_ git clone . "$rsrc"
prep_release src
prep_release tarball
[ "$relmode" = "src" ] || prep_release bin
x_ rm -Rf "$rsrc"
x_ mkdir -p "$reldir"
x_ mv "$vdir" "$reldir"
x_ rm -Rf "${vdir%"/$version"}"
printf "\n\nDONE! Check release files under %s\n" "$reldest"
}
prep_release()
{
x_ touch "$rsrc/lock"
(
[ "$1" = "tarball" ] || x_ cd "$rsrc"
prep_release_$1
) || err "can't prep release $1"
}
prep_release_src()
{
x_ ./mk -f
fx_ "x_ rm -Rf" x_ find . -name ".git"
fx_ "x_ rm -Rf" x_ find . -name ".gitmodules"
( fx_ nuke x_ find config -type f -name "nuke.list" ) || err; :
}
nuke()
{
r="$rsrc/src/${1#config/}"
[ -d "${r%/*}" ] && x_ cd "${r%/*}" && \
dx_ "eval [ -L \"\$fx\" ] || x_ rm -Rf" "$rsrc/$1"; :
}
prep_release_tarball()
{
git log --graph --pretty=format:'%Cred%h%Creset %s %Creset' \
--abbrev-commit > "$rsrc/CHANGELOG" || err "!log $rsrc"
x_ rm -f "$rsrc/lock"
x_ rm -Rf "$rsrc/cache" "$rsrc/tmp"
(
x_ cd "${rsrc%/*}"
x_ mktarball "${rsrc##*/}" "${rsrc##*/}.tar.xz"
) || err "can't create src tarball"; :
}
prep_release_bin()
{
fx_ "x_ ./mk -b" printf \
"coreboot\npico-serprog\nstm32-vserprog\npcsx-redux\n"
fx_ mkrom_tarball x_ find bin -maxdepth 1 -type d -name "serprog_*"
x_ mv bin ../roms
}

View File

@ -44,7 +44,7 @@ mkpayload_grub()
mkvendorfiles()
{
[ -z "$mode" ] && $dry cook_coreboot_config
fx_ check_coreboot_util printf "cbfstool\nifdtool\n"
check_coreboot_utils "$tree"
printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \
err "!mk $srcdir .coreboot-version"; :
}
@ -57,24 +57,26 @@ cook_coreboot_config()
make -C "$srcdir" oldconfig || err "Could not cook $srcdir/.config"; :
}
check_coreboot_util()
check_coreboot_utils()
{
[ "$badhash" = "y" ] && x_ rm -f "elf/$1/$tree/$1"
e "elf/$1/$tree/$1" f && return 0
for util in cbfstool ifdtool; do
[ "$badhash" = "y" ] && x_ rm -f "elf/$util/$1/$util"
e "elf/$util/$1/$util" f && continue
utilelfdir="elf/$1/$tree"
utilsrcdir="src/coreboot/$tree/util/$1"
utilelfdir="elf/$util/$1"
utilsrcdir="src/coreboot/$1/util/$util"
utilmode="" && [ -n "$mode" ] && utilmode="clean"
x_ make -C "$utilsrcdir" $utilmode -j$XBMK_THREADS $makeargs
[ -n "$mode" ] && x_ rm -Rf "$utilelfdir" && return 0
[ -z "$mode" ] || return 0
[ -f "$utilelfdir/$1" ] && return 0
x_ mkdir -p "$utilelfdir"
x_ cp "$utilsrcdir/$1" "$utilelfdir"
[ "$1" = "cbfstool" ] || return 0
x_ cp "$utilsrcdir/rmodtool" "$utilelfdir"
utilmode="" && [ -n "$mode" ] && utilmode="clean"
x_ make -C "$utilsrcdir" $utilmode -j$XBMK_THREADS $makeargs
if [ -z "$mode" ] && [ ! -f "$utilelfdir/$util" ]; then
x_ mkdir -p "$utilelfdir"
x_ cp "$utilsrcdir/$util" "$utilelfdir"
[ "$util" = "cbfstool" ] || continue
x_ cp "$utilsrcdir/rmodtool" "$utilelfdir"
elif [ -n "$mode" ]; then
x_ rm -Rf "$utilelfdir"
fi; :
done; :
}
mkcorebootbin()

View File

@ -1,339 +0,0 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (c) 2022-2023 Alper Nebi Yasak <alpernebiyasak@gmail.com>
# Copyright (c) 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
# Copyright (c) 2023-2025 Leah Rowe <leah@libreboot.org>
eval "`setvars "" xarch srcdir premake gnatdir xlang mode makeargs elfdir cmd \
project target target_dir targets xtree _f release bootstrapargs mkhelper \
autoconfargs listfile autogenargs btype rev build_depend gccdir cmakedir \
defconfig postmake mkhelpercfg dry dest_dir mdir cleanargs gccver gccfull \
gnatver gnatfull do_make badhash tree`"
trees()
{
flags="f:b:m:u:c:x:s:l:n:d:"
while getopts $flags option; do
[ -n "$_f" ] && err "only one flag is permitted"
_f="$1"
case "$_f" in
-d) dry=":" ;;
-b) : ;;
-u) mode="oldconfig" ;;
-m) mode="menuconfig" ;;
-c) mode="distclean" ;;
-x) mode="crossgcc-clean" ;;
-f)
do_make="n"
dry=":" ;;
-s) mode="savedefconfig" ;;
-l) mode="olddefconfig" ;;
-n) mode="nconfig" ;;
*) err "invalid option '-$option'" ;;
esac
if [ -z "${OPTARG+x}" ]; then
shift 1
break
fi
project="${OPTARG#src/}"
project="${project#config/git/}"
shift 2
done
[ -z "$_f" ] && err "missing flag ($flags)"
[ -z "$project" ] && fx_ "x_ ./mk $_f" x_ ls -1 config/git && return 1
[ -f "config/git/$project/pkg.cfg" ] || \
err "config/git/$project/pkg.cfg missing"
for d in "elf" "config/data" "config" "src"; do
eval "${d#*/}dir=\"$d/$project\""
done
dest_dir="$elfdir"
listfile="$datadir/build.list"
[ -f "$listfile" ] || listfile="" # optional on all projects
mkhelpercfg="$datadir/mkhelper.cfg"
if e "$mkhelpercfg" f missing; then
mkhelpercfg="$xbmktmp/mkhelper.cfg"
x_ touch "$mkhelpercfg"
fi
targets="$*"
cmd="build_targets $targets"
singletree "$project" && cmd="build_project"
remkdir "${tmpgit%/*}"
}
build_project()
{
configure_project "$configdir" || return 0
[ ! -f "$listfile" ] || $dry elfcheck || return 0
[ "$mode" = "distclean" ] && mode="clean"
run_make_command || return 0
[ -n "$mode" ] || $dry copy_elf; :
}
build_targets()
{
[ -d "$configdir" ] || err "directory, $configdir, does not exist"
[ $# -gt 0 ] || targets="$(ls -1 "$configdir")" || err "!o $configdir"
for x in $targets; do
unset CROSS_COMPILE
export PATH="$xbmkpath"
[ "$x" = "list" ] && x_ ls -1 "config/$project" && \
listfile="" && break
target="$x"
printf "'make %s', '%s', '%s'\n" "$mode" "$project" "$target"
x_ handle_defconfig
[ -n "$mode" ] || x_ $postmake
done; :
}
handle_defconfig()
{
target_dir="$configdir/$target"
[ -f "CHANGELOG" ] || fetch_project "$project"
configure_project "$target_dir" || return 0
chkvars tree
srcdir="src/$project/$tree"
[ "$mode" = "${mode%clean}" ] && [ ! -d "$srcdir" ] && return 0
[ -z "$mode" ] && for _xarch in $xarch; do
$dry check_cross_compiler "$_xarch"
done; :
for y in "$target_dir/config"/*; do
[ "$_f" = "-d" ] || [ -f "$y" ] || continue
[ "$_f" = "-d" ] || defconfig="$y"
[ -n "$mode" ] || check_defconfig || continue
handle_makefile
[ -n "$mode" ] || $dry copy_elf
done; :
}
configure_project()
{
eval "`setvars "" cleanargs build_depend autoconfargs xtree postmake \
makeargs btype mkhelper bootstrapargs premake release xlang xarch \
badhash`"
_tcfg="$1/target.cfg"
[ -f "$_tcfg" ] || btype="auto"
e "$datadir/mkhelper.cfg" f && eval "`setcfg "$datadir/mkhelper.cfg"`"
while e "$_tcfg" f || [ "$cmd" != "build_project" ]; do
eval "`setvars "" rev tree`"
eval "`setcfg "$_tcfg"`"
printf "Loading %s config: %s\n" "$project" "$_tcfg"
[ "$_f" = "-d" ] && build_depend="" # dry run
[ "$cmd" = "build_project" ] && break
[ "$do_make" != "n" ] && break
[ "${_tcfg%/*/target.cfg}" = "${_tcfg%"/$tree/target.cfg"}" ] \
&& break
_tcfg="${_tcfg%/*/target.cfg}/$tree/target.cfg"
done
[ "$XBMK_RELEASE" = "y" ] && [ "$release" = "n" ] && return 1
[ -z "$btype" ] || [ "${mode%config}" = "$mode" ] || return 1
[ -z "$mode" ] && $dry build_dependencies
mdir="$xbmkpwd/config/submodule/$project"
[ -n "$tree" ] && mdir="$mdir/$tree"
[ -f "CHANGELOG" ] || check_project_hashes
if [ "$do_make" = "n" ]; then
[ -f "CHANGELOG" ] || fetch_${cmd#build_}
return 1
fi
x_ ./mk -f "$project" "$target"
}
build_dependencies()
{
for bd in $build_depend; do
bd_p="${bd%%/*}"
bd_t="${bd##*/}"
[ -z "$bd_p" ] && $dry err "$project/$tree: !bd '$bd'"
[ "${bd##*/}" = "$bd" ] && bd_t=""
[ -z "$bd_p" ] || $dry x_ ./mk -b $bd_p $bd_t; :
done; :
}
check_project_hashes()
{
old_pjhash="" && x_ mkdir -p "$XBMK_CACHE/hash"
[ ! -f "$XBMK_CACHE/hash/$project$tree" ] || \
read -r old_pjhash < "$XBMK_CACHE/hash/$project$tree"
fx_ "x_ sha512sum" find "$datadir" "$configdir/$tree" "$mdir" \
-type f -not -path "*/.git*/*" | awk '{print $1}' > \
"$xbmktmp/project.hash" || err "!h $project $tree"
pjhash="$(sha512sum "$xbmktmp/project.hash" | awk '{print $1}')" || :
[ "$pjhash" != "$old_pjhash" ] && badhash="y"
[ -f "$XBMK_CACHE/hash/$project$tree" ] || badhash="y"
printf "%s\n" "$pjhash" > "$XBMK_CACHE/hash/$project$tree" || \
err "!mk $XBMK_CACHE/hash/$project$tree"
[ "$badhash" != "y" ] || x_ rm -Rf "src/$project/$tree" \
"elf/$project/$tree" "elf/$project/$target"; :
}
check_cross_compiler()
{
cbdir="src/coreboot/$tree"
[ "$project" != "coreboot" ] && cbdir="src/coreboot/default"
[ -n "$xtree" ] && cbdir="src/coreboot/$xtree"
x_ ./mk -f coreboot "${cbdir#src/coreboot/}"
export PATH="$xbmkpwd/$cbdir/util/crossgcc/xgcc/bin:$PATH"
export CROSS_COMPILE="${xarch% *}-"
[ -n "$xlang" ] && export BUILD_LANGUAGES="$xlang"
# match gnat-X to gcc
check_gnu_path gcc gnat || x_ check_gnu_path gnat gcc
xfix="${1%-*}" && [ "$xfix" = "x86_64" ] && xfix="x64"
xgccargs="crossgcc-$xfix UPDATED_SUBMODULES=1 CPUS=$XBMK_THREADS"
make -C "$cbdir" $xgccargs || x_ make -C "$cbdir" $xgccargs
# we only want to mess with hostcc to build xgcc
remkdir "$XBMK_CACHE/gnupath"
}
# fix mismatching gcc/gnat versions on debian trixie/sid. as of december 2024,
# trixie/sid had gnat-13 as gnat and gcc-14 as gcc, but has gnat-14 in apt. in
# some cases, gcc 13+14 and gnat-13 are present; or gnat-14 and gcc-14, but
# gnat in PATH never resolves to gnat-14, because gnat-14 was "experimental"
check_gnu_path()
{
command -v "$1" 1>/dev/null || err "Host '$1' unavailable"
eval "`setvars "" gccver gccfull gnatver gnatfull gccdir gnatdir`"
x_ gnu_setver "$1" "$1" || err "Command '$1' unavailable."
gnu_setver "$2" "$2" || :
eval "[ -z \"\$$1ver\" ] && err \"Cannot detect host '$1' version\""
[ "$gnatfull" = "$gccfull" ] && return 0
eval "$1dir=\"$(dirname "$(command -v "$1")")\""
eval "_gnudir=\"\$$1dir\"; _gnuver=\"\$$1ver\""
for _bin in "$_gnudir/$2-"*; do
[ "${_bin#"$_gnudir/$2-"}" = "$_gnuver" ] && [ -x "$_bin" ] \
&& _gnuver="${_bin#"$_gnudir/$2-"}" && break; :
done
gnu_setver "$2" "$_gnudir/$2-$_gnuver" || return 1
[ "$gnatfull" = "$gccfull" ] || return 1
(
remkdir "$XBMK_CACHE/gnupath" && x_ cd "$XBMK_CACHE/gnupath"
for _gnubin in "$_gnudir/$2"*"-$_gnuver"; do
_gnuutil="${_gnubin##*/}" && [ -e "$_gnubin" ] && \
x_ ln -s "$_gnubin" "${_gnuutil%"-$_gnuver"}"
done
) || err "Cannot create $2-$_gnuver link in $_gnudir"; :
}
gnu_setver()
{
eval "$2 --version 1>/dev/null 2>/dev/null || return 1"
eval "$1ver=\"`"$2" --version 2>/dev/null | head -n1`\""
eval "$1ver=\"\${$1ver##* }\""
eval "$1full=\"\$$1ver\""
eval "$1ver=\"\${$1ver%%.*}\""; :
}
check_defconfig()
{
[ -f "$defconfig" ] || $dry err "$project/$target: missing defconfig"
dest_dir="$elfdir/$target/${defconfig#"$target_dir/config/"}"
$dry elfcheck || return 1; : # skip build if a previous one exists
}
elfcheck()
{
# TODO: *STILL* very hacky check. do it properly (based on build.list)
( fx_ "eval exit 1 && err" find "$dest_dir" -type f ) || return 1; :
}
handle_makefile()
{
$dry check_makefile "$srcdir" && 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!"
_copy=".config" && [ "$mode" = "savedefconfig" ] && _copy="defconfig"
[ "${mode%config}" = "$mode" ] || \
$dry x_ cp "$srcdir/$_copy" "$defconfig"
[ -e "$srcdir/.git" ] && [ "$project" = "u-boot" ] && \
[ "$mode" = "distclean" ] && \
$dry x_ git -C "$srcdir" $cleanargs clean -fdx; :
}
run_make_command()
{
[ -n "$mode" ] || x_ $premake
$dry check_cmake "$srcdir" && [ -z "$mode" ] && \
$dry check_autoconf "$srcdir"
$dry check_makefile "$srcdir" || return 1
$dry x_ make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs
[ -n "$mode" ] || x_ $mkhelper
[ "$mode" != "clean" ] || \
$dry make -C "$srcdir" $cleanargs distclean || :; :
}
check_cmake()
{
[ -z "$cmakedir" ] || $dry check_makefile "$1" || cmake -B "$1" \
"$1/$cmakedir" || $dry x_ check_makefile "$1"
[ -z "$cmakedir" ] || $dry x_ check_makefile "$1"; :
}
check_autoconf()
{
(
x_ cd "$1"
[ -f "bootstrap" ] && x_ ./bootstrap $bootstrapargs
[ -f "autogen.sh" ] && x_ ./autogen.sh $autogenargs
[ -f "configure" ] && x_ ./configure $autoconfargs; :
) || err "can't bootstrap project: $1"; :
}
check_makefile()
{
[ -f "$1/Makefile" ] || [ -f "$1/makefile" ] || \
[ -f "$1/GNUmakefile" ] || return 1; :
}
copy_elf()
{
[ -f "$listfile" ] && x_ mkdir -p "$dest_dir" && while read -r f; do
[ -f "$srcdir/$f" ] && x_ cp "$srcdir/$f" "$dest_dir"
done < "$listfile"
x_ make clean -C "$srcdir" $cleanargs
}

416
mk
View File

@ -2,6 +2,8 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (c) 2020-2025 Leah Rowe <leah@libreboot.org>
# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
# Copyright (c) 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
# Copyright (c) 2022-2023 Alper Nebi Yasak <alpernebiyasak@gmail.com>
set -u -e
@ -11,11 +13,12 @@ if [ "./${0##*/}" != "${0}" ] || [ ! -f "mk" ] || [ -L "mk" ]; then
fi
. "include/lib.sh"
. "include/init.sh"
. "include/inject.sh"
. "include/rom.sh"
. "include/release.sh"
. "include/get.sh"
eval "`setvars "" vdir src_dirname srcdir mode`"
main()
{
@ -24,16 +27,417 @@ main()
case "$cmd" in
version) printf "%s\nWebsite: %s\n" "$relname" "$projectsite" ;;
release|inject) $cmd "$@" ;;
-*) return 0 ;;
-*) return 1 ;;
*) err "bad command" ;;
esac
set -u -e # some commands disable them. turn them on!
return 1
}
main "$@" || exit 0
release()
{
export XBMK_RELEASE="y"
. "include/tree.sh"
vdir="release"
while getopts d:m: option; do
[ -z "$OPTARG" ] && err "empty argument not allowed"
case "$option" in
d) vdir="$OPTARG" ;;
m) mode="$OPTARG" ;;
*) err "invalid option '-$option'" ;;
esac
done
vdir="$vdir/$version"
src_dirname="${relname}_src"
srcdir="$vdir/$src_dirname"
[ -e "$vdir" ] && err "already exists: \"$vdir\""
mkdir -p "$vdir" || err "mkvdir: !mkdir -p \"$vdir\""
git clone . "$srcdir" || err "mkdir: !gitclone \"$srcdir\""
touch "$srcdir/lock" || err "can't make lock file in $srcdir/"
build_release
printf "\n\nDONE! Check release files under %s\n" "$vdir"
}
build_release()
{
(
cd "$srcdir" || err "$vdir: !cd \"$srcdir\""
x_ ./mk -f
rmgit .
x_ mv src/docs docs
) || err "can't create release files"
git log --graph --pretty=format:'%Cred%h%Creset %s %Creset' \
--abbrev-commit > "$srcdir/CHANGELOG" || err "!gitlog $srcdir"
rm -f "$srcdir/lock" || err "can't remove lock file in $srcdir"
(
cd "${srcdir%/*}" || err "$vdir: mktarball \"$srcdir\""
mktarball "${srcdir##*/}" "${srcdir##*/}.tar.xz" || err "$vdir: mksrc"
) || err "can't create src tarball"
[ "$mode" = "src" ] && return 0
touch "$srcdir/lock" || err "can't make lock file in $srcdir/"
(
cd "$srcdir" || err "$vdir: 2 !cd \"$srcdir\""
mk -b coreboot pico-serprog stm32-vserprog pcsx-redux
fx_ mkrom_tarball x_ find bin -maxdepth 1 -type d -name "serprog_*"
x_ mv bin ../roms
) || err "can't build rom images"
rm -Rf "$srcdir" || err "!rm -Rf $srcdir"
}
main "$@" && exit 0
# what follows was formerly script/trees, whose main() is now trees()
. "include/git.sh"
eval "`setvars "" xarch srcdir premake gnatdir xlang mode makeargs elfdir cmd \
project target target_dir targets xtree _f release bootstrapargs mkhelper \
autoconfargs listfile autogenargs btype rev build_depend gccdir cmakedir \
defconfig postmake mkhelpercfg dry dest_dir mdir cleanargs gccver gccfull \
gnatver gnatfull do_make badhash tree`"
trees()
{
flags="f:b:m:u:c:x:s:l:n:d:"
while getopts $flags option; do
[ -n "$_f" ] && err "only one flag is permitted"
_f="$1"
case "$_f" in
-d) dry=":" ;;
-b) : ;;
-u) mode="oldconfig" ;;
-m) mode="menuconfig" ;;
-c) mode="distclean" ;;
-x) mode="crossgcc-clean" ;;
-f)
do_make="n"
dry=":" ;;
-s) mode="savedefconfig" ;;
-l) mode="olddefconfig" ;;
-n) mode="nconfig" ;;
*) err "invalid option '-$option'" ;;
esac
if [ -z "${OPTARG+x}" ]; then
shift 1
break
fi
project="${OPTARG#src/}"
shift 2
done
[ -z "$_f" ] && err "missing flag ($flags)"
if [ -z "$project" ]; then
mk $_f $(ls -1 config/git)
return 1
fi
[ -f "config/git/$project/pkg.cfg" ] || \
err "config/git/$project/pkg.cfg missing"
for d in "elf" "config/data" "config" "src"; do
eval "${d#*/}dir=\"$d/$project\""
done
dest_dir="$elfdir"
listfile="$datadir/build.list"
[ -f "$listfile" ] || listfile="" # optional on all projects
mkhelpercfg="$datadir/mkhelper.cfg"
if e "$mkhelpercfg" f missing; then
mkhelpercfg="$xbmktmp/mkhelper.cfg"
x_ touch "$mkhelpercfg"
fi
targets="$*"
cmd="build_targets $targets"
singletree "$project" && cmd="build_project"
remkdir "${tmpgit%/*}"
}
build_project()
{
configure_project "$configdir" || return 0
[ ! -f "$listfile" ] || $dry elfcheck || return 0
[ "$mode" = "distclean" ] && mode="clean"
run_make_command || return 0
[ -n "$mode" ] || $dry copy_elf; :
}
build_targets()
{
[ -d "$configdir" ] || err "directory, $configdir, does not exist"
[ $# -gt 0 ] || targets="$(ls -1 "$configdir")" || err "!o $configdir"
for x in $targets; do
unset CROSS_COMPILE
export PATH="$xbmkpath"
[ "$x" = "list" ] && x_ ls -1 "config/$project" && \
listfile="" && break
target="$x"
printf "'make %s', '%s', '%s'\n" "$mode" "$project" "$target"
x_ handle_defconfig
[ -n "$mode" ] || x_ $postmake
done; :
}
handle_defconfig()
{
target_dir="$configdir/$target"
[ -f "CHANGELOG" ] || fetch_project "$project"
configure_project "$target_dir" || return 0
x_ mkdir -p "$elfdir/$target"
chkvars tree
srcdir="src/$project/$tree"
if [ "$mode" = "distclean" ] || [ "$mode" = "crossgcc-clean" ]; then
[ -d "$srcdir" ] || return 0
fi
[ -z "$mode" ] && for _xarch in $xarch; do
$dry check_cross_compiler "$_xarch"
done; :
for y in "$target_dir/config"/*; do
[ "$_f" = "-d" ] || [ -f "$y" ] || continue
[ "$_f" = "-d" ] || defconfig="$y"
[ -n "$mode" ] || check_defconfig || continue
handle_makefile
[ -n "$mode" ] || $dry copy_elf
done; :
}
configure_project()
{
eval "`setvars "" cleanargs build_depend autoconfargs xtree postmake \
makeargs btype mkhelper bootstrapargs premake release xlang xarch \
badhash`"
_tcfg="$1/target.cfg"
[ -f "$_tcfg" ] || btype="auto"
e "$datadir/mkhelper.cfg" f && eval "`setcfg "$datadir/mkhelper.cfg"`"
while e "$_tcfg" f || [ "$cmd" != "build_project" ]; do
eval "`setvars "" rev tree`"
eval "`setcfg "$_tcfg"`"
printf "Loading %s config: %s\n" "$project" "$_tcfg"
[ "$_f" = "-d" ] && build_depend="" # dry run
[ "$cmd" = "build_project" ] && break
[ "$do_make" != "n" ] && break
[ "${_tcfg%/*/target.cfg}" = "${_tcfg%"/$tree/target.cfg"}" ] \
&& break
_tcfg="${_tcfg%/*/target.cfg}/$tree/target.cfg"
done
[ "$XBMK_RELEASE" = "y" ] && [ "$release" = "n" ] && return 1
[ -z "$btype" ] || [ "${mode%config}" = "$mode" ] || return 1
[ -z "$mode" ] && $dry build_dependencies
mdir="$xbmkpwd/config/submodule/$project"
[ -n "$tree" ] && mdir="$mdir/$tree"
[ -f "CHANGELOG" ] || check_project_hashes
if [ "$do_make" = "n" ]; then
[ -f "CHANGELOG" ] || fetch_${cmd#build_}
return 1
fi
x_ ./mk -f "$project" "$target"
}
build_dependencies()
{
for bd in $build_depend; do
bd_p="${bd%%/*}"
bd_t="${bd##*/}"
[ -z "$bd_p" ] && $dry err "$project/$tree: !bd '$bd'"
[ "${bd##*/}" = "$bd" ] && bd_t=""
[ -z "$bd_p" ] || $dry x_ ./mk -b $bd_p $bd_t; :
done; :
}
check_project_hashes()
{
old_pjhash="" && x_ mkdir -p "$XBMK_CACHE/hash"
[ ! -f "$XBMK_CACHE/hash/$project$tree" ] || \
read -r old_pjhash < "$XBMK_CACHE/hash/$project$tree"
fx_ "x_ sha512sum" find "$datadir" "$configdir/$tree" "$mdir" \
-type f -not -path "*/.git*/*" | awk '{print $1}' > \
"$xbmktmp/project.hash" || err "!h $project $tree"
pjhash="$(sha512sum "$xbmktmp/project.hash" | awk '{print $1}')" || :
[ "$pjhash" != "$old_pjhash" ] && badhash="y"
[ -f "$XBMK_CACHE/hash/$project$tree" ] || badhash="y"
printf "%s\n" "$pjhash" > "$XBMK_CACHE/hash/$project$tree" || \
err "!mk $XBMK_CACHE/hash/$project$tree"
[ "$badhash" != "y" ] || x_ rm -Rf "src/$project/$tree" \
"elf/$project/$tree" "elf/$project/$target"; :
}
check_cross_compiler()
{
cbdir="src/coreboot/$tree"
[ "$project" != "coreboot" ] && cbdir="src/coreboot/default"
[ -n "$xtree" ] && cbdir="src/coreboot/$xtree"
x_ ./mk -f coreboot "${cbdir#src/coreboot/}"
export PATH="$xbmkpwd/$cbdir/util/crossgcc/xgcc/bin:$PATH"
export CROSS_COMPILE="${xarch% *}-"
[ -n "$xlang" ] && export BUILD_LANGUAGES="$xlang"
# match gnat-X to gcc
check_gnu_path gcc gnat || x_ check_gnu_path gnat gcc
xfix="${1%-*}" && [ "$xfix" = "x86_64" ] && xfix="x64"
xgccargs="crossgcc-$xfix UPDATED_SUBMODULES=1 CPUS=$XBMK_THREADS"
make -C "$cbdir" $xgccargs || x_ make -C "$cbdir" $xgccargs
# we only want to mess with hostcc to build xgcc
remkdir "$XBMK_CACHE/gnupath"
}
# fix mismatching gcc/gnat versions on debian trixie/sid. as of december 2024,
# trixie/sid had gnat-13 as gnat and gcc-14 as gcc, but has gnat-14 in apt. in
# some cases, gcc 13+14 and gnat-13 are present; or gnat-14 and gcc-14, but
# gnat in PATH never resolves to gnat-14, because gnat-14 was "experimental"
check_gnu_path()
{
command -v "$1" 1>/dev/null || err "Host '$1' unavailable"
eval "`setvars "" gccver gccfull gnatver gnatfull gccdir gnatdir`"
x_ gnu_setver "$1" "$1" || err "Command '$1' unavailable."
gnu_setver "$2" "$2" || :
eval "[ -z \"\$$1ver\" ] && err \"Cannot detect host '$1' version\""
[ "$gnatfull" = "$gccfull" ] && return 0
eval "$1dir=\"$(dirname "$(command -v "$1")")\""
eval "_gnudir=\"\$$1dir\"; _gnuver=\"\$$1ver\""
for _bin in "$_gnudir/$2-"*; do
[ "${_bin#"$_gnudir/$2-"}" = "$_gnuver" ] && [ -x "$_bin" ] \
&& _gnuver="${_bin#"$_gnudir/$2-"}" && break; :
done
gnu_setver "$2" "$_gnudir/$2-$_gnuver" || return 1
[ "$gnatfull" = "$gccfull" ] || return 1
(
remkdir "$XBMK_CACHE/gnupath" && x_ cd "$XBMK_CACHE/gnupath"
for _gnubin in "$_gnudir/$2"*"-$_gnuver"; do
_gnuutil="${_gnubin##*/}" && [ -e "$_gnubin" ] && \
x_ ln -s "$_gnubin" "${_gnuutil%"-$_gnuver"}"
done
) || err "Cannot create $2-$_gnuver link in $_gnudir"; :
}
gnu_setver()
{
eval "$2 --version 1>/dev/null 2>/dev/null || return 1"
eval "$1ver=\"`"$2" --version 2>/dev/null | head -n1`\""
eval "$1ver=\"\${$1ver##* }\""
eval "$1full=\"\$$1ver\""
eval "$1ver=\"\${$1ver%%.*}\""; :
}
check_defconfig()
{
[ -f "$defconfig" ] || $dry err "$project/$target: missing defconfig"
dest_dir="$elfdir/$target/${defconfig#"$target_dir/config/"}"
$dry elfcheck || return 1 # skip build if a previous one exists
$dry x_ mkdir -p "$dest_dir"
}
elfcheck()
{
# TODO: *STILL* very hacky check. do it properly (based on build.list)
( fx_ "exit 1" find "$dest_dir" -type f ) || return 1; :
}
handle_makefile()
{
$dry check_makefile "$srcdir" && 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!"
_copy=".config" && [ "$mode" = "savedefconfig" ] && _copy="defconfig"
[ "${mode%config}" = "$mode" ] || \
$dry x_ cp "$srcdir/$_copy" "$defconfig"
[ -e "$srcdir/.git" ] && [ "$project" = "u-boot" ] && \
[ "$mode" = "distclean" ] && \
$dry x_ git -C "$srcdir" $cleanargs clean -fdx; :
}
run_make_command()
{
[ -n "$mode" ] || x_ $premake
$dry check_cmake "$srcdir" && [ -z "$mode" ] && \
$dry check_autoconf "$srcdir"
$dry check_makefile "$srcdir" || return 1
$dry x_ make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs
[ -n "$mode" ] || x_ $mkhelper
[ "$mode" != "clean" ] || \
$dry make -C "$srcdir" $cleanargs distclean || :; :
}
check_cmake()
{
[ -z "$cmakedir" ] || $dry check_makefile "$1" || cmake -B "$1" \
"$1/$cmakedir" || $dry x_ check_makefile "$1"
[ -z "$cmakedir" ] || $dry x_ check_makefile "$1"; :
}
check_autoconf()
{
(
cd "$1" || err "!cd $1"
[ -f "bootstrap" ] && x_ ./bootstrap $bootstrapargs
[ -f "autogen.sh" ] && x_ ./autogen.sh $autogenargs
[ -f "configure" ] && x_ ./configure $autoconfargs; :
) || err "can't bootstrap project: $1"; :
}
check_makefile()
{
[ -f "$1/Makefile" ] || [ -f "$1/makefile" ] || \
[ -f "$1/GNUmakefile" ] || return 1; :
}
copy_elf()
{
[ -f "$listfile" ] && x_ mkdir -p "$dest_dir" && while read -r f; do
[ -f "$srcdir/$f" ] && x_ cp "$srcdir/$f" "$dest_dir"
done < "$listfile"
x_ make clean -C "$srcdir" $cleanargs
}
trees "$@" || exit 0
. "$mkhelpercfg"