Commit Graph

353 Commits (audit2-merge1)

Author SHA1 Message Date
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
fuel-pcbox 323a17d0c8 Add dependency scripts for Fedora 40 and Ubuntu 24.04 2024-06-09 07:44:45 +01:00
Leah Rowe 62b2310a28 add crossgcc tarballs to config/submodules/
support redundant downloads, and enable inclusion of these
tarballs inside release archives, for offline builds.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09 07:38:03 +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 573199c07d trees: simplified copy_elf() handling
don't create elfdir, create dest_dir, which is elfdir
plus the location within it

only create dest_dir within copy_elf, which is only
called if actually compiling the code

this avoids creating empty elf directories, and it
generally cleans up all handling, unifying the
handling of directories into a single function,
namely copy_elf() which already exists

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:41:25 +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 8d5edd4f06 trees: don't check empty path in copy_elf()
it could lead to some whackiness later on

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:39:20 +01:00
Leah Rowe c1176bbd28 trees: fix build issue caused by bad elf check
we're not checking for bad elfs, but the check itself was bad

due to a quirk in how sh works. really, really obscure bug.

fixed now!

if the given directory didn't actually exist, or there were no
files in it, it'd be searching for the file named "*"

which is obviously wrong

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:39:15 +01:00
Leah Rowe c88fb8c129 trees: fix listfile check in copy_elf()
don't check that the variable is empty

check that the file itself exists or not

this should fix the recent build issues

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:39:10 +01:00
Leah Rowe 9168d33741 trees: don't say check elf/ if build.list missing
(on single tree projects. this complements the last patch)

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:39:04 +01:00
Leah Rowe db09530905 trees: don't do elfcheck if build.list missing
otherwise, some checks are done too soon, and nothing
gets built.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:38:58 +01:00
Leah Rowe 99418a7e82 define mdfiles/images in config/submodules/docs/
again: the "depend" variable must never be used for subprojects
that point to a subdirectory of the main project, because there's
no clean way of handling this in case of error conditions.

make it a submodule under config/submodules/. this is for the
documentation, including static site generator documentation,
and image files (photos).

as of this revision, there are now only those "depend" projects
defined in config/git/, where the destination directory of the
subject is not a subdirectory of the main project, so:

in a subsequest revision, i will mitigate an existing bug whereby
failure of the dependency project leaves the main one still
intact, breaking builds; this revision enables that to be done.

from now on, subproject-to-subdirectory-of-main-project will
be avoided in config/git/; config/submodules/ will be used.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:37:41 +01:00
Leah Rowe 83d84797d8 libopencm3 to config/submodules/ on stm32-vserprog
same as the previous patch, we must no longer use "define"
variables in config/git/ when the path is a subdirectory of
a given project, because it means that the download can only
happen after the main one, and currently if that fails, the
download of the main repo would remain intact, breaking future
builds in ways that we can't control - to be clear, it could
be controlled, but with added code complexity in the build
system, so:

put it in config/submodules/

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:34:24 +01:00
Leah Rowe c3cabcddf9 add tinyusb to config/submodule/ for pico-sdk
don't define it as a "depend" variable in config/git/,
because it means putting the files in a subdirectory of
an existing project was was already then downloaded, and
that means it can't be downloaded first; if the download
of it fails, the old download is left intact.

this bug isn't currently fixed in the build system, at all,
so this and other patches are being made to mitigate it.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:34:18 +01:00
Leah Rowe e4eb82e089 trees: unified coreboot makeargs
in particular, the coreboot build system may auto-download
submodules when building cbfstool; vboot for instance.

we do not want such unpredictable behaviour, so now we
use UPDATED_SUBMODULES=1 when building coreboot utilities.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:33:25 +01:00
Leah Rowe f7170092c8 trees: use multiple threads to build cbutils
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:33:20 +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
Leah Rowe a30bfd334f trees: skip single-tree build if a build exists
this replicates the same behaviour as multi-tree builds,
checking for files inside the relevant elf/ directory

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:31:11 +01:00
Leah Rowe b682b4ddca use correct memtest86plus path in script/roms
the previous change makes memtest.bin get cached in elf/
but the path was being prefixed with src/ by script/roms

do away with the prefix

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:31:05 +01:00
Leah Rowe 4749a5a29f put memtest86plus builds in elf/memtest86plus/
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:31:00 +01:00
Leah Rowe 0e9d9b33b2 put flashprog builds in elf/flashprog/
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:30:55 +01:00
Leah Rowe 7fe0106fa0 trees: also print "DONE! check elf/dir" on single
e.g. ./update trees -b flashprog

tell the user to check elf/flashprog

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:30:51 +01:00
Leah Rowe 74759d876a trees: handle build-test on multi-tree projects
for example, now flashprog binaries could be placed
in the elf/ directory, under elf/flashprog/

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:30:40 +01:00
Leah Rowe 98e9cf6864 git.sh: use singletree() to decide submodules
now it no longer hardcodes a check for whether the
project name is coreboot. this maintains the same
behaviour but will now work for other multi-tree
projects; in practise, the other multi-tree projects
did not use .gitmodules files anyway, but some of
them used config/submodules/ in our build system.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:29:58 +01:00
Leah Rowe b3b887567a remove cbcfgsdir variable (unused)
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:28:50 +01:00
Leah Rowe cb446e7d24 move cfgsdir/datadir variables to lib.sh
it's also used from script/roms, in addition to trees

move these variables to a common file used everywhere

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:28:16 +01:00
Leah Rowe 7d99786a1a handle build.list from config/data/, not config/
certain code checks for build.list, to skip it, for
example in items()

we already use config/data/grub to store grub config data
that applied to all trees

create these directories too:

config/data/coreboot
config/data/u-boot
config/data/seabios

move the respective build.list files in here, and also
to config/data/grub

now multi-tree projects contain, per directory, just the
target.cfg file and the patches directory. this is much
cleaner, because some of the logic can be simplified more

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:27:45 +01:00
Leah Rowe a61794dfca don't use build.list to detect multi-tree projects
instead, check for the presence of target.cfg files
not in config/project/ but config/project/tree/

the way this check is done, it merely returns 1 if
config/project/*/target.cfg is detected, and returns
0 in all other cases, even if config/project/target.cfg
exists

that way, if the maintainer accidentally adds a
target.cfg in the main directory, the given multi-tree
project will not break

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:27:40 +01:00
Leah Rowe 878056f37b move id check to lib.sh too
doesn't really matter, it's just an extra layer to ensure
reliability, but "id" is pretty standard

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07 17:27:36 +01:00
Leah Rowe 3900642471 move root check to lib.sh (bugfix)
this avoids writing the version/versiondate files as root.

this complements the previous fix, that avoided writing those
same files when running the dependencies command.

initial setup of the build system requires root, to run the
dependencies script, but otherwise the build system prevents
running as root for everything else, so we must avoid writing
the version/versiondate files as root.

that same avoidance is necessary when checking whether running
other commands as root; ironically, this check then prevented
running the build system at all!

the bug should be fully fixed now. i found this quite by accident
the other day, when testing something else.

good thing this got fixed because the release!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-05 11:15:44 +01:00
Leah Rowe 740b1803fa bugfix: move dependencies handling to lib.sh
do it strategically, in just the right place so that the
version and versiondate files aren't written.

otherwise, version/versiondate are written as root and
the build system becomes unusable after that, unless you
reset the file ownerships from root. hardly user-friendly.

mitigate this bug.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-05 11:15:39 +01:00