2023-06-13 11:09:01 +00:00
|
|
|
#!/usr/bin/env sh
|
2023-09-25 01:19:30 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-only
|
2022-11-14 00:51:12 +00:00
|
|
|
# SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
|
2023-06-13 11:09:01 +00:00
|
|
|
# SPDX-FileCopyrightText: 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
2023-05-18 12:19:38 +00:00
|
|
|
# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
|
2022-11-14 00:51:12 +00:00
|
|
|
|
2023-08-23 17:56:31 +00:00
|
|
|
. "include/err.sh"
|
2023-09-25 10:37:35 +00:00
|
|
|
. "include/git.sh"
|
2023-09-30 00:31:40 +00:00
|
|
|
. "include/option.sh"
|
2023-08-23 17:56:31 +00:00
|
|
|
|
2023-09-30 17:41:57 +00:00
|
|
|
eval "$(setvars "" name rev loc url bkup_url depend)"
|
2023-09-25 10:37:35 +00:00
|
|
|
tmp_dir="${PWD}/tmp/gitclone"
|
2023-05-06 16:15:14 +00:00
|
|
|
|
2023-05-18 11:34:47 +00:00
|
|
|
main()
|
|
|
|
{
|
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
|
|
|
[ $# -gt 0 ] || fail "no argument given"
|
|
|
|
|
|
|
|
[ -z "${1+x}" ] && fail 'main(): name not set'
|
2023-05-18 11:34:47 +00:00
|
|
|
name=${1}
|
2022-11-14 00:51:12 +00:00
|
|
|
|
2023-09-30 00:31:40 +00:00
|
|
|
scan_config "${name}" "config/git" "fail"
|
2023-05-18 11:55:34 +00:00
|
|
|
verify_config
|
|
|
|
|
|
|
|
clone_project
|
2023-09-07 22:03:32 +00:00
|
|
|
[ "${depend}" = "" ] || for d in ${depend} ; do
|
2023-10-01 05:33:43 +00:00
|
|
|
xx_ ./update project repo ${d}
|
2023-09-07 22:03:32 +00:00
|
|
|
done
|
2023-10-01 05:33:43 +00:00
|
|
|
xx_ rm -Rf "${tmp_dir}"
|
2023-05-18 11:55:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
verify_config()
|
2023-05-18 11:34:47 +00:00
|
|
|
{
|
2023-09-30 00:31:40 +00:00
|
|
|
[ -z "${rev+x}" ] && fail 'verify_config: rev not set'
|
|
|
|
[ -z "${loc+x}" ] && fail 'verify_config: loc not set'
|
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
|
|
|
[ -z "${url+x}" ] && fail 'verify_config: url not set'
|
2022-11-14 00:51:12 +00:00
|
|
|
}
|
|
|
|
|
2023-05-18 11:34:47 +00:00
|
|
|
clone_project()
|
|
|
|
{
|
2023-10-01 05:33:43 +00:00
|
|
|
xx_ rm -Rf "${tmp_dir}"
|
|
|
|
xx_ mkdir -p "${tmp_dir%/*}"
|
2023-05-18 11:55:34 +00:00
|
|
|
|
2023-08-27 08:25:50 +00:00
|
|
|
git clone ${url} "${tmp_dir}" || git clone ${bkup_url} "${tmp_dir}" || \
|
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
|
|
|
fail "clone_project: could not download ${name}"
|
2023-09-30 00:31:40 +00:00
|
|
|
git_reset_rev "${tmp_dir}" "${rev}" "fail" || \
|
|
|
|
fail "clone_project ${loc}/: cannot reset <- ${rev}"
|
2023-09-25 10:37:35 +00:00
|
|
|
git_am_patches "${tmp_dir}" "${PWD}/config/${name}/patches" "fail" || \
|
2023-09-30 00:31:40 +00:00
|
|
|
fail "clone_project ${loc}/: cannot apply patches"
|
2023-05-18 12:03:28 +00:00
|
|
|
|
2023-09-30 00:31:40 +00:00
|
|
|
[ ! -d "${loc}" ] || \
|
2023-10-01 05:33:43 +00:00
|
|
|
xx_ rm -Rf "${loc}"
|
|
|
|
[ "${loc}" = "${loc%/*}" ] || xx_ mkdir -p ${loc%/*}
|
|
|
|
xx_ mv "${tmp_dir}" "${loc}"
|
2023-05-18 11:34:47 +00:00
|
|
|
}
|
|
|
|
|
2023-08-23 17:56:31 +00:00
|
|
|
fail()
|
|
|
|
{
|
2023-09-30 00:31:40 +00:00
|
|
|
for x in "${loc}" "${tmp_dir}"; do
|
|
|
|
[ -z "${x}" ] || [ ! -d "${x}" ] || rm -Rf "${loc}" || :
|
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
|
|
|
done
|
2023-08-23 17:56:31 +00:00
|
|
|
usage
|
|
|
|
err "${1}"
|
|
|
|
}
|
|
|
|
|
2023-05-18 11:34:47 +00:00
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat <<- EOF
|
2023-09-01 08:38:24 +00:00
|
|
|
Usage: ./update project repo [name]
|
2022-11-14 00:51:12 +00:00
|
|
|
|
2023-05-18 11:34:47 +00:00
|
|
|
Options:
|
update/repos: concatenate multiple revision files
With this change, it's still possible to have a single
file at config/git/revisions, but this has been scrapped.
Instead, multiple files now exist under config/git/ with
the same modules declared, but the files are separated
logically. List of files under config/git:
* bios_extract
* biosutilities
* coreboot
* flashrom
* grub (gnulib also defined here)
* me_cleaner
* memtest86plus
* seabios
* serprog (multiple projects defined)
* u-boot
* uefitool
The rationale behind this change is simple: in the future,
we will stop relying on build systems within imported
projects for the import of git submodules. Instead, we
will handle them directly in lbmk.
Additionally, a Linux payload is planned for Libreboot, made
easier by the recent audit (script handle/make/config makes
it easy to integrate Linux, and handle cross-compilers for
userland utilities); a "linux" file under config/git/ could
also define rules for each project besides linux, such as
musl libc, busybox and other utilities.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-24 23:40:56 +00:00
|
|
|
name: Module name as specified in files under config/git/
|
2023-05-18 11:34:47 +00:00
|
|
|
EOF
|
|
|
|
}
|
2022-11-14 00:51:12 +00:00
|
|
|
|
2023-05-18 11:34:47 +00:00
|
|
|
main $@
|