Commit Graph

130 Commits (ae28debf21a3401fa0c030383daaf853b752a03b)

Author SHA1 Message Date
Leah Rowe ae28debf21 lib.sh: condense setvars() a bit
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-25 00:28:39 +01:00
Leah Rowe 8c06c62e06 simplified lock message
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-25 00:28:33 +01:00
Leah Rowe 2965d526fd lib.sh: simplify reading of version files
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-25 00:28:27 +01:00
Leah Rowe 3319147306 lib.sh: simplify use of environment variables
don't have a separate variable for them.

just export them directly and use them directly.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-25 00:28:12 +01:00
Leah Rowe fc408f5554 lib.sh: fix error running ./build dependencies
the e() and setvars() functions need to be declared before
the dependencies function.

also: after calling install_packages, it was doing a return
when it should have done an exit.

this is all fixed now. i apologise to anyone who previously
ran into trouble with this!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-23 12:37:06 +01:00
Leah Rowe ad1d0cb58c use backticks on eval commands, not subshells
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-22 13:51:21 +01:00
Leah Rowe e7fcfac14e lib.sh: remove badcmd()
it's bloat. telling the user to rtfm is something that
we already do on irc; they will still ask how to do
everything, and ignore the message from badcmd(), or
they will automatically know to rtfm.

i'm on a massive purge, removing bloat from lbmk as
part of Libreboot Build System Audit 6.

all bloat must go.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-22 13:51:01 +01:00
Leah Rowe dec9ae9b43 lib.sh: more unified config handling
replace it with logic that simply uses "." to load
files directly.

config/git files are now directories, also containing
pkg.cfg files each with the same variables as before,
such as repository link and commit hash

this change results in a noticeable reduction in code
complexity within the build system.

unified reading of config files: new function setcfg()
added to lib.sh

setcfg checks if a config exists. if a 2nd argument is
passed, it is used as a return value for eval, otherwise
a string calling err is passed. setcfg output is passed
through eval, to set strings based on config; eval must
be used, so that the variables are set within the same
scope, otherwise they'd be set within setcfg which could
lead to some whacky results.

there's still a bit more more to do, but this single change
results in a substantial reduction in code complexity.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-22 13:50:43 +01:00
Leah Rowe 448d02babb git.sh: revert modification to for loop
i tried to be clever with this one, but it just made
the script exit with an error.

revert back to the old check (check whether one of
either repo or repo backup is set)

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-20 01:43:23 +01:00
Leah Rowe 381ed442d9 minor code cleanup in the build system
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-20 01:15:54 +01:00
Leah Rowe 295471644a git.sh: general code cleanup in fetch_submodule()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-20 00:58:31 +01:00
Leah Rowe 3ba876932d git.sh: reduced indentation on repo/file check
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-20 00:58:27 +01:00
Leah Rowe 109db65932 git.sh: simplified repo/backup check
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-20 00:58:21 +01:00
Leah Rowe b1ec5ad719 roms: remind the user about gkb files
nowadays, we don't insert GRUB keymaps automatically, for
sake of efficiency; without one, the default is US QWERTY.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-17 15:52:18 +01:00
Leah Rowe a8f44ab80a unify coreboot elfdir (DO_NOT_FLASH)
use a common string when setting this path

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-16 17:58:50 +01:00
Leah Rowe 7f5adffc02 roms: unify all add-payload commands
add a generic function that can insert payloads with lzma
compression, or raw files without compression

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-15 23:18:47 +01:00
Leah Rowe bb7b04cb59 unified checks for variable initialisation
new function chkvars() does the job

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-15 23:17:27 +01:00
Leah Rowe 1399f2137f lib.sh: remove the items() function
it's pretty much just doing the same thing as ls -1

remove it!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-15 23:17:06 +01:00
Leah Rowe 4f6fbfde81 minor code cleanup in the build system
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 19:18:41 +01:00
Leah Rowe 686bad6d4e lib.sh: more useful lock message
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 16:34:54 +01:00
Leah Rowe f1caf89a28 create a lock file during builds
prevent duplicate main instances of the build
system from running

the lock file is deleted when the parent process
exits, alongside the tmpdir deletion

the build system must only ever be run ot one
instance at a time, per work directory

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 16:34:49 +01:00
Leah Rowe b6dc23bc67 git.sh: hide e() output on for loop
this for loop is a hack to make sure that all the
sources get nuked (using nuke.list files).

hide the messages so that they do not appear when
running just any command in the trees script.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 16:34:45 +01:00
Leah Rowe e51eae0d25 lib.sh: fix regression
i was being a bit too clever about some optimisations

revert this change. otherwise, nothing will download
or build

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 16:34:38 +01:00
Leah Rowe 8b1a54d19e git.sh: download xtree *before*, not after
downloading it after means that if an error occurs
when downloading the xtree project, the main project
will still be there and nothing will mandate the
downloading of the xtree project. whereas, if we
grab the xtree project first, then the main project
won't get saved to src/

this makes the build system a bit more resilient under
fault conditions, but otherwise doesn't change behaviour.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 16:34:31 +01:00
Leah Rowe 14bba2d789 git.sh: fix deletion path in nuke()
i accidentally forgot to include src/ in the prefix

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 16:34:25 +01:00
Leah Rowe ab4c4d406f lib.sh: less confusing error in download()
don't say "file missing", because it may be present!

instead, say that the download failed. this covers both
contexts: internet failed and thus no file present, or
the file is present but checksum verification failed.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 16:34:20 +01:00
Leah Rowe 2eaaa63f58 lib.sh: hide stderr on download()
on the initial check, the output is confusing because
it will say "checksum verification failed" if the
file doesn't already exist, but then goes to download.

only say checksum failed if a download occured, and the
check failed, otherwise report nothing except that the
file already exists.

this will not reduce the ability to debug issues later
on, and it will reduce the amount of confusion for users.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 16:34:15 +01:00
Leah Rowe 9e2584fbd9 lib.sh: simplify download()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 16:34:03 +01:00
Leah Rowe 79fb79d239 lib.sh: fix redundancy in download()
it was only downloading the main url, even when
it should use the backup.

fix it by actually using the for loop variable.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 16:33:58 +01:00
Leah Rowe e8b1d45631 lib.sh: simplify singletree()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 16:33:53 +01:00
Leah Rowe 90a8ef90b0 git.sh: further simplify nuke()
it's a very compact nuke

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 16:33:48 +01:00
Leah Rowe c6b692208b git.sh: simplify link_crossgcc()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 16:33:42 +01:00
Leah Rowe c043e5810d git.sh: simplify nuke()
do not over-engineer such a trivial thing.

seriously. all we're doing is nuking some files.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 16:33:33 +01:00
Leah Rowe 8a34a0d338 git.sh: support downloading *files* as submodules
when we download coreboot, we currently don't have a way to
download crossgcc tarballs, so we rely on coreboot to do it,
which means running the coreboot build system to do it; which
means we don't get them in release archives, unless we add
very hacky logic (which did exist and was removed).

the problem with coreboot's build system is that it does not
define backup links for each given tarball, instead relying
on gnu.org exclusively, which seems OK at first because the
gnu.org links actually return an HTTP 302 response leading
to a random mirror, HOWEVER:

the gnu.org 302 redirect often fails, and the download fails,
causing an error. a mitigation for this has been to patch the
coreboot build system to download directly from a single mirror
that is reliable (in our case mirrorservice.org).

while this mitigation mostly works, it's not redundant; the
kent mirror is occasionally down too, and again we still have
the problem of not being able to cleanly provide crossgcc
tarballs inside release archives.

do it in config/submodules, like so:

module.list shall say the relative path of a given file,
once downloaded, relative to the given source tree.

module.cfg shall be re-used, in the same way as for git
submodules, but:

subfile="url"
subfile_bkup="backup url"

do this, instead of:

subrepo="url"
subrepo_bkup="backup url"

example entries in module.list:

util/crossgcc/tarballs/binutils-2.41.tar.xz
util/crossgcc/tarballs/gcc-13.2.0.tar.xz
util/crossgcc/tarballs/gmp-6.3.0.tar.xz
util/crossgcc/tarballs/mpc-1.3.1.tar.gz
util/crossgcc/tarballs/mpfr-4.2.1.tar.xz
util/crossgcc/tarballs/nasm-2.16.01.tar.bz2
util/crossgcc/tarballs/R06_28_23.tar.gz

the "subrev" variable (in module.cfg) has been renamed
to "subhash", so that this makes sense, and that name is
common to both subfile/subrepo.

the download logic from the vendor scripts has been re-used
for this purpose, and it verifies files using sha512sum.
therefore:

when specifying subrepo(git submodule), subhash will still
be a sha1 checksum, but:

when specifying subfile(file, e.g. tarball), subhash will
be a sha512 checksum

the logic for both (subrepo and subfile) is unified, and
has this rule:

subrepo* and subfile* must never *both* be declared.

the actual configuration of coreboot crossgcc tarballs
will be done in a follow-up commit. this commit simply
modifies the code to accomodate this.

over time, this feature could be used for many other files
within source trees, and could perhaps be expanded to allow
extracting source tarballs in leiu of git repositories, but
the latter is not yet required and thus not implemented.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 07:35:15 +01:00
Leah Rowe 0730513709 git.sh: remove unnecessary line break
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 07:32:51 +01:00
Leah Rowe ad05266f8d import file download function from lbmk c202dc61
in future revisions, i will make tarballs become subfiles,
to complement submodules. e.g. crossgcc tarballs in coreboot

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 07:30:07 +01:00
Leah Rowe b8e9eab0ba lib.sh: shorten a string in e()
line exceeds 80 characters

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 07:29:43 +01:00
Leah Rowe a29cf274bc git.sh: fix submodule path
i accidentally cloned to tmpdir rather than tmpgit

oops!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:41:39 +01:00
Leah Rowe 7ac2264f53 git.sh: simplify prep_submodules()
copying the module list into tmpdir/ no longer makes sense,
because it was only done before when we supported either
running the list from "git submodule update", or module.list.

since we only support handling of module.list, we can
greatly simplify this function.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:41:34 +01:00
Leah Rowe 7c8173ebd4 git.sh: unified handling of git clone/reset/am
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:41:30 +01:00
Leah Rowe d0d9b1204f git.sh: simplify submodule handling
there were stragglers remaining, from when we used to
actually run "git submodule update", but this was removed.

clean up the submodule functions and merge them together.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:41:21 +01:00
Leah Rowe df5d7c18bf git.sh: provide feedback for repository downloads
otherwise, it's not clear to the operator what's happening

i'm normally against such verbose feedback, because it's bloat,
but this minimal amount of feedback will make the build system
more pleasant to use, especially during testing.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:41:16 +01:00
Leah Rowe 591c7d28e0 git.sh: download "depend" projects *before*
don't do it after, because that means the main project
is saved under src/ before we know whether the subrepo
was downloaded.

the "depend" variable (in config/git/) is no longer used
for projects that go in subdirectories of a parent; now,
we use config/submodules/ for this type of dependency.

download the "depend" projects (as per config/git/) first.
this way, if they fail, the main one will fail, but if
they succeed and main fails, you can just run the main
download again and it won't fail.

this fixes a bug where, depending on how you download a
set of projects and depending on the order which you do so,
a given project can become un-downloadable on current design,
because git will complain that a directory already exists.

this fix is done not only in code (by this commit), but
by prior configuration changes.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:41:12 +01:00
Leah Rowe 548d1e20c1 git.sh: reduced indentation in fetch_submodule
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:41:06 +01:00
Leah Rowe 12a04e8de2 git.sh: reduced indentation in prep_submodules
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:41:01 +01:00
Leah Rowe 9825e97a83 git.sh: *never* run git submodule update
only use config/submodules/ which the build system then
uses to run git clones manually, replicating the submodules
feature. we must never use a project's own gitmodules feature,
because we can't easily control it. better to let it break first,
and then figure out what modules to add manually, so that we
have only what we need for each project.

it's done this way, because git's own submodules feature
doesn't have very good error checking in general, nor
does it have good redundancy.

with the current design, we can declare backup repositories
for each submodule.

we replicate it precisely. for example:

3rdparty/vboot

this is a coreboot submodule, and we handle that in the
coreboot trees.

however, our current design also allows you to do this even
if the upstream repository does not contain a .gitmodules file

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:40:16 +01:00
Leah Rowe 860deb3e7e lib.sh: rename variable for clarity
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:39:27 +01:00
Leah Rowe 1d7a6f04c9 move handle_coreboot_utils to script/trees
it doesn't really make sense placed in lib.sh,
because it's only called from script/trees

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:33:14 +01:00
Leah Rowe ff16d27991 put coreboot utils in elf/, not cbutils/
one directory per util, under elf/

e.g. elf/cbfstool/

further split by tree name, e.g.:

elf/cbfstool/default/
elf/cbfstool/foo/

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:32:38 +01:00
Leah Rowe 3748f710c9 fix build issue building coreboot utils
just run make directly. the trees script isn't really
designed to directly build directories, so don't.

nothing wrong with good old fashioned make -C

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:31:16 +01:00