Commit Graph

47 Commits (c20e29005fa28b0a5732175fba43d233c3d76adc)

Author SHA1 Message Date
Leah Rowe 2acdfefdf9 inject.sh: bring in sync with lbmk 0f931b508a8
see lbmk commit:
0f931b508a8eb34e70b2ed3628ac4fe74f22b8e8
from 10 May 2025

The lbmk version of inject.sh also contained logic to
download vendor files, which cbmk doesn't and won't support.

This made merging patches between the two projects harder, so
lbmk's version has been modified to mostly only include the MAC
address related code on inject.sh, just like the Canoeboot one.

On lbmk, extra functionality for vendor files is now provided
on include/vendor.sh, which cbmk lacks (and will never have).

With a few minor alterations, this script is now very much in
sync with the lbmk version.

In fact, just to provide the point, here is the diff between
lbmk's version of inject.sh, compared to the version in cbmk
introduced by this commit. Observe:

(< is a subtracted line, and > is an added line. So the < shows
what was removed from lbmk's version when adding to cbmk, and
the > lines show what cbmk added to its version).

yes me cbmk$ colordiff ../lbmk/include/inject.sh include/inject.sh
89,90d88
< 	[ -n "$vcfg" ] && check_vcfg
<
94,95d91
< 	mecleaner="$xbmkpwd/$cbdir/util/me_cleaner/me_cleaner.py"
< 	kbc1126_ec_dump="$xbmkpwd/$cbdir/util/kbc1126/kbc1126_ec_dump"
103,104d98
< 	[ "$nukemode" = "nuke" ] || x_ ./mk download "$board"
<
112,113c106,107
< 		e "$tmpromdir/$_hashes" f && \
< 		    has_hashes="y" && hashfile="$_hashes" && break; :
---
> 		e "$tmpromdir/$_hashes" f && err \
> 		    "'$archive': vendorfile insertion unsupported"
118,120d111
< 	fx_ prep x_ find "$tmpromdir" -maxdepth 1 -type f -name "*.rom"
< 	( check_vendor_hashes ) || err "Can't verify hashes for '$archive'"; :
<
129d119
< 	setvfile && return 1; :

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-10 18:20:44 +01:00
Leah Rowe a170ab4118 cbmk: use x_ instead of err, where appropriate
many places in cbmk used err, because older versions
of x_ did not handle globbing properly.

however, use of x_ is preferable on trivial commands.

the only time err() should be called is what it has
to be, when x_ can't work, or when a more useful error
message is needed, for context.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-10 18:09:43 +01:00
Leah Rowe e320ce60a7 init.sh: Only check XBMK_CACHE if it exists
Otherwise, if it doesn't exist, the current check will
wrongly exit with error status, preventing you from
running the build system at all!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-08 22:19:01 +01:00
Leah Rowe 63cef86bdb init.sh: remove useless export
we already reset to n if not y, afterward

just rely on that

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-08 16:09:41 +01:00
Leah Rowe 0a3793ad4e init.sh: also allow XBMK_RELEASE=Y or N
as opposed to =n or =y

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-08 16:09:34 +01:00
Leah Rowe 433b5de916 init.sh: Resolve XBMK_CACHE via readlink
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-08 16:09:26 +01:00
Leah Rowe 5d2c94a8bd init.sh: check XBMK_CACHE is a directory instead
it doesn't matter if it's not a file. that's the wrong check.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-08 16:09:20 +01:00
Leah Rowe f0a0f678bf init.sh: export LOCALVERSION in set_env
Don't do it in set_version

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-08 16:09:14 +01:00
Leah Rowe 542d72192d init.sh: run set_version before set_env
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-08 16:09:08 +01:00
Leah Rowe 9ccfee43e7 init.sh: Use readlink in pybin()
Use realpath only as a fallback.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-08 16:09:03 +01:00
Leah Rowe e47324619d lbmk: Replace err with much simpler implementation
The current implementation is insanely over-engineered,
and completely unnecessary.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-06 04:44:03 +01:00
Leah Rowe 5b2d537123 init.sh: Silence the output of git config --global
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:45:02 +01:00
Leah Rowe edfa4a0ddd init.sh: Run git name/email check before init
Otherwise, it returns if init is already done, which
later leads to build errors in coreboot.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:44:57 +01:00
Leah Rowe 15afad4a2b init.sh: single-quote xbmklock in xbmk_lock()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:44:35 +01:00
Leah Rowe 41bc473276 init.sh: define lock file in a variable instead
don't hardcode it.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:44:26 +01:00
Leah Rowe 4415865ccc init.sh: tidy up xbmk_child_exec()
make the command style more consistent, for example
relying on x_ inside a subshell to print the command
and arguments if a command failed.

this is a good style, and i'll probably use it in other
places on lbmk.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:44:21 +01:00
Leah Rowe cd979e3b09 lbmk: MUCH safer err function
Don't directly call a variable. Call a function that
checks the variable instead.

The new err function also checks whether an exit was
actually done, and exits 1 if not.

If an exit was done by the given function, but the exit
was zero, this is also corrected to perform an exit 1.

This fixes a longstanding design flaw of lbmk.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:43:18 +01:00
Leah Rowe 6e14ab7c09 init.sh: tidy up the python version check
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:36:32 +01:00
Leah Rowe 7944fd6297 init.sh: move non-init functions to lib.sh
these were missed in a previous cleanup

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:36:27 +01:00
Leah Rowe 159ded1c4e init.sh: simplify dependencies handling
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:36:23 +01:00
Leah Rowe e05787d82f init.sh: tidy up pathdir creation
we can use remkdir here. it does the same thing.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:36:00 +01:00
Leah Rowe bb5228dc32 init.sh: *Re-create* tmpdirs on parent instance
To make sure any old files are removed, always re-create.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:32:53 +01:00
Leah Rowe 0c05289152 init.sh: Always create xbmklocal
If we're in a release work directory, TMPDIR is already
set, so the local ./tmp won't be created, which would
lead to an error.

Fix it by creating xbmklocal before checking TMPDIR.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:32:47 +01:00
Leah Rowe b2c14b6759 lbmk: Unified local ./tmp handling
Make it an absolute directory, relative to xbmktmp.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:32:24 +01:00
Leah Rowe 2d05cd260d init.sh: Explicitly create the xbmktmp directory
mktemp would normally do it, but we must not rely on that

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:29:02 +01:00
Leah Rowe e32a6c96d5 init.sh: unified handling of ./tmp
not to be confused with /tmp

we use ./tmp inside the lbmk work directory, for large files,
because /tmp might not be very big, or might be a tmpfs

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:28:12 +01:00
Leah Rowe 6348e8a93e move x_() to lib.sh
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:17:58 +01:00
Leah Rowe a30fd38ae4 init.sh: move setvars/err_ to lib.sh
these functions make more sense in lib.sh

i made mk link lib.sh first, so that the
functions on init.sh can still use them.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-04 17:17:53 +01:00
Leah Rowe db162c3662 init.sh: fix yet another double quote for dotfiles
i missed this one, in another recent revision

double-quote because of the dot, for bash users

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:47:02 +01:00
Leah Rowe 34d134f2f2 init.sh: don't use eval to read version files
it's not necessary, and was the cause of a recent issue,
which i mitigated, but why mitigate it?

prevent bugs. don't use eval unless absolutely necessary.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:46:16 +01:00
Leah Rowe b63612871d init.sh: use backslash for dotfiles in eval
see:

commit f0c629dcc6c3f2242a735567cdd6855fa108d1a5
Author: Leah Rowe <leah@libreboot.org>
Date:   Sat Apr 12 13:51:49 2025 +0100

    lib.sh: write version/versiondate to dotfiles

and this bug report:

https://codeberg.org/libreboot/lbmk/issues/284

The report indicates that the above commit broke bash,
when sh (on the user's system) is bash.

I know sometimes when using bash, I need to use the
back slash when dealing with dots, e.g. when grepping
something.

Also double quote references to dotfiles, e.g. when
directing the output of printf.

I never noticed the issue myself, since I use dash.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:46:10 +01:00
Leah Rowe 4ff7cd3d77 init.sh: make git name/email error more useful
instruct the user what to do in these conditions

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:45:25 +01:00
Leah Rowe ec287ca69e init.sh: move git name/mail check to xbmk_git_init
the command -v check has been removed, since this function
already calls git immediately, which would accomplish the
same thing since that causes an error if git isn't there.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:45:19 +01:00
Leah Rowe f89e5ad87a init.sh: tidy up the git name/email check
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:45:13 +01:00
Leah Rowe f3caaf394e mk: move git check to init.sh xbmk_set_version
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:44:24 +01:00
Leah Rowe f30892e92f init.sh: tidy up xbmk_init()
more version-related code moved to xbmk_set_version

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:44:18 +01:00
Leah Rowe cbf486789d mk: move git_init to init.sh
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:44:14 +01:00
Leah Rowe 2c39a2bc7b init.sh: minor cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:44:08 +01:00
Leah Rowe d6d8ee1d4b init.sh: clean up setvars
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:44:03 +01:00
Leah Rowe ef78f88117 init.sh setvars: make err a printf for eval
setvars is always invoked with eval, so make the error
condition a message for eval, to ensure that it is reliably
handled, in case of error condition.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:43:58 +01:00
Leah Rowe 3221ca7742 init.sh: merge xbmk_child_init with xbmk_init
the for loop at the end of xbmk_init does essentially
the same thing. adapt accordingly, and merge.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:43:52 +01:00
Leah Rowe 723e979c8c init.sh: split xbmk_child_init into functions
one function, for one task. skeleton functions for
performing multiple tasks. that is the basic coding
style guideline for lbmk.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:43:47 +01:00
Leah Rowe 0d86ef50ac init.sh: move parent fork to new function
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:43:41 +01:00
Leah Rowe 68d5660cca init.sh: Provide more complete error info
On initialisation of the child instance, ./mk is
executed, but an error from it won't reveal what
command was actually executed.

This change makes that the case, since x_ does
print the command that caused an error.

This is useful for debugging. However, we don't
want x_ to cause a real exit, because we still
need to handle the lock file from the parent
instance.

Therefore, the first child instance is executed
inside a subshell, and xbmk_rval is set if that
subshell returns non-zero.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:43:35 +01:00
Leah Rowe 2c8570c07a move variables out of init.sh to others
move them where they are used, or if they are used
in many places, move them to lib.sh

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:42:08 +01:00
Leah Rowe a16d9f35a2 re-split include/init.sh to lib.sh
move non-init functions to lib.sh

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:40:33 +01:00
Leah Rowe 6d54f46148 rename include/lib.sh to init.sh
this is in prep for the next change, where non-init
functions will be moved to another file, again named
include/lib.sh

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-04-30 15:37:55 +01:00