Commit Graph

85 Commits (74ae84afba74994e3a854d189d9e7226f7e4187c)

Author SHA1 Message Date
Leah Rowe bea089bbe4 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-06 01:01:22 +01:00
Leah Rowe 6e1b8087c5 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-05 11:26:08 +01:00
Leah Rowe 62c25ac7ab 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:11:01 +01:00
Leah Rowe 75382a4126 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:07:53 +01:00
Leah Rowe 00653aab1e better help text on invalid commands
adding help again is a bad idea. code should never
document itself; that's what documentation is for.

so, make the code do a better job telling the user
where to find documentation.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-03 00:17:36 +01:00
Leah Rowe afac9a06d2 build: print the project website address on help
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-02 23:34:10 +01:00
Leah Rowe 13d4b6d3c7 delete u-boot test/lib/strlcat.c using nuke()
we don't need to do it in the release function

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-30 07:37:19 +01:00
Leah Rowe 914852dd40 rename include/option.sh to include/lib.sh
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-26 12:10:27 +01:00
Leah Rowe 5c14e8e1bc general code cleanup in the build system
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-26 07:22:44 +01:00
Leah Rowe 48c2cef800 build: simplify git_init()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-25 16:56:44 +01:00
Leah Rowe db06bbdb6e build: do root check before git check
otherwise, git could be initialised as root.

running as root is not allowed.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-25 16:34:48 +01:00
Leah Rowe 8d199a31d1 build: simplify git checks
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-25 16:34:07 +01:00
Leah Rowe 5d87eea77c build: hide git-init output
following on from the previous commit, if you run
something like "./build roms list" when running for
the first time from a codeberg tarball, the output
of the git commands will be included in the output

hide this output

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-24 15:00:46 +01:00
Leah Rowe aadccc591b more minor cleanup in the build system
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-19 08:14:57 +01:00
Leah Rowe cc7ed6926b build/roms: rename moverom to copyrom
it copies, it doesn't move, so name it right

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-19 06:43:37 +01:00
Leah Rowe b40118ae59 minor code cleanup in the build system
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-19 06:30:32 +01:00
Leah Rowe f8e3ca3b22 git.sh: Remove .git if XBMK_RELEASE=y
The build system already deletes .git in all source
directories for each given release, but does so at
the very end; it still does, but now it is deleted
one by one per project, to save space during very
large builds (release sizes vary wildly, depending
on how many trees exist for coreboot basically).

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

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

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

This change will not be the last of such changes!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-18 04:53:31 +01:00
Leah Rowe dd851caac9 build: remove initcmd() and simplify main()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-16 11:34:53 +01:00
Leah Rowe 4ea843a490 build: initialise git first (before commands)
when running the inject logic, we should still initialise
the git repository because these commands make use of the
coreboot build system which requires git.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-16 11:29:57 +01:00
Leah Rowe 5702f5a4dc build: remove excmd() and simplify main()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-16 11:23:22 +01:00
Leah Rowe b76a70c3f9 build: don't make script_path a global variable
this allows a mild cleanup of the code (reduction by 1 line)

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

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

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

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

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

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-16 03:56:52 +01:00
Leah Rowe 885fcebd81 remove help commands (user should read docs)
i always say, code should never document itself.

that's what documentation is for. the releases
contain documentation under docs/ but the git
repository does not; for that, use the website.

(in practise, lbmk usually needs internet anyway)

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

therefore, move the logic into main()

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 04:03:16 +01:00
Leah Rowe 313c4c01e0 build: define "xp" in the global variables
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 03:55:44 +01:00
Leah Rowe 350857fff3 build: simplify for loop in fetch_trees()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 03:53:26 +01:00
Leah Rowe 8e05399d91 build: simplified downloads in fetch_trees()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 03:39:28 +01:00
Leah Rowe 914ff1ad12 ./build release: don't do u-boot-only archives
it's a pointless feature, initially added just to one-up
gnuboot and only intended for canoeboot, to provide u-boot
tarballs with deblobbing. this was done, because the parabola
build system has certain limitations so the idea is to provide
them with tarballs. but why? they can just fix their build system...

delete this bloat from lbmk. we only need to provide full sources,
and rom images.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 03:19:32 +01:00
Leah Rowe 5c3fb9a4f8 build: use utc+0 when initialising git repo dates
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 03:10:43 +01:00
Leah Rowe e281966f22 remove check_project() (always set variables)
in lbmk, we call check_project() to set variables
such as projectname, version, version date

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

do it by default

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 03:04:41 +01:00
Leah Rowe ee2bf0d25a build: simplify deletions in fetch_trees()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 02:56:58 +01:00
Leah Rowe 39df62301d build: delete mkversion() (just print relname)
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 02:49:30 +01:00
Leah Rowe e5ffb2afe6 rm src/u-boot/*/test/lib/strlcat.c in u-boot
i accidentally removed this in a previous commit

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 02:33:35 +01:00
Leah Rowe c149cbb884 build: remove mkrom_images
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 01:41:19 +01:00
Leah Rowe 4135ce5e27 build: use same tarball name on uboot-only release
it's a rarely used feature, not currently used by the
libreboot project itself

remove unnecessary bloat

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

now the release logic simply has to move a directory

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 01:27:45 +01:00
Leah Rowe 267c13cca7 cleanup: remove mkvdir
this function is not needed, because it's only called
once and it's very small.

furthermore: insert_version_files does ntot need to be called here,
because they same files are generated immediately afterward when
running that version of lbmk.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-15 00:42:44 +01:00
Leah Rowe 1ce7e33976 move rom tarball creation to script/roms
export LBMK_RELEASE="y"

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

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

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

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

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

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-11 18:53:12 +01:00
Leah Rowe d7ce26dc23 move script/*/* to script/
there are only two scripts under script/ now, and there
probably won't be many more. lbmk's design has simplified
to such a degree that the two-level directory structure is
no longer necessary.

the existing command structure has not changed. for example:

./build roms list
./update trees -f coreboot default

these will still work, but the symlinks to "build" are now
strictly for backwards compatibility; they may be removed
at a later date, but i'll keep the current design for now.

this also leads to a quirk, for example:

./build roms all
./update roms all

these now do the exact same thing, whereas "./update roms all"
would have previously been an invalid command.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-11 06:26:52 +01:00
Leah Rowe 029291e549 merge script/vendor/* into include/vendor.sh
stub it from the main build script

the commands remain identical:
./vendor download arguments_here
./vendor inject arguments_here

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-11 05:57:49 +01:00
Leah Rowe c8fb24bb7b build: print usage for special commands
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-11 05:19:48 +01:00
Leah Rowe 5f63b594fa merge script/update/release into build
the main script isn't that big, and since the main
purpose of lbmk is geared toward the releases, it
makes sense to reduce the number of scripts by
merging into the main one

the way this works, "./update release" still works
afterward

so, the way lbmk is used shall remain unchanged

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-11 04:15:30 +01:00
Leah Rowe 052414c0ca build: further prevent non-lbmk-work-directory
this is a follow-up to the previous commit

again, there's no posix way to check the path to the
file at argument 0, because readlink (utility) isn't
defined in posix (the C function is defined, but not
the utility included on many unices)

check whether "build" (file) exists, and whether it
is a symlink; if the latter, then we are definitely
not in the lbmk work directory!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-09 14:48:14 +01:00
Leah Rowe fb8d0c86c4 build: exit if not running from lbmk directory
there's no portable(posix) way to check when running
from a symlink to lbmk in the current work directory

for example:

ln -s lbmk/build lbmktest
./lbmktest roms list

this would pass the new test, and first try to
include option.sh. in practise, the user probably  doesn't
happen to have include/option.sh in their current path

i can use readlink here, but again not portable

the current check will suffice. it also works when
the symlink is called from $PATH

e.g. /usr/bin/lbmktest exists and you do:
lbmktest roms list

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-09 14:31:43 +01:00
Leah Rowe 5e4009b539 merge include/err.sh with include/option.sh
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-06 22:54:55 +01:00
Leah Rowe 64177dbb8e exports variables from err.sh, not build
LC_COLLATE and LBMK_RELEASE are important variables. we want
to make sure that these are seen by everything.

since err.sh is included from all scripts, doing it there will
accomplish just that.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-04-26 08:20:19 +01:00
Leah Rowe 08859bb4a5 lbmk: export TMPDIR from err.sh, not build
lbmk sets TMPDIR to /tmp, and then creates a tmpdir, then
exports *that* as the value of TMPDIR. this unified TMPDIR
location then contains all subsequent files and directories,
when any script or program makes use of /tmp, via mktemp. at
least, that's the theory!

in practise, because it was only being properly exported from
the main build scripts, subscripts that are then called were
not exporting it, at least that is my assumption because in
some cases, i found that the coreboot build system was leaving
errant files behind outside of our own TMPDIR, and that build
system did not seem to be setting TMPDIR itself; more debugging
is needed.

anyway: use the exact same logic, but do it from err.sh. since
err.sh is included from every lbmk script, that means it will
always be exported when running every single part of lbmk. this
should reduce the chance that mktemp creates files and directories
outside of our custom TMPDIR location.

this is because in lbmk, we mitigate unhandled tmpdirs/files by
unifying it in the manner described, then deleting the entire
TMPDIR on exit from the main lbmk parent process (the main
script that the user called from, which is always the "build"
file).

in lbmk, effort is made to clean up temporary files properly,
without relying on this catch-all, but we can't rely on that.
the catch-all should also be as robust as possible.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-04-25 19:08:53 +01:00
Leah Rowe ed0678ae2e haswell: only provide NRI-based ROMs in releases
release="n" is set in target.cfg on haswell build targets
that use mrc.bin

script/update/release exports LBMK_RELEASE="y"

script/build/roms skips building a given target if release="n"
in target.cfg *and* LBMK_RELEASE="y"

you could also do the export yourself before running ./build roms,
for example:

export LBMK_RELEASE="y"
./build roms all

This would skip these ROM images. The native haswell raminit is
now stable enough in my testing, that I wish to delete the MRC-based
targets. This is in line with Libreboot's Binary Blob Reduction Policy,
which states: if a blob can be avoided, it should be avoided.

The problem is that users often run the inject script in *lbmk* from
Git, instead of from the src release archive. I forsee some users
running this on modern lbmk with older release images. If the mrc-based
target isn't there, the user may use an NRI-based target name, and
think it works; they will insert without MRC. I foresaw this ages
ago, which is why Caleb and I ensured that the script checks hashes,
and hashes are included in releases.

Therefore: for the time being, keep the MRC-based configs in lbmk
but do not include images for them in releases. This can be done
indefinitely, but I'll probably remove those configs entirely at
some point.

On the following boards, Libreboot now will *only* provide NRI-based
ROM images for the following machines:

* Dell OptiPlex 9020 SFF
* Dell OptiPlex 9020 MT
* Lenovo ThinkPad T440p
* Lenovo ThinkPad W541/W540

I now recommend exclusive use of NRI-based images, on Haswell
hardware. It's stable enough in my testing, and now supports S3.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-04-24 05:27:27 +01:00