Commit Graph

89 Commits (741ef57efc70e418615602a56fa7bc9a3ba2fa4d)

Author SHA1 Message Date
Leah Rowe adf1a2e1a4 lib.sh: Much safer python version check
See:
https://docs.python.org/3/library/sys.html#sys.version_info

The sys.version_info tuple is a more reliable way to
get the version. Our previous logic assumed that Python
would always output "Python versionnumber", but this may
not always be how it works. We've seen this for example
where Debian modifies some GNU toolchains to include Debian
something in the output.

Python has a standard method built in for outputting exact
the information we need. In my system, what I got was this:

(3, 11, 2, 'final', 0)

That output was from running this command:

python -c 'import sys; print(sys.version_info[:])'

This is much more robust, so use this instead.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:37:37 +00:00
Leah Rowe 1b1dae36d2 set up python in PATH, ensuring that it is python3
we already check the python version, and set a variable
for it, so that we can reliably use python3, even if
python in PATH doesn't correspond to python3. for
example if a system has python as python2 and python3
as python3

well, we use that when running deguard for example, but
various upstream projects that we use may need python,
and all of them use python3, not 2

so, re-use the python variable set up by lbmk, and
set it up in PATH accordingly. this now makes the note
about python3 obsolete, on docs/build.md in lbwww.git

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:36:27 +00:00
Leah Rowe d731b07aa7 lib.sh: Set python after dependencies
otherwise, the user can't install python, which is
in the dependencies. an irony!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:32:58 +00:00
Leah Rowe bf5979f0b2 lib.sh: Fix unescaped quotes in chkvars()
This should be the proper fix now

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:32:33 +00:00
Leah Rowe 9baf6a72a7 Revert "fix more unescaped quotes in eval"
This reverts commit ec6bcc1fba5fbdf8b19b3d1cf9711f3d4c9c3741.
2025-01-07 00:32:28 +00:00
Leah Rowe c1dd3da298 fix more unescaped quotes in eval
it should fix more build errors that might have appeared
in the aforementioned revision, mentioned in the previous
commit message

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:32:22 +00:00
Leah Rowe caa18bdcb3 fix ./mk dependencies build issue
the bug was actually caused by chkvars

add an escape for the quotes and bam. fixed.

without this, i got the following e.g.

For command: ./mk dependencies debian

Output:

./mk: 1: [: apt-get: unexpected operator
ERROR ./mk: pkg_add unset

Someone reported a similar issue with the Arch one,
which is also now fixed. This regression was caused
by the previous commit:

commit 0cf58c22734b19293f4cbef83add59b031ca1773
Author: Leah Rowe <leah@libreboot.org>
Date:   Thu Jan 2 23:52:45 2025 +0000

    fix lbmk shellcheck errors

I forgot to escape the double quotes in an eval.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:32:16 +00:00
Leah Rowe 76d87782a8 lib.sh mktarball: cleaner if statement
i also removed that printf, because the path it prints is
actually wrong sometimes; in the recent re-write of vendor.sh,
it prints the correct path instead

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:29:28 +00:00
Leah Rowe 3d1fea0977 fix lbmk shellcheck errors
There was also a condition in run_make_command that is now
an OR, where it was an AND, on script/trees, to fix the use
of mixed (and erroneous) OR/AND operators.

I'm planning a much more invasive audit than this. These are
light fixes, intended for Libreboot 20241206 rev8.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:28:41 +00:00
Leah Rowe 4862f6a348 lib.sh and rom.sh: update my header
i made modifications to them in 2025, so
update them to 2025

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:27:37 +00:00
Leah Rowe 8bdfd31498 rom.sh: handle tarballs in mkcoreboottar
don't make sha512 files for tar archives, because it
is my intention to add the ./mk inject command to
canoeboot in a future commit, but without the vendor
file download/inject functionality, just the mac
address changer.

this commit is based on lbmk commit 41275d699ca

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:25:53 +00:00
Leah Rowe 4a83659885 compile rmodtool alongside cbfstool
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:16:30 +00:00
Leah Rowe 012f530656 lib.sh dependencies: support --reinstall argument
./mk dependencies debian --reinstall

Add --reinstall and it'll do:

apt-get install --reinstall

This can be useful when updating from a stable release
to a testing release. The variable, "reinstall" can be
configured for other distros, but it's currently only
configured for Debian-based distros.

Also, it can be anything. For example, you could add -y;
however, a 4th argument will not be accepted. For example,
you cannot do:

./mk dependencies debian --reinstall -y

If you do this, it'll only see --reinstall; similarly, if
you did this command:

./mk dependencies debian -y --reinstall

then -y would be passed, but not --reinstall. This is an
intentional design decision, in case you accidentally pasted
or subshelled something that outputted something undesirable,
to prevent possible abuse.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:12:11 +00:00
Leah Rowe 33206cae60 move xbmkpath to XBMK_CACHE/
When doing ./mk release, the build system would create
symlinks inside xbmkpath/ relative to the current work tree,
which will differ from what's in PATH.

Since XBMK_CACHE is already set globally, from the main work
tree and the release-build work tree, that means we can know
reliably that PATH is always correct if we put xbmkpath/
inside XBMK_CACHE.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:11:59 +00:00
Leah Rowe 2608bea771 use command -v instead of which
which is a non-standard command, whereas command is part of posix

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:11:31 +00:00
Leah Rowe 444154c002 path.sh: Further cleanup
Remove all symlinks each time, to ensure that no
stragglers are left behind, since they are being
re-generated each time anyway.

The code for determining version numbers has now
been unified under gnu_setver()

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:10:57 +00:00
Leah Rowe 5a5a7c37f5 Fix globbing issue in cbmk
When doing e.g. $@ we should use double quotes to prevent globbing.

Thanks go to XRevan86 for pointing this out.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:10:11 +00:00
Leah Rowe 7ee6ec0ce9 Mitigate Debian Trixie/Sid GCC/GNAT version mismatch
When I tested Debian Trixie, and Debian Sid, I saw that
GCC in PATH pointed to gcc-14, but gnat in path pointed
to GNAT-13, even if you manually install gnat-14.

GNAT 14 was marked experimental, but GCC 14 was marked
for use, in the apt repositories.

So this patch doesn't address the mismatch when doing e.g.
apt-get install gcc gnat

I will address the actual package dependency in a follow-up
patch, on the Debian dependencies config.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-07 00:07:24 +00:00
Leah Rowe 417accd9e0 lib.sh: Support copying files locally
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-06 23:50:39 +00:00
Leah Rowe 7b8bda9977 lib.sh: Safer exit from ./mk dependencies
The exit was dependent upon install_packages returning
zero status, which it always would in practise, due to
its design, but this exit must always be observed, so
the code has been modified to honour this design.

A direct exit violates lbmk's design in most instances,
where a temporary directory and lock file has already
been created; at this stage, no such act was performed,
so a direct exit is perfectly acceptable.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-01-06 23:44:36 +00:00
Leah Rowe ac5c87681f Add U-Boot x86_64 payload
Currently seems to stall when booted from the GRUB
payload, but works when booted from the SeaBIOS menu.

I also tested it as a standalone payload and it seems
to boot. Will test on hardware next, and start adding
it to more mainboards.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-11-28 20:27:10 +00:00
Leah Rowe 966fc8c23f Experimental U-Boot payload (32-bit dtb, U-Boot)
NOTE: Support added for xarch target x86_64-elf,
but U-Boot failed to build with this error:

OBJCOPY lib/efi_loader/helloworld.efi
x86_64-elf-objcopy: lib/efi_loader/helloworld_efi.so: invalid bfd target
make[2]: *** [scripts/Makefile.lib:476: lib/efi_loader/helloworld.efi] Error 1

Since I'm building U-Boot for x86_64 *on* an x86-64
host, and since that is currently the recommended type
of machine to use for cbmk development, and since the
other x86 payloads currently don't cross compile anyway,
this is an acceptable compromise for now. This is because
at present, I'm not making U-Boot the primary payload on x86,
instead preferring to chain it from GRUB and SeaBIOS.

The target.cfg file for x86 u-boot shows xarch/xtree commented.
Uncomment these to compile on crossgcc instead of hostcc.

I mention 64-bit because I initially did this first, but decided
to do 32-bit first. I'll work on the 64-bit one next (SPL).

It's only enabled in QEMU for now.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-11-28 19:53:23 +00:00
Leah Rowe 01331db17f lib.sh: more verbose error in x_
part of the command was cut off in the output

Signed-off-by: Leah Rowe <info@minifree.org>
2024-08-14 22:15:55 +01:00
Leah Rowe 8b74fe2c14 lib.sh: new function mk() to handle trees in bulk
single-tree projects cannot be handled in bulk, e.g.
./mk -f project1 project2 project3

that is still the case, from the shell, but internally
it is now possible:
mk -f project1 project2 project3

mk() is a function that simply handles the given flag,
and all projects specified.

it does not handle cases without argument, for example
you cannot do:
mk -f

arguments must be provided. it can be used internally,
to simplify cases where multiple single-tree projects
must be handled, but *also* allows multi-tree projects
to be specified, without being able to actually handle
trees within that multi-tree project; so for example,
you can only specify coreboot, and then it would run
on every coreboot tree.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-07-28 15:40:56 +01:00
Leah Rowe 7942aff43d general code cleanup in the build system
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-07-26 20:53:06 +01:00
Leah Rowe 16f9ad55ca put cachedir in environmental variable
XBMK_CACHE is now used, instead of hardcoding cache/

this is exported initialised to cache/, if unset.
this means you can set your own directory, and it means
./update release will use the same directory.

this means bandwidth wastage is further avoided.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-07-19 15:02:00 +01:00
Leah Rowe 8bb3730e7b cache downloaded files(module) to cache/file/HASH
lib.sh download() is used by subfile handling in git.sh,
e.g. crossgcc tarballs.

they are not currently cached, but are downloaded directly
in place.

cache them, under cache/file/, saved with the name equal
to the checksum, so: cache/file/CHECKSUM

if the given cached file exists, use it as-is for simple
copy, instead of curl. this avoids re-downloading a lot of
crossgcc tarballs, where different coreboot trees may use
some archives that are the same throughout.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-07-18 02:14:23 +01:00
Leah Rowe 3365fca06a trees: general code cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-07-12 16:40:02 +01:00
Leah Rowe 3681c29e77 remove executable permission on include/
files under include/ should never be executed directly

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-07-12 16:36:53 +01:00
Leah Rowe e01995d491 rom.sh: new file, to replace script/roms
stub it from the trees script. the way it works now,
there is less code in the build system.

./build roms

this is no longer a thing

./build roms serprog

this is also no longer a thing. instead, do:

./update trees -b coreboot targetnamehere

./update trees -b pico-serprog

./update trees -b stm32-vserprog

the old commands still works, which causes the new
commands to run

coreboot roms now appear in elf/, not bin/, as before,
but those images now contain payloads.

NOTE: to contradict the above: ./build roms is no
longer a thing, in that it's now deprecated, but
backward compatibility is present for now. it will
be removed in a future release.

./build roms list also still works! it will do:
./update trees -b coreboot list

also:
./update trees -b grub list
this is now possible too

if a target "list" is provided, for multi-tree sources,
the targets are shown.

there is another difference: seagrub roms are now seagrub_,
instead of seabios_withgrub.

seabios-only roms are no longer provided, where grub is also
enabled; only seagrub is used. the user can easily remove
the bootorder file, if they want seabios to not try grub first.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-07-08 01:37:26 +01:00
Leah Rowe 7322a2b53d lib.sh: stricter check in chkvars()
testing +x is all well and good, but the variable string
may be empty, even if set. some of the checks in the build
system are relying on the latter, so handle it.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-28 22:34:13 +01:00
Leah Rowe 203fdb8007 tidy up some setvars lists
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-28 22:16:32 +01:00
Leah Rowe 0dcd8852dd lib.sh: keep versiondate check to 80 characters
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-28 22:13:33 +01:00
Leah Rowe 2ebdd184b7 lib.sh: condense for loop
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-28 22:13:27 +01:00
Leah Rowe 5dc30167de lib.sh: condense err_() a bit
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-28 22:13:23 +01:00
Leah Rowe a9882cfa00 lib.sh: add a return to the end of chkvars()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-28 22:13:17 +01:00
Leah Rowe 511423a85a lib.sh: remove unused variable "boarddir"
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-28 22:12:33 +01:00
Leah Rowe 2827917b0a lib.sh: remove unused cbdir variable
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-27 16:24:11 +01:00
Leah Rowe f3baebe7e1 lib.sh: move git_err() to build
it's only used in the main build script, so move it there.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-27 16:23:11 +01:00
Leah Rowe 43238fa0c5 lib.sh: condense singletree() a bit
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-27 16:23:06 +01:00
Leah Rowe de331e5da0 lib.sh: add a return to the end of check_defconfig
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-27 16:23:01 +01:00
Leah Rowe 35c516c2f4 lib.sh: condense e() a bit
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-27 13:59:22 +01:00
Leah Rowe 9ba28a0b86 lib.sh: make elf/coreboot* a dot directory
we don't want the user to flash coreboot from elf/, because
those images do not contain payloads. the user must flash from
bin/

ample warning is given, at build time, but the warning is written
in english. therefore, some people may not understand it, because
they may not even speak english.

hide the coreboot elf/ directory, to mitigate this possibility.
in most cases, this will probably prevent the average user from
flashing those images, since they likely won't see it.

the "DO NOT FLASH" warning is still included in that directory
name, while creating it.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-27 03:27:52 +01:00
Leah Rowe 6daea94df8 lib.sh: simplified TMPDIR handling
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-27 03:27:42 +01:00
Leah Rowe 0c0b8124c1 lib.sh: condense setcfg() if/else logic
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-27 03:27:21 +01:00
Leah Rowe aac8720382 lib.sh: introduce mandatory check of projectname
error out if it's not set. ditto projectsite.

that way, if the files are accidentally deleted, or not
added in a derivative of the build system, you'll know.

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

just export them directly and use them directly.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-25 00:28:12 +01:00