Commit Graph

1013 Commits

Author SHA1 Message Date
Leah Rowe e9e33d4b4d lib.sh: always sanitize xbmkver before writing
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>
2026-09-13 14:33:37 +01:00
Leah Rowe 3b37a0b17d lib.sh: simplify update_xbmkver
sanitization can be done with a single sed command

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-13 14:25:09 +01:00
Leah Rowe 77b0b448e2 more cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-12 19:37:57 +01:00
Leah Rowe c7fb6a2bc8 get.sh: remove redundant check
we don't pull anything from supermicro's site.
we did briefly, in an earlier port for that
one supermicro board.

don't maintain dead code. dead code has one purpose:
be deleted.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-12 18:12:36 +01:00
Leah Rowe 2d1d7624e9 get.sh: add try_fetch_copy function
just a skeleton that calls the curl function

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-12 15:10:44 +01:00
Leah Rowe a32374f6cc more cleanup
this will be the last time, i promise

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-12 14:29:11 +01:00
Leah Rowe 897c2667af get.sh: even more cleanup (simplified fetch)
fetch_submodule now contains just the right amount
of eval, which means all of the eval.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-12 13:24:13 +01:00
Leah Rowe 446eca846e get.sh: further cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-12 12:49:12 +01:00
Leah Rowe c3e2d8c8bc get.sh: simplify xbget
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-12 11:19:42 +01:00
Leah Rowe b094c60a39 more variable cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-12 09:02:04 +01:00
Leah Rowe 798cc79399 mk: export locales much earlier
also simplify the way it works (eval and awk)

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-12 08:49:53 +01:00
Leah Rowe 6a2e9a7919 remove include/chromebook.sh import script (not needed)
i will be adding chromebooks, but not using this script,
which is why i never finished the script. i previously
had the plan to patch upstream coreboot, by importing
patches from mrchromebox, but that results in an extreme
number of patches. several hundred patches, in fact.

more efficient is to add multi-upstream support in
include/get.sh, for using different upstreams including
forks, on a given multi-tree project. i haven't done
this yet, but this is what will be done, and then
adding each chromebook will be a matter of importing
configs from mrchromebox alongside edk2 integration.

a script will still need to be written, for the initial
import, and imported chromebooks will be set release=n
until and when each target is fully tested.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-11 21:51:00 +01:00
Leah Rowe d0a1b40910 more cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-11 21:43:50 +01:00
Leah Rowe 0fd3d72998 tree.sh: remove redundant TODO
infinite loop detection was here before. i removed it
because it was bloat. we don't take general user input
here, so careful configuration is all we need.

infinite loops are harmless to the user. they are merely
annoying. they would never be introduced to the user,
because configs are always tested before release.
before commit, even.

we can save the user a few watts of electricity, or we
can Keep It Simple.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-11 19:49:26 +01:00
Leah Rowe 425855899f rom.sh: remove another TODO
this one is unnecessary, because we're not taking general input
from the user. we mitigate this carefully by being, you know,
careful.

implementing the TODO would have bloated the code, in ways that
might only introduce other serious bugs.

the current logic is fine, and great care will always be taken
by me to keep the code safe, while i'm in charge.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-11 19:46:07 +01:00
Leah Rowe f648167b9f rom.sh: remove redundant TODO
the code is correct. no TODO needed here.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-11 19:45:14 +01:00
Leah Rowe 36fef51e8f init.sh: universally set git commit/auth date
do it as an export. to avoid pollution elsewhere,
do it inside a subshell.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-11 19:42:03 +01:00
Leah Rowe b6b5f70934 init.sh: set git committer date as well
only the author date was being set before

with this change, at least on my system, i
now get the same commit ID and date each time
on the following test:

NOTE: . is lbmk (main work directory)
NOTE: here, we are copying the current clone

git clone . lbmktest
cd lbmktest
./mk version
rm -Rf .git
./mk version
git log

same output each time. we have thus eliminated
timestamps as a variable. this is but a part of
in a series of changes that will eventually lead
to libreboot being built reproducibly.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-11 19:32:12 +01:00
Leah Rowe 58094bd017 init.sh: portable date on git-init
don't even call the date util at all, to fix the
portability issues. now we don't need GNU date
anymore.

git itself can just take an epoch, and it will
do whatever it will do. yes.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-11 19:28:15 +01:00
Leah Rowe cdd399017e init.sh: don't check PATH on startup
even if i unset PATH before running lbmk, it is
reinitialised because of the shebang. if no PATH
exists, then it's either a broken system and you
have bigger problems, or you have some weird
system that uses something else.

our job is not to fix the world. there was no
scenario in which this check would even trigger
an error or fallback, so just remove it.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-11 19:02:20 +01:00
Leah Rowe 15204cda63 xbmk: re-introduce condensed if statements
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>
2026-09-11 16:18:09 +01:00
Leah Rowe 8173aea83b xbmk: reintroduce setvar as newvar (init only)
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>
2026-09-11 14:24:55 +01:00
Leah Rowe aad748c5ca inject.sh: simplify xbmkcheck initialisation
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-10 22:49:57 +01:00
Leah Rowe 8db320799b inject.sh: re-order variables
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-10 22:20:05 +01:00
Leah Rowe 6050cdd1db init.sh: much more thorough locale initialisation
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-10 19:35:17 +01:00
Leah Rowe 8c927b535d update header again
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-10 19:28:27 +01:00
Leah Rowe 5f0bd5ea10 xbmk: remove setvars function
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>
2026-09-10 19:25:45 +01:00
Leah Rowe 8822c56815 mk: make it completely generic
commands now fed from a file, include/common.sh
which in turn also includes other lib files

this makes mk completely generic, and means
that changes will now be completely in sync
with cbmk, ensuring a lack of merge conflicts,
though the file was already pretty small anyway.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-10 18:05:57 +01:00
Leah Rowe 1ceeb0ab55 update lbmk headers
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>
2026-09-10 17:45:11 +01:00
Leah Rowe e973584123 mk: generalised dispatch loop
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>
2026-09-10 13:49:34 +01:00
Leah Rowe afdf8c7733 Revert "xbmk: general code cleanup"
This reverts commit 1b65e8914c.

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-09-10 12:34:35 +01:00
Leah Rowe 01cb422c97 include/get.sh: 3-way merge on git am
this will make managing updates easier. which will
be soon, because i have a lot of patches.

no idea why i didn't add this before. normally, i just
copy a directory and git-fetch, then cherry-pick as
i please. this will make it trivial to just update
a revision and merge the patches. then i can just
intervene only when necessary, on a given src tree.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-06 10:16:00 +01:00
Leah Rowe 1b65e8914c xbmk: general code cleanup
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-07-30 11:58:11 +01:00
Zoomm Deka ab13b80250 fix git identity handling in xbmk_git_init
Signed-off-by: Zoomm Deka <zoomm10@gmail.com>
2026-07-28 03:02:02 +02:00
Leah Rowe 8b59310209 only disable git check for ./mk -b coreboot
the previous patch was half the battle. now that
annoying person who complained on irc should be
happy.

someone complained about having to enter git
name/email when just doing e.g. ./mk inject

a valid complaint, but their attitude kinda
stunk. oh well. this patch should satisfy them.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-07-27 23:35:38 +01:00
Leah Rowe 06fd12953f make the bitch on irc happy
some person complained about this. see diff.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-07-27 23:27:56 +01:00
Leah Rowe 1265eb5b63 init.sh: add a throught-provoking TODO
this will be revisited by October 2026 Leah.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-07-21 20:27:57 +01:00
Leah Rowe 56697c1da3 init.sh: add error check on mkdir in gentoo check
yes. i should have reviewed that patch properly.

the code should meet lbmk standards now.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-07-21 20:24:12 +01:00
Leah Rowe 8d9d1a88a0 init.sh: fix bad printf string in gentoo check
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-07-21 20:23:12 +01:00
Leah Rowe e1384a1b9f init.sh: add -p on mkdir command in gentoo check
probably redundant, but can't hurt

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-07-21 20:21:44 +01:00
Leah Rowe 598a57639f init.sh: double-quote variables in gentoo check
yes. silly twit.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-07-21 20:21:23 +01:00
Leah Rowe 86142b7e81 init.sh: fix indentation in gentoo check
the submitted messed up indentation, yeah

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-07-21 20:19:53 +01:00
Leah Rowe 1514e82be0 init.sh: add --includes to git config check
just to be sure

this now matches util/gitconfig/gitconfig.sh in coreboot

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-07-21 20:12:44 +01:00
Leah Rowe 83842c9481 Merge pull request 'Add Gentoo dependencies.' (#428) from lordbaraa/lbmk:add-gentoo-dependencies into master
Reviewed-on: https://codeberg.org/libreboot/lbmk/pulls/428
2026-07-21 20:43:00 +02:00
Leah Rowe 9dd6ed84ca init.sh: Don't check global git config
Some users have it in a file e.g. inside ~/.gitconfig

Those users are currently forced to set git config
globally by lbmk. We only need to check that a git
config is set, regardless of scope, because coreboot
needs it in parts of its build system when used on
lbmk.

This prevents a pointless error report for users who
have their git config on such a scope. Thanks go to
Hendrik Jäger for reporting this to me.

Yes, thank you. Further context:

https://lore.kernel.org/git/20260720113402.0dc16abe@frustcomp.hnjs.home.arpa/T/#u

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-07-21 19:34:26 +01:00
Baraa Al-Masri cf930f3b32 Add portage package use 2026-05-10 20:40:40 +03:00
Leah Rowe 7f4f07fc40 use old nvmutil for now, in lbmk
i'm trying to make nvmutil work on openbsd. the new code
in lbutils is a bit buggy, likely somewhere in mkhtemp.
i'm still debugging it.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-04-21 13:39:29 +01:00
Leah Rowe 01aa95ec15 Revert "lbmk: use mkhtemp in libreboot's build system"
This reverts commit e54862fccc.

nope. not ready yet. will fix it later.
2026-03-29 16:25:41 +01:00
Leah Rowe e54862fccc lbmk: use mkhtemp in libreboot's build system
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>
2026-03-29 16:08:00 +01:00
Leah Rowe 718095b0fe util/mkhtemp: extremely hardened mkhtemp
This will also be used in lbmk itself at some point,
which currently just uses regular mktemp, for tmpdir
handling during the build process.

Renamed util/nvmutil to util/libreboot-utils, which
now contains two tools. The new tool, mkhtemp, is a
hardened implementation of mktemp, which nvmutil
also uses now. Still experimental, but good enough
for nvmutil.

Mkhtemp attempts to provide TOCTOU resistance on
Linux, by using modern features in Linux such as
Openat2 (syscall) with O_EXCL and O_TMPFILE,
and many various security checks e.g.
inode/dev during creation. Checks are done constantly,
to try to detect race conditions. The code is very
strict about things like sticky bits in world writeable
directories, also ownership (it can be made to bar even
root access on files and directories it doesn't own).

It's a security-first implementation of mktemp, likely
even more secure than the OpenBSD mkstemp, but more
auditing and testing is needed - more features are
also planned, including a compatibility mode to make
it also work like traditional mktemp/mkstemp. The
intention, once this becomes stable, is that it will
become a modern drop-in replacement for mkstemp on
Linux and BSD systems.

Some legacy code has been removed, and in general
cleaned up. I wrote mkhtemp for nvmutil, as part of
its atomic write behaviour, but mktemp was the last
remaining liability, so I rewrote that too!

Docs/manpage/website will be made for mkhtemp once
the code is mature.

Other changes have also been made. This is from another
experimental branch of Libreboot, that I'm pushing
early. For example, nvmutil's state machine has been
tidied up, moving more logic back into main.

Mktemp is historically prone to race conditions,
e.g. symlink attacks, directory replacement, remounting
during operation, all sorts of things. Mkhtemp has
been written to solve, or otherwise mitigate, that
problem. Mkhtemp is currently experimental and will
require a major cleanup at some point, but it
already works well enough, and you can in fact use
it; at this time, the -d, -p and -q flags are
supported, and you can add a custom template at
the end, e.g.

mkhtemp -p test -d

Eventually, I will make this have complete parity
with the GNU and BSD implementations, so that it is
fully useable on existing setups, while optionally
providing the hardening as well.

A lot of code has also been tidied up. I didn't
track the changes I made with this one, because
it was a major re-write of nvmutil; it is now
libreboot-utils, and I will continue to write
more programs in here over time. It's basically
now a bunch of hardened wrappers around various
libc functions, e.g. there is also a secure I/O
wrapper for read/write.

There is a custom randomisation function, rlong,
which simply uses arc4random or getrandom, on
BSD and Linux respectively. Efforts are made to
make it as reliable as possible, to the extent
that it never returns with failure; in the unlikely
event that it fails, it aborts. It also sleeps
between failure, to mitigate certain DoS attacks.

You can just go in util/libreboot-utils and
type make, then you will have the nvmutil and
mkhtemp binaries, which you can just use. It
all works. Everything was massively rewritten.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-26 06:59:42 +00:00