download/coreboot: fix error handling in subshell

Signed-off-by: Leah Rowe <leah@libreboot.org>
fsdg20230625
Leah Rowe 2023-05-24 07:45:07 +01:00
parent d0171eeff3
commit 2be1a8ea76
1 changed files with 14 additions and 5 deletions

View File

@ -149,16 +149,19 @@ prepare_new_coreboot_tree()
cp -R coreboot/coreboot "coreboot/${cbtree}" || exit 1 cp -R coreboot/coreboot "coreboot/${cbtree}" || exit 1
( (
cd "coreboot/${cbtree}" || exit 1 cd "coreboot/${cbtree}" \
git reset --hard ${cbrevision} || exit 1 || err "cannot cd to coreboot/${cbtree}"
git submodule update --init --checkout || exit 1 git reset --hard ${cbrevision} \
|| err "cannot reset coreboot revision for tree, ${cbtree}"
git submodule update --init --checkout \
|| err "cannot update coreboot submodules for tree, ${cbtree}"
for patch in ../../"${cbcfgsdir}"/"${cbtree}"/patches/*.patch; do for patch in ../../"${cbcfgsdir}"/"${cbtree}"/patches/*.patch; do
[ ! -f "${patch}" ] && \ [ ! -f "${patch}" ] && \
continue continue
if ! git am "${patch}"; then if ! git am "${patch}"; then
git am --abort git am --abort
exit 1 err "cannot patch ${cbtree}"
fi fi
done done
@ -166,9 +169,15 @@ prepare_new_coreboot_tree()
# but should *only* be a last resort # but should *only* be a last resort
if [ -f "../../${cbcfgsdir}/${cbtree}/extra.sh" ]; then if [ -f "../../${cbcfgsdir}/${cbtree}/extra.sh" ]; then
"../../${cbcfgsdir}/${cbtree}/extra.sh" || \ "../../${cbcfgsdir}/${cbtree}/extra.sh" || \
exit 1 err "${cbtree} extra.sh"
fi fi
) )
} }
err()
{
printf "ERROR: %s: %s\n" $0 $1 1>&2
exit 1
}
main $@ main $@