64 Commits

Author SHA1 Message Date
Leah Rowe
1b10c072d3 tree.sh: tidy up check_gnu_path
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-11-15 16:57:48 +00:00
Leah Rowe
2aea7f6229 Revert "get.sh: make forcepull a macro"
This reverts commit b3232a7c4a.
2025-10-17 16:07:16 +01:00
Leah Rowe
b3232a7c4a get.sh: make forcepull a macro
:

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-17 14:02:55 +01:00
Leah Rowe
54aa5b7d32 tree.sh: unify -f/-F in case/switch handling
they're the same commands, but -F does forcepull

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-17 13:57:14 +01:00
Leah Rowe
96f786b962 tree.sh: convert do_make into a macro
use it similarly to if_dry_build/if_not_dry_build

there is nothing cooler than an sh macro

:

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-17 13:29:56 +01:00
Leah Rowe
e1b6ccf69e xbmk: sort global variables alphabetically
also separate some of the special ones.

this makes the variables easier to read/find.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-16 15:46:44 +01:00
Leah Rowe
fb95e4ad68 tree.sh: add missing -F flag
i support -F, but didn't include it in the
actual getopt string.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-07 03:02:01 +01:00
Leah Rowe
8636d7497c rom.sh/tree.sh: clean up if_not_dry_build
the way it was used is messy, and a relic of the
old chained command coding style, from before when
i recently loosened that requirement.

the new focus is simple, readable code, regardless
of size.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-06 13:28:34 +01:00
Leah Rowe
1b54c7a744 rom.sh: use if_dry_build macro
instead of checking if_not_dry_build.

use it here the same way.

yes. shell script macros. it's how i roll.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-06 12:43:04 +01:00
Leah Rowe
c1d6cd22c2 xbmk: don't call mkdir. use xbmkdir (new function)
xbmkdir checks if a directory exists, before running
mkdir, and then still uses -p

i was testing xbmk on arch linux today, and noticed
that it errored out when a directory already exists.

i'm mitigating against buggy or differently behaving
mkdir implementations this way, by wrapping around
it.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-04 22:42:42 +01:00
Leah Rowe
8969cc734f xbmk: use sbase sha512sum, not host sha512sum
the --status flag seems to be a GNUism

as stated in the previous commit, i import sbase
suckless now, so as to have a consistent implementation
of sha512sum.

this ensures that its output is reliable, when i'm using
the output of this command within backticks.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-04 09:58:24 +01:00
Leah Rowe
1943dba608 tree.sh: rename xtree to xgcctree, for clarity
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-04 08:37:41 +01:00
Leah Rowe
51e424c7d1 tree.sh: rename btype to buildtype, for clarity
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-04 08:36:18 +01:00
Leah Rowe
63002732f5 tree.sh: rename _f to flag, for code clarity
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-04 08:29:33 +01:00
Leah Rowe
b4c7cac8a2 xbmk: rename the "dry" variable to if_not_dry_run
and add a line break where it is used

now it is essentially a macro of sorts, used in
terms of syntax, to mean the same as:

if [ "$dry" != ":" ]; do
	thing
fi

in this case, we say:

$if_not_dry_build \
	thing

yes. macros in sh are a thing.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-04 07:50:34 +01:00
Leah Rowe
4f01dc704a xbmk: remove even more eval statements
in one or two cases, the use of eval is retained, but
modified so as to be safer.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-04 07:17:42 +01:00
Leah Rowe
7f8d85140f xbmk: remove the setcfg function
this allows me to remove several eval calls, and the
errors relating to configs can now show exactly which
function they occured in, allowing for easier debugging.

once again, eval should be used sparingly if at all.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-04 05:23:47 +01:00
Leah Rowe
0a74cc8ec6 xbmk: clean up a few err calls
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-04 03:05:23 +01:00
Leah Rowe
0605fbe720 xbmk: general cleanup: unroll condensed code lines
i overlooked a number of lines, during previous cleanup

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-04 02:43:24 +01:00
Leah Rowe
a74af6aa05 tree.sh: remove superfluous eval statements
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-02 06:55:29 +01:00
Leah Rowe
be1f4ebb9c get.sh: allow force-pull via -F instead of -f
use of ./mk -F behaves the same as -f before the
previous commit.

this can be useful, during development when we want
to update revisions.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-01 16:51:00 +01:00
Leah Rowe
8b351e51aa tree.sh: break up check_gnu_path to subfunctions
this whole check could probably be removed, honestly.

it was only put in place during the debian trixie testing
release cycle, before they finally updated gnat just before
the stable release of trixie came out.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-01 07:43:12 +01:00
Leah Rowe
e42cb4f4cd xbmk: tidy up some if statements
this is an extension of the previous work to unroll
most of the condensed code lines.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-26 00:09:46 +01:00
Leah Rowe
4686ba8a4a make notices a bit more readable
add line breaks, so that the license and author are
visually separated. this makes it easier to read.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-24 20:14:51 +01:00
Leah Rowe
8347e2c85d xbmk: cleanup of recent code refactoring
be a bit less pedantic about if else clauses. leave the
big ones still with then on separate lines, where else
is specified.

also unroll a few condensed code lines where i missed
a few.

sloccount 2303 in lbmk. that's still only slightly bigger
than libreboot 20260907 which was 2180, and still much
smaller than libreboot 20230625 which was 3322.

this is *without* the condensed codelines, so now the only
thing that's reduced is the overall amount of logic present
in the build system.

and i should clarify that lbmk is presently much more powerful
than both of those two versions (20160907/20230625).

the 2016 one is useful for comparison historically, since that
was the last major version of libreboot prior to the great
second coming of leah in 2021; and the 2023 june release was
basically the last one before the great audits of 2023 to
2025 began.

not to brag (not much anyway), but all of this means that lbmk
is an insanely efficient build system, considering all the
features it has and what it does.

i unrolled the condensed code style in lbmk, making the scripts
a lot easier to read, because i received complainst about the
condensed style previously used; nicholas chin and alper nebi
yasak both told me that it sucked, and riku viitanen had hinted
at that same fact several months prior.

so hopefully now, lbmk is a bit nicer. those and other people
often find it challenging to challenge me because for reason
they assume i'll get upset and fly off the handle, but it's the
opposite. i want constant criticism, so that i know to improve!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-24 13:19:23 +01:00
Leah Rowe
e282586427 tree.sh: unroll condensed commands
i went further than in the previosu commit. in this
commit, i also provide indentation inside subshells,
to make it clearer that soomething is being done
inside a subshell.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-23 05:55:18 +01:00
Leah Rowe
c11c5a7a14 Revert "xbmk: don't use backticks for command substitution"
This reverts commit 4999a49de3.
2025-09-18 23:35:12 +01:00
Leah Rowe
c734a6e757 tree.sh: fix bad variable reference
we didn't want to say a variable name here.
we only wanted to say "trees".

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-14 19:23:40 +01:00
Leah Rowe
995963baf4 xbmk: much more verbose error messages
use the new functionality in err(), whereby a given
function name and arguments can be provided, for
debugging purposes.

something similar was already done in a few places,
and replaced with this unified functionality.

this patch will make xbmk much easier to debug, under
fault conditions.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-13 13:27:47 +01:00
Leah Rowe
4999a49de3 xbmk: don't use backticks for command substitution
the newer way handles escaped characters better, and it
can be nested more easily. it's also more readable.

personally, i prefer the old way, because it's more
minimalist, but it occurs to me that a lot of people
nowadays don't know about backticks, but they do know
of the modern way.

to make the code more readable, i have modernised it.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-11 10:29:59 +01:00
Leah Rowe
53491bdca2 tree.sh: don't combine remkdir/cd gnupath
it's stupid. separate them, to make the code readable.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-07 17:49:12 +01:00
Leah Rowe
4475b4db4b init.sh/tree.sh: put PATH dirs in xbtmp
e.g. gnupath, xbmkpath

these currently go in XBMK_CACHE/, which is bad
because they're meant to be temporary.

XBMK_CACHE is for permanent files.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-07 15:24:02 +01:00
Leah Rowe
ddbefea475 Revert "get.sh: put tmpclone dirs in xbtmp"
This reverts commit 01a779d4eb.

This commit broke ./mk -d coreboot for vendor files in lbmk.
2025-09-04 15:27:20 +01:00
Leah Rowe
aa38608bff Revert "tree.sh: add missing colon at the end of trees()"
This reverts commit 568887cd5e.

This commit broke ./mk -d coreboot for vendor files in lbmk.
2025-09-04 15:27:07 +01:00
Leah Rowe
568887cd5e tree.sh: add missing colon at the end of trees()
this is because when using chained commands at the end
of functions, sometimes you have to explicitly terminate
the line.

the way i do it in this patch is common across the
build system, to mitigate this sh quirk.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-02 06:49:38 +01:00
Leah Rowe
01a779d4eb get.sh: put tmpclone dirs in xbtmp
and generate them, don't hardcode them - this reduces
the chance of race conditions, which we have seen in
the past and which current execution flow in xbmk even
mitigates in a few places, by doing things in a certain
order.

this change makes the code more robust and easier to
maintain.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-02 06:33:31 +01:00
Leah Rowe
89238c0579 tree.sh: tidy up check_cross_compiler
group related operations together, without whitespace.

declare all variables at the start of the function.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-23 17:38:29 +01:00
Leah Rowe
07562e3f28 tree.sh: don't re-check xgcc needlessly
instead, create a file indicating that a given xgcc
target had already been built successfully, within a
given coreboot tree.

this will considerably speed up the building of release
archives, especially when there are a lot of boards.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-23 16:02:40 +01:00
Leah Rowe
66f1be1ba7 tree.sh: check xgcc AFTER checking elfdir
if e.g. elf/coreboot/default/w500_16mb contains readied
images from before, crossgcc is still being checked.

if you already built all the coreboot images, and wanted
to just modify all the payloads for example, this would
result in a much slower re-build process, because it is
needlessly re-checking crossgcc every time.

by doing it this way, we need up the testing of payloads
quite considerably, during xbmk development.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-23 15:49:10 +01:00
Leah Rowe
41945a2220 tree.sh: Delete files *before* updating hashes
The current logic deletes old project files e.g. sources,
but *after* updating the project hash.

This means that if a deletion fails, and the directory
is still there (e.g. src/coreboot/default/) afterward, it's
now a tainted archive, yet the hash has been updated, so
subsequent runs of the build system will cause unknown
errors.

This patch fixes that, by first copying the new hash to
a temporary file. *Then*, deletions are handled, and the
final hash file is updated afterward.

The code is now a bit more bloated as a result, but this will
reduce the risk of tainted sources being handled under fault
conditions.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-10 14:50:32 +01:00
Leah Rowe
d44c143846 tree.sh: rename hashtype to hashname
since it's the name, e.g. "default", referring to a
project tree (in this example, coreboot/default).

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-10 14:17:57 +01:00
Leah Rowe
289c4e1c2f tree.sh: rename hashname to hashdir
since it's only ever used as a directory name

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-10 14:15:55 +01:00
Leah Rowe
b31f2387ee tree.sh: rename hashvar to badhashvar
now the code that uses it makes a bit more sense
to the casual reader.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-10 14:13:47 +01:00
Leah Rowe
2c24b94d80 tree.sh: rename function and remove comments
the new function names make the comments redundant. the
code is now self-explanatory.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-10 14:12:48 +01:00
Leah Rowe
ef79b11082 tree.sh: don't delete builds if tree==target
in that case, the previous tree-wide check will cover
it, so the current logic wastes computational time.

this patch therefore somewhat optimises the code.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-04 09:33:33 +01:00
Leah Rowe
1c5c28f2cb tree.sh: re-add comments to check_hashes
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-04 09:16:58 +01:00
Leah Rowe
3d5a6bccae tree.sh: unified project hash handling
the target/project hash checks are basically identical,
so let's unify them under a single function.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-02 11:31:28 +01:00
Leah Rowe
7c6c9ff547 tree.sh: delete individual target builds if needed
Detect when a config changes. This is done even if the
entire tree doesn't change.

This is already done per-tree if files change, but
individual project files don't change.

For example, if a grub.cfg changes, the given cached
build for that GRUB tree isn't deleted. Same thing if
a given U-Boot config doesn't change.

This patch fixes a longstanding design flaw of lbmk,
making auto-re-builds more reliable. This complements
another recent change, that deletes all target builds
of a given tree when the tree changes.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-07-10 02:00:13 +01:00
Leah Rowe
fb95230a4c tree.sh: Remove redundant deletion
Target builds go inside a common directory for
the given tree now, which gets deleted, thus
deleting all target builds of that given tree.

Therefore, the deletion being removed is redundant.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-07-10 01:07:55 +01:00
Leah Rowe
cc82b733d3 tree.sh: Place target builds under tree/target/
as opposed to target/

for example:

image the command:

./mk -b u-boot amd64coreboot

This would put the U-Boot binaries here:
elf/u-boot/amd64coreboot/default/

With this change, they now go here:

elf/u-boot/x86_64/amd64coreboot/default/

This solves a problem that existed previously, where
you could modify a given tree in a multi-tree project,
but cached builds for targets branching separately off
of each tree would not be deleted, and thus not re-built.

This accomplishes such a result, without needing to
further check hashes of individual targets.

The latter will still be done, in a future change, because
this change doesn't fix another problem:

If you change a given config, e.g. targetname "foo" which
uses tree "bar", elf/foo/ would not be removed automatically
for re-build.

So this change only deletes individual target builds when
their master tree changes.

Where the target and tree are the same, this also means
elf/tree/target/

for example: seabios/default would create binaries in:

elf/seabios/default/default/

not:

elf/seabios/default/

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-07-08 13:38:59 +01:00