Commit Graph

45 Commits (ce10c1b38c6ed2137803e37e8a69e7eecd5ce61d)

Author SHA1 Message Date
Leah Rowe 176722a841 unify handle/make/* into build/project/trees
Just one script.

Just one.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-06 01:16:39 +01:00
Leah Rowe 9d419e77a0 handle/make/*: unified main() function
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-05 22:51:05 +01:00
Leah Rowe cad7648a26 build/boot/*: merge all logic into one script
for the first time ever, this is a single script.
with recent simplifications in how variables are
handled, and techniques i've developed during
auditing, it's now feasible design-wise for this
to be a single script, without a helper script.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-05 03:48:05 +01:00
Leah Rowe 923a96c18e check git/version: properly call err()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-04 10:02:59 +01:00
Leah Rowe 1223bfaeef check_git: call fail() first (fallback to err)
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-04 10:00:12 +01:00
Leah Rowe 727dc7ff2f more verbosely print git config error
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-04 09:57:42 +01:00
Leah Rowe fbd464b4f7 include/err.sh: checkgit,checkversion
call these as functions, instead of executing scripts

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-04 08:06:10 +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 d38b958d7a include/err x_(): more verbose error message
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-02 04:57:51 +01:00
Leah Rowe 8886f9958f include/err: remove unused variable
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-02 04:56:53 +01:00
Leah Rowe 7ce3f93e44 build/boot/*: unify more logic in main()
slight sloccount reduction. light renaming of
functions between the two scripts, placing more
logic in main() under include/boot.sh

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-02 03:54:39 +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 5f914a4d00 build/boot/roms: optimise main() for code size
handle everything in the getopts loop

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-01 04:30:02 +01:00
Leah Rowe 92c6da7b21 build/boot/roms_helper: shorten variable names
also: further reduce the number of arguments passed,
to certain functions as and when feasible, in cases
where those are global variables that never change.

the cbfstool argument in mkUbootRom wasn't even used.
that function was only using the global variable, which
again is only set once.

i also shortened a few messages, removed a few errant
line breaks and reduced sloccount by exactly 1 in main()
by re-arranging how the shift command is used.

it's mainly about shortening variable names, to then
reduce the number of line breaks, but it's a surgical
code size reduction in build/boot/roms.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-01 04:08:30 +01:00
Leah Rowe 42d4fa9b12 include/boot.sh: simplify variable initialisation
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-01 01:17:59 +01:00
Leah Rowe 0a0defd325 simplify initialising variables in shell scripts
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30 19:09:25 +01:00
Leah Rowe 49b266eb42 build/boot/roms: only do 1 custom kbd/payload/mode
-k, -p and -d let you set keymap, payload and displaymode
respectively, but the handling for this is buggy when
passing multiple arguments.

Support only one argument, for simplicity. This is how
people use them anyway, and it makes lbmk less buggy.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30 16:14:27 +01:00
Leah Rowe d268f5eb28 build/boot/roms: move usage() to include/boot.sh
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30 15:36:53 +01:00
Leah Rowe 7922b6e0e5 build/boot/*: unified main() function
The *same* main() function is now used on both scripts.

However, merging both scripts together would be less efficient
on sloccount, and would be error-prone. The purpose of having
roms_helper is that the variables get re-initialised the same
way each time, for each board, automatically.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30 15:28:52 +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 9f5a5450af blobs/download: move helpers to include/blobutil
mkdirs() should be in include/blobutil.sh, as should
extract_archive(), because that is primarily where
they are used.

script/update/blobs/download calls these functions
aswell, but it sources include/blobutil.sh so it's OK.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-29 23:40:57 +01:00
Leah Rowe 416704fb4e include/blobutil: try curl first, then wget
Don't use only wget. Some systems may only have curl.

The user can always install wget anyway, but why not
support both? I've added the right user agent string.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-29 23:04:30 +01:00
Leah Rowe 6519cea9cf include/blobutil: simplify check_defconfig()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-29 22:34:34 +01:00
Leah Rowe 9b94df5dbb blobs/download: do final check of _dest in fetch()
This way, the file is checked regardless of what type of
blob is handled, not just Intel ME.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-29 21:44:51 +01:00
Leah Rowe 9a7bf4af0f blobs/download: don't pass dl_path as argument
Because fetch() is only called now from blobs/download,
we can reliably know what dl_path should be.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-29 20:43:24 +01:00
Leah Rowe 2b7ae8e204 blob scripts: unified handling of blob destination
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-29 20:29:13 +01:00
Leah Rowe 8ea62a1661 remove unused variables in blob scripts
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-29 18:44:27 +01:00
Leah Rowe 32da4e319b merge include/fetch.sh, blobutil.sh, defconfig.sh
They are only ever used by script/update/blobs/*, so
put them all in blobutil.sh. This cuts down on the
number of scripts in lbmk.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-29 17:23:47 +01:00
Leah Rowe 710171f92b update/blobs/*: simplify mrc.bin handling
mrc.bin is now handled by include/mrc.sh, adapted
from now-deleted script/update/blobs/mrc

much of the logic has been re-written or adapted for
inside script/update/blobs/download

mrc links/hashes now defined in config/blobs/sources

the new code is simpler (and smaller). in addition,
lbmk can now easily handle mrc.bin files for other
platforms such as broadwell. watch this space.

the full .zip download is now cached, like with other
vendor downloads. this means it won't be re-downloaded
if it was already downloaded before.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-29 16:40:49 +01:00
Leah Rowe 0bb3c59620 update/blobs/*: unified download/checksum logic
Use the same logic between blobs/download and blobs/mrc.

The logic is taken from blobs/download.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-29 04:03:18 +01:00
Leah Rowe 178b888aa0 include/blobutil: properly set global variables
I was setting certain global variables inside for loops,
but some sh implementations won't like this.

Instead, don't run eval inside the for loops. Set a string
for eval inside the for loops, then execute eval outside of
the loops. This should work on every shell.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-28 02:28:51 +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
Leah Rowe d023327f98 blobs/download: greatly simplify sources handling
remove the giant case/esac list, and set variables directly.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-27 16:10:48 +01:00
Leah Rowe 65a3269835 include/blobutil: simplify setting empty strings
use a for loop and eval to set them.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-27 15:26:17 +01:00
Leah Rowe 36b7f01a8a only update git submodules in project/trees
do not update them in project/repos - despite what
the previous commit message says, this behaviour is
error prone and should be avoided.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-25 12:46:54 +01:00
Leah Rowe 81d073d5a1 update/project/*: unified git reset handling
With this change, lbmk now also updates submodules on
simple git clones, not just multi-tree clones.

This is OK, because git does not return non-zero status
when git submodule update is ran, where git submodules
are not actually defined.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-25 12:21:23 +01:00
Leah Rowe a823bab365 include/git: support applying patch subdirectories
This is done recursively, with the following rule:
files first, then directories.

Where all patch files are applied from within the
patch directory, subdirectories (within the patch
directory) are then tried in alphanumerical order.

Then, within each subdirectory tried, the same rule
is once again applied. This is done recursively,
until every patch file is applied.

The code no longer applies *.patch, but instead any
file. Additionally, symlinks are avoided.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-25 12:00:43 +01:00
Leah Rowe 3738ec90ec update/project/*: unified patch handling
Handle patches by a function at include/git.sh

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-25 11:49:13 +01:00
Leah Rowe 208620198c Update email address for Leah Rowe copyrights
also, some of them were out of date; years now updated.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-25 02:27:26 +01:00
Leah Rowe cc1642096e Use SPDX license headers on all scripts
This results in much cleaner copyright and license declarations.
SPDX headers are legally recognised and make auditing easier.

Also, remove descriptions of each script, from each script.
Libreboot documentation at docs/maintain/ describes them.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-25 02:19:48 +01:00
Leah Rowe a56cad71c0 update/blobs: unify global variables
they all more or less use the same variables, so put
them all under include/blobutil.sh

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-04 18:12:49 +01:00
Leah Rowe 2cbc7eea95 update/blobs/*: unify checking of defconfig files
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-04 16:16:53 +01:00
Leah Rowe 4885c7962d handle TMPDIR from include/export.sh
it looks a bit cluttered just sitting there in
the main script. make it an include.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-02 10:22:39 +01:00
Leah Rowe 57adbc6eb1 unify err functions across scripts
include/err.sh

this new handling also does mundane things,
such as tell you what script b0rked

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-23 19:12:00 +01:00