2023-06-13 11:09:01 +00:00
|
|
|
#!/usr/bin/env sh
|
2021-05-18 12:56:12 +00:00
|
|
|
|
|
|
|
# helper script: build various coreboot utilities
|
|
|
|
#
|
2023-05-20 16:56:11 +00:00
|
|
|
# Copyright (C) 2014-2016,2020,2021,2023 Leah Rowe <info@minifree.org>
|
2021-05-18 12:56:12 +00:00
|
|
|
#
|
2023-05-20 15:12:25 +00:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
2021-05-18 12:56:12 +00:00
|
|
|
#
|
2023-05-20 15:12:25 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2021-05-18 12:56:12 +00:00
|
|
|
#
|
2023-05-20 15:12:25 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2021-05-18 12:56:12 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
|
|
|
set -u -e
|
|
|
|
|
2023-08-23 23:30:07 +00:00
|
|
|
. "include/err.sh"
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-05-20 16:53:03 +00:00
|
|
|
main()
|
|
|
|
{
|
2023-08-23 23:30:07 +00:00
|
|
|
printf "Building coreboot utils\n"
|
|
|
|
|
2023-05-20 16:53:03 +00:00
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
for board in "${@}"; do
|
2023-08-23 18:56:01 +00:00
|
|
|
build_for_mainboard ${board} || \
|
|
|
|
err "cannot build cbutils for target, ${board}"
|
2023-05-20 16:53:03 +00:00
|
|
|
done
|
|
|
|
else
|
2023-09-04 01:36:41 +00:00
|
|
|
for boarddir in config/coreboot/*; do
|
2023-05-20 16:53:03 +00:00
|
|
|
[ ! -d "${boarddir}" ] && continue
|
2023-08-23 18:56:01 +00:00
|
|
|
build_for_mainboard ${boarddir##*/} || \
|
|
|
|
err "cannot build cbutils for target, ${board}"
|
2023-05-20 16:53:03 +00:00
|
|
|
done
|
2023-05-20 15:12:25 +00:00
|
|
|
fi
|
2021-05-18 12:56:12 +00:00
|
|
|
}
|
|
|
|
|
2023-05-20 17:00:31 +00:00
|
|
|
build_for_mainboard() {
|
2023-05-20 15:12:25 +00:00
|
|
|
board="${1}"
|
2023-09-04 01:36:41 +00:00
|
|
|
[ -d "config/coreboot/${board}" ] || \
|
2023-09-01 07:46:24 +00:00
|
|
|
err "build_for_mainboard ${board}: boarddir does not exist"
|
2023-09-04 01:36:41 +00:00
|
|
|
[ -f "config/coreboot/${board}/target.cfg" ] || \
|
2023-09-01 07:46:24 +00:00
|
|
|
err "build_for_mainboard ${board}: target.cfg does not exist"
|
2023-08-16 20:34:21 +00:00
|
|
|
tree="undefined"
|
2023-09-04 01:36:41 +00:00
|
|
|
. "config/coreboot/${board}/target.cfg" # source
|
2023-08-23 23:30:07 +00:00
|
|
|
[ "${tree}" = "undefined" ] && \
|
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
|
|
|
err "build_for_mainboard: improper tree definition for '${board}'"
|
2023-08-23 23:30:07 +00:00
|
|
|
buildutils "${tree}"
|
2021-05-18 12:56:12 +00:00
|
|
|
}
|
|
|
|
|
2023-05-20 16:53:03 +00:00
|
|
|
buildutils() {
|
2023-08-16 20:34:21 +00:00
|
|
|
tree="${1}"
|
2023-08-21 18:41:49 +00:00
|
|
|
[ -d "coreboot/${tree}/" ] || \
|
2023-09-01 07:30:08 +00:00
|
|
|
./update project trees coreboot $tree || \
|
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
|
|
|
err "buildutils: cannot fetch ${tree}"
|
2023-06-13 11:09:01 +00:00
|
|
|
for util in cbfstool ifdtool; do
|
2023-08-21 18:41:49 +00:00
|
|
|
[ -f "cbutils/${tree}/${util}" ] && continue
|
|
|
|
[ -d "cbutils/${tree}" ] || \
|
2023-08-23 23:30:07 +00:00
|
|
|
mkdir -p "cbutils/${tree}" || \
|
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
|
|
|
err "buildutils: can't mkdir cbutils/${tree}"
|
2023-06-24 22:23:16 +00:00
|
|
|
|
2023-08-16 20:34:21 +00:00
|
|
|
utildir="coreboot/${tree}/util/${util}"
|
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
|
|
|
make distclean -C "${utildir}" || \
|
|
|
|
err "buildutils: cannot clean ${utildir}"
|
|
|
|
make -j$(nproc) -C "${utildir}" || \
|
|
|
|
err "buildutils: cannot build ${utildir}"
|
2023-08-23 23:30:07 +00:00
|
|
|
cp "${utildir}/${util}" "cbutils/${tree}" || \
|
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
|
|
|
err "buildutils: can't cp ${util} cbutils/${tree}/"
|
|
|
|
make distclean -C "${utildir}" || \
|
|
|
|
err "buildutils: can't clean ${utildir}"
|
2023-05-20 15:12:25 +00:00
|
|
|
done
|
2023-05-20 16:53:03 +00:00
|
|
|
}
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-05-20 16:53:03 +00:00
|
|
|
main $@
|