summaryrefslogtreecommitdiff
path: root/include/lib.sh
AgeCommit message (Collapse)Author
2 daysxbmk: make all projects multi-treeLeah Rowe
we currently distinguish, by virtue of logic, multi- and single-tree projects. this introduces a lot of complexity, so the following patch has removed this distinction. all single-tree projects are now multi tree, but with only one tree. other design changes: config/git removed. rev/tree now handled with mkhelper and target configs. this allows per-tree remote handling, so we could (for example) add the mrchromebox coreboot fork easily, for specific chromebook models. config/project is now config/module/project. this cleans up the main config/ directory. cfgname variable: .config no longer hardcoded when doing configs in projects. it is configurable with this variable. if unset, the previous .cfg is used noconfig variable: set this in target/mkhelper configs, and config/module/project/tree/config/ is unused; instead, make is called without config copying. a "noconfig" placeholder is used. this enables cleaner usage of previously single-tree projects in the new multi-tree-only structure. cfgvars: variables reinitialised in project config are cleaned more reliably. in particular, several variables e.g. autogenargs were not being reset between projects, although the autogenargs variable is currently unused. general cleanup has been conducted across the build system, as part of this redesign. several parts of the build system more over-engineered as a result of the previous design, and the new design enabled a severe reduction in sloccount (75 lines reduced in lbmk). yes, this change *adds features* but there are fewer lines of code than before. this is the best kind of change. way better than the 3-line-diff. yes. rev= and tree= are set more centrally in configs. the mkhelper config can be used to set url/url_bkup, but individual trees can override them. configs have been cleaned up, with several variables now much more heavily centralised. config/git/ was used before to first download the bare repository, and then the real clone was made with patches. this allows git repositories to be cached for future re-builds. with config/git/ gone, the download logic for projects is more centrally implemented. a separate call to ./mk -f is no longer performed, and in fact ./mk -f never needs to be used anymore as a result. ./mk -f now is basically the same thing as -b, just without any action performed. this change will allow rapid expansion of the libreboot project. i want to add hundreds of chromebooks to the project, using mrchromebox, but the previous design did not permit this. this change means that i can easily have unlimited upstreams per project. coreboot will, in some follow-up changes, have the following upstreams: coreboot/default: coreboot.org coreboot/fam15h: 15h.org fork coreboot/chromebook: mrchromebox fork this can now be done freely without massive changes to the build system. under the previous design, i worked on a now-abandoned patch to do N remotes per project, reading repo links from a file. this meant that i'd have coreboot.org first (main and backup), then mrchromebox. this meant that lbmk would failover through to mrchromebox, wasting time for the user. this new design is much cleaner, and will enable the project to be maintained much more easily. Signed-off-by: Leah Rowe <leah@libreboot.org>
5 daysminor cleanupLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
5 dayspcsx-redux: check dry build in mkhelperLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
5 dayslib.sh: make build_sbase a macroLeah Rowe
sh macros are cool Signed-off-by: Leah Rowe <leah@libreboot.org>
5 daysxbmk: general cleanupLeah Rowe
note: mecleaner check removed in vendor.sh, because it's already guaranteed to be fetched. the check will never indicate failure, so we can just assume that the me cleaner python script exists. Signed-off-by: Leah Rowe <leah@libreboot.org>
6 daysmk: tidy up xbmk_sanitize_versionLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
8 daysmove findpath and err functions to mkLeah Rowe
otherwise, it's totally broken. i also now include lib.sh later. Signed-off-by: Leah Rowe <leah@libreboot.org>
9 daysmk: simplified command handlingLeah Rowe
just do includes in mk again. common.sh was stupidly small, just pointless. replace the entire command dispatcher with eval, printf and awk, because i can, and it further reduces sloccount. Signed-off-by: Leah Rowe <leah@libreboot.org>
9 daysfix regression in version checkLeah Rowe
it occured to me that this style of check was bad. it only works when checking if both variables are set my bad Signed-off-by: Leah Rowe <leah@libreboot.org>
9 daysxbmk: remove xbmkdir()Leah Rowe
pointless function. literally pointless. it is literally the most pointless function ever written in the history of functions. literally pointless in every possible way. Signed-off-by: Leah Rowe <leah@libreboot.org>
9 dayslib.sh: always sanitize xbmkver before writingLeah Rowe
this removed the need to check it in xbmk_set_version as it calls update_xbmkver, which in turn performs the same check. this increases the general reliability and safety of xbmk when recording its own version after update. Signed-off-by: Leah Rowe <leah@libreboot.org>
9 dayslib.sh: simplify update_xbmkverLeah Rowe
sanitization can be done with a single sed command Signed-off-by: Leah Rowe <leah@libreboot.org>
10 daysmore cleanupLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
11 daysxbmk: re-introduce condensed if statementsLeah Rowe
i've been careful to makely only use it on AND operations, not onse that use OR. a lot of blocks are not condensed, unlike previously when this design was used. i removed the condensed design because it made the code allegedly easier to read, but i found it harder to read and found the code looked dirty. this change makes it clean again, but i've done it in a way where the shorthand conditional statements are easy to understand for most people. this strikes a compromise; i would go further. Signed-off-by: Leah Rowe <leah@libreboot.org>
11 daysxbmk: reintroduce setvar as newvar (init only)Leah Rowe
use the simpler logic recently introduced, generalised but it only sets variables to empty. this is safer than the previous design, and brings the same reduction in sloccount overall since i wasn't doing anything other than emptying variables anyway, when it was used before. i didn't like the long list of variables inside files, so this makes everything more readable. Signed-off-by: Leah Rowe <leah@libreboot.org>
12 daysxbmk: remove setvars functionLeah Rowe
only one file used it. i've replaced its use with a simple awk call alongside eval. Signed-off-by: Leah Rowe <leah@libreboot.org>
12 daysupdate lbmk headersLeah Rowe
i made several modificatinos to several files thus for in 2026, in the main part of the build system. i've added 2026 to the ones that i modified. Signed-off-by: Leah Rowe <leah@libreboot.org>
12 daysmk: generalised dispatch loopLeah Rowe
with this new function, i can turn commands on and off by virtue of config. for now, behaviour is unchanged, but this new design means i will be able to disable certain commands in child processes Signed-off-by: Leah Rowe <leah@libreboot.org>
12 daysRevert "xbmk: general code cleanup"Leah Rowe
This reverts commit 1b65e8914c4ad1e140b573fa6bc8feead14542ad. NOTE: cleanup of xbmk_git_init was retained this "cleanup" actually made the code harder to read. Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-07-30xbmk: general code cleanupLeah Rowe
make the code much easier to read i also cleaned up the recent git identity check Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-29Revert "lbmk: use mkhtemp in libreboot's build system"Leah Rowe
This reverts commit e54862fcccca0325da8ae2879c1fa965267d3df0. nope. not ready yet. will fix it later.
2026-03-29lbmk: use mkhtemp in libreboot's build systemLeah Rowe
i added a fake -t option, which doesn't actually read optarg, so that -t usage can just override the normal template. mkhtemp isn't ready for distros yet, but it's ready for lbmk. i hacked the makefile to also copy the binary to mktemp, and i set PATH in lbmk so that this binary is used insttead of the one on your system. that way, upstream projects use it. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-11-15lib.sh: reduce indentation in setvarsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-10-04xbmk: don't call mkdir. use xbmkdir (new function)Leah Rowe
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-04xbmk: use sbase sha512sum, not host sha512sumLeah Rowe
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-04xbmk: remove even more eval statementsLeah Rowe
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-04xbmk: remove the setcfg functionLeah Rowe
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-04xbmk: general cleanup: unroll condensed code linesLeah Rowe
i overlooked a number of lines, during previous cleanup Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-26xbmk: tidy up some if statementsLeah Rowe
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-24make notices a bit more readableLeah Rowe
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-24xbmk: cleanup of recent code refactoringLeah Rowe
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-24lib.sh: unroll condensed code linesLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-18Revert "xbmk: don't use backticks for command substitution"Leah Rowe
This reverts commit 4999a49de39667b3239fc2010d0e99c958b29417.
2025-09-13xbmk: much more verbose error messagesLeah Rowe
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-13lib.sh: use xprintf in err()Leah Rowe
if more than one argument is provided, it is interpreted as a command, and the command is outputted. this means that now for example, where you have: ls -l foo | err "could not list directory" you could do: ls -l foo | err "could not list directory" "$@" this would show all the arguments given to the calling function that tried to run "ls" let's say that function was called bar, you might do: ls -l foo | err "could not list directory" bar "$@" right now, it's not easy to provide good debug info where err is used, unless it was called with x_, which provides the command/arguments that was bugging out. with this, we now have an easy and readable/maintainable way to do the same thing everywhere in xbmk. this will now be done, in a follow-up commit. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-13lib.sh: use xprintf in x_Leah Rowe
don't echo the arguments this new logic shows quotes, in error outputs. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-13lib.sh: check args for errors in fx_ and dx_Leah Rowe
check that there are at least two arguments, and ensure that they are not empty. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-11xbmk: don't use backticks for command substitutionLeah Rowe
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-07lib/init.sh: sanitize the version stringLeah Rowe
the release functions in release.sh rely on the version string *not* being a path containing slashes. just a single string e.g. "foo", not e.g. "foo/bar" this is because several checks there make that assumption. in practise, we always ensure that tags and such do not contain these characters. however, someone else working on their own version of xbmk might not know of this design flaw, so let's try to correct it in code. we can add more filtering as designed, in the relevant function (xbmk_sanitize_version). Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-01lib.sh and rom.sh: stricter mktemp usageLeah Rowe
error out under fault condition Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-23lib.sh: safer pad_one_byte functionLeah Rowe
instead of copying to a temp file and then concatenating with padding back to the main file, we concatenate and create the temp file, then move the temp file back to the main file. this is because cat can be quite error prone, more so than mv, so this will reduce the chance of corrupt files being left behind depending on the context (of course, the latter is often avoided due to xbmk's design, which emphasises use of temporary files first). this matches the same design used in the function unpad_one_byte, which creates the deconcatenated output in a temporary file first, moving it back. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-23lib.sh: additional error handling on catLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-07-10cache coreboot builds in elf/ againLeah Rowe
This was a problem when I did it before, because individual target builds weren't automatically re-compiled when needed. The recent design improvements in lbmk enable this to be done again. Cached images in elf/ have no payloads, so they are a liability, therefore they are padded by one byte to prevent flashing. This solves the problem that the previous caching had. With this change, modifying payloads can be tested without needing to re-build coreboot each time. The cached coreboot builds are also automatically re-built when needed, which is another improvement this time, compared to the last time coreboot builds were cached in this manner. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-07-06lib.sh: remove erroneous break from fx_Leah Rowe
it means nothing here. in context, if a non-zero return is observed, we should not do anything here, which is already the behaviour anyway, except that "break" means nothing since we're not in a loop here. where an error exit should be observed, x_ is used inside the command given for fx_ Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-27put coreboot utils in elf/coreboot/TREELeah Rowe
not elf/UTIL/TREE This way, they are automatically deleted when a tree has to be re-built. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-26lib.sh: simplify setvars()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-26lib.sh: simplify chkvars()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-19tree.sh: fix up copy_elf(), bad for loopLeah Rowe
Because of how sh works, having just the [] line causes sh to exit, annoyingly without an error message, but it does cause a non-zero exit. This bug will have already been triggering, before I added the recent error handling on files for this for loop. also do it to the other loop in lib.sh Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-19lib.sh: Use while, not for, to process argumentsLeah Rowe
This is more reliable against globbing, in context of for. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-19xbmk: stricter handling of files on while loopsLeah Rowe
i overlooked these! Signed-off-by: Leah Rowe <leah@libreboot.org>