Compare commits

...

81 Commits

Author SHA1 Message Date
Leah Rowe addbd95a24 init.sh: merge xbmk_lock() with xbmk_set_env()
it's just two lines, and we want much more granular
control of where the lock is enforced. it should be
JUST after confirming that the instance is a parent.

it is at this moment that we should bail if a lock
file exists, because this signals that another instance
of xbmk is running.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:19:26 +01:00
Leah Rowe 1c34d4567b init.sh: move xbmk_set_version
it's called before set_pyver, so move it above that

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:19:21 +01:00
Leah Rowe a4103517ea init.sh: set pyver from set_env
it's related to this function, no point calling from main

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:19:16 +01:00
Leah Rowe 6a3c771feb init.sh: merge xbmk_mkdirs with set_env
it's just two lines, and they relate.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:19:10 +01:00
Leah Rowe de62243cd2 init.sh: check version/versiondate once read
once again, we are being stricter in child instances.

we must ensure that these variables are set by xbmk.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:19:05 +01:00
Leah Rowe 6b8ee3d3b3 init.sh: error if version not read
we no longer rely on the .git version being
read by child instances, so we MUST ensure
that it is being read.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:19:00 +01:00
Leah Rowe 08610f4145 init.sh: only update version files on parent
don't update them on child instances, since it's a waste
of time; the lock file prevents further execution, so we
are just wasting time writing to disk.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:18:54 +01:00
Leah Rowe 412b0a81d7 init.sh: simplify unknown version creation
we don't need to read or write a file at all, in that case.
we only then need to generate one if running ./mk release.

the scenario in which no .git and no version files exist
is when someone grabs the build system from a snapshot
generated by e.g. forgejo instances. it's ill advised, so
we advise against it, but it is mitigated in code.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:18:49 +01:00
Leah Rowe 2a6a4d765d init.sh: only set xbmk version on parent instance
On child instances, we need only read.

Apply the principle of least privilege.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:18:44 +01:00
Leah Rowe 416b1f66be init.sh: initialise variables AFTER path
That way, unnecessary work is avoided on child instances.

Of course, the current check assumes that TMPDIR wasn't
already set by a wily user before running lbmk, but then
those sorts of users probably know what they're doing.

If they don't know, they will soon find out. Therefore, I
have added additional checks on child instances, preventing
the build system from running if XBMK_CACHE is not set; if
it isn't, then that could very easy lead to certain system
files being overwritten.

The user must never know what happens if XBMK_CACHE is unset.
We simply will not allow it.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:18:39 +01:00
Leah Rowe 46f09075c2 init.sh: merge create_pathdirs with set_pyver
all this function does now is create the python symlink,
based on work that was already performed in set_pyver

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:18:33 +01:00
Leah Rowe abf52b0394 init.sh: Set python version only on parent
Do it after the creation of xbmkpath.

This avoids performing an unnecessary check, since
PATH will have already been corrected for child
instances; Python will already be correct there.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:18:28 +01:00
Leah Rowe 1e4e3f36f4 init.sh: remove useless command
we mkdir -p xbmklocal, only to remkdir it immediately
afterward, which is the intended behaviour; on parent
instances, xbmklocal is to be re-created fresh.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:18:22 +01:00
Leah Rowe ed83718cf2 init.sh: remove useless comment
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:18:18 +01:00
Leah Rowe 8617375799 init.sh: xbmk_create_tmpdir to xbmk_mkdirs
this function now simply creates directories that lbmk
will use, rather than creating specific directories.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:18:13 +01:00
Leah Rowe 83064459d9 init.sh: move gnupath creation to create_tmpdir
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:18:07 +01:00
Leah Rowe 0389d1eadb init.sh: move PATH init to set_env
we must only set this in the parent instance, not
child instances. this prevents the variable from
being over-populated with repeated entries.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:18:03 +01:00
Leah Rowe 4aba9ef29e init.sh: check the lock file BEFORE git init
this way, initialisation will not be performed erroneously
while another parent instance of lbmk is running.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:17:57 +01:00
Leah Rowe fa2c288939 init.sh: return from child in set_env instead
This is earlier than the current check, thus preventing
the initialisation of a git repository and/or the recreation
of xbmktmp and xbmklocal by erroneous parent executions of lbmk
while another parent is running - the latter of which could have
caused a massively unpredictable build failure, so this is also
a pre-emptive bug fix, fixing all kinds of weird bugs.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:17:34 +01:00
Leah Rowe 9b1d4dfe82 inject.sh: shorten the nukemode variable name
just call it "nuke". this is what tells whether to remove
vendor files from an archive.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:16:46 +01:00
Leah Rowe e34651a98a release.sh: rename relsrc to rsrc
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:15:46 +01:00
Leah Rowe 1523a67729 release.sh: tidy up nuke()
i wasn't ok having that variable initialisation and
then the commands on the same line. it looks messy.

having the commands on a separate line makes the code nice
to read, so let's separate them.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:15:40 +01:00
Leah Rowe c068efec88 get.sh: remove useless message
the user doesn't care where the temporary git repo is

git shows that information anyway, in the git clone command

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:15:30 +01:00
Leah Rowe c660ecde62 get.sh: simplify bad_checksum()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:15:25 +01:00
Leah Rowe 2d13b4c2e2 release.sh: simplify nuke() EVEN MORE, yet again
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:15:19 +01:00
Leah Rowe c20e29005f release.sh: use x_ on find command for nuke()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:15:13 +01:00
Leah Rowe 97603a43cf release.sh: simplify nuke() EVEN MORE
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:15:07 +01:00
Leah Rowe 534a4d4870 get.sh: move nuke() to release.sh
we really only need it there, because the context is
for release archives. normal use of the git repository
doesn't matter in the context of deletions, because that
will not be distributed. only the result of ./mk release
will be distributed.

the builds produced will not change as a result of this,
for people using the normal git repository, because the
files in question are never used anyway, in our configs.

this is being done to make working on local repos easier.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:15:00 +01:00
Leah Rowe 8b646abe9a release.sh: simplify prep_release_bin()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:14:38 +01:00
Leah Rowe aeb1187a8a release.sh: don't move src/docs/
otherwise, ./mk -b (without argument) will fail, on release
archives. also, perhaps i should add an mkhelper to build it?

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18 19:13:56 +01:00
Leah Rowe 8cb0c224a5 get.sh: FURTHER simplify nuke()
this is getting almost comical now

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-17 12:18:26 +01:00
Leah Rowe 8cb23315d9 get.sh: simplify tmpclone()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-17 11:09:35 +01:00
Leah Rowe 8d6244bb7f get.sh: fix bad mkdir command
this is the mkdir call that createsn the directory where
a cached git repository is moved to, during creation.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-17 11:09:25 +01:00
Leah Rowe 4582a21abf inject.sh: Stronger hash verification
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-16 13:43:00 +01:00
Leah Rowe fd98310f5b properly exit 1 when calling fx_
in a few places, we use the presence of a file found
by fx_ to cause an exit, but the command that runs
looks something like:

exit 1 "string"

this yields an error, and a non-zero exit, because of
too many arguments to "exit", but we wanted a non-zero
exit anyway.

nevertheless, this is incorrect.

to fix it, eval is used instead. if the never-going-to-exist
condition one day exists where exit 1 actually returns, not,
you know, exits, we will use err instead, with the string
as argument.

this should be fine. it's a bit hacky, but so is fx_, and
it works. fx_ is used in several places to keep the sloccount
down, providing a common way to perform while loops on the
output of a command; that is its only purpose..

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-15 02:42:26 +01:00
Leah Rowe e96dfae0b3 get.sh: simplify nuke()
more specifically, re-write it so that it can be called with fx_

this means that the single-tree check for nuke.list can be made
much simpler

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-15 02:12:34 +01:00
Leah Rowe 3bfb82cb82 get.sh: fix broken printf statement
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:45:37 +01:00
Leah Rowe 9c24b170c2 get.sh: use subshells on try_ functions
This way, we can use x_ which will then print the command
that failed, if we need to debug future errors.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:45:31 +01:00
Leah Rowe 4f926ee708 get.sh: simplify try_copy()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:45:24 +01:00
Leah Rowe 36cf7892df get.sh submodules: Don't delete files recursively
I overlooked this in a previous patch. It doesn't really
matter, since we're operating on a file anyway, but it's
not correct.

Files should have rm -f on them, not rm -Rf, for deletion.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:45:14 +01:00
Leah Rowe 398f265359 get.sh: simplify fetch_submodules() config check
We already do what the old code does in setcfg, by
virtue of the fact that the st variable is later
checked, after loading this config conditionally,
where the st variable is otherwise blank.

We can avoid the unnecessary work after loading
the config, by returning if the config is absent.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:45:06 +01:00
Leah Rowe a3f48f3115 get.sh: simplify fetch_submodules()
We are calling xbmkget in the same way, whether it's
a subfile or subrepo.

Rename these variables to subcurl and subgit, so that we
can call xbmkget unconditionally.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:44:42 +01:00
Leah Rowe 142b79b206 get.sh: fix caching of crossgcc tarballs
they were always re-downloading every time.

i've basically re-written most of xbmkget.

there was some erroneous conditions under which
it wrongly deleted the cached file, resulting in
it being downloaded again.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:42:52 +01:00
Leah Rowe a658265a86 release.sh: Don't run prep_release with fx_
The result of the printf statement is sorted, making
it do binaries first, which results in a lot of junk
files then being present inside the source archive.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:42:32 +01:00
Leah Rowe aaa0a1ff93 git.sh: rename to get.sh
it now handles more than just git, and i forsee
it handling even more in the future, e.g. rsync,
ftp, bittorrent.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:42:17 +01:00
Leah Rowe 2d691c7377 git.sh: Only create destination repo on success
Don't leave a broken cache laying around, which would
otherwise break lbmk for the user.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:42:10 +01:00
Leah Rowe 6199bc5b95 git.sh: cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:42:02 +01:00
Leah Rowe 1dd18a9a55 git.sh: Re-implement redundant git downloads
And this time it works.

I'm now calling xbmkget() which in turn calls tmpclone(),
instead of me calling tmpclone() directly.

The git-pull is done on both remotes, regardless of whether
the first succeeds. This way, if I forgot to update a mirror,
downloads would probably still work.

This also fixes an issue people were having, for example where
the gnulib repository of GRUB was always being downloaded
every time.

I'm using a new directory, XBMK_CACHE/clone, instead
of XBMK_CACHE/repo (which I used before), in case people
still have the old caches from before.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:41:53 +01:00
Leah Rowe 176c0fa1c4 rom.sh: reduce indendation in check_coreboot_utils
call it via fx_, instead of using a for loop

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:41:42 +01:00
Leah Rowe 584de778f8 release.sh: simplify release()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:41:31 +01:00
Leah Rowe ed8644177b release.sh: clean up the vdir after release
do this after moving the version directory within it.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:40:56 +01:00
Leah Rowe 2ca6337b0a release.sh: remove src_dirname variable
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:40:48 +01:00
Leah Rowe abfa2d1ec7 release.sh: build in tmp directory first
don't move to the real directory until the work
is done.

that way, a re-try can be done, while analysing
the old files. it is created based on the tmpdir,
under XBMK_CACHE/

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:40:26 +01:00
Leah Rowe d3ec7e8635 release.sh: remove unnecessary mkdir command
the following git clone command creates that directory

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:40:12 +01:00
Leah Rowe b68447e75c release.sh: split up build_release()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:39:35 +01:00
Leah Rowe 4b36ba9765 release.sh: delete tmp/cache from the tarball
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:38:11 +01:00
Leah Rowe 5861c25a7c lib.sh: remove rmgit()
We don't need to call it from git.sh, because it's
only being done when building a release anyway,
and we already run rmgit when doing a release.

The function itself is only two simple fx_ calls,
so we can just do that from build_release().

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:37:51 +01:00
Leah Rowe 1f2c8e47d4 lib.sh: remove mk()
i don't need it. i can use fx_ instead, on functions
that previously called mk().

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:37:22 +01:00
Leah Rowe 19888e2cb8 lib.sh: move xbmkget() to git.sh
in cbmk, it's only used from there.

in lbmk, it's also used from vendor.sh.

however, i plan to further expand git.sh at
some point, tidying it up so that git cloning
is also done from xbmkget, with dlop=git and
git.sh would then be renamed to get.sh

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:36:31 +01:00
Leah Rowe 9c5f59cc42 lib.sh: remove mksha512sum()
this is unused in cbmk.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:35:54 +01:00
Leah Rowe 279b7f20be lib.sh: split up try_file()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:35:31 +01:00
Leah Rowe 3347e3d314 lib.sh: move _ua to try_file()
it's only used there

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:35:25 +01:00
Leah Rowe 57f68535a2 inject.sh: remove the hashfiles variable
we only use it once, and it's a trivial string

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:34:51 +01:00
Leah Rowe d07bd53b07 inject.sh: define xchanged here instead
this is used here, and also needed in cbmk.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:33:39 +01:00
Leah Rowe 47b9a261d7 lib.sh: use fx_ in rmgit()
with fx_, i have more much granular control over
how errors are handled.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:32:53 +01:00
Leah Rowe ed9f6338af lib.sh: split up xbmkget()
it was too complicated. most of the logic has been moved
to a new function, try_file()

the for loop is handled by xbmkget(), whereas each try
is now handled in try_file()

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:32:39 +01:00
Leah Rowe 753af0a7a2 inject.sh: only compile nvmutil if needed
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:32:33 +01:00
Leah Rowe 387f4b785b inject.sh: simplified serprog check
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:32:26 +01:00
Leah Rowe 31bab5c10c remove another confusing message
the current message says the file name, and implies that
the given file has already been updated.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-14 21:31:47 +01:00
Leah Rowe 6c3ea129a4 inject.sh: Remove confusing path on tar creation
The path is wrong. The correct path is printed afterward.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-10 20:49:19 +01:00
Leah Rowe 3062f04c45 inject.sh: re-add mac address confirmation
it just makes the script more user-friendly

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-10 20:24:30 +01:00
Leah Rowe cf8ca4cdd6 inject.sh: further cleanup
this is based on lbmk commit e5af201060e

this removes more code that is not needed in cbmk's version
of inject.sh

lbmk and cbmk inject.sh are now much more in sync, in that
they are much more similar to each other than before.

the cbmk version only handles MAC addresses, and does not
do vendor file downloading or patching.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-10 20:16:23 +01:00
Leah Rowe a82ca2da5f tree.sh: only create elfdir in copy_elf()
otherwise, we create empty directories where build.list
doesn't exist, like on coreboot.

we already create a directory when needed, when actually
copying elf files, so let's just leave it at that.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-10 18:22:30 +01:00
Leah Rowe 33debfcf1c tree.sh: simplified srcdir check on make-clean
this is the check that ksips a given target if the tree
directory does not exist, on the clean command.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-10 18:22:25 +01:00
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 5cdd377547 mk: use zero exit instead, to run trees
that way, with set -u -e, we aren't risking some
buggy sh implementations from causing an error exit
where it shouldn't.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-10 18:06:27 +01:00
Leah Rowe c022a14c9e remove useless comment
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-10 18:05:47 +01:00
Leah Rowe c9325f234e mk: remove unnecessary line break
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-10 18:05:37 +01:00
Leah Rowe e22593f037 mk: re-split tree logic to include/tree.sh
I really think mk should just be a small stub.

Better to keep everything separate.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-10 18:03:45 +01:00
Leah Rowe c463e8a52d mk: move release functions to idnclude/release.sh
The idea with mk is that it's meant to basically be a
stub for running everything else, while mainly having
the trees logic within it (what was once script/trees).

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-10 18:03:32 +01:00
36 changed files with 837 additions and 809 deletions

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subfile="https://www.mirrorservice.org/sites/libreboot.org/release/misc/acpica/acpica-unix-20241212.tar.gz"
subfile_bkup="https://mirror.math.princeton.edu/pub/libreboot/misc/acpica/acpica-unix-20241212.tar.gz"
subcurl="https://www.mirrorservice.org/sites/libreboot.org/release/misc/acpica/acpica-unix-20241212.tar.gz"
subcurl_bkup="https://mirror.math.princeton.edu/pub/libreboot/misc/acpica/acpica-unix-20241212.tar.gz"
subhash="daa4243f927451ac18c337cf17c27849e68329b3f7eb25b8c3379fda9c6a484201b73d4ffccab89a0ae22cc5e432f141ba149015a003834b0515bdb3d4efe0a8"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subrepo="https://review.coreboot.org/arm-trusted-firmware.git"
subrepo_bkup="https://github.com/coreboot/arm-trusted-firmware"
subgit="https://review.coreboot.org/arm-trusted-firmware.git"
subgit_bkup="https://github.com/coreboot/arm-trusted-firmware"
subhash="57ac3f74b34a3303f03deee264a1f2247c68008d"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/binutils/binutils-2.43.1.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/binutils/binutils-2.43.1.tar.xz"
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/binutils/binutils-2.43.1.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/binutils/binutils-2.43.1.tar.xz"
subhash="20977ad17729141a2c26d358628f44a0944b84dcfefdec2ba029c2d02f40dfc41cc91c0631044560d2bd6f9a51e1f15846b4b311befbe14f1239f14ff7d57824"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.xz"
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.xz"
subhash="932bdef0cda94bacedf452ab17f103c0cb511ff2cec55e9112fc0328cbf1d803b42595728ea7b200e0a057c03e85626f937012e49a7515bc5dd256b2bf4bc396"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/gmp/gmp-6.3.0.tar.xz"
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/gmp/gmp-6.3.0.tar.xz"
subhash="e85a0dab5195889948a3462189f0e0598d331d3457612e2d3350799dba2e244316d256f8161df5219538eb003e4b5343f989aaa00f96321559063ed8c8f29fd2"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subrepo="https://review.coreboot.org/libgfxinit.git"
subrepo_bkup="https://github.com/coreboot/libgfxinit"
subgit="https://review.coreboot.org/libgfxinit.git"
subgit_bkup="https://github.com/coreboot/libgfxinit"
subhash="17cfc92f402493979783585b6581efbd98c0cf07"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subrepo="https://review.coreboot.org/libhwbase.git"
subrepo_bkup="https://github.com/coreboot/libhwbase"
subgit="https://review.coreboot.org/libhwbase.git"
subgit_bkup="https://github.com/coreboot/libhwbase"
subhash="584629b9f4771b7618951cec57df2ca3af9c6981"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/mpc/mpc-1.3.1.tar.gz"
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/mpc/mpc-1.3.1.tar.gz"
subhash="4bab4ef6076f8c5dfdc99d810b51108ced61ea2942ba0c1c932d624360a5473df20d32b300fc76f2ba4aa2a97e1f275c9fd494a1ba9f07c4cb2ad7ceaeb1ae97"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/mpfr/mpfr-4.2.1.tar.xz"
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/mpfr/mpfr-4.2.1.tar.xz"
subhash="bc68c0d755d5446403644833ecbb07e37360beca45f474297b5d5c40926df1efc3e2067eecffdf253f946288bcca39ca89b0613f545d46a9e767d1d4cf358475"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subfile="https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/nasm-2.16.03.tar.bz2"
subfile_bkup="https://www.mirrorservice.org/sites/distfiles.macports.org/nasm/nasm-2.16.03.tar.bz2"
subcurl="https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/nasm-2.16.03.tar.bz2"
subcurl_bkup="https://www.mirrorservice.org/sites/distfiles.macports.org/nasm/nasm-2.16.03.tar.bz2"
subhash="f28445d368debdf44219cc57df33800a8c0e49186cd60836d4adfec7700d53b801d34aa9fc9bfda74169843f33a1e8b465e11292582eb968bb9c3a26f54dd172"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subrepo="https://review.coreboot.org/vboot.git"
subrepo_bkup="https://github.com/coreboot/vboot"
subgit="https://review.coreboot.org/vboot.git"
subgit_bkup="https://github.com/coreboot/vboot"
subhash="3f94e2c7ed58c4e67d6e7dc6052ec615dbbb9bb4"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subfile="https://www.mirrorservice.org/sites/libreboot.org/release/misc/acpica/acpica-unix2-20190703.tar.gz"
subfile_bkup="https://mirror.math.princeton.edu/pub/libreboot/misc/acpica/acpica-unix2-20190703.tar.gz"
subcurl="https://www.mirrorservice.org/sites/libreboot.org/release/misc/acpica/acpica-unix2-20190703.tar.gz"
subcurl_bkup="https://mirror.math.princeton.edu/pub/libreboot/misc/acpica/acpica-unix2-20190703.tar.gz"
subhash="8445a6d354ce3bcbfb5159f4ec0312b1e910c0b1b2033a2300f892e4ac580abab4e3f5b4ded379f0036299359d307330511ab7053678cfd9031d7df4c365f555"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/binutils/binutils-2.32.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/binutils/binutils-2.32.tar.xz"
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/binutils/binutils-2.32.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/binutils/binutils-2.32.tar.xz"
subhash="d326408f12a03d9a61a9de56584c2af12f81c2e50d2d7e835d51565df8314df01575724afa1e43bd0db45cfc9916b41519b67dfce03232aa4978704492a6994a"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gcc/gcc-8.3.0/gcc-8.3.0.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/gcc/gcc-8.3.0/gcc-8.3.0.tar.xz"
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gcc/gcc-8.3.0/gcc-8.3.0.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/gcc/gcc-8.3.0/gcc-8.3.0.tar.xz"
subhash="1811337ae3add9680cec64968a2509d085b6dc5b6783fc1e8c295e3e47416196fd1a3ad8dfe7e10be2276b4f62c357659ce2902f239f60a8648548231b4b5802"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/gmp/gmp-6.1.2.tar.xz"
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/gmp/gmp-6.1.2.tar.xz"
subhash="9f098281c0593b76ee174b722936952671fab1dae353ce3ed436a31fe2bc9d542eca752353f6645b7077c1f395ab4fdd355c58e08e2a801368f1375690eee2c6"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/mpc/mpc-1.1.0.tar.gz"
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/mpc/mpc-1.1.0.tar.gz"
subhash="72d657958b07c7812dc9c7cbae093118ce0e454c68a585bfb0e2fa559f1bf7c5f49b93906f580ab3f1073e5b595d23c6494d4d76b765d16dde857a18dd239628"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subfile="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.xz"
subfile_bkup="https://ftp.nluug.nl/pub/gnu/mpfr/mpfr-4.0.2.tar.xz"
subcurl="https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.xz"
subcurl_bkup="https://ftp.nluug.nl/pub/gnu/mpfr/mpfr-4.0.2.tar.xz"
subhash="d583555d08863bf36c89b289ae26bae353d9a31f08ee3894520992d2c26e5683c4c9c193d7ad139632f71c0a476d85ea76182702a98bf08dde7b6f65a54f8b88"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subfile="https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/nasm-2.16.03.tar.bz2"
subfile_bkup="https://www.mirrorservice.org/sites/distfiles.macports.org/nasm/nasm-2.16.03.tar.bz2"
subcurl="https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/nasm-2.16.03.tar.bz2"
subcurl_bkup="https://www.mirrorservice.org/sites/distfiles.macports.org/nasm/nasm-2.16.03.tar.bz2"
subhash="f28445d368debdf44219cc57df33800a8c0e49186cd60836d4adfec7700d53b801d34aa9fc9bfda74169843f33a1e8b465e11292582eb968bb9c3a26f54dd172"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subrepo="https://review.coreboot.org/vboot.git"
subrepo_bkup="https://github.com/coreboot/vboot"
subgit="https://review.coreboot.org/vboot.git"
subgit_bkup="https://github.com/coreboot/vboot"
subhash="ecdca931ae0637d1a9498f64862939bd5bb99e0b"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subhash="5d25331352e7a4ff010096af7dfd1a2d5f74e688"
subrepo="https://codeberg.org/canoeboot/cbwww"
subrepo_bkup="https://git.disroot.org/canoeboot/cbwww"
subgit="https://codeberg.org/canoeboot/cbwww"
subgit_bkup="https://git.disroot.org/canoeboot/cbwww"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subhash="dfab6aea12b770d72cdc69cd9c5eb3e48bc9f679"
subrepo="https://codeberg.org/canoeboot/cbwww-img"
subrepo_bkup="https://git.disroot.org/canoeboot/cbwww-img"
subgit="https://codeberg.org/canoeboot/cbwww-img"
subgit_bkup="https://git.disroot.org/canoeboot/cbwww-img"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subrepo="https://codeberg.org/libreboot/gnulib"
subrepo_bkup="git://git.sv.gnu.org/gnulib" # ALWAYS slow. only use as backup!
subgit="https://codeberg.org/libreboot/gnulib"
subgit_bkup="git://git.sv.gnu.org/gnulib" # ALWAYS slow. only use as backup!
subhash="9f48fb992a3d7e96610c4ce8be969cff2d61a01b"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subrepo="https://codeberg.org/libreboot/gnulib"
subrepo_bkup="git://git.sv.gnu.org/gnulib" # ALWAYS slow. only use as backup!
subgit="https://codeberg.org/libreboot/gnulib"
subgit_bkup="git://git.sv.gnu.org/gnulib" # ALWAYS slow. only use as backup!
subhash="9f48fb992a3d7e96610c4ce8be969cff2d61a01b"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subrepo="https://codeberg.org/libreboot/gnulib"
subrepo_bkup="git://git.sv.gnu.org/gnulib" # ALWAYS slow. only use as backup!
subgit="https://codeberg.org/libreboot/gnulib"
subgit_bkup="git://git.sv.gnu.org/gnulib" # ALWAYS slow. only use as backup!
subhash="9f48fb992a3d7e96610c4ce8be969cff2d61a01b"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subhash="7c6f1973a16893cf1f0868af6f8e60a028b933ad"
subrepo="https://github.com/grumpycoders/uC-sdk.git"
subrepo_bkup="https://codeberg.org/vimuser/uC-sdk"
subgit="https://github.com/grumpycoders/uC-sdk.git"
subgit_bkup="https://codeberg.org/vimuser/uC-sdk"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subhash="86c416d4c0fb38432460b3e11b08b9de76941bf5"
subrepo="https://codeberg.org/libreboot/tinyusb"
subrepo_bkup="https://github.com/hathach/tinyusb.git"
subgit="https://codeberg.org/libreboot/tinyusb"
subgit_bkup="https://github.com/hathach/tinyusb.git"

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
subhash="458250dc6147dc807eec9e4d5a6caf38a699ecb1"
subrepo="https://codeberg.org/libreboot/libopencm3"
subrepo_bkup="https://github.com/libopencm3/libopencm3"
subgit="https://codeberg.org/libreboot/libopencm3"
subgit_bkup="https://github.com/libopencm3/libopencm3"

162
include/get.sh Normal file
View File

@ -0,0 +1,162 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (c) 2020-2021,2023-2025 Leah Rowe <leah@libreboot.org>
# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
eval "`setvars "" loc url bkup_url subcurl subhash subgit subgit_bkup \
depend subcurl_bkup repofail`"
tmpgit="$xbmklocal/gitclone"
tmpgitcache="$XBMK_CACHE/tmpgit"
fetch_targets()
{
e "src/$project/$tree" d && return 0
printf "Creating %s tree %s\n" "$project" "$tree"
git_prep "$url" "$bkup_url" "$xbmkpwd/$configdir/$tree/patches" \
"src/$project/$tree" with_submodules
}
fetch_project()
{
eval "`setvars "" xtree`"
eval "`setcfg "config/git/$project/pkg.cfg"`"
chkvars url
[ -n "$xtree" ] && x_ ./mk -f coreboot "$xtree"
[ -z "$depend" ] || for d in $depend ; do
printf "'%s' needs '%s'; grabbing '%s'\n" "$project" "$d" "$d"
x_ ./mk -f $d
done
clone_project
}
clone_project()
{
loc="$XBMK_CACHE/clone/$project" && singletree "$project" && \
loc="src/$project"
printf "Downloading project '%s' to '%s'\n" "$project" "$loc"
e "$loc" d missing && remkdir "${tmpgit%/*}" && git_prep \
"$url" "$bkup_url" "$xbmkpwd/config/$project/patches" "$loc"; :
}
git_prep()
{
_patchdir="$3"
_loc="$4" # $1 and $2 are gitrepo and gitrepo_backup
chkvars rev
xbmkget git "$1" "$2" "$tmpgit" "$rev" "$_patchdir"
if singletree "$project" || [ $# -gt 4 ]; then
dx_ fetch_submodule "$mdir/module.list"
fi
[ "$_loc" = "${_loc%/*}" ] || x_ mkdir -p "${_loc%/*}"
x_ mv "$tmpgit" "$_loc"
}
fetch_submodule()
{
mcfgdir="$mdir/${1##*/}"; eval \
"`setvars "" subhash subgit subgit_bkup subcurl subcurl_bkup st`"
eval "`setcfg "$mcfgdir/module.cfg" 0`"
for xt in git curl; do
_seval="if [ -n \"\$sub$xt\" ] || [ -n \"\$sub${xt}_bkup\" ]"
eval "$_seval; then st=\"\$st \$xt\"; fi"
done
st="${st# }" && [ "$st" = "git curl" ] && err "$mdir: git+curl defined"
[ -z "$st" ] && return 0 # subgit/subcurl not defined
chkvars "sub${st}" "sub${st}_bkup" "subhash"
[ "$st" = "git" ] && x_ rm -Rf "$tmpgit/$1"
eval xbmkget "$st" "\$sub$st" "\$sub${st}_bkup" "$tmpgit/$1" \
"$subhash" "$mdir/${1##*/}/patches"
}
xbmkget()
{
[ "$1" = "curl" ] || [ "$1" = "copy" ] || [ "$1" = "git" ] || \
err "Bad dlop (arg 1): xbmkget $*"
echk="f" && [ "$1" = "git" ] && echk="d"
for url in "$2" "$3"; do
[ -n "$url" ] && try_file "$url" "$@" && \
eval "[ -$echk \"$4\" ] && return 0"
done && err "$1 $2 $3 $4: not downloaded"; :
}
try_file()
{
cached="file/$6" && [ "$2" = "git" ] && cached="clone/${3##*/}" && \
cached="${cached%.git}" # always the main repo as basis for naming,
# in case the backup has another name
cached="$XBMK_CACHE/$cached"
x_ mkdir -p "${5%/*}" "${cached%/*}"
echk="d" && [ "$2" != "git" ] && echk="f" && \
bad_checksum "$6" "$cached" 2>/dev/null && x_ rm -f "$cached"
eval "[ -$echk \"$cached\" ] || try_$2 \"\$cached\" \"\$@\" || return 1"
[ "$2" != "git" ] && [ -f "$5" ] && \
bad_checksum "$6" "$5" 2>/dev/null && x_ cp "$cached" "$5"
eval "[ -$echk \"$cached\" ] || return 1"
if [ "$2" = "git" ]; then
[ -d "$5" ] || tmpclone "$cached" "$5" "$6" "$7" || return 1
else
bad_checksum "$6" "$cached" && x_ rm -f "$cached" && return 1
[ "$cached" != "$5" ] && x_ cp "$cached" "$5"
bad_checksum "$6" "$5" && x_ rm -f "$5" && return 1; :
fi
eval "[ -$echk \"$5\" ] || return 1"
}
try_curl()
{
_ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
( x_ curl --location --retry 3 -A "$_ua" "$2" -o "$1" ) || \
( x_ wget --tries 3 -U "$_ua" "$2" -O "$1" ) || return 1; :
}
try_copy()
{
[ -L "$2" ] && printf "symlink %s (trycp %s)\n" "$2" "$*" && return 1
[ ! -f "$2" ] && printf "%s missing (trycp %s)\n" "$2" "$*" && return 1
( x_ cp "$2" "$1" ) || return 1; :
}
try_git()
{
gitdest="`findpath "$1"`" || err "Can't get readpath for '$1'"
x_ rm -Rf "$tmpgitcache"
[ -d "$gitdest" ] || ( x_ git clone "$2" "$tmpgitcache" ) || return 1
[ -d "$gitdest" ] || x_ mkdir -p "${gitdest%/*}"
[ -d "$gitdest" ] || x_ mv "$tmpgitcache" "$gitdest"
( x_ git -C "$gitdest" remote add main "$4" 2>/dev/null ) || :
( x_ git -C "$gitdest" remote add backup "$5" 2>/dev/null ) || :
( x_ git -C "$gitdest" fetch --all ) || :
( x_ git -C "$gitdest" pull --all ) || :; :
}
bad_checksum()
{
[ ! -f "$2" ] && printf "'%s' missing, %s\n" "$2" "$1" 1>&2 && return 0
csum="$(x_ sha512sum "$2" | awk '{print $1}')" || err "!sha512 '$2' $1"
[ "$csum" != "$1" ] && printf "BAD SHA512, '%s'; need '%s', got %s\n" \
"$2" "$1" "$csum" 1>&2 && x_ rm -f "$2" && return 0; return 1
}
tmpclone()
{
( x_ git clone "$1" "$2" ) || return 1
( x_ git -C "$2" reset --hard "$3" ) || return 1
( fx_ "eval x_ git -C \"$2\" am" find "$4" -type f ) || return 1; :
}

View File

@ -1,106 +0,0 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (c) 2020-2021,2023-2025 Leah Rowe <leah@libreboot.org>
# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
eval "`setvars "" loc url bkup_url subfile subhash subrepo subrepo_bkup \
depend subfile_bkup repofail`"
tmpgit="$xbmklocal/gitclone"
fetch_targets()
{
e "src/$project/$tree" d && return 0
printf "Creating %s tree %s\n" "$project" "$tree"
git_prep "$loc" "$loc" "$xbmkpwd/$configdir/$tree/patches" \
"src/$project/$tree" with_submodules
nuke "$project/$tree" "$project/$tree"
}
fetch_project()
{
eval "`setvars "" xtree`"
eval "`setcfg "config/git/$project/pkg.cfg"`"
chkvars url
[ -n "$xtree" ] && x_ ./mk -f coreboot "$xtree"
[ -z "$depend" ] || for d in $depend ; do
printf "'%s' needs '%s'; grabbing '%s'\n" "$project" "$d" "$d"
x_ ./mk -f $d
done
clone_project
for x in config/git/*; do
[ -d "$x" ] && nuke "${x##*/}" "src/${x##*/}" 2>/dev/null; :
done; :
}
clone_project()
{
loc="$XBMK_CACHE/repo/$project" && singletree "$project" && \
loc="src/$project"
printf "Downloading project '%s' to '%s'\n" "$project" "$loc"
e "$loc" d missing && remkdir "${tmpgit%/*}" && git_prep \
"$url" "$bkup_url" "$xbmkpwd/config/$project/patches" "$loc"; :
}
git_prep()
{
_patchdir="$3"
_loc="$4" # $1 and $2 are gitrepo and gitrepo_backup
chkvars rev
tmpclone "$1" "$2" "$tmpgit" "$rev" "$_patchdir"
if singletree "$project" || [ $# -gt 4 ]; then
dx_ fetch_submodule "$mdir/module.list"
fi
[ "$_loc" != "$XBMK_CACHE/repo/$project" ] && \
[ "$XBMK_RELEASE" = "y" ] && rmgit "$tmpgit"
[ "$_loc" = "${_loc%/*}" ] || x_ mkdir -p "${_loc%/*}"
mv "$tmpgit" "$_loc" || err "git_prep: !mv $tmpgit $_loc"
}
fetch_submodule()
{
mcfgdir="$mdir/${1##*/}"; eval \
"`setvars "" subhash subrepo subrepo_bkup subfile subfile_bkup st`"
[ ! -f "$mcfgdir/module.cfg" ] || . "$mcfgdir/module.cfg" || \
err "! . $mcfgdir/module.cfg"
for xt in repo file; do
_seval="if [ -n \"\$sub$xt\" ] || [ -n \"\$sub${xt}_bkup\" ]"
eval "$_seval; then st=\"\$st \$xt\"; fi"
done
st="${st# }" && [ "$st" = "repo file" ] && err "$mdir: repo+file"
[ -z "$st" ] && return 0 # subrepo/subfile not defined
chkvars "sub${st}" "sub${st}_bkup" "subhash"
[ "$st" = "file" ] && xbmkget "$subfile" "$subfile_bkup" \
"$tmpgit/$1" "$subhash" && return 0
rm -Rf "$tmpgit/$1" || err "!rm '$mdir' '$1'"
tmpclone "$subrepo" "$subrepo_bkup" "$tmpgit/$1" "$subhash" \
"$mdir/${1##*/}/patches"
}
tmpclone()
{
[ -d "$3" ] && return 0
printf "Creating git clone '%s' from '%s', '%s'\n" "$3" "$1" "$2"
git clone "$1" "$3" || x_ rm -Rf "$3"
[ -d "$3" ] || x_ git clone "$2" "$3"
x_ git -C "$3" reset --hard "$4"
fx_ "eval x_ git -C \"$3\" am" find "$5" -type f
}
nuke()
{
e "config/${1%/}/nuke.list" f missing || while read -r nukefile; do
rmf="src/${2%/}/$nukefile" && [ -L "$rmf" ] && continue
e "$rmf" e missing || rm -Rf "$rmf" || err "!rm $rmf, ${2%/}"
done < "config/${1%/}/nuke.list"; :
}

View File

@ -12,11 +12,10 @@ projectsite="https://canoeboot.org/"
[ -z "${PATH+x}" ] && \
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
xbmkpath="$PATH"
eval "`setvars "" _nogit board reinstall versiondate aur_notice configdir \
datadir version xbmkpwd relname xbmkpwd xbmktmp python pyver xbmklocal \
xbmklock`"
xbmklock cvxbmk cvchk xbmkpath`"
xbmk_init()
{
@ -31,8 +30,7 @@ xbmk_init()
id -u 1>/dev/null 2>/dev/null || err "suid check failed (id -u)"
[ "$(id -u)" != "0" ] || err "this command as root is not permitted"
for init_cmd in set_pyver set_version set_env git_init create_tmpdir \
lock create_pathdirs child_exec; do
for init_cmd in get_version set_env git_init child_exec; do
xbmk_$init_cmd "$@" || break
done
}
@ -45,12 +43,101 @@ xbmkpkg()
eval "`setcfg "config/dependencies/$2"`"
chkvars pkg_add pkglist
$pkg_add $pkglist || err "Cannot install packages"
x_ $pkg_add $pkglist
[ -n "$aur_notice" ] && \
printf "You need AUR packages: %s\n" "$aur_notice" 1>&2; :
}
xbmk_get_version()
{
[ ! -f ".version" ] || read -r version < ".version" || err
[ ! -f ".versiondate" ] || read -r versiondate < ".versiondate" || err
[ ! -f ".version" ] || chkvars version
[ ! -f ".versiondate" ] || chkvars versiondate
[ ! -e ".git" ] && [ ! -f ".version" ] && version="unknown"
[ ! -e ".git" ] && [ ! -f ".versiondate" ] && versiondate="1716415872"
[ -n "$version" ] && relname="$projectname-$version"; :
}
xbmk_set_env()
{
is_child="n"
xbmkpath="$PATH"
# unify all temporary files/directories in a single TMPDIR
[ -z "${TMPDIR+x}" ] || [ "${TMPDIR%_*}" = "/tmp/xbmk" ] || \
unset TMPDIR
[ -n "${TMPDIR+x}" ] && export TMPDIR="$TMPDIR" && xbmktmp="$TMPDIR"
[ -z "${TMPDIR+x}" ] || is_child="y" # child instance, so return
if [ "$is_child" = "y" ]; then
[ -z "${XBMK_CACHE+x}" ] && err "XBMK_CACHE unset on child"
[ -z "${XBMK_THREADS+x}" ] && err "XBMK_THREADS unset on child"
e "lock" f missing && err "lock file absent on child"
return 1
fi
[ -f "$xbmklock" ] && err "'$xbmklock' exists. Is a build running?"
touch "$xbmklock" || err "cannot create '$xbmklock'"; :
# parent instance of xbmk, so don't return. set up TMPDIR
export TMPDIR="/tmp"
export TMPDIR="$(mktemp -d -t xbmk_XXXXXXXX)"
xbmktmp="$TMPDIR"
# XBMK_CACHE is a directory, for caching downloads and git repon
[ -z "${XBMK_CACHE+x}" ] && export XBMK_CACHE="$xbmkpwd/cache"
[ -z "$XBMK_CACHE" ] && export XBMK_CACHE="$xbmkpwd/cache"
[ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$xbmkpwd/cache" ] && \
err "cachedir '$xbmkpwd/cache' is a symlink"
[ -L "$XBMK_CACHE" ] && export XBMK_CACHE="$xbmkpwd/cache"
xbmkcache="`findpath "$XBMK_CACHE"`" || \
err "Can't resolve cachedir: '$XBMK_CACHE'"
export XBMK_CACHE="$xbmkcache"
[ ! -e "$XBMK_CACHE" ] || \
[ -d "$XBMK_CACHE" ] || err "cachedir '$XBMK_CACHE' is a file"; :
export PATH="$XBMK_CACHE/xbmkpath:$XBMK_CACHE/gnupath:$PATH"
xbmkpath="$PATH"
# if "y": a coreboot target won't be built if target.cfg says release="n"
# (this is used to exclude certain build targets from releases)
[ -z "${XBMK_RELEASE+x}" ] && export XBMK_RELEASE="n"
[ "$XBMK_RELEASE" = "Y" ] && export XBMK_RELEASE="y"
[ "$XBMK_RELEASE" = "y" ] || export XBMK_RELEASE="n"
[ -z "${XBMK_THREADS+x}" ] && export XBMK_THREADS=1
expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \
1>/dev/null 2>/dev/null || export XBMK_THREADS=1
xbmk_set_version
export LOCALVERSION="-$projectname-${version%%-*}"
remkdir "$xbmktmp" "$xbmklocal"
remkdir "$XBMK_CACHE/gnupath" "$XBMK_CACHE/xbmkpath"
xbmk_set_pyver
}
xbmk_set_version()
{
version_="$version"
[ ! -e ".git" ] || version="$(git describe --tags HEAD 2>&1)" || \
version="git-$(git rev-parse HEAD 2>&1)" || version="$version_"
versiondate_="$versiondate"
[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
--pretty='%ct' HEAD)" || versiondate="$versiondate_"
chkvars version versiondate
update_xbmkver "."
relname="$projectname-$version"
}
xbmk_set_pyver()
{
pyv="import sys; print(sys.version_info[:])"
@ -63,7 +150,14 @@ xbmk_set_pyver()
[ -n "$pyver" ] && \
pyver="$("$(pybin "$python")" -c "$pyv" | awk '{print $1}')" && \
pyver="${pyver#(}" && pyver="${pyver%,}"
[ "${pyver%%.*}" = "3" ] || err "Bad python version (must by 3.x)"; :
[ "${pyver%%.*}" = "3" ] || err "Bad python version (must by 3.x)"
(
# set up python v3.x in PATH, in case it's not set up correctly.
# see code above that detected the correct python3 command.
x_ cd "$XBMK_CACHE/xbmkpath"
x_ ln -s "`pybin "$python"`" python
) || err "Can't set up python symlink in $XBMK_CACHE/xbmkpath"; :
}
# Use direct path, to prevent a hang if Python is using a virtual environment,
@ -97,57 +191,6 @@ pybin()
command -v "$1" 2>/dev/null || return 1
}
xbmk_set_version()
{
[ ! -f ".version" ] || read -r version < ".version" || :; :
[ ! -f ".versiondate" ] || read -r versiondate < ".versiondate" || :; :
[ -e ".git" ] || [ -f ".version" ] || printf "unknown\n" > ".version" \
|| err "Cannot generate unknown .version file"
[ -e ".git" ] || [ -f ".versiondate" ] || printf "1716415872\n" > \
".versiondate" || err "Can't generate unknown versiondate file"; :
version_="$version"
[ ! -e ".git" ] || version="$(git describe --tags HEAD 2>&1)" || \
version="git-$(git rev-parse HEAD 2>&1)" || version="$version_"
versiondate_="$versiondate"
[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
--pretty='%ct' HEAD)" || versiondate="$versiondate_"
chkvars version versiondate
printf "%s\n" "$version" > ".version" || err "can't save version"
printf "%s\n" "$versiondate" > ".versiondate" || err "can't save date"
relname="$projectname-$version"
}
xbmk_set_env()
{
export LOCALVERSION="-$projectname-${version%%-*}"
# XBMK_CACHE is a directory, for caching downloads and git repon
[ -z "${XBMK_CACHE+x}" ] && export XBMK_CACHE="$xbmkpwd/cache"
[ -z "$XBMK_CACHE" ] && export XBMK_CACHE="$xbmkpwd/cache"
[ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$xbmkpwd/cache" ] && \
err "cachedir '$xbmkpwd/cache' is a symlink"
[ -L "$XBMK_CACHE" ] && export XBMK_CACHE="$xbmkpwd/cache"
xbmkcache="`findpath "$XBMK_CACHE"`" || \
err "Can't resolve cachedir: '$XBMK_CACHE'"
export XBMK_CACHE="$xbmkcache"
[ ! -e "$XBMK_CACHE" ] || \
[ -d "$XBMK_CACHE" ] || err "cachedir '$XBMK_CACHE' is a file"; :
# if "y": a coreboot target won't be built if target.cfg says release="n"
# (this is used to exclude certain build targets from releases)
[ -z "${XBMK_RELEASE+x}" ] && export XBMK_RELEASE="n"
[ "$XBMK_RELEASE" = "Y" ] && export XBMK_RELEASE="y"
[ "$XBMK_RELEASE" = "y" ] || export XBMK_RELEASE="n"
[ -z "${XBMK_THREADS+x}" ] && export XBMK_THREADS=1
expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \
1>/dev/null 2>/dev/null || export XBMK_THREADS=1; :
}
xbmk_git_init()
{
for gitarg in "--global user.name" "--global user.email"; do
@ -167,44 +210,6 @@ xbmk_git_init()
2>/dev/null; :
}
xbmk_create_tmpdir()
{
x_ mkdir -p "$xbmklocal"
# unify all temporary files/directories in a single TMPDIR
[ -z "${TMPDIR+x}" ] || [ "${TMPDIR%_*}" = "/tmp/xbmk" ] || \
unset TMPDIR
[ -n "${TMPDIR+x}" ] && export TMPDIR="$TMPDIR" && xbmktmp="$TMPDIR"
[ -z "${TMPDIR+x}" ] || return 1 # child instance, so return
# parent instance of xbmk, so don't return. set up TMPDIR
export TMPDIR="/tmp"
export TMPDIR="$(mktemp -d -t xbmk_XXXXXXXX)"
xbmktmp="$TMPDIR"
# /tmp might be a tmpfs, so for large files we use ./tmp,
# not to be confused with xbmktmp (xbmktmp points to /tmp)
remkdir "$xbmktmp" "$xbmklocal"
}
xbmk_lock()
{
[ -f "$xbmklock" ] && err "'$xbmklock' exists. Is a build running?"
touch "$xbmklock" || err "cannot create '$xbmklock'"; :
}
xbmk_create_pathdirs()
{
remkdir "$XBMK_CACHE/gnupath" "$XBMK_CACHE/xbmkpath"
export PATH="$XBMK_CACHE/xbmkpath:$XBMK_CACHE/gnupath:$PATH"
(
# set up python v3.x in PATH, in case it's not set up correctly.
# see code above that detected the correct python3 command.
cd "$XBMK_CACHE/xbmkpath" || err "can't cd $XBMK_CACHE/xbmkpath"
x_ ln -s "`pybin "$python"`" python
) || err "Can't set up python symlink in $XBMK_CACHE/xbmkpath"; :
}
xbmk_child_exec()
{
xbmk_rval=0

View File

@ -4,83 +4,101 @@
# Copyright (c) 2023-2025 Leah Rowe <leah@libreboot.org>
cbcfgsdir="config/coreboot"
hashfiles="vendorhashes blobhashes" # used to detect and error out
# if running on an archive that needs vendor files
dontflash="!!! AN ERROR OCCURED! Do NOT flash these images !!!"
tmpromdel="$xbmklocal/DO_NOT_FLASH"
tmpromdel="$XBMK_CACHE/DO_NOT_FLASH"
nvm="util/nvmutil/nvm"
ifdtool="elf/ifdtool/default/ifdtool"
cv="CONFIG_GBE_BIN_PATH"
[ -n "$cvxbmk" ] && cv="$cv $cvxbmk"
[ -n "$cvchk" ] && cv="$cv $cvchk"
eval "`setvars "" archive boarddir IFD_platform ifdprefix tree new_mac \
tmpromdir board xchanged $cv`"
inject()
{
remkdir "$tmpromdel"
set +u +e
[ $# -lt 1 ] && err "No options specified. - $dontflash"
eval "`setvars "" new_mac xchanged`"
[ $# -lt 1 ] && err "No options specified"
eval "`setvars "" nuke new_mac xchanged`"
archive="$1";
new_mac="xx:xx:xx:xx:xx:xx"
[ $# -gt 1 ] && case "$2" in
nuke)
new_mac=""
nuke="nuke" ;;
setmac)
[ $# -gt 2 ] && new_mac="$3" && \
[ -z "$new_mac" ] && err "Empty MAC address specified" ;;
*) err "Unrecognised inject mode: '$2'"
*)
err "Unrecognised inject mode: '$2'"
esac
[ "$new_mac" = "keep" ] && new_mac=""
[ -n "$new_mac" ] && [ "$new_mac" != "restore" ] && \
x_ make -C util/nvmutil clean && x_ make -C util/nvmutil
check_release
check_target && patch_release
check_release "$archive" || err "'$archive' is not a release archive"
[ "$xchanged" = "y" ] && remktar
if readcfg && readkconfig; then
patch_release_roms
fi
xnot=" NOT" && [ "$xchanged" = "y" ] && xnot=""
printf "\n'%s' was%s modified\n" "$archive" "$xnot" 1>&2
[ "$xchanged" != "y" ] && printf "\n'%s' *NOT* modified.\n" "$archive"
[ "$xchanged" = "y" ] && printf "\n'%s' %s.\n" "$archive" "$xtype"; :
x_ rm -Rf "$tmpromdel"
}
check_release()
{
[ -L "$archive" ] && err "'$archive' is a symlink. $dontflash"
e "$archive" f missing && return 1
[ -L "$archive" ] && err "'$archive' is a symlink"
e "$archive" f missing && err "'$archive' missing"
archivename="`basename "$archive"`"
[ -z "$archivename" ] && err "Can't determine archive name. $dontflash"
archivename="`basename "$archive"`" || err "Can't get '$archive' name"
[ -z "$archivename" ] && err "Can't determine archive name"
case "$archivename" in
*_src.tar.xz)
err "'$archive' is a src archive, silly!" ;;
grub_*|seagrub_*|custom_*|seauboot_*|seabios_withgrub_*)
return 1 ;;
err "'$archive' is a ROM image (it must be a tarball)" ;;
*.tar.xz) _stripped_prefix="${archivename#*_}"
board="${_stripped_prefix%.tar.xz}" ;;
*) err "'$archive': could not detect board type - $dontflash"
*)
err "'$archive': could not detect board type"
esac; :
}
readcfg()
check_target()
{
if [ "$board" = "serprog_rp2040" ] || [ "$board" = "serprog_stm32" ] \
|| [ "$board" = "serprog_pico" ]; then
printf "'%s' is a serprog firmware archive.\n" "$archive" 1>&2
return 1
fi
[ "$board" = "${board#serprog_}" ] || return 1
boarddir="$cbcfgsdir/$board"
eval "`setcfg "$boarddir/target.cfg"`"
chkvars tree && x_ ./mk -d coreboot "$tree"
cbdir="src/coreboot/$tree"
cbfstool="elf/cbfstool/$tree/cbfstool"
rmodtool="elf/cbfstool/$tree/rmodtool"
cbfstool="elf/cbfstool/$tree/cbfstool"
ifdtool="elf/ifdtool/$tree/ifdtool"
[ -n "$IFD_platform" ] && ifdprefix="-p $IFD_platform"; :
}
patch_release()
{
has_hashes="n"
tmpromdir="$tmpromdel/bin/$board"
remkdir "${tmpromdir%"/bin/$board"}"
x_ tar -xf "$archive" -C "${tmpromdir%"/bin/$board"}"
for _hashes in "vendorhashes" "blobhashes"; do
e "$tmpromdir/$_hashes" f && err \
"'$archive': vendorfile insertion unsupported"
done
readkconfig || exit 0
[ -n "$new_mac" ] && [ -n "$CONFIG_GBE_BIN_PATH" ] && modify_mac; :
}
readkconfig()
{
x_ rm -f "$xbmktmp/cbcfg"
@ -95,38 +113,17 @@ scankconfig()
done
}
patch_release_roms()
{
tmpromdir="$xbmklocal/DO_NOT_FLASH/bin/$board"
remkdir "${tmpromdir%"/bin/$board"}"
x_ tar -xf "$archive" -C "${tmpromdir%"/bin/$board"}"
for _hashes in $hashfiles; do
e "$tmpromdir/$_hashes" f && err \
"'$archive': vendorfile insertion unsupported; $dontflash"
done
[ -z "$new_mac" ] || [ -z "$CONFIG_GBE_BIN_PATH" ] || modify_mac
[ "$xchanged" = "y" ] || rm -Rf "$tmpromdel" || :
[ "$xchanged" = "y" ] || return 0
(
x_ cd "${tmpromdir%"/bin/$board"}"
mkrom_tarball "bin/$board"
) || err "Cannot re-generate '$archive' - $dontflash"
mv "${tmpromdir%"/bin/$board"}/bin/${relname}_${board}.tar.xz" \
"$archive" || err "'$archive' -> Can't overwrite - $dontflash"; :
}
modify_mac()
{
x_ cp "${CONFIG_GBE_BIN_PATH##*../}" "$xbmklocal/gbe"
[ -n "$new_mac" ] && [ "$new_mac" != "restore" ] && \
x_ make -C util/nvmutil clean && x_ make -C util/nvmutil && \
x_ "$nvm" "$xbmklocal/gbe" setmac "$new_mac"
fx_ newmac x_ find "$tmpromdir" -maxdepth 1 -type f -name "*.rom"
printf "\nThe following GbE NVM data will be written:\n"
x_ "$nvm" "$xbmklocal/gbe" dump | grep -v "bytes read from file" || :
}
newmac()
@ -134,3 +131,15 @@ newmac()
e "$1" f && xchanged="y" && x_ \
"$ifdtool" $ifdprefix -i GbE:"$xbmklocal/gbe" "$1" -O "$1"; :
}
remktar()
{
(
x_ cd "${tmpromdir%"/bin/$board"}"
printf "Re-building tar archive (please wait)\n"
mkrom_tarball "bin/$board" 1>/dev/null
) || err "Cannot re-generate '$archive'"
mv "${tmpromdir%"/bin/$board"}/bin/${relname}_${board}.tar.xz" \
"$archive" || err "'$archive' -> Can't overwrite"; :
}

View File

@ -15,13 +15,17 @@ remkdir()
mkrom_tarball()
{
printf "%s\n" "$version" > "$1/.version" || err "$1 !version"
printf "%s\n" "$versiondate" > "$1/.versiondate" || err "$1 !vdate"
update_xbmkver "$1"
mktarball "$1" "${1%/*}/${relname}_${1##*/}.tar.xz"
x_ rm -Rf "$1"
}
update_xbmkver()
{
printf "%s\n" "$version" > "$1/.version" || err "$1 !version"; :
printf "%s\n" "$versiondate" > "$1/.versiondate" || err "$1 !vdate"; :
}
mktarball()
{
printf "Creating tar archive '%s' from directory '%s'\n" "$2" "$1"
@ -29,63 +33,6 @@ mktarball()
x_ tar -c "$1" | xz -T$XBMK_THREADS -9e > "$2" || err "mktarball2, $1"
}
mksha512sum()
{
(
[ "${1%/*}" != "$1" ] && x_ cd "${1%/*}"
sha512sum ./"${1##*/}" >> "$2" || err "!sha512sum \"$1\" > \"$2\""
) || err "failed to create tarball checksum"
}
rmgit()
{
x_ find "$1" -name ".git" -exec rm -Rf {} +
x_ find "$1" -name ".gitmodules" -exec rm -Rf {} +
}
# can grab from the internet, or copy locally.
# if copying locally, it can only copy a file.
xbmkget()
{
_ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
_dlop="curl" && [ $# -gt 4 ] && _dlop="$5"
cached="$XBMK_CACHE/file/$4"
dl_fail="n" # 1 url, 2 url backup, 3 destination, 4 checksum
bad_checksum "$4" "$cached" 2>/dev/null && dl_fail="y"
[ "$dl_fail" = "n" ] && e "$3" f && return 0
x_ mkdir -p "${3%/*}" "$XBMK_CACHE/file"
for url in "$1" "$2"; do
[ "$dl_fail" = "n" ] && break
[ -z "$url" ] && continue
rm -f "$cached" || err "!rm -f '$cached'"
if [ "$_dlop" = "curl" ]; then
curl --location --retry 3 -A "$_ua" "$url" \
-o "$cached" || wget --tries 3 -U "$_ua" "$url" \
-O "$cached" || continue
elif [ "$_dlop" = "copy" ]; then
[ -L "$url" ] && \
printf "dl %s %s %s %s: '%s' is a symlink\n" \
"$1" "$2" "$3" "$4" "$url" 1>&2 && continue
[ ! -f "$url" ] && \
printf "dl %s %s %s %s: '%s' not a file\n" \
"$1" "$2" "$3" "$4" "$url" 1>&2 && continue
cp "$url" "$cached" || continue
else
err "$1 $2 $3 $4: Unsupported dlop type: '$_dlop'"
fi
bad_checksum "$4" "$cached" || dl_fail="n"
done
[ "$dl_fail" = "y" ] && err "$1 $2 $3 $4: not downloaded"
[ "$cached" = "$3" ] || x_ cp "$cached" "$3"; :
}
bad_checksum()
{
[ "$(sha512sum "$2" | awk '{print $1}')" != "$1" ] || return 1
printf "Bad checksum for file: %s\n" "$2" 1>&2; rm -f "$2" || :; :
}
e()
{
es_t="e" && [ $# -gt 1 ] && es_t="$2"
@ -97,14 +44,6 @@ e()
printf "%s %s\n" "$1" "$es2" 1>&2
}
mk()
{
mk_flag="$1" || err "No argument given"
shift 1 && for mk_arg in "$@"; do
x_ ./mk $mk_flag $mk_arg
done; :
}
setvars()
{
_setvars=""
@ -140,8 +79,8 @@ chkvars()
# e.g. coreboot is multi-tree, so 1
singletree()
{
( fx_ "exit 1" find "config/$1/"*/ -type f -name "target.cfg" ) || \
return 1
( fx_ "eval exit 1 && err" find "config/$1/"*/ -type f \
-name "target.cfg" ) || return 1; :
}
findpath()

86
include/release.sh Normal file
View File

@ -0,0 +1,86 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (c) 2023-2025 Leah Rowe <leah@libreboot.org>
eval "`setvars "" reldir reldest vdir rsrc relmode`"
release()
{
export XBMK_RELEASE="y"
reldir="release"
while getopts d:m: option; do
[ -z "$OPTARG" ] && err "empty argument not allowed"
case "$option" in
d) reldir="$OPTARG" ;;
m) relmode="$OPTARG" ;;
*) err "invalid option '-$option'" ;;
esac
done
reldest="$reldir/$version"
[ -e "$reldest" ] && \
err "already exists: \"$reldest\""
vdir="$XBMK_CACHE/relpwd/${xbmktmp##*/}/$version"
rsrc="$vdir/${relname}_src"
remkdir "$vdir"
x_ git clone . "$rsrc"
prep_release src
prep_release tarball
[ "$relmode" = "src" ] || prep_release bin
x_ rm -Rf "$rsrc"
x_ mkdir -p "$reldir"
x_ mv "$vdir" "$reldir"
x_ rm -Rf "${vdir%"/$version"}"
printf "\n\nDONE! Check release files under %s\n" "$reldest"
}
prep_release()
{
x_ touch "$rsrc/lock"
(
[ "$1" = "tarball" ] || x_ cd "$rsrc"
prep_release_$1
) || err "can't prep release $1"
}
prep_release_src()
{
x_ ./mk -f
fx_ "x_ rm -Rf" x_ find . -name ".git"
fx_ "x_ rm -Rf" x_ find . -name ".gitmodules"
( fx_ nuke x_ find config -type f -name "nuke.list" ) || err; :
}
nuke()
{
r="$rsrc/src/${1#config/}"
[ -d "${r%/*}" ] && x_ cd "${r%/*}" && \
dx_ "eval [ -L \"\$fx\" ] || x_ rm -Rf" "$rsrc/$1"; :
}
prep_release_tarball()
{
git log --graph --pretty=format:'%Cred%h%Creset %s %Creset' \
--abbrev-commit > "$rsrc/CHANGELOG" || err "!log $rsrc"
x_ rm -f "$rsrc/lock"
x_ rm -Rf "$rsrc/cache" "$rsrc/tmp"
(
x_ cd "${rsrc%/*}"
x_ mktarball "${rsrc##*/}" "${rsrc##*/}.tar.xz"
) || err "can't create src tarball"; :
}
prep_release_bin()
{
fx_ "x_ ./mk -b" printf \
"coreboot\npico-serprog\nstm32-vserprog\npcsx-redux\n"
fx_ mkrom_tarball x_ find bin -maxdepth 1 -type d -name "serprog_*"
x_ mv bin ../roms
}

View File

@ -44,7 +44,7 @@ mkpayload_grub()
mkvendorfiles()
{
[ -z "$mode" ] && $dry cook_coreboot_config
check_coreboot_utils "$tree"
fx_ check_coreboot_util printf "cbfstool\nifdtool\n"
printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \
err "!mk $srcdir .coreboot-version"; :
}
@ -57,26 +57,24 @@ cook_coreboot_config()
make -C "$srcdir" oldconfig || err "Could not cook $srcdir/.config"; :
}
check_coreboot_utils()
check_coreboot_util()
{
for util in cbfstool ifdtool; do
[ "$badhash" = "y" ] && x_ rm -f "elf/$util/$1/$util"
e "elf/$util/$1/$util" f && continue
[ "$badhash" = "y" ] && x_ rm -f "elf/$1/$tree/$1"
e "elf/$1/$tree/$1" f && return 0
utilelfdir="elf/$util/$1"
utilsrcdir="src/coreboot/$1/util/$util"
utilelfdir="elf/$1/$tree"
utilsrcdir="src/coreboot/$tree/util/$1"
utilmode="" && [ -n "$mode" ] && utilmode="clean"
x_ make -C "$utilsrcdir" $utilmode -j$XBMK_THREADS $makeargs
if [ -z "$mode" ] && [ ! -f "$utilelfdir/$util" ]; then
x_ mkdir -p "$utilelfdir"
x_ cp "$utilsrcdir/$util" "$utilelfdir"
[ "$util" = "cbfstool" ] || continue
x_ cp "$utilsrcdir/rmodtool" "$utilelfdir"
elif [ -n "$mode" ]; then
x_ rm -Rf "$utilelfdir"
fi; :
done; :
utilmode="" && [ -n "$mode" ] && utilmode="clean"
x_ make -C "$utilsrcdir" $utilmode -j$XBMK_THREADS $makeargs
[ -n "$mode" ] && x_ rm -Rf "$utilelfdir" && return 0
[ -z "$mode" ] || return 0
[ -f "$utilelfdir/$1" ] && return 0
x_ mkdir -p "$utilelfdir"
x_ cp "$utilsrcdir/$1" "$utilelfdir"
[ "$1" = "cbfstool" ] || return 0
x_ cp "$utilsrcdir/rmodtool" "$utilelfdir"
}
mkcorebootbin()

339
include/tree.sh Normal file
View File

@ -0,0 +1,339 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (c) 2022-2023 Alper Nebi Yasak <alpernebiyasak@gmail.com>
# Copyright (c) 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
# Copyright (c) 2023-2025 Leah Rowe <leah@libreboot.org>
eval "`setvars "" xarch srcdir premake gnatdir xlang mode makeargs elfdir cmd \
project target target_dir targets xtree _f release bootstrapargs mkhelper \
autoconfargs listfile autogenargs btype rev build_depend gccdir cmakedir \
defconfig postmake mkhelpercfg dry dest_dir mdir cleanargs gccver gccfull \
gnatver gnatfull do_make badhash tree`"
trees()
{
flags="f:b:m:u:c:x:s:l:n:d:"
while getopts $flags option; do
[ -n "$_f" ] && err "only one flag is permitted"
_f="$1"
case "$_f" in
-d) dry=":" ;;
-b) : ;;
-u) mode="oldconfig" ;;
-m) mode="menuconfig" ;;
-c) mode="distclean" ;;
-x) mode="crossgcc-clean" ;;
-f)
do_make="n"
dry=":" ;;
-s) mode="savedefconfig" ;;
-l) mode="olddefconfig" ;;
-n) mode="nconfig" ;;
*) err "invalid option '-$option'" ;;
esac
if [ -z "${OPTARG+x}" ]; then
shift 1
break
fi
project="${OPTARG#src/}"
project="${project#config/git/}"
shift 2
done
[ -z "$_f" ] && err "missing flag ($flags)"
[ -z "$project" ] && fx_ "x_ ./mk $_f" x_ ls -1 config/git && return 1
[ -f "config/git/$project/pkg.cfg" ] || \
err "config/git/$project/pkg.cfg missing"
for d in "elf" "config/data" "config" "src"; do
eval "${d#*/}dir=\"$d/$project\""
done
dest_dir="$elfdir"
listfile="$datadir/build.list"
[ -f "$listfile" ] || listfile="" # optional on all projects
mkhelpercfg="$datadir/mkhelper.cfg"
if e "$mkhelpercfg" f missing; then
mkhelpercfg="$xbmktmp/mkhelper.cfg"
x_ touch "$mkhelpercfg"
fi
targets="$*"
cmd="build_targets $targets"
singletree "$project" && cmd="build_project"
remkdir "${tmpgit%/*}"
}
build_project()
{
configure_project "$configdir" || return 0
[ ! -f "$listfile" ] || $dry elfcheck || return 0
[ "$mode" = "distclean" ] && mode="clean"
run_make_command || return 0
[ -n "$mode" ] || $dry copy_elf; :
}
build_targets()
{
[ -d "$configdir" ] || err "directory, $configdir, does not exist"
[ $# -gt 0 ] || targets="$(ls -1 "$configdir")" || err "!o $configdir"
for x in $targets; do
unset CROSS_COMPILE
export PATH="$xbmkpath"
[ "$x" = "list" ] && x_ ls -1 "config/$project" && \
listfile="" && break
target="$x"
printf "'make %s', '%s', '%s'\n" "$mode" "$project" "$target"
x_ handle_defconfig
[ -n "$mode" ] || x_ $postmake
done; :
}
handle_defconfig()
{
target_dir="$configdir/$target"
[ -f "CHANGELOG" ] || fetch_project "$project"
configure_project "$target_dir" || return 0
chkvars tree
srcdir="src/$project/$tree"
[ "$mode" = "${mode%clean}" ] && [ ! -d "$srcdir" ] && return 0
[ -z "$mode" ] && for _xarch in $xarch; do
$dry check_cross_compiler "$_xarch"
done; :
for y in "$target_dir/config"/*; do
[ "$_f" = "-d" ] || [ -f "$y" ] || continue
[ "$_f" = "-d" ] || defconfig="$y"
[ -n "$mode" ] || check_defconfig || continue
handle_makefile
[ -n "$mode" ] || $dry copy_elf
done; :
}
configure_project()
{
eval "`setvars "" cleanargs build_depend autoconfargs xtree postmake \
makeargs btype mkhelper bootstrapargs premake release xlang xarch \
badhash`"
_tcfg="$1/target.cfg"
[ -f "$_tcfg" ] || btype="auto"
e "$datadir/mkhelper.cfg" f && eval "`setcfg "$datadir/mkhelper.cfg"`"
while e "$_tcfg" f || [ "$cmd" != "build_project" ]; do
eval "`setvars "" rev tree`"
eval "`setcfg "$_tcfg"`"
printf "Loading %s config: %s\n" "$project" "$_tcfg"
[ "$_f" = "-d" ] && build_depend="" # dry run
[ "$cmd" = "build_project" ] && break
[ "$do_make" != "n" ] && break
[ "${_tcfg%/*/target.cfg}" = "${_tcfg%"/$tree/target.cfg"}" ] \
&& break
_tcfg="${_tcfg%/*/target.cfg}/$tree/target.cfg"
done
[ "$XBMK_RELEASE" = "y" ] && [ "$release" = "n" ] && return 1
[ -z "$btype" ] || [ "${mode%config}" = "$mode" ] || return 1
[ -z "$mode" ] && $dry build_dependencies
mdir="$xbmkpwd/config/submodule/$project"
[ -n "$tree" ] && mdir="$mdir/$tree"
[ -f "CHANGELOG" ] || check_project_hashes
if [ "$do_make" = "n" ]; then
[ -f "CHANGELOG" ] || fetch_${cmd#build_}
return 1
fi
x_ ./mk -f "$project" "$target"
}
build_dependencies()
{
for bd in $build_depend; do
bd_p="${bd%%/*}"
bd_t="${bd##*/}"
[ -z "$bd_p" ] && $dry err "$project/$tree: !bd '$bd'"
[ "${bd##*/}" = "$bd" ] && bd_t=""
[ -z "$bd_p" ] || $dry x_ ./mk -b $bd_p $bd_t; :
done; :
}
check_project_hashes()
{
old_pjhash="" && x_ mkdir -p "$XBMK_CACHE/hash"
[ ! -f "$XBMK_CACHE/hash/$project$tree" ] || \
read -r old_pjhash < "$XBMK_CACHE/hash/$project$tree"
fx_ "x_ sha512sum" find "$datadir" "$configdir/$tree" "$mdir" \
-type f -not -path "*/.git*/*" | awk '{print $1}' > \
"$xbmktmp/project.hash" || err "!h $project $tree"
pjhash="$(sha512sum "$xbmktmp/project.hash" | awk '{print $1}')" || :
[ "$pjhash" != "$old_pjhash" ] && badhash="y"
[ -f "$XBMK_CACHE/hash/$project$tree" ] || badhash="y"
printf "%s\n" "$pjhash" > "$XBMK_CACHE/hash/$project$tree" || \
err "!mk $XBMK_CACHE/hash/$project$tree"
[ "$badhash" != "y" ] || x_ rm -Rf "src/$project/$tree" \
"elf/$project/$tree" "elf/$project/$target"; :
}
check_cross_compiler()
{
cbdir="src/coreboot/$tree"
[ "$project" != "coreboot" ] && cbdir="src/coreboot/default"
[ -n "$xtree" ] && cbdir="src/coreboot/$xtree"
x_ ./mk -f coreboot "${cbdir#src/coreboot/}"
export PATH="$xbmkpwd/$cbdir/util/crossgcc/xgcc/bin:$PATH"
export CROSS_COMPILE="${xarch% *}-"
[ -n "$xlang" ] && export BUILD_LANGUAGES="$xlang"
# match gnat-X to gcc
check_gnu_path gcc gnat || x_ check_gnu_path gnat gcc
xfix="${1%-*}" && [ "$xfix" = "x86_64" ] && xfix="x64"
xgccargs="crossgcc-$xfix UPDATED_SUBMODULES=1 CPUS=$XBMK_THREADS"
make -C "$cbdir" $xgccargs || x_ make -C "$cbdir" $xgccargs
# we only want to mess with hostcc to build xgcc
remkdir "$XBMK_CACHE/gnupath"
}
# fix mismatching gcc/gnat versions on debian trixie/sid. as of december 2024,
# trixie/sid had gnat-13 as gnat and gcc-14 as gcc, but has gnat-14 in apt. in
# some cases, gcc 13+14 and gnat-13 are present; or gnat-14 and gcc-14, but
# gnat in PATH never resolves to gnat-14, because gnat-14 was "experimental"
check_gnu_path()
{
command -v "$1" 1>/dev/null || err "Host '$1' unavailable"
eval "`setvars "" gccver gccfull gnatver gnatfull gccdir gnatdir`"
x_ gnu_setver "$1" "$1" || err "Command '$1' unavailable."
gnu_setver "$2" "$2" || :
eval "[ -z \"\$$1ver\" ] && err \"Cannot detect host '$1' version\""
[ "$gnatfull" = "$gccfull" ] && return 0
eval "$1dir=\"$(dirname "$(command -v "$1")")\""
eval "_gnudir=\"\$$1dir\"; _gnuver=\"\$$1ver\""
for _bin in "$_gnudir/$2-"*; do
[ "${_bin#"$_gnudir/$2-"}" = "$_gnuver" ] && [ -x "$_bin" ] \
&& _gnuver="${_bin#"$_gnudir/$2-"}" && break; :
done
gnu_setver "$2" "$_gnudir/$2-$_gnuver" || return 1
[ "$gnatfull" = "$gccfull" ] || return 1
(
remkdir "$XBMK_CACHE/gnupath" && x_ cd "$XBMK_CACHE/gnupath"
for _gnubin in "$_gnudir/$2"*"-$_gnuver"; do
_gnuutil="${_gnubin##*/}" && [ -e "$_gnubin" ] && \
x_ ln -s "$_gnubin" "${_gnuutil%"-$_gnuver"}"
done
) || err "Cannot create $2-$_gnuver link in $_gnudir"; :
}
gnu_setver()
{
eval "$2 --version 1>/dev/null 2>/dev/null || return 1"
eval "$1ver=\"`"$2" --version 2>/dev/null | head -n1`\""
eval "$1ver=\"\${$1ver##* }\""
eval "$1full=\"\$$1ver\""
eval "$1ver=\"\${$1ver%%.*}\""; :
}
check_defconfig()
{
[ -f "$defconfig" ] || $dry err "$project/$target: missing defconfig"
dest_dir="$elfdir/$target/${defconfig#"$target_dir/config/"}"
$dry elfcheck || return 1; : # skip build if a previous one exists
}
elfcheck()
{
# TODO: *STILL* very hacky check. do it properly (based on build.list)
( fx_ "eval exit 1 && err" find "$dest_dir" -type f ) || return 1; :
}
handle_makefile()
{
$dry check_makefile "$srcdir" && x_ make -C "$srcdir" $cleanargs clean
[ -f "$defconfig" ] && x_ cp "$defconfig" "$srcdir/.config"
[ -n "$mode" ] || [ -n "$btype" ] || $dry make -C \
"$srcdir" silentoldconfig || make -C "$srcdir" oldconfig || :
run_make_command || err "handle_makefile $srcdir: no makefile!"
_copy=".config" && [ "$mode" = "savedefconfig" ] && _copy="defconfig"
[ "${mode%config}" = "$mode" ] || \
$dry x_ cp "$srcdir/$_copy" "$defconfig"
[ -e "$srcdir/.git" ] && [ "$project" = "u-boot" ] && \
[ "$mode" = "distclean" ] && \
$dry x_ git -C "$srcdir" $cleanargs clean -fdx; :
}
run_make_command()
{
[ -n "$mode" ] || x_ $premake
$dry check_cmake "$srcdir" && [ -z "$mode" ] && \
$dry check_autoconf "$srcdir"
$dry check_makefile "$srcdir" || return 1
$dry x_ make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs
[ -n "$mode" ] || x_ $mkhelper
[ "$mode" != "clean" ] || \
$dry make -C "$srcdir" $cleanargs distclean || :; :
}
check_cmake()
{
[ -z "$cmakedir" ] || $dry check_makefile "$1" || cmake -B "$1" \
"$1/$cmakedir" || $dry x_ check_makefile "$1"
[ -z "$cmakedir" ] || $dry x_ check_makefile "$1"; :
}
check_autoconf()
{
(
x_ cd "$1"
[ -f "bootstrap" ] && x_ ./bootstrap $bootstrapargs
[ -f "autogen.sh" ] && x_ ./autogen.sh $autogenargs
[ -f "configure" ] && x_ ./configure $autoconfargs; :
) || err "can't bootstrap project: $1"; :
}
check_makefile()
{
[ -f "$1/Makefile" ] || [ -f "$1/makefile" ] || \
[ -f "$1/GNUmakefile" ] || return 1; :
}
copy_elf()
{
[ -f "$listfile" ] && x_ mkdir -p "$dest_dir" && while read -r f; do
[ -f "$srcdir/$f" ] && x_ cp "$srcdir/$f" "$dest_dir"
done < "$listfile"
x_ make clean -C "$srcdir" $cleanargs
}

416
mk
View File

@ -2,8 +2,6 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (c) 2020-2025 Leah Rowe <leah@libreboot.org>
# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
# Copyright (c) 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
# Copyright (c) 2022-2023 Alper Nebi Yasak <alpernebiyasak@gmail.com>
set -u -e
@ -13,12 +11,11 @@ if [ "./${0##*/}" != "${0}" ] || [ ! -f "mk" ] || [ -L "mk" ]; then
fi
. "include/lib.sh"
. "include/init.sh"
. "include/inject.sh"
. "include/rom.sh"
eval "`setvars "" vdir src_dirname srcdir mode`"
. "include/release.sh"
. "include/get.sh"
main()
{
@ -27,417 +24,16 @@ main()
case "$cmd" in
version) printf "%s\nWebsite: %s\n" "$relname" "$projectsite" ;;
release|inject) $cmd "$@" ;;
-*) return 1 ;;
-*) return 0 ;;
*) err "bad command" ;;
esac
set -u -e # some commands disable them. turn them on!
return 1
}
release()
{
export XBMK_RELEASE="y"
main "$@" || exit 0
vdir="release"
while getopts d:m: option; do
[ -z "$OPTARG" ] && err "empty argument not allowed"
case "$option" in
d) vdir="$OPTARG" ;;
m) mode="$OPTARG" ;;
*) err "invalid option '-$option'" ;;
esac
done
vdir="$vdir/$version"
src_dirname="${relname}_src"
srcdir="$vdir/$src_dirname"
[ -e "$vdir" ] && err "already exists: \"$vdir\""
mkdir -p "$vdir" || err "mkvdir: !mkdir -p \"$vdir\""
git clone . "$srcdir" || err "mkdir: !gitclone \"$srcdir\""
touch "$srcdir/lock" || err "can't make lock file in $srcdir/"
build_release
printf "\n\nDONE! Check release files under %s\n" "$vdir"
}
build_release()
{
(
cd "$srcdir" || err "$vdir: !cd \"$srcdir\""
x_ ./mk -f
rmgit .
x_ mv src/docs docs
) || err "can't create release files"
git log --graph --pretty=format:'%Cred%h%Creset %s %Creset' \
--abbrev-commit > "$srcdir/CHANGELOG" || err "!gitlog $srcdir"
rm -f "$srcdir/lock" || err "can't remove lock file in $srcdir"
(
cd "${srcdir%/*}" || err "$vdir: mktarball \"$srcdir\""
mktarball "${srcdir##*/}" "${srcdir##*/}.tar.xz" || err "$vdir: mksrc"
) || err "can't create src tarball"
[ "$mode" = "src" ] && return 0
touch "$srcdir/lock" || err "can't make lock file in $srcdir/"
(
cd "$srcdir" || err "$vdir: 2 !cd \"$srcdir\""
mk -b coreboot pico-serprog stm32-vserprog pcsx-redux
fx_ mkrom_tarball x_ find bin -maxdepth 1 -type d -name "serprog_*"
x_ mv bin ../roms
) || err "can't build rom images"
rm -Rf "$srcdir" || err "!rm -Rf $srcdir"
}
main "$@" && exit 0
# what follows was formerly script/trees, whose main() is now trees()
. "include/git.sh"
eval "`setvars "" xarch srcdir premake gnatdir xlang mode makeargs elfdir cmd \
project target target_dir targets xtree _f release bootstrapargs mkhelper \
autoconfargs listfile autogenargs btype rev build_depend gccdir cmakedir \
defconfig postmake mkhelpercfg dry dest_dir mdir cleanargs gccver gccfull \
gnatver gnatfull do_make badhash tree`"
trees()
{
flags="f:b:m:u:c:x:s:l:n:d:"
while getopts $flags option; do
[ -n "$_f" ] && err "only one flag is permitted"
_f="$1"
case "$_f" in
-d) dry=":" ;;
-b) : ;;
-u) mode="oldconfig" ;;
-m) mode="menuconfig" ;;
-c) mode="distclean" ;;
-x) mode="crossgcc-clean" ;;
-f)
do_make="n"
dry=":" ;;
-s) mode="savedefconfig" ;;
-l) mode="olddefconfig" ;;
-n) mode="nconfig" ;;
*) err "invalid option '-$option'" ;;
esac
if [ -z "${OPTARG+x}" ]; then
shift 1
break
fi
project="${OPTARG#src/}"
shift 2
done
[ -z "$_f" ] && err "missing flag ($flags)"
if [ -z "$project" ]; then
mk $_f $(ls -1 config/git)
return 1
fi
[ -f "config/git/$project/pkg.cfg" ] || \
err "config/git/$project/pkg.cfg missing"
for d in "elf" "config/data" "config" "src"; do
eval "${d#*/}dir=\"$d/$project\""
done
dest_dir="$elfdir"
listfile="$datadir/build.list"
[ -f "$listfile" ] || listfile="" # optional on all projects
mkhelpercfg="$datadir/mkhelper.cfg"
if e "$mkhelpercfg" f missing; then
mkhelpercfg="$xbmktmp/mkhelper.cfg"
x_ touch "$mkhelpercfg"
fi
targets="$*"
cmd="build_targets $targets"
singletree "$project" && cmd="build_project"
remkdir "${tmpgit%/*}"
}
build_project()
{
configure_project "$configdir" || return 0
[ ! -f "$listfile" ] || $dry elfcheck || return 0
[ "$mode" = "distclean" ] && mode="clean"
run_make_command || return 0
[ -n "$mode" ] || $dry copy_elf; :
}
build_targets()
{
[ -d "$configdir" ] || err "directory, $configdir, does not exist"
[ $# -gt 0 ] || targets="$(ls -1 "$configdir")" || err "!o $configdir"
for x in $targets; do
unset CROSS_COMPILE
export PATH="$xbmkpath"
[ "$x" = "list" ] && x_ ls -1 "config/$project" && \
listfile="" && break
target="$x"
printf "'make %s', '%s', '%s'\n" "$mode" "$project" "$target"
x_ handle_defconfig
[ -n "$mode" ] || x_ $postmake
done; :
}
handle_defconfig()
{
target_dir="$configdir/$target"
[ -f "CHANGELOG" ] || fetch_project "$project"
configure_project "$target_dir" || return 0
x_ mkdir -p "$elfdir/$target"
chkvars tree
srcdir="src/$project/$tree"
if [ "$mode" = "distclean" ] || [ "$mode" = "crossgcc-clean" ]; then
[ -d "$srcdir" ] || return 0
fi
[ -z "$mode" ] && for _xarch in $xarch; do
$dry check_cross_compiler "$_xarch"
done; :
for y in "$target_dir/config"/*; do
[ "$_f" = "-d" ] || [ -f "$y" ] || continue
[ "$_f" = "-d" ] || defconfig="$y"
[ -n "$mode" ] || check_defconfig || continue
handle_makefile
[ -n "$mode" ] || $dry copy_elf
done; :
}
configure_project()
{
eval "`setvars "" cleanargs build_depend autoconfargs xtree postmake \
makeargs btype mkhelper bootstrapargs premake release xlang xarch \
badhash`"
_tcfg="$1/target.cfg"
[ -f "$_tcfg" ] || btype="auto"
e "$datadir/mkhelper.cfg" f && eval "`setcfg "$datadir/mkhelper.cfg"`"
while e "$_tcfg" f || [ "$cmd" != "build_project" ]; do
eval "`setvars "" rev tree`"
eval "`setcfg "$_tcfg"`"
printf "Loading %s config: %s\n" "$project" "$_tcfg"
[ "$_f" = "-d" ] && build_depend="" # dry run
[ "$cmd" = "build_project" ] && break
[ "$do_make" != "n" ] && break
[ "${_tcfg%/*/target.cfg}" = "${_tcfg%"/$tree/target.cfg"}" ] \
&& break
_tcfg="${_tcfg%/*/target.cfg}/$tree/target.cfg"
done
[ "$XBMK_RELEASE" = "y" ] && [ "$release" = "n" ] && return 1
[ -z "$btype" ] || [ "${mode%config}" = "$mode" ] || return 1
[ -z "$mode" ] && $dry build_dependencies
mdir="$xbmkpwd/config/submodule/$project"
[ -n "$tree" ] && mdir="$mdir/$tree"
[ -f "CHANGELOG" ] || check_project_hashes
if [ "$do_make" = "n" ]; then
[ -f "CHANGELOG" ] || fetch_${cmd#build_}
return 1
fi
x_ ./mk -f "$project" "$target"
}
build_dependencies()
{
for bd in $build_depend; do
bd_p="${bd%%/*}"
bd_t="${bd##*/}"
[ -z "$bd_p" ] && $dry err "$project/$tree: !bd '$bd'"
[ "${bd##*/}" = "$bd" ] && bd_t=""
[ -z "$bd_p" ] || $dry x_ ./mk -b $bd_p $bd_t; :
done; :
}
check_project_hashes()
{
old_pjhash="" && x_ mkdir -p "$XBMK_CACHE/hash"
[ ! -f "$XBMK_CACHE/hash/$project$tree" ] || \
read -r old_pjhash < "$XBMK_CACHE/hash/$project$tree"
fx_ "x_ sha512sum" find "$datadir" "$configdir/$tree" "$mdir" \
-type f -not -path "*/.git*/*" | awk '{print $1}' > \
"$xbmktmp/project.hash" || err "!h $project $tree"
pjhash="$(sha512sum "$xbmktmp/project.hash" | awk '{print $1}')" || :
[ "$pjhash" != "$old_pjhash" ] && badhash="y"
[ -f "$XBMK_CACHE/hash/$project$tree" ] || badhash="y"
printf "%s\n" "$pjhash" > "$XBMK_CACHE/hash/$project$tree" || \
err "!mk $XBMK_CACHE/hash/$project$tree"
[ "$badhash" != "y" ] || x_ rm -Rf "src/$project/$tree" \
"elf/$project/$tree" "elf/$project/$target"; :
}
check_cross_compiler()
{
cbdir="src/coreboot/$tree"
[ "$project" != "coreboot" ] && cbdir="src/coreboot/default"
[ -n "$xtree" ] && cbdir="src/coreboot/$xtree"
x_ ./mk -f coreboot "${cbdir#src/coreboot/}"
export PATH="$xbmkpwd/$cbdir/util/crossgcc/xgcc/bin:$PATH"
export CROSS_COMPILE="${xarch% *}-"
[ -n "$xlang" ] && export BUILD_LANGUAGES="$xlang"
# match gnat-X to gcc
check_gnu_path gcc gnat || x_ check_gnu_path gnat gcc
xfix="${1%-*}" && [ "$xfix" = "x86_64" ] && xfix="x64"
xgccargs="crossgcc-$xfix UPDATED_SUBMODULES=1 CPUS=$XBMK_THREADS"
make -C "$cbdir" $xgccargs || x_ make -C "$cbdir" $xgccargs
# we only want to mess with hostcc to build xgcc
remkdir "$XBMK_CACHE/gnupath"
}
# fix mismatching gcc/gnat versions on debian trixie/sid. as of december 2024,
# trixie/sid had gnat-13 as gnat and gcc-14 as gcc, but has gnat-14 in apt. in
# some cases, gcc 13+14 and gnat-13 are present; or gnat-14 and gcc-14, but
# gnat in PATH never resolves to gnat-14, because gnat-14 was "experimental"
check_gnu_path()
{
command -v "$1" 1>/dev/null || err "Host '$1' unavailable"
eval "`setvars "" gccver gccfull gnatver gnatfull gccdir gnatdir`"
x_ gnu_setver "$1" "$1" || err "Command '$1' unavailable."
gnu_setver "$2" "$2" || :
eval "[ -z \"\$$1ver\" ] && err \"Cannot detect host '$1' version\""
[ "$gnatfull" = "$gccfull" ] && return 0
eval "$1dir=\"$(dirname "$(command -v "$1")")\""
eval "_gnudir=\"\$$1dir\"; _gnuver=\"\$$1ver\""
for _bin in "$_gnudir/$2-"*; do
[ "${_bin#"$_gnudir/$2-"}" = "$_gnuver" ] && [ -x "$_bin" ] \
&& _gnuver="${_bin#"$_gnudir/$2-"}" && break; :
done
gnu_setver "$2" "$_gnudir/$2-$_gnuver" || return 1
[ "$gnatfull" = "$gccfull" ] || return 1
(
remkdir "$XBMK_CACHE/gnupath" && x_ cd "$XBMK_CACHE/gnupath"
for _gnubin in "$_gnudir/$2"*"-$_gnuver"; do
_gnuutil="${_gnubin##*/}" && [ -e "$_gnubin" ] && \
x_ ln -s "$_gnubin" "${_gnuutil%"-$_gnuver"}"
done
) || err "Cannot create $2-$_gnuver link in $_gnudir"; :
}
gnu_setver()
{
eval "$2 --version 1>/dev/null 2>/dev/null || return 1"
eval "$1ver=\"`"$2" --version 2>/dev/null | head -n1`\""
eval "$1ver=\"\${$1ver##* }\""
eval "$1full=\"\$$1ver\""
eval "$1ver=\"\${$1ver%%.*}\""; :
}
check_defconfig()
{
[ -f "$defconfig" ] || $dry err "$project/$target: missing defconfig"
dest_dir="$elfdir/$target/${defconfig#"$target_dir/config/"}"
$dry elfcheck || return 1 # skip build if a previous one exists
$dry x_ mkdir -p "$dest_dir"
}
elfcheck()
{
# TODO: *STILL* very hacky check. do it properly (based on build.list)
( fx_ "exit 1" find "$dest_dir" -type f ) || return 1; :
}
handle_makefile()
{
$dry check_makefile "$srcdir" && x_ make -C "$srcdir" $cleanargs clean
[ -f "$defconfig" ] && x_ cp "$defconfig" "$srcdir/.config"
[ -n "$mode" ] || [ -n "$btype" ] || $dry make -C \
"$srcdir" silentoldconfig || make -C "$srcdir" oldconfig || :
run_make_command || err "handle_makefile $srcdir: no makefile!"
_copy=".config" && [ "$mode" = "savedefconfig" ] && _copy="defconfig"
[ "${mode%config}" = "$mode" ] || \
$dry x_ cp "$srcdir/$_copy" "$defconfig"
[ -e "$srcdir/.git" ] && [ "$project" = "u-boot" ] && \
[ "$mode" = "distclean" ] && \
$dry x_ git -C "$srcdir" $cleanargs clean -fdx; :
}
run_make_command()
{
[ -n "$mode" ] || x_ $premake
$dry check_cmake "$srcdir" && [ -z "$mode" ] && \
$dry check_autoconf "$srcdir"
$dry check_makefile "$srcdir" || return 1
$dry x_ make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs
[ -n "$mode" ] || x_ $mkhelper
[ "$mode" != "clean" ] || \
$dry make -C "$srcdir" $cleanargs distclean || :; :
}
check_cmake()
{
[ -z "$cmakedir" ] || $dry check_makefile "$1" || cmake -B "$1" \
"$1/$cmakedir" || $dry x_ check_makefile "$1"
[ -z "$cmakedir" ] || $dry x_ check_makefile "$1"; :
}
check_autoconf()
{
(
cd "$1" || err "!cd $1"
[ -f "bootstrap" ] && x_ ./bootstrap $bootstrapargs
[ -f "autogen.sh" ] && x_ ./autogen.sh $autogenargs
[ -f "configure" ] && x_ ./configure $autoconfargs; :
) || err "can't bootstrap project: $1"; :
}
check_makefile()
{
[ -f "$1/Makefile" ] || [ -f "$1/makefile" ] || \
[ -f "$1/GNUmakefile" ] || return 1; :
}
copy_elf()
{
[ -f "$listfile" ] && x_ mkdir -p "$dest_dir" && while read -r f; do
[ -f "$srcdir/$f" ] && x_ cp "$srcdir/$f" "$dest_dir"
done < "$listfile"
x_ make clean -C "$srcdir" $cleanargs
}
. "include/tree.sh"
trees "$@" || exit 0
. "$mkhelpercfg"