Commit Graph

1009 Commits (1f2c8e47d473b8dcf852fbd814cd6b7cb4f2f87c)

Author SHA1 Message Date
Leah Rowe 85b1996afa rom.sh: remove unnecessary check
the cbfs function will call cbfstool, which will perform
the same check, and the same error condition would cause
the same exit behaviour in lbmk. the error message would
also provide output that is just as useful for debugging.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 14:40:09 +01:00
Leah Rowe c3910fbc5f cbmk: minor cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 14:39:57 +01:00
Leah Rowe 6fc23805cb lib.sh mktarball: stricter tar error handling
There was no error handling, *at all*, on the actual tar
command, due to the lack of set -o pipefail, which we cannot
rely on in sh.

The x_ wrapper can be used in this case, as a mitigation.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 14:37:45 +01:00
Leah Rowe 58a17c8d15 mk check_project_hashes: handle error on sha512sum
We can't do set -o pipefail in POSIX sh, which we're using,
but the build system has x_ which wraps around a command
and executes it, exiting with non-zero status if it does.

This fact enables lbmk to have functionality that is actually
superior to pipefail, since you can more easily control
specifically which parts error.

For example:

foo | bar | foo2 | bar2 | $err "error"

ERROR exits with non-zero status, but foo2, bar and foo
would not exit on error, only bar2 would. In *bash*, which
we avoid, set -o pipefail would make all of them exit on
error, but what if you wanted "bar" to not exit?

With lbmk, you could do, in the above example, and with the
above question asked ("what if you wanted bar not to exit"):

x_ foo | bar | x_ foo2 | bar2 > file | $err "error"

of course, you could also do, if not outputting to "file":

x_ foo | bar | x_ foo2 | x_ bar2

NOTE: in lbmk, $err is a variable containing the name of
a function that does something (whatever you want) and
then exits with non-zero status.

This entire explanation is beyond the scope of simply
providing (and explaining) this fix, but I also wanted to
use this commit as an example of the power of lbmk with
regards to POSIX shell scripting.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:59:41 +01:00
Leah Rowe d65d93b300 Revert "lib.sh: use eval for the command in x_"
This reverts commit 7c98661271.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:58:37 +01:00
Leah Rowe 0aace67a54 lib.sh: fix bad eval writing version/versiondate
x_ cannot be used, where output is redirected to a file;
only the convention piping can be used, for errors.

relying on x_ in these cases will cause unpredictable bugs.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:57:19 +01:00
Leah Rowe 7c98661271 lib.sh: use eval for the command in x_
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:57:09 +01:00
Leah Rowe e63c14677f mk: use eval to run mkhelp commands
directly quoting it and running it quoted means
that the shell way try to execute it as a file.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:57:01 +01:00
Leah Rowe f4e5879534 mk: tidy up the switch/case block in main()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:56:00 +01:00
Leah Rowe 85373b9b91 mk: tidier error handling
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:54:06 +01:00
Leah Rowe d0b95ffe6e lib.sh: tidy up the error handling
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:53:58 +01:00
Leah Rowe caaaf46540 rom.sh: tidy up error handling
same as the last change

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:53:30 +01:00
Leah Rowe 7bd9fb9a7b git.sh: clean up fetch_project()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:51:10 +01:00
Leah Rowe 4d15c476b6 mk: Remove unnecessary argument checks on trees()
These checks are no longer necessary, because these
checks are already properly handled in main().

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:51:02 +01:00
Leah Rowe 94a8fa816f inject.sh: properly call err_ in fail_inject
i can't call $err (variable), because it's set
to fail_inject. fix this infinite loop, which
was an oversight in the previous commit.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:50:42 +01:00
Leah Rowe ca6a3c8958 remove xbmk_parent, handle forking in lib.sh
I was using a complicated method of knowing whether
the current instance was parent or a child, to know
whether the lock file and TMPDIR needed to be purged.

It was quite error-prone too. Instead, I'm now handling
it directly from within the if statement that previously
initialised xbmk_parent=y, forking ./mk from there.

The forked instance would not trigger that if clause
again, since then TMPDIR is created, thus avoiding
recursion.

This is an improvement because it doesn't rely on how
the parent handles exit statuses, and it ensures that
the lock/tmp files are never accidentally deleted.

Even if a given program/script that cbmk runs would
export TMPDIR, it doesn't matter because cbmk doesn't,
so it would be unaffected.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:49:12 +01:00
Leah Rowe f3c757c2d2 lib.sh: define x_ right after err_
because the top-down function order isn't as reliable
in lib.sh, since this is what first runs, included
in every other script

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:47:28 +01:00
Leah Rowe 2b9881639f mk: minor cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:47:18 +01:00
Leah Rowe 3b2718bd9d lib.sh: minor cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:47:07 +01:00
Leah Rowe 8999d30b96 rom.sh: minor cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:46:42 +01:00
Leah Rowe 32242cc03b inject.sh: tidy up check_release()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:45:38 +01:00
Leah Rowe f439230604 inject.sh: tidy up xbmk_inject()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:43:57 +01:00
Leah Rowe bbc28e73f8 inject.sh: tidy up readcfg()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:39:44 +01:00
Leah Rowe cdcdadf097 inject.sh: tidy up patch_release_roms()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:37:27 +01:00
Leah Rowe ff35a6a300 inject.sh: tidy up modify_mac_addresses()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:29:54 +01:00
Leah Rowe 67c8338acf script/trees: merge with mk and delete script/
script/ no longer exists. this means that the
only executable script in cbmk is now mk.

script/trees was never called directly; instead,
we used ./update trees in the past, then just ./mk.

this is part of a larger audit to simplify cbmk,
in preparation for the next Libreboot release.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:22:40 +01:00
Leah Rowe d4dba9140c mk: remove the legacy "roms" command
we don't need it. the documentation only tells you
now to run ./mk -b coreboot target1 target2 etc

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:20:45 +01:00
Leah Rowe 4cb9db2ba2 lib.sh: write version/versiondate to dotfiles
write to .version and .versiondate, instead
of version and versiondate.

this will hide them to avoid visual clutter while
analysing files within cbmk.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:19:20 +01:00
Leah Rowe f0dcaca4ee lib.sh: hardcode projectname/projectsite
remove the corresponding files, containing these strings

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:18:00 +01:00
Leah Rowe ba5487aa34 remove update symlink
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:16:51 +01:00
Leah Rowe 062e057e87 move build to mk
i'm removing all the backward-compatibility in the
build system, so that only the ./mk command is available

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:16:17 +01:00
Leah Rowe 02785da1af trees: unify the execution of mkhelper commands
provide it in a new function: mkhelp()

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:13:49 +01:00
Leah Rowe 6405f92bd4 trees: tidy up configure_project()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:13:44 +01:00
Leah Rowe 019b885cd8 build: make coreboot building an else in "roms"
Otherwise, the current return prevents set -u -e
after the case/switch block, which is a problem if
set +u +e was done at any point before the return.

Remove the return in the roms) section of the case/switch
block, and make the building of coreboot images part of
an else clause.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:13:39 +01:00
Leah Rowe f2f4aaefb7 trees: don't build dependencies if dry=":"
build_depend is already blanked anyway, but it can't
hurt to have an extra check here.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:13:34 +01:00
Leah Rowe e5fefd8074 trees: unified handling of flags
this way, the error message will never be incorrect,
which i had to fix in a recent patch.

now, the same string is used for error messages and getopt.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:13:30 +01:00
Leah Rowe 6696e69f01 trees: simplified handling of badhash/do_make
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:13:25 +01:00
Leah Rowe 28ef540e74 trees: don't set mode on ./mk -b
mode is already initialised as an empty string

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:13:21 +01:00
Leah Rowe dd60b2ee84 trees: don't set mod on ./mk -d
mode is already initialised as an empty string

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:13:16 +01:00
Leah Rowe c429fc8e3f trees: don't initialise mode to "all"
this is not necessary. the fetch mode is still handled,
as before, and no make commands will run in this case.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:13:11 +01:00
Leah Rowe c5dacebe44 trees: clean up some comments
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:13:05 +01:00
Leah Rowe 8d27e6c786 inject.sh: simplified readkconfig()
So much bloat

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-14 01:12:46 +01:00
Leah Rowe ca5618628b inject.sh: replace xbmkpath with xbmkpwd
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-11 20:44:42 +01:00
Leah Rowe 9130750ebb lib.sh: double-quote pwd to prevent globbing
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-11 20:41:12 +01:00
Leah Rowe 12e600bf5c cbmk: unified PWD handling (work directory)
instead of running pwd all the time, run it once in lib.sh,
and export PWD.

for cbmk-specific use of PWD, use xbmkpwd, which contains
the value of PWD as was set by the pwd utility in lib.sh.

many parts of cbmk rely on pwd, and it *must* be correct.
this change adds basic error handling, since pwd can in
fact return errors in some cases.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-11 20:39:55 +01:00
Leah Rowe 891a7d8e63 lib.sh: initialise PATH if it's unset
it's incorrect for PATH not to be set, but some users
may foolishly blank it out before running cbmk.

prevent such issues, by initialising it.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-11 20:38:48 +01:00
Leah Rowe 18689092d3 move XBMKPATH to include/lib.sh
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-11 20:37:14 +01:00
Leah Rowe dcc7f10ec7 cbmk: use pwd util, not PWD environmental variable
PWD could be anything, if the user manually exported
it before running cbmk.

always run pwd instead, to get the real string.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-11 20:36:54 +01:00
Leah Rowe 6e6b54cc24 clean up a few semicolons in the build system
several code lines were condensed together, which
make them less readable. make the code more readable
by having separate commands on separate lines.

i previously did this during my manic build system
audits of 2023 and 2024; condensing lines like this
is overly pedantic and serves no real purpose.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-11 20:36:05 +01:00
Leah Rowe 7b7642dc90 trees: err if first argument is not a flag
E.g. ./mk -f coreboot is valid

./mk coreboot -f is not valid

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-11 20:32:53 +01:00