Commit Graph

44 Commits (aadccc591bb57091ee645f2db0d63cc53e397906)

Author SHA1 Message Date
Leah Rowe 71baf65351 option.sh: don't return 1 in mkrom_tarball
one of the calling functions relies on the return value
to be always 0, so these error conditions in mkrom_tarball
have been altered to cause an *exit* (non-zero) instead.

in practise, the commands in question were printf commands
run after tho directory they output to had been created,
so write access would probably not be an issue.

nonetheless, technically correct is the best kind of correct.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-19 06:51:20 +01:00
Leah Rowe 1fe9c4b899 option.sh: mktar_release to mkrom_tarball
that's all it's used for, to compress the rom images

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-19 06:45:38 +01:00
Leah Rowe 5b5dccd630 vendor.sh: further simplify config handling
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-18 19:51:40 +01:00
Leah Rowe 8418ea9ab2 vendor.sh: greatly simplified config handling
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-18 19:45:52 +01:00
Leah Rowe f8e3ca3b22 git.sh: Remove .git if XBMK_RELEASE=y
The build system already deletes .git in all source
directories for each given release, but does so at
the very end; it still does, but now it is deleted
one by one per project, to save space during very
large builds (release sizes vary wildly, depending
on how many trees exist for coreboot basically).

If you're building entirely in tmpfs (as I do), this
could be a problem if you have lots of .git/ directories.

This change reduces disk usage, or in the above example,
memory usage when running the build system from tmpfs.

This complements another recent change, where ROM images
are compressed per target during release builds, rather
than all at the very end of the process. It is part of a
series of optimisations, to reduce the memory and disk
usage of the build system, and to reduce I/O wastage
in general.

This change will not be the last of such changes!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-18 04:53:31 +01:00
Leah Rowe 839ef680cd lbmk: allow easier sync with cbmk
an equivalent change has been made in cbmk.

certain lbmk-specific variable names have been made
generic, with certain functions and other variables
moved around.

i maintain sync between libreboot and canoeboot, where
both projects can have the same behaviours, and most of
the merge conflicts have to do with variable names
containing "LBMK", "lbmk", "cbmk" or "CBMK", or
indeed "canoeboot" and "libreboot"

LBMK/lbmk/CBMK/cbmk variables between canoeboot and
libreboot now contain the string XBMK/xbmk

it should now be *much* easier to merge build system
changes between lbmk and cbmk.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-16 03:56:52 +01:00
Leah Rowe c6ba0a0e9b option.sh: delete check_git()
it's only used from main() in the main build script,
and it's very small, as is main()

therefore, move the logic into main()

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 04:03:16 +01:00
Leah Rowe e281966f22 remove check_project() (always set variables)
in lbmk, we call check_project() to set variables
such as projectname, version, version date

this is unnecessary, because all main scripts use
this functionality anyway

do it by default

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 03:04:41 +01:00
Leah Rowe 189b70ddcb build/roms: create full release tarball name
set relname from option.sh under check_project()

now the release logic simply has to move a directory

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 01:27:45 +01:00
Leah Rowe 36d45474c0 option.sh: don't bother checking for GNU tar
releases aren't reproducible anyway. we were
using options available in gnu tar for this.

it will be revisited at a later date. however, the next
time this is done, we will use another method because
there are in fact portable ways to create tarballs
reproducibly, documented on reproducible-builds.org

to be revisited, at a later date. for now, remove bloat.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 00:48:08 +01:00
Leah Rowe f0b604fc95 option.sh: remove insert_version_files()
it's only called once, from this file, within a small
function, and the function itself is very small.

remove, and put the contents of the function in the
calling function.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 00:45:01 +01:00
Leah Rowe 08c9f94a1a unified sha512sum creation for tarballs
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 00:37:12 +01:00
Leah Rowe 1ce7e33976 move rom tarball creation to script/roms
export LBMK_RELEASE="y"

if this is done, the tarball is created instead
of a directory, and the rom images are nuked using
./vendor inject with the nuke option, inserting the
correct version files; the rom directory is deleted

now the release script logic simple renames existing
tarballs. the benefit of this change is fewer lines of
code, and now lbmk doesn't use an insane amount of disk
space when building a *lot* of release images (the
uncompressed directories are deleted after each build)

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-14 23:44:28 +01:00
Leah Rowe 05fbd39298 remove all status checks. only handle release.
the release variable is all we need, turning a target on
or off for a given release.

the status checks were prone to bugs, and unnecessary; it
also broke certain benchmark scripts.

it's better to keep the lbmk logic simpler. board status
will be moved to the documentation instead.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-11 18:53:12 +01:00
Leah Rowe 5e4009b539 merge include/err.sh with include/option.sh
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-06 22:54:55 +01:00
Leah Rowe 55204dc444 option.sh: don't use nproc (not portable)
export LBMK_THREADS=x

where x is an integer. this is already supported for
setting the number of build threads, but if not set
it uses nproc.

openbsd doesn't have nproc. default to 1 thread.

now you MUST set threads. e.g. in linux do:

export LBMK_THREADS=$(nproc)

preliminary work is being done to make lbmk run
on openbsd!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-04-28 17:31:16 +01:00
Leah Rowe 332778973c allow users to specify number of build threads
lbmk otherwise uses nproc to set the number of build threads,
in these places:

* generic make commands in script/update/trees
* crossgcc make command in script/update/trees

the -T0 option is also used in script/update/release, when running
tar.

with this change, you can do:

export LBMK_THREADS=x

where x is the number of threads. when you then run
lbmk, your chosen number of threads will override
the default. this may be useful on a host that does
not have a lot of memory.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-03-27 07:38:16 +00:00
Leah Rowe 6ebab10caa safer, simpler error handling in lbmk
in shell scripts, a function named the same as a program included in
the $PATH will override that program. for example, you could make a
function called ls() and this would override the standand "ls".

in lbmk, a part of it was first trying to run the "fail" command,
deferring to "err", because some scripts call fail() which does
some minor cleanup before calling err.

in most cases, fail() is not defined, and it's possible that the user
could have a program called "fail" in their $PATH, the behaviour of
which we could not determine, and it could have disastrous effects.

lbmk error handling has been re-engineered in such a way that the
err function is defined in a variable, which defaults to err_ which
calls err_, so defined under include/err.sh.

in functions that require cleanup prior to error handling, a fail()
function is still defined, and err is overridden, thus:

err="fail"

this change has made xx_() obsolete, so now only x_ is used. the x_
function is a wrapper that can be used to run a command and exit with
non-zero status (from lbmk) if the command fails. the xx_ command
did the same thing, but called fail() which would have called err();
now everything is $err

example:

	rm -f "$filename" || err "could not delete file"

this would now be:

	rm -f "$filename" || $err "could not delete file"

overriding of err= must be done *after* including err.sh. for
example:

err="fail"
. "include/err.sh"

^ this is wrong. instead, one must do:

. "include/err.sh"
err="fail"

this is because err is set as a global variable under err.sh

the new error handling is much cleaner, and safer. it also reduces
the chance of mistakes such as: calling err when you meant to
call fail. this is because the standard way is now to call $err,
so you set err="fail" at the top of the script and all is well.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-03-27 01:50:31 +00:00
Leah Rowe 401c0882aa NEW MAINBOARD: HP EliteBook 820 G2
This is of Broadwell platform, one generation above Haswell.

Of note: this uses HP Sure Start. Although the flash is 16MB,
our CBFS section (and IFD configuration) assumes 12MB flash,
so the final 4MB will be left unflashed on installation,
after blanking the private flash. The coreboot documents have
more information about this.

Some minor design changes in lbmk were made, to accomodate
this port:

Support for extracting refcode binaries added (pulled from
Google recovery images). The refcode file is an ELF that
initialises the MRC and the PCH. It is also responsible for
enabling or disabling the Intel GbE device, where Google
does not enable it, but lbmk modifies it per the instructions
on the coreboot documentation, so as to enable Intel GbE.

Google's recovery image stores the refcode as a stage file,
but coreboot changed the format (for CBFS files) after 4.13
so coreboot 4.13's cbfstool is used to extract refcode. This
realisation made me also change the script logic to use a
cbfstool and ifdtool version matching the coreboot tree, for
all parts of lbmk, whereas lbmk previously used only the
default tree for cbfstool/ifdtool, on insertion and deletion
of vendor files - it was 81dc20e744 that broke extraction of
refcode on google's recovery images, where google used an older
version of cbfstool to insert the files in their coreboot ROMs.
A further backported patch has been added, copying coreboot
revision f22f408956 which is a build fix from Nico Huber.

Iru Cai submitted an ACPI bugfix after the revision lbmk
currently uses, for coreboot/default, and this fix is
needed for rebooting to work on Linux 6.1 or higher. This
patch has been backported to lbmk, while it still uses the
same October 2023 revision of coreboot.

Broadwell MRC is inserted at the same offset as Haswell,
so I didn't need to tweak that.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-01-10 00:50:29 +00:00
Leah Rowe 535c9007fd add copyright 2024 leah rowe to edited files
i forgot to add 2024 on the copyright years, for my
copyright files that i edited on 1 january 2024

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-01-01 17:08:38 +00:00
Leah Rowe 48551ced3f git.sh: unify am/submodule and tree copying
do it all in a single function!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-01-01 15:21:46 +00:00
Leah Rowe e6953dc4f0 git.sh: clean up handling of tmp_git_dir
delete it once once, and delete it much sooner, right
at the start of script/update/trees main()

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-01-01 12:41:43 +00:00
Leah Rowe eb3a8e2b53 unify script/update/trees and script/build/grub
the script can now also handle autoconf build systems,
whereas this could previously only be done for grub.

with this change, the overall sloccount is also lower

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-12-30 13:53:45 +00:00
Leah Rowe bc87b5f67e lbmk scripts: general code cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-12-27 17:26:37 +00:00
Leah Rowe 0aca6332ee lbmk scripts: shorter code lines
while seemingly pedantic, this does actually make code
easier to read. mostly just switching to shorthand for
variable names, where no expansions or patterns are used

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-12-24 09:04:36 +00:00
Leah Rowe b0e5fc9d9c lbmk scripts: general code cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-12-23 02:52:30 +00:00
Leah Rowe ab65ea4c99 general code cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-12-22 10:24:00 +00:00
Leah Rowe f6ebab5702 option.sh scan_config: clean up if/else block
the code wasn't very clear. make it clearer.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-12-19 02:35:55 +00:00
Leah Rowe 3b7009aafa option.sh: print error on stderr, not stdout
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-12-19 02:32:56 +00:00
Leah Rowe c75ca20c0a option.sh: don't rely on zero status on printf
this part of the code *must* return. the for loop
afterwards must not be permitted to execute.

it's unlikely that this would ever occur, unless
perhaps the user is using a very buggy sh.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-12-19 02:32:30 +00:00
Leah Rowe 5f6ba01d41 include/option.sh: fix i945 bootblock copy
it wasn't being copied right

the roms under elf/ were being copied, but not the ones
under bin/ - i need to audit it further

for now, i run modify_coreboot_roms from build/roms
instead of update/trees

so, the ones under elf/ no longer have bootblocks copied.
it's only done in bin/

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-25 12:58:52 +01:00
Leah Rowe e86af9a60a 20231021hotfix: replace x_ with err in some places
keymaps weren't being set in keymay.cfg of cbfs, due
to use of x_ in the rom script, and x_ doesn't handle
quotes or spaces in arguments well.

i'm going to remove use of x_ and xx_ (it's in my todo),
for next release.

for now, hot patch the release. i've gone through and
replaced use of x_ with || err, in some places.

not just the keymap.cfg command, but others too. in case
there are more issues we missed.

this commit is being tagged "20231021fix" and i'm using
this tag to re-build the 20231021 release. i'll just
replace the tarballs in rsync and add errata to the news
page announcing the release. all i did was break peoples
umlauts, i didn't brick their machines fortunately!

very minor bug. anyway, x_/xx_ is a great idea, but sh
isn't really designed for that style of programming. i'll
go back to using just || err in the next release.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-22 12:34:45 +01:00
Leah Rowe 6af65ad430 error handling code cleanup and fixes
in some cases, use of x_ or xx_ can be error-prone,
due to the way $@ is handled; commands requiring
quotes, or with funny file names as arguments such
as spaces in the file name, or other special
characters, can make the x/xx functions break.

in those cases, where x/xx must not be used, the
commands use || err instead

in other cases, use of x/xx is superfluous, and has
been removed in some commands.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-20 05:03:16 +01:00
Leah Rowe 8d9aeef3de lbmk: use 2-level directory structure in script/
as opposed to the current 3-level structure.

recent build system simplifications have enabled
this change, thus:

./build fw coreboot -> ./build roms
./build fw grub -> ./build grub
./build fw serprog -> ./build serprog
./update project release -> ./update release
./update project trees -> ./update trees
./update vendor download -> ./vendor download
./update vendor inject -> ./vendor inject

alper criticised that the commands were too long,
so i made them shorter!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-20 01:00:38 +01:00
Leah Rowe 0b98c9b00c minor code cleanup in shell scripts
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-19 23:36:56 +01:00
Leah Rowe c14461a56b delete include/vendor.sh and merge elsewhere
move it all to other files where items are used, and not
used anywhere else. this reduces the size of vendor.sh.

also remove a few redundant variables, or variables that
are not meaningfully used.

a few items have been moved to include/option.sh

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-15 13:00:14 +01:00
Leah Rowe 1e89264ce3 update/project/*: merge to update/project/trees
Just one script.

Just one!

Well, two, but the 2nd one already existed:
logic in update/project/trees and
update/project/repo was merged into
include/git.sh and update/project/build
was renamed to update/project/trees; an -f
option was added, which calls the functions
under git.sh

so git clones are now handled by the main build
script (for handling makefiles and defconfigs)
but the logic there is a stub, where git.sh
does all the actual heavy lifting

this cuts the file count down by two, and reduces
sloccount a reasonable amount because much of
the logic already exists in the build script, when
it comes to handling targets. git.sh was adjusted
to integrate with this, rather than act standalone

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-07 10:26:11 +01:00
Leah Rowe 4708da2ca9 use quotes when checking empty strings in scripts
this is far less error-prone

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-07 05:37:11 +01:00
Leah Rowe ea27c92842 update/project/build: move helpers to option.sh
certain functions are better placed there, rather than
in the main script

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-07 05:16:46 +01:00
Leah Rowe 5de8eda21c general code cleanup in shell scripts
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-03 12:59:49 +01:00
Leah Rowe 7b02bb9aa6 do not handle errors on mktemp in shell scripts
errors are not defined for mktemp, and the /tmp file
system should be assumed reliable.

if /tmp is *unreliable*, then this is not something that
lbmk either can or should fix; the user clearly has
bigger problems.

manpages for mktemp do not define errors. it is assumed
to be completely reliable.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-02 03:39:10 +01:00
Leah Rowe 8c03b886c4 Greatly simplify error handling in shell scripts
Instead of having detailed error messages, run most
commands through a function that calls err() under
fault conditions.

Where detail is still required, err() is still called
manually. Where it isn't, the error message is simply
whatever command was executed to cause the error.

This results in a massive sloccount reduction for lbmk;
specifically, 178 sloc reduction, or a 8.1% reduction.
The total sloccount is now 2022, for shell scripts.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-01 22:47:02 +01:00
Leah Rowe 385eb90c8c update/*/*: unified scanning of revisions/sources
update/blobs/download and update/project/repo both use
the same logic, for setting variables with awk and a
specially formatted configuration file.

unify this logic under include/option.sh, and use that.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30 12:31:30 +01:00
Leah Rowe 74c48a881d move build/command/options to include/option.sh
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-27 22:31:24 +01:00