2023-08-16 20:34:21 +00:00
|
|
|
#!/usr/bin/env sh
|
2023-09-25 01:19:30 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2024-05-26 00:54:36 +00:00
|
|
|
# Copyright (c) 2022-2023 Alper Nebi Yasak <alpernebiyasak@gmail.com>
|
|
|
|
# Copyright (c) 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
# Copyright (c) 2023-2024 Leah Rowe <leah@libreboot.org>
|
2023-08-16 20:34:21 +00:00
|
|
|
|
|
|
|
set -u -e
|
|
|
|
|
2024-05-26 11:10:27 +00:00
|
|
|
. "include/lib.sh"
|
2023-10-07 05:55:10 +00:00
|
|
|
. "include/git.sh"
|
|
|
|
|
2024-07-10 21:14:39 +00:00
|
|
|
eval `setvars "" xarch srcdir premake cmakedir xlang mode makeargs elfdir cmd \
|
trees: support -d (dry run) for custom build logic
-d does the same as -b, except for actually building
anything! in effect, it does the same as -f (fetch)
except that the resulting variable assignments will
not be recursive (as with -f).
if -d is passed, configuration is still loaded, defconfig
files are still cycled through, and more importantly:
helper functions are still processed.
the grub, serprog and coreboot helper functions have
been modified to return early (zero status) if -d is
passed.
this behaviour will be used to integrate vendor.sh
logic in with the trees script, for cases where the
user wants to only handle vendor files. e.g.:
./update trees -b coreboot x230_12mb
this would download the files as usual, build coreboot,
with those files, and then build the payloads. but:
./update trees -d coreboot x230_12mb
this would download the files, NOT build coreboot, and
NOT build the payloads.
this change increases the sloccount a bit, but i'm relying
on the fact that the vendor.sh script already re-implements
config handling wastefully; the plan is to only use trees.
for now, simply stub the same ./vendor download command.
there is one additional benefit to doing it this way:
this method is *per-kconfig* rather than per-target.
this way, one kconfig might specify a given vendor file
that is not specified in the other. although the stub
still simply handles this per target, it's done in premake,
which means that the given .config file has been copied.
this means that when i properly re-integrate the logic
into script/trees, i'll be able to go for it per-kconfig.
the utils command has been removed, e.g.
./update trees -b coreboot utils default
the equivalent is now:
./update trees -d coreboot default
this would technically download vendor files, but here
we are specifying a target for which no kconfigs exist;
a check is also in place, to avoid running the vendor file
download logic if tree==target
the overall effect of this change is that the trees script
no longer contains any project-specific logic, except for
the crossgcc build logic.
it does include some config/data mkhelper files at the top,
for serprog and coreboot, so that those variables defined in
those files can be global, but another solution to mitigate
that will also be implemented in a future commit.
the purpose of this and other revisions (in the final push
to complete lbmk audit 6 / cbmk audit 2) is to generalise as
much logic as possible, removing various ugly hacks.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-07-09 00:31:25 +00:00
|
|
|
project target target_dir targets xtree _f release bootstrapargs mkhelper \
|
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-06 22:36:13 +00:00
|
|
|
autoconfargs listfile autogenargs btype tree rev tree_depend build_depend \
|
2024-07-17 13:55:49 +00:00
|
|
|
defconfig postmake mkhelpercfg dry dest_dir mdir badhash`
|
2023-10-07 05:55:10 +00:00
|
|
|
|
2023-08-16 20:34:21 +00:00
|
|
|
main()
|
|
|
|
{
|
trees: support -d (dry run) for custom build logic
-d does the same as -b, except for actually building
anything! in effect, it does the same as -f (fetch)
except that the resulting variable assignments will
not be recursive (as with -f).
if -d is passed, configuration is still loaded, defconfig
files are still cycled through, and more importantly:
helper functions are still processed.
the grub, serprog and coreboot helper functions have
been modified to return early (zero status) if -d is
passed.
this behaviour will be used to integrate vendor.sh
logic in with the trees script, for cases where the
user wants to only handle vendor files. e.g.:
./update trees -b coreboot x230_12mb
this would download the files as usual, build coreboot,
with those files, and then build the payloads. but:
./update trees -d coreboot x230_12mb
this would download the files, NOT build coreboot, and
NOT build the payloads.
this change increases the sloccount a bit, but i'm relying
on the fact that the vendor.sh script already re-implements
config handling wastefully; the plan is to only use trees.
for now, simply stub the same ./vendor download command.
there is one additional benefit to doing it this way:
this method is *per-kconfig* rather than per-target.
this way, one kconfig might specify a given vendor file
that is not specified in the other. although the stub
still simply handles this per target, it's done in premake,
which means that the given .config file has been copied.
this means that when i properly re-integrate the logic
into script/trees, i'll be able to go for it per-kconfig.
the utils command has been removed, e.g.
./update trees -b coreboot utils default
the equivalent is now:
./update trees -d coreboot default
this would technically download vendor files, but here
we are specifying a target for which no kconfigs exist;
a check is also in place, to avoid running the vendor file
download logic if tree==target
the overall effect of this change is that the trees script
no longer contains any project-specific logic, except for
the crossgcc build logic.
it does include some config/data mkhelper files at the top,
for serprog and coreboot, so that those variables defined in
those files can be global, but another solution to mitigate
that will also be implemented in a future commit.
the purpose of this and other revisions (in the final push
to complete lbmk audit 6 / cbmk audit 2) is to generalise as
much logic as possible, removing various ugly hacks.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-07-09 00:31:25 +00:00
|
|
|
while getopts f:b:m:u:c:x:s:l:n:d: option; do
|
2024-06-27 01:33:45 +00:00
|
|
|
[ -n "$_f" ] && $err "only one flag is permitted"
|
2024-07-10 19:38:36 +00:00
|
|
|
_f="$1" && [ "$_f" = "-d" ] && dry=":"
|
2024-05-26 00:54:36 +00:00
|
|
|
case "$1" in
|
trees: support -d (dry run) for custom build logic
-d does the same as -b, except for actually building
anything! in effect, it does the same as -f (fetch)
except that the resulting variable assignments will
not be recursive (as with -f).
if -d is passed, configuration is still loaded, defconfig
files are still cycled through, and more importantly:
helper functions are still processed.
the grub, serprog and coreboot helper functions have
been modified to return early (zero status) if -d is
passed.
this behaviour will be used to integrate vendor.sh
logic in with the trees script, for cases where the
user wants to only handle vendor files. e.g.:
./update trees -b coreboot x230_12mb
this would download the files as usual, build coreboot,
with those files, and then build the payloads. but:
./update trees -d coreboot x230_12mb
this would download the files, NOT build coreboot, and
NOT build the payloads.
this change increases the sloccount a bit, but i'm relying
on the fact that the vendor.sh script already re-implements
config handling wastefully; the plan is to only use trees.
for now, simply stub the same ./vendor download command.
there is one additional benefit to doing it this way:
this method is *per-kconfig* rather than per-target.
this way, one kconfig might specify a given vendor file
that is not specified in the other. although the stub
still simply handles this per target, it's done in premake,
which means that the given .config file has been copied.
this means that when i properly re-integrate the logic
into script/trees, i'll be able to go for it per-kconfig.
the utils command has been removed, e.g.
./update trees -b coreboot utils default
the equivalent is now:
./update trees -d coreboot default
this would technically download vendor files, but here
we are specifying a target for which no kconfigs exist;
a check is also in place, to avoid running the vendor file
download logic if tree==target
the overall effect of this change is that the trees script
no longer contains any project-specific logic, except for
the crossgcc build logic.
it does include some config/data mkhelper files at the top,
for serprog and coreboot, so that those variables defined in
those files can be global, but another solution to mitigate
that will also be implemented in a future commit.
the purpose of this and other revisions (in the final push
to complete lbmk audit 6 / cbmk audit 2) is to generalise as
much logic as possible, removing various ugly hacks.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-07-09 00:31:25 +00:00
|
|
|
-d) mode="" ;;
|
2024-06-27 01:31:54 +00:00
|
|
|
-b) mode="" ;;
|
2023-10-07 05:55:10 +00:00
|
|
|
-u) mode="oldconfig" ;;
|
|
|
|
-m) mode="menuconfig" ;;
|
|
|
|
-c) mode="distclean" ;;
|
|
|
|
-x) mode="crossgcc-clean" ;;
|
|
|
|
-f) mode="fetch" ;;
|
2023-10-13 08:16:41 +00:00
|
|
|
-s) mode="savedefconfig" ;;
|
|
|
|
-l) mode="olddefconfig" ;;
|
|
|
|
-n) mode="nconfig" ;;
|
2024-06-22 02:55:04 +00:00
|
|
|
*) $err "invalid option '-$option'" ;;
|
2023-10-07 05:55:10 +00:00
|
|
|
esac
|
2024-06-30 20:31:01 +00:00
|
|
|
[ -z "${OPTARG+x}" ] && shift 1 && break
|
2024-06-27 01:36:18 +00:00
|
|
|
project="${OPTARG#src/}"; shift 2
|
2023-10-07 05:55:10 +00:00
|
|
|
done
|
safer, simpler error handling in lbmk
in shell scripts, a function named the same as a program included in
the $PATH will override that program. for example, you could make a
function called ls() and this would override the standand "ls".
in lbmk, a part of it was first trying to run the "fail" command,
deferring to "err", because some scripts call fail() which does
some minor cleanup before calling err.
in most cases, fail() is not defined, and it's possible that the user
could have a program called "fail" in their $PATH, the behaviour of
which we could not determine, and it could have disastrous effects.
lbmk error handling has been re-engineered in such a way that the
err function is defined in a variable, which defaults to err_ which
calls err_, so defined under include/err.sh.
in functions that require cleanup prior to error handling, a fail()
function is still defined, and err is overridden, thus:
err="fail"
this change has made xx_() obsolete, so now only x_ is used. the x_
function is a wrapper that can be used to run a command and exit with
non-zero status (from lbmk) if the command fails. the xx_ command
did the same thing, but called fail() which would have called err();
now everything is $err
example:
rm -f "$filename" || err "could not delete file"
this would now be:
rm -f "$filename" || $err "could not delete file"
overriding of err= must be done *after* including err.sh. for
example:
err="fail"
. "include/err.sh"
^ this is wrong. instead, one must do:
. "include/err.sh"
err="fail"
this is because err is set as a global variable under err.sh
the new error handling is much cleaner, and safer. it also reduces
the chance of mistakes such as: calling err when you meant to
call fail. this is because the standard way is now to call $err,
so you set err="fail" at the top of the script and all is well.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-03-27 01:19:39 +00:00
|
|
|
[ -z "$_f" ] && $err "missing flag (-m/-u/-b/-c/-x/-f/-s/-l/-n)"
|
2024-06-30 20:31:01 +00:00
|
|
|
[ -z "$project" ] && for p in $(ls -1 config/git); do
|
2024-07-17 17:55:18 +00:00
|
|
|
./update trees $_f "$p" || $err "!./update trees $_f $p"; :
|
2024-07-10 23:28:32 +00:00
|
|
|
done && return 1
|
2024-06-09 14:57:53 +00:00
|
|
|
|
lib.sh: more unified config handling
replace it with logic that simply uses "." to load
files directly. for this, "vcfg" is added as a variable
in coreboot target.cfg files, referring to a directory
in config/vendor/ containing a file named pkg.cfg, and
this file then contains the same variables as the
erstwhile config/vendor/sources
config/git files are now directories, also containing
pkg.cfg files each with the same variables as before,
such as repository link and commit hash
this change results in a noticeable reduction in code
complexity within the build system.
unified reading of config files: new function setcfg()
added to lib.sh
setcfg checks if a config exists. if a 2nd argument is
passed, it is used as a return value for eval, otherwise
a string calling err is passed. setcfg output is passed
through eval, to set strings based on config; eval must
be used, so that the variables are set within the same
scope, otherwise they'd be set within setcfg which could
lead to some whacky results.
there's still a bit more more to do, but this single change
results in a substantial reduction in code complexity.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-22 01:35:25 +00:00
|
|
|
[ -f "config/git/$project/pkg.cfg" ] || $err "'$project' not defined"
|
2024-06-09 14:57:53 +00:00
|
|
|
|
2024-07-10 21:14:39 +00:00
|
|
|
for d in "elf" "config/data" "config" "src"; do
|
|
|
|
eval "${d#*/}dir=\"$d/$project\""
|
|
|
|
done; dest_dir="$elfdir"
|
|
|
|
listfile="$datadir/build.list"
|
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-06 22:36:13 +00:00
|
|
|
[ -f "$listfile" ] || listfile="" # optional on all projects
|
2023-10-07 05:55:10 +00:00
|
|
|
|
trees: remove project-specific hacks
move the coreboot-specific includes into mkhelper.cfg
for that project.
on some projects, we need variables from mkhelper.cfg
to be global, so I was including serprog and coreboot
mkhelper.cfg files in this script.
instead, set a new variable "mkhelpercfg" pointing to
the config file. if it doesn't exist, create and then
point to a temporary (empty) mkhelper.cfg file.
the rom.sh include has been moved to coreboot mkhelper.cfg
The only remaining project-specific logic, in this trees
script, is now the coreboot crossgcc handling, but this
needs to be there as it's also used to build U-Boot.
The way this now works, certain includes are done twice.
For example, include/rom.sh will be included once globally,
outside of main(), and then again in configure_project().
This means that certain functions will be defined twice.
I'm uncertain if shell has anything equivalent to an ifdef
guard as in C, but we actually want this here anyway, and
it shouldn't cause any problems. It's a bit of a hack, but
otherwise results in much cleaner code.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-07-10 12:06:32 +00:00
|
|
|
mkhelpercfg="$datadir/mkhelper.cfg"
|
2024-07-10 21:14:39 +00:00
|
|
|
e "$mkhelpercfg" f missing && mkhelpercfg="$TMPDIR/mkhelper.cfg" && \
|
|
|
|
x_ touch "$mkhelpercfg"
|
trees: remove project-specific hacks
move the coreboot-specific includes into mkhelper.cfg
for that project.
on some projects, we need variables from mkhelper.cfg
to be global, so I was including serprog and coreboot
mkhelper.cfg files in this script.
instead, set a new variable "mkhelpercfg" pointing to
the config file. if it doesn't exist, create and then
point to a temporary (empty) mkhelper.cfg file.
the rom.sh include has been moved to coreboot mkhelper.cfg
The only remaining project-specific logic, in this trees
script, is now the coreboot crossgcc handling, but this
needs to be there as it's also used to build U-Boot.
The way this now works, certain includes are done twice.
For example, include/rom.sh will be included once globally,
outside of main(), and then again in configure_project().
This means that certain functions will be defined twice.
I'm uncertain if shell has anything equivalent to an ifdef
guard as in C, but we actually want this here anyway, and
it shouldn't cause any problems. It's a bit of a hack, but
otherwise results in much cleaner code.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-07-10 12:06:32 +00:00
|
|
|
|
|
|
|
targets="$@"
|
|
|
|
cmd="build_targets $targets" && singletree "$project" && \
|
2024-07-10 21:14:39 +00:00
|
|
|
cmd="build_project"
|
2024-06-06 07:53:29 +00:00
|
|
|
|
2024-07-10 21:14:39 +00:00
|
|
|
remkdir "${tmpgit%/*}"
|
2023-10-07 05:55:10 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 15:41:23 +00:00
|
|
|
build_project()
|
2023-10-07 05:55:10 +00:00
|
|
|
{
|
2024-07-10 21:14:39 +00:00
|
|
|
configure_project "$configdir" || return 0
|
|
|
|
[ ! -f "$listfile" ] || $dry elfcheck || return 0
|
2023-10-06 21:59:36 +00:00
|
|
|
|
2023-12-24 09:04:36 +00:00
|
|
|
[ "$mode" = "distclean" ] && mode="clean"
|
2023-10-07 05:55:10 +00:00
|
|
|
run_make_command || return 0
|
2024-06-06 02:08:24 +00:00
|
|
|
|
2024-07-10 19:38:36 +00:00
|
|
|
[ -n "$mode" ] || $dry copy_elf; return 0
|
2023-08-16 20:34:21 +00:00
|
|
|
}
|
|
|
|
|
2023-10-07 05:55:10 +00:00
|
|
|
build_targets()
|
2023-10-03 12:21:30 +00:00
|
|
|
{
|
2024-07-10 21:14:39 +00:00
|
|
|
[ -d "$configdir" ] || $err "directory, $configdir, does not exist"
|
|
|
|
[ $# -gt 0 ] || targets="$(ls -1 "$configdir")" || $err "!o $configdir"
|
2023-10-03 12:21:30 +00:00
|
|
|
|
2023-12-24 09:04:36 +00:00
|
|
|
for x in $targets; do
|
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-06 22:36:13 +00:00
|
|
|
[ "$x" = "list" ] && x_ ls -1 "config/$project" && \
|
|
|
|
listfile="" && break
|
2024-05-26 00:54:36 +00:00
|
|
|
target="$x"
|
|
|
|
printf "'make %s', '%s', '%s'\n" "$mode" "$project" "$target"
|
2023-10-07 05:55:10 +00:00
|
|
|
x_ handle_defconfig
|
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-06 22:36:13 +00:00
|
|
|
[ -n "$mode" ] || [ -z "$postmake" ] || $postmake || \
|
|
|
|
$err "$project/$target: !postmake: $postmake"; continue
|
|
|
|
done; return 0
|
2023-10-03 12:21:30 +00:00
|
|
|
}
|
|
|
|
|
2023-10-07 05:55:10 +00:00
|
|
|
handle_defconfig()
|
2023-08-16 20:34:21 +00:00
|
|
|
{
|
2024-07-10 21:14:39 +00:00
|
|
|
target_dir="$configdir/$target"
|
2023-10-07 05:55:10 +00:00
|
|
|
|
2024-06-30 15:23:32 +00:00
|
|
|
[ -f "CHANGELOG" ] || fetch_project "$project"
|
2024-07-10 21:14:39 +00:00
|
|
|
configure_project "$target_dir" || return 0
|
2024-05-26 00:54:36 +00:00
|
|
|
x_ mkdir -p "$elfdir/$target"
|
2023-10-07 05:55:10 +00:00
|
|
|
|
2024-06-14 12:36:31 +00:00
|
|
|
chkvars tree
|
2024-07-10 21:14:39 +00:00
|
|
|
srcdir="src/$project/$tree"
|
2023-10-07 05:55:10 +00:00
|
|
|
|
2024-06-30 16:13:49 +00:00
|
|
|
if [ "$mode" = "distclean" ] || [ "$mode" = "crossgcc-clean" ]; then
|
2024-07-10 21:14:39 +00:00
|
|
|
[ -d "$srcdir" ] || return 0
|
2023-10-07 05:55:10 +00:00
|
|
|
fi
|
2024-07-10 21:14:39 +00:00
|
|
|
[ -z "$mode" ] && $dry check_cross_compiler
|
|
|
|
|
|
|
|
for y in "$target_dir/config"/*; do
|
|
|
|
[ "$_f" = "-d" ] || [ -f "$y" ] || continue
|
|
|
|
[ "$_f" = "-d" ] || defconfig="$y"
|
2023-10-07 05:55:10 +00:00
|
|
|
|
2024-07-10 21:14:39 +00:00
|
|
|
[ -n "$mode" ] || check_defconfig || continue
|
|
|
|
handle_makefile
|
|
|
|
[ -n "$mode" ] || $dry copy_elf
|
|
|
|
done; return 0
|
2023-08-16 20:34:21 +00:00
|
|
|
}
|
|
|
|
|
2024-07-06 03:33:55 +00:00
|
|
|
configure_project()
|
2023-12-30 16:03:29 +00:00
|
|
|
{
|
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-06 22:36:13 +00:00
|
|
|
eval `setvars "" xarch xlang build_depend autoconfargs xtree postmake \
|
2024-07-17 13:55:49 +00:00
|
|
|
tree_depend makeargs btype mkhelper bootstrapargs premake release \
|
|
|
|
badhash`
|
2024-07-16 02:57:08 +00:00
|
|
|
|
2024-06-27 15:33:30 +00:00
|
|
|
[ -f "$1/target.cfg" ] || btype="auto"
|
2024-06-30 21:22:15 +00:00
|
|
|
[ -f "$datadir/mkhelper.cfg" ] && eval `setcfg "$datadir/mkhelper.cfg"`
|
2024-06-27 15:38:49 +00:00
|
|
|
|
trees: unified multi-tree configuration handling
the same function that loads configurations for single-tree
projects has been merged with the function for multi-tree
configs in git.sh, and that functionality has been removed
from git.sh; now it is all unified in the trees script.
as the saying goes: write one program to do one thing well.
the purpose of git.sh is to download source code, but not
to handle configuration files; the latter is meant to be
handled by the trees script, which then calls into git.sh
before running the build logic for that given project.
additionally: the "seen" files are no longer handled, at all.
the logic there was added ages ago, because at the time, i was
considering whether to separate configuration into a new
repository, so that users could more easily make their own
configuration, so it was a guard against misconfiguration.
however, that decision was canceled and we're always very
careful not to introduce a loop; if a loop does occur, the
worst that can possibly happen is you waste some CPU cycles.
Instead, print (on standard output) what config file is being
used, so the operator can see when an infinite loop occurs.
ALSO:
remove _setcfgarg in load_project_config()
it was used to skip when a target.cfg file didn't exist,
specifically on single-tree projects, but this is now
handled using -f instead, on the while loop inside that
function, so _setcfgarg is now a redundant variable.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-29 22:13:55 +00:00
|
|
|
_tcfg="$1/target.cfg"
|
2024-07-11 00:14:28 +00:00
|
|
|
while [ -f "$_tcfg" ] || [ "$cmd" != "build_project" ]; do
|
trees: unified multi-tree configuration handling
the same function that loads configurations for single-tree
projects has been merged with the function for multi-tree
configs in git.sh, and that functionality has been removed
from git.sh; now it is all unified in the trees script.
as the saying goes: write one program to do one thing well.
the purpose of git.sh is to download source code, but not
to handle configuration files; the latter is meant to be
handled by the trees script, which then calls into git.sh
before running the build logic for that given project.
additionally: the "seen" files are no longer handled, at all.
the logic there was added ages ago, because at the time, i was
considering whether to separate configuration into a new
repository, so that users could more easily make their own
configuration, so it was a guard against misconfiguration.
however, that decision was canceled and we're always very
careful not to introduce a loop; if a loop does occur, the
worst that can possibly happen is you waste some CPU cycles.
Instead, print (on standard output) what config file is being
used, so the operator can see when an infinite loop occurs.
ALSO:
remove _setcfgarg in load_project_config()
it was used to skip when a target.cfg file didn't exist,
specifically on single-tree projects, but this is now
handled using -f instead, on the while loop inside that
function, so _setcfgarg is now a redundant variable.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-29 22:13:55 +00:00
|
|
|
eval `setvars "" rev tree`
|
|
|
|
|
|
|
|
printf "Loading %s config: %s\n" "$project" "$_tcfg"
|
|
|
|
eval `setcfg "$_tcfg"`
|
trees: support -d (dry run) for custom build logic
-d does the same as -b, except for actually building
anything! in effect, it does the same as -f (fetch)
except that the resulting variable assignments will
not be recursive (as with -f).
if -d is passed, configuration is still loaded, defconfig
files are still cycled through, and more importantly:
helper functions are still processed.
the grub, serprog and coreboot helper functions have
been modified to return early (zero status) if -d is
passed.
this behaviour will be used to integrate vendor.sh
logic in with the trees script, for cases where the
user wants to only handle vendor files. e.g.:
./update trees -b coreboot x230_12mb
this would download the files as usual, build coreboot,
with those files, and then build the payloads. but:
./update trees -d coreboot x230_12mb
this would download the files, NOT build coreboot, and
NOT build the payloads.
this change increases the sloccount a bit, but i'm relying
on the fact that the vendor.sh script already re-implements
config handling wastefully; the plan is to only use trees.
for now, simply stub the same ./vendor download command.
there is one additional benefit to doing it this way:
this method is *per-kconfig* rather than per-target.
this way, one kconfig might specify a given vendor file
that is not specified in the other. although the stub
still simply handles this per target, it's done in premake,
which means that the given .config file has been copied.
this means that when i properly re-integrate the logic
into script/trees, i'll be able to go for it per-kconfig.
the utils command has been removed, e.g.
./update trees -b coreboot utils default
the equivalent is now:
./update trees -d coreboot default
this would technically download vendor files, but here
we are specifying a target for which no kconfigs exist;
a check is also in place, to avoid running the vendor file
download logic if tree==target
the overall effect of this change is that the trees script
no longer contains any project-specific logic, except for
the crossgcc build logic.
it does include some config/data mkhelper files at the top,
for serprog and coreboot, so that those variables defined in
those files can be global, but another solution to mitigate
that will also be implemented in a future commit.
the purpose of this and other revisions (in the final push
to complete lbmk audit 6 / cbmk audit 2) is to generalise as
much logic as possible, removing various ugly hacks.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-07-09 00:31:25 +00:00
|
|
|
|
|
|
|
[ "$_f" = "-d" ] && build_depend="" # dry run
|
trees: unified multi-tree configuration handling
the same function that loads configurations for single-tree
projects has been merged with the function for multi-tree
configs in git.sh, and that functionality has been removed
from git.sh; now it is all unified in the trees script.
as the saying goes: write one program to do one thing well.
the purpose of git.sh is to download source code, but not
to handle configuration files; the latter is meant to be
handled by the trees script, which then calls into git.sh
before running the build logic for that given project.
additionally: the "seen" files are no longer handled, at all.
the logic there was added ages ago, because at the time, i was
considering whether to separate configuration into a new
repository, so that users could more easily make their own
configuration, so it was a guard against misconfiguration.
however, that decision was canceled and we're always very
careful not to introduce a loop; if a loop does occur, the
worst that can possibly happen is you waste some CPU cycles.
Instead, print (on standard output) what config file is being
used, so the operator can see when an infinite loop occurs.
ALSO:
remove _setcfgarg in load_project_config()
it was used to skip when a target.cfg file didn't exist,
specifically on single-tree projects, but this is now
handled using -f instead, on the while loop inside that
function, so _setcfgarg is now a redundant variable.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-29 22:13:55 +00:00
|
|
|
[ "$cmd" = "build_project" ] && break
|
|
|
|
[ "$mode" = "fetch" ] || break
|
|
|
|
|
|
|
|
[ "${_tcfg%/*/target.cfg}" = "${_tcfg%"/$tree/target.cfg"}" ] \
|
|
|
|
&& break; _tcfg="${_tcfg%/*/target.cfg}/$tree/target.cfg"
|
|
|
|
done
|
2024-06-29 21:02:26 +00:00
|
|
|
|
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-06 22:36:13 +00:00
|
|
|
[ "$XBMK_RELEASE" = "y" ] && [ "$release" = "n" ] && return 1
|
2024-06-29 21:02:26 +00:00
|
|
|
[ -z "$btype" ] || [ "${mode%config}" = "$mode" ] || return 1
|
2024-06-27 15:38:49 +00:00
|
|
|
|
2024-07-13 22:07:45 +00:00
|
|
|
[ -z "$mode" ] && build_dependencies
|
trees: support build dependencies, not just fetch
We already have this to an extent, e.g. the xtree variable.
The xtree variable could probably be removed, in favour of
this, and used for the same purpose.
It works like this, for example:
build_depend="coreboot/default grub/xhci seabios u-boot/gru_bob flashprog"
the "/" denotes a tree, if it's a multi-tree project. However, specifying
the entire multi-tree project without slash is possible, for example:
build_depend="coreboot"
this would specify that all coreboot trees must be built.
This functionality will be used in follow-up commits, centralising
script/trees into mk on the main directory, repacing "build".
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-07-06 03:29:03 +00:00
|
|
|
|
2024-07-17 13:55:49 +00:00
|
|
|
mdir="$PWD/config/submodule/$project"
|
|
|
|
[ -n "$tree" ] && mdir="$mdir/$tree"
|
|
|
|
|
|
|
|
[ -f "CHANGELOG" ] || check_project_hashes
|
|
|
|
|
2024-07-10 21:14:39 +00:00
|
|
|
[ "$mode" = "fetch" ] || x_ ./update trees -f "$project" $target
|
2024-06-29 21:02:26 +00:00
|
|
|
[ "$mode" = "fetch" ] || return 0
|
2024-07-16 02:57:08 +00:00
|
|
|
|
trees: unified multi-tree configuration handling
the same function that loads configurations for single-tree
projects has been merged with the function for multi-tree
configs in git.sh, and that functionality has been removed
from git.sh; now it is all unified in the trees script.
as the saying goes: write one program to do one thing well.
the purpose of git.sh is to download source code, but not
to handle configuration files; the latter is meant to be
handled by the trees script, which then calls into git.sh
before running the build logic for that given project.
additionally: the "seen" files are no longer handled, at all.
the logic there was added ages ago, because at the time, i was
considering whether to separate configuration into a new
repository, so that users could more easily make their own
configuration, so it was a guard against misconfiguration.
however, that decision was canceled and we're always very
careful not to introduce a loop; if a loop does occur, the
worst that can possibly happen is you waste some CPU cycles.
Instead, print (on standard output) what config file is being
used, so the operator can see when an infinite loop occurs.
ALSO:
remove _setcfgarg in load_project_config()
it was used to skip when a target.cfg file didn't exist,
specifically on single-tree projects, but this is now
handled using -f instead, on the while loop inside that
function, so _setcfgarg is now a redundant variable.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-29 22:13:55 +00:00
|
|
|
[ -f "CHANGELOG" ] && return 1; fetch_${cmd#build_}; return 1
|
2023-12-30 16:03:29 +00:00
|
|
|
}
|
|
|
|
|
2024-07-13 22:07:45 +00:00
|
|
|
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 ./update trees -b $bd_p $bd_t \
|
|
|
|
|| $err "!mk $project/$tree $bd_p/$bd_t"; continue
|
|
|
|
done; return 0
|
|
|
|
}
|
|
|
|
|
2024-07-17 13:55:49 +00:00
|
|
|
check_project_hashes()
|
|
|
|
{
|
2024-07-17 17:39:42 +00:00
|
|
|
x_ mkdir -p cache/hash
|
2024-07-17 13:55:49 +00:00
|
|
|
|
|
|
|
old_pjhash=""
|
2024-07-17 17:39:42 +00:00
|
|
|
[ ! -f "cache/hash/$project$tree" ] || \
|
|
|
|
read -r old_pjhash < "cache/hash/$project$tree"
|
2024-07-17 13:55:49 +00:00
|
|
|
|
|
|
|
x_ rm -f "$TMPDIR/project.list" "$TMPDIR/project.hash" \
|
|
|
|
"$TMPDIR/project.tmp"; x_ touch "$TMPDIR/project.tmp"
|
|
|
|
x_ touch "$TMPDIR/project.hash"
|
|
|
|
|
|
|
|
for delcheck in "$datadir" "$configdir/$tree" "$mdir"; do
|
|
|
|
[ -d "$delcheck" ] || continue
|
|
|
|
find "$delcheck" -type f -not -path "*/.git*/*" \
|
|
|
|
>> "$TMPDIR/project.tmp" || \
|
|
|
|
$err "!find $delcheck > project.tmp"
|
|
|
|
done
|
|
|
|
sort "$TMPDIR/project.tmp" > "$TMPDIR/project.list" || \
|
|
|
|
$err "!sort project tmp/list"
|
|
|
|
|
|
|
|
while read -r delcheck; do
|
|
|
|
[ -f "$delcheck" ] || continue
|
|
|
|
sha512sum "$delcheck" | awk '{print $1}' >> \
|
|
|
|
"$TMPDIR/project.hash" || $err "!findhash $delcheck"
|
|
|
|
done < "$TMPDIR/project.list"
|
|
|
|
|
|
|
|
pjhash="$(sha512sum "$TMPDIR/project.hash" | awk '{print $1}')" || :
|
|
|
|
badhash="y" && [ "$pjhash" = "$old_pjhash" ] && badhash="n"
|
2024-07-17 17:39:42 +00:00
|
|
|
[ -f "cache/hash/$project$tree" ] || badhash="y"
|
2024-07-17 13:55:49 +00:00
|
|
|
|
2024-07-17 17:39:42 +00:00
|
|
|
printf "%s\n" "$pjhash" > "cache/hash/$project$tree" || \
|
|
|
|
$err "!mk cache/hash/$project$tree"
|
2024-07-17 13:55:49 +00:00
|
|
|
|
|
|
|
[ "$badhash" = "n" ] || rm -Rf "src/$project/$tree" \
|
|
|
|
"elf/$project/$tree" "elf/$project/$target" || \
|
|
|
|
$err "!rmproject $project $tree"; :
|
|
|
|
}
|
|
|
|
|
2023-10-07 05:55:10 +00:00
|
|
|
check_cross_compiler()
|
2023-08-16 20:34:21 +00:00
|
|
|
{
|
2023-12-27 15:18:21 +00:00
|
|
|
for _xarch in $xarch; do
|
2024-05-26 00:54:36 +00:00
|
|
|
cbdir="src/coreboot/$tree"
|
2023-12-27 15:18:21 +00:00
|
|
|
[ "$project" != "coreboot" ] && cbdir="src/coreboot/default"
|
2024-01-21 05:58:37 +00:00
|
|
|
[ -n "$xtree" ] && cbdir="src/coreboot/$xtree"
|
2023-12-21 10:48:07 +00:00
|
|
|
|
2023-12-27 15:18:21 +00:00
|
|
|
x_ ./update trees -f coreboot ${cbdir#src/coreboot/}
|
2023-12-21 10:48:07 +00:00
|
|
|
|
2024-05-26 00:54:36 +00:00
|
|
|
export PATH="$PWD/$cbdir/util/crossgcc/xgcc/bin:$PATH"
|
2023-12-27 15:18:21 +00:00
|
|
|
export CROSS_COMPILE="${xarch% *}-"
|
2024-05-26 00:54:36 +00:00
|
|
|
[ -n "$xlang" ] && export BUILD_LANGUAGES="$xlang"
|
2023-08-16 20:34:21 +00:00
|
|
|
|
2024-06-24 13:23:56 +00:00
|
|
|
# sometimes buildgcc fails for like no reason. try twice.
|
2024-07-05 17:15:56 +00:00
|
|
|
make -C "$cbdir" crossgcc-${_xarch%-*} $makeargs || \
|
|
|
|
make -C "$cbdir" crossgcc-${_xarch%-*} $makeargs || \
|
|
|
|
$err "!mkxgcc $project/$xtree '${_xarch%-*}' '$makeargs'"
|
2024-06-24 13:23:56 +00:00
|
|
|
done; return 0
|
2023-10-07 05:55:10 +00:00
|
|
|
}
|
2023-08-16 20:34:21 +00:00
|
|
|
|
2024-06-30 13:13:52 +00:00
|
|
|
check_defconfig()
|
2023-10-07 05:55:10 +00:00
|
|
|
{
|
2024-07-10 19:38:36 +00:00
|
|
|
[ -f "$defconfig" ] || $dry $err "$project/$target: missing defconfig"
|
2024-06-30 13:10:49 +00:00
|
|
|
dest_dir="$elfdir/$target/${defconfig#"$target_dir/config/"}"
|
2024-06-06 08:20:45 +00:00
|
|
|
|
2024-07-10 21:14:39 +00:00
|
|
|
$dry elfcheck || return 1 # skip build if a previous one exists
|
2024-07-10 19:38:36 +00:00
|
|
|
$dry x_ mkdir -p "$dest_dir"
|
2024-06-06 08:20:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
elfcheck()
|
|
|
|
{
|
2023-10-07 05:55:10 +00:00
|
|
|
# TODO: very hacky check. do it properly (based on build.list)
|
2024-05-26 00:54:36 +00:00
|
|
|
for elftest in "$dest_dir"/*; do
|
2024-06-27 13:05:19 +00:00
|
|
|
[ -e "$elftest" ] && e "$elftest" f && return 1
|
|
|
|
done; return 0
|
2023-08-16 20:34:21 +00:00
|
|
|
}
|
|
|
|
|
2023-10-07 05:55:10 +00:00
|
|
|
handle_makefile()
|
2023-08-16 20:34:21 +00:00
|
|
|
{
|
2024-07-10 21:14:39 +00:00
|
|
|
$dry check_makefile "$srcdir" && x_ make clean -C "$srcdir"
|
|
|
|
[ -f "$defconfig" ] && x_ cp "$defconfig" "$srcdir/.config"
|
2024-07-10 19:38:36 +00:00
|
|
|
[ -n "$mode" ] || [ -n "$btype" ] || $dry make -C \
|
2024-07-10 21:14:39 +00:00
|
|
|
"$srcdir" silentoldconfig || make -C "$srcdir" oldconfig || :
|
2023-10-07 05:55:10 +00:00
|
|
|
|
2024-07-10 21:14:39 +00:00
|
|
|
run_make_command || $err "handle_makefile $srcdir: no makefile!"
|
2023-10-02 04:21:20 +00:00
|
|
|
|
2024-06-30 12:30:35 +00:00
|
|
|
_copy=".config" && [ "$mode" = "savedefconfig" ] && _copy="defconfig"
|
2024-07-10 21:14:39 +00:00
|
|
|
[ "${mode%config}" = "$mode" ] || \
|
|
|
|
$dry x_ cp "$srcdir/$_copy" "$defconfig"
|
2024-04-28 18:28:02 +00:00
|
|
|
|
2024-07-10 21:14:39 +00:00
|
|
|
[ -e "$srcdir/.git" ] && [ "$project" = "u-boot" ] && \
|
|
|
|
[ "$mode" = "distclean" ] && $dry x_ git -C "$srcdir" clean -fdx; :
|
2023-08-16 20:34:21 +00:00
|
|
|
}
|
|
|
|
|
2023-10-07 05:55:10 +00:00
|
|
|
run_make_command()
|
2023-08-16 20:34:21 +00:00
|
|
|
{
|
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-06 22:36:13 +00:00
|
|
|
[ -z "$premake" ] || [ -n "$mode" ] || $premake || $err "!$premake"
|
|
|
|
|
2024-07-10 21:14:39 +00:00
|
|
|
$dry check_cmake "$srcdir" && [ -z "$mode" ] && $dry check_autoconf \
|
|
|
|
"$srcdir"; $dry check_makefile "$srcdir" || return 1
|
2023-12-30 13:08:29 +00:00
|
|
|
|
2024-07-10 21:14:39 +00:00
|
|
|
$dry make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs || $err "!$mode"
|
2024-06-30 12:42:42 +00:00
|
|
|
[ -z "$mkhelper" ] || [ -n "$mode" ] || $mkhelper || $err "!$mkhelper"
|
make GRUB multi-tree and re-add xhci patches
Re-add xHCI only on haswell and broadwell machines, where
they are needed. Otherwise, keep the same GRUB code.
The xHCI patches were removed because they caused issues
on Sandybridge-based Dell Latitude laptops. See:
https://codeberg.org/libreboot/lbmk/issues/216
The issue was not reported elsewhere, including on the
Haswell/Broadwell hardware where they are needed, but the
build system could only build one version of GRUB.
The older machines do not need xHCI patches, because they
either do not have xHCI patches, or work (in GRUB) because
they're in EHCI mode when running the payload.
So, the problem is that we need the xHCI patches for GRUB
on Haswell/Broadwell hardware, but the patches break
Sandybridge hardware, and we only had the one build of GRUB.
To mitigate this problem, the build system now supports
building multiple revisions of GRUB, with different patches,
and each given coreboot target can say which GRUB tree to use
by setting this in target.cfg:
grubtree="xhci"
In the above example, the "xhci" tree would be used. Some
generic GRUB config has been moved to config/data/grub/
and config/grub/ now looks like config/coreboot/ - also,
the grub.cfg file (named "payload" in each tree) is copied
to the GRUB source tree as ".config", then added to GRUB's
memdisk in the same way, as grub.cfg.
Several other design changes had to be made because of this:
* grub.cfg in memdisk no longer automatically jumps to one
in CBFS, but now shows a menuentry for it if available
* Certain commands in script/trees are disabled for GRUB,
such as *config make commands.
* gnulib is now defined in config/submodule/grub/, instead
of config/git/grub - and this mitigates an existing bug
where downloading gnulib first would make grub no longer
possible to download in lbmk.
The coreboot option CONFIG_FINALIZE_USB_ROUTE_XHCI has been
re-enabled on: Dell OptiPlex 9020 MT, Dell OptiPlex 9020 SFF,
Lenovo ThinkPad T440p and Lenovo ThinkPad W541 - now USB should
work again in GRUB.
The GRUB payload has been re-enabled on HP EliteBook 820 G2.
This change will enable per-board GRUB optimisation in the
future. For example, we hardcode what partitions and LVMs
GRUB scans because * is slow on ICH7-based machines, due
to GRUB's design. On other machines, * is reasonably fast,
for automatically enumerating the list of devices for boot.
Use of * (and other wildcards) could enable our GRUB payload
to automatically boot more distros, with minimal fuss. This
can be done at a later date, in subsequent revisions.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-01 22:01:30 +00:00
|
|
|
|
2024-07-10 21:14:39 +00:00
|
|
|
[ "$mode" = "clean" ] && $dry make -C "$srcdir" distclean || :; :
|
2023-08-16 20:34:21 +00:00
|
|
|
}
|
|
|
|
|
update/trees: generic cmake handling
it is no longer hardcoded just to be handled for uefiextract.
it is now defined as cmakedir in target.cfg, for a single or
multi tree project. if multi tree, it is applied to the specific
tree, and has to be defined per tree
the way it works is: as per cmakelist, a project will define
which directory is to be built, and it will then generate
a makefile in the main source tree (the build tree in cmake
language, where the main CMakeLists.txt file exists)
when the makefile has been generated, the project is then treated
like any other project. the way cmake works, if a makefile has
already been generated by it, in a given directory, running it
again will fail and not affect anything; if it fails but the
makefile doesn't exist, then something is wrong, but if the
makefile does exist, then it's all fine and nothing happens
at present, this is only used for uefiextract, which is part
of src/uefitool
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-12-30 16:52:34 +00:00
|
|
|
check_cmake()
|
|
|
|
{
|
2024-07-10 19:38:36 +00:00
|
|
|
[ -z "$cmakedir" ] || $dry check_makefile "$1" || cmake -B "$1" \
|
|
|
|
"$1/$cmakedir" || $dry check_makefile "$1" || $err \
|
|
|
|
"$1: !cmk $cmakedir"
|
|
|
|
[ -z "$cmakedir" ] || $dry check_makefile "$1" || \
|
|
|
|
$err "check_cmake $1: can't generate Makefile"; return 0
|
update/trees: generic cmake handling
it is no longer hardcoded just to be handled for uefiextract.
it is now defined as cmakedir in target.cfg, for a single or
multi tree project. if multi tree, it is applied to the specific
tree, and has to be defined per tree
the way it works is: as per cmakelist, a project will define
which directory is to be built, and it will then generate
a makefile in the main source tree (the build tree in cmake
language, where the main CMakeLists.txt file exists)
when the makefile has been generated, the project is then treated
like any other project. the way cmake works, if a makefile has
already been generated by it, in a given directory, running it
again will fail and not affect anything; if it fails but the
makefile doesn't exist, then something is wrong, but if the
makefile does exist, then it's all fine and nothing happens
at present, this is only used for uefiextract, which is part
of src/uefitool
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-12-30 16:52:34 +00:00
|
|
|
}
|
|
|
|
|
2023-12-30 13:08:29 +00:00
|
|
|
check_autoconf()
|
|
|
|
{
|
|
|
|
(
|
2024-05-26 00:54:36 +00:00
|
|
|
cd "$1" || $err "!cd $1"
|
2023-12-30 16:03:29 +00:00
|
|
|
[ -f "bootstrap" ] && x_ ./bootstrap $bootstrapargs
|
2024-05-26 00:54:36 +00:00
|
|
|
[ -f "autogen.sh" ] && x_ ./autogen.sh $autogenargs
|
2023-12-30 16:03:29 +00:00
|
|
|
[ -f "configure" ] && x_ ./configure $autoconfargs; return 0
|
safer, simpler error handling in lbmk
in shell scripts, a function named the same as a program included in
the $PATH will override that program. for example, you could make a
function called ls() and this would override the standand "ls".
in lbmk, a part of it was first trying to run the "fail" command,
deferring to "err", because some scripts call fail() which does
some minor cleanup before calling err.
in most cases, fail() is not defined, and it's possible that the user
could have a program called "fail" in their $PATH, the behaviour of
which we could not determine, and it could have disastrous effects.
lbmk error handling has been re-engineered in such a way that the
err function is defined in a variable, which defaults to err_ which
calls err_, so defined under include/err.sh.
in functions that require cleanup prior to error handling, a fail()
function is still defined, and err is overridden, thus:
err="fail"
this change has made xx_() obsolete, so now only x_ is used. the x_
function is a wrapper that can be used to run a command and exit with
non-zero status (from lbmk) if the command fails. the xx_ command
did the same thing, but called fail() which would have called err();
now everything is $err
example:
rm -f "$filename" || err "could not delete file"
this would now be:
rm -f "$filename" || $err "could not delete file"
overriding of err= must be done *after* including err.sh. for
example:
err="fail"
. "include/err.sh"
^ this is wrong. instead, one must do:
. "include/err.sh"
err="fail"
this is because err is set as a global variable under err.sh
the new error handling is much cleaner, and safer. it also reduces
the chance of mistakes such as: calling err when you meant to
call fail. this is because the standard way is now to call $err,
so you set err="fail" at the top of the script and all is well.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-03-27 01:19:39 +00:00
|
|
|
) || $err "can't bootstrap project: $1"
|
2023-12-30 13:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
check_makefile()
|
|
|
|
{
|
2024-05-26 00:54:36 +00:00
|
|
|
[ -f "$1/Makefile" ] || [ -f "$1/makefile" ] || \
|
|
|
|
[ -f "$1/GNUmakefile" ] || return 1; return 0
|
2023-12-30 13:08:29 +00:00
|
|
|
}
|
|
|
|
|
2023-10-07 05:55:10 +00:00
|
|
|
copy_elf()
|
2023-08-16 20:34:21 +00:00
|
|
|
{
|
2024-06-15 22:01:45 +00:00
|
|
|
[ -f "$listfile" ] && x_ mkdir -p "$dest_dir" && while read -r f; do
|
2024-07-10 21:14:39 +00:00
|
|
|
[ -f "$srcdir/$f" ] && x_ cp "$srcdir/$f" "$dest_dir"
|
|
|
|
done < "$listfile"; x_ make clean -C "$srcdir"
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
}
|
|
|
|
|
2024-07-10 23:28:32 +00:00
|
|
|
main $@ || exit 0
|
trees: remove project-specific hacks
move the coreboot-specific includes into mkhelper.cfg
for that project.
on some projects, we need variables from mkhelper.cfg
to be global, so I was including serprog and coreboot
mkhelper.cfg files in this script.
instead, set a new variable "mkhelpercfg" pointing to
the config file. if it doesn't exist, create and then
point to a temporary (empty) mkhelper.cfg file.
the rom.sh include has been moved to coreboot mkhelper.cfg
The only remaining project-specific logic, in this trees
script, is now the coreboot crossgcc handling, but this
needs to be there as it's also used to build U-Boot.
The way this now works, certain includes are done twice.
For example, include/rom.sh will be included once globally,
outside of main(), and then again in configure_project().
This means that certain functions will be defined twice.
I'm uncertain if shell has anything equivalent to an ifdef
guard as in C, but we actually want this here anyway, and
it shouldn't cause any problems. It's a bit of a hack, but
otherwise results in much cleaner code.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-07-10 12:06:32 +00:00
|
|
|
. "$mkhelpercfg"
|
2024-07-10 21:14:39 +00:00
|
|
|
$cmd
|