summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfetch39
-rwxr-xr-xfetch_trees8
-rwxr-xr-xinclude/err.sh8
-rwxr-xr-xlbmk25
-rwxr-xr-xresources/scripts/build/boot/roms7
-rwxr-xr-xresources/scripts/build/boot/roms_helper6
-rwxr-xr-xresources/scripts/build/clean/crossgcc8
-rwxr-xr-xresources/scripts/build/descriptors/ich9m8
-rwxr-xr-xresources/scripts/build/grub/utils8
-rwxr-xr-xresources/scripts/build/release/roms8
-rwxr-xr-xresources/scripts/build/release/src7
-rwxr-xr-xresources/scripts/build/src/for8
-rwxr-xr-xresources/scripts/handle/config/file37
-rwxr-xr-xresources/scripts/update/blobs/download32
-rwxr-xr-xresources/scripts/update/blobs/extract31
-rwxr-xr-xresources/scripts/update/blobs/inject44
-rwxr-xr-xresources/scripts/update/blobs/mrc18
17 files changed, 127 insertions, 175 deletions
diff --git a/fetch b/fetch
index 4466d4ee..a8ec96de 100755
--- a/fetch
+++ b/fetch
@@ -5,6 +5,8 @@
# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
# SPDX-License-Identifier: GPL-3.0-only
+. "include/err.sh"
+
name=""
revision=""
location=""
@@ -15,7 +17,7 @@ depend=""
main()
{
- [ -z "${1+x}" ] && err 'Error: name not set'
+ [ -z "${1+x}" ] && fail 'Error: name not set'
name=${1}
read_config
@@ -51,9 +53,9 @@ EOF
verify_config()
{
- [ -z "${revision+x}" ] && err 'Error: revision not set'
- [ -z "${location+x}" ] && err 'Error: location not set'
- [ -z "${url+x}" ] && err 'Error: url not set'
+ [ -z "${revision+x}" ] && fail 'Error: revision not set'
+ [ -z "${location+x}" ] && fail 'Error: location not set'
+ [ -z "${url+x}" ] && fail 'Error: url not set'
}
clone_project()
@@ -61,19 +63,19 @@ clone_project()
tmp_dir=$(mktemp -dt "${name}_XXXXX")
git clone ${url} ${tmp_dir} || git clone ${bkup_url} ${tmp_dir} || \
- err "ERROR: could not download ${name}"
+ fail "ERROR: could not download ${name}"
(
- cd ${tmp_dir} || err "tmpdir not created"
- git reset --hard ${revision} || err "Cannot reset revision"
+ cd ${tmp_dir} || fail "tmpdir not created"
+ git reset --hard ${revision} || fail "Cannot reset revision"
)
patch_project
[ ! -d "${location}" ] || \
- rm -Rf ${location} || err "Can't remove directory '${location}'"
+ rm -Rf ${location} || fail "Can't remove directory '${location}'"
mv ${tmp_dir} ${location} && return 0
printf "ERROR: Could not copy temp file to destination.\n"
- err " ${tmp_dir} > ${location} check permissions"
+ fail " ${tmp_dir} > ${location} check permissions"
}
patch_project()
@@ -83,12 +85,19 @@ patch_project()
for patchfile in ${PWD}/${patchdir}/*.patch ; do
[ -f "${patchfile}" ] || continue
(
- cd ${tmp_dir} || err "tmpdir not created"
- git am ${patchfile} || err "Cannot patch project: $name"
+ cd ${tmp_dir} || fail "tmpdir not created"
+ git am ${patchfile} || fail "Cannot patch project: $name"
)
done
}
+fail()
+{
+ usage
+ rm -Rf "${tmp_dir}" > /dev/null 2>&1 | :
+ err "${1}"
+}
+
usage()
{
cat <<- EOF
@@ -99,12 +108,4 @@ usage()
EOF
}
-err()
-{
- printf "${@}\n"
- usage
- rm -Rf ${tmp_dir} >/dev/null 2>&1
- exit 1
-}
-
main $@
diff --git a/fetch_trees b/fetch_trees
index ed15739a..83d26e66 100755
--- a/fetch_trees
+++ b/fetch_trees
@@ -24,6 +24,8 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
+. "include/err.sh"
+
_target=""
tree=""
rev=""
@@ -175,10 +177,4 @@ prepare_new_tree()
)
}
-err()
-{
- printf "ERROR, %s, %s\n" $0 $1 1>&2
- exit 1
-}
-
main $@
diff --git a/include/err.sh b/include/err.sh
new file mode 100755
index 00000000..ea46ccb3
--- /dev/null
+++ b/include/err.sh
@@ -0,0 +1,8 @@
+# Copyright (c) 2022, 2023 Leah Rowe <info@minifree.org>
+# SPDX-License-Identifier: MIT
+
+err()
+{
+ printf "ERROR %s: %s\n" "${0}" "${1}" 1>&2
+ exit 1
+}
diff --git a/lbmk b/lbmk
index f759e461..cab3d4bd 100755
--- a/lbmk
+++ b/lbmk
@@ -24,6 +24,8 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
+. "include/err.sh"
+
projectname="$(cat projectname)"
buildpath=""
mode=""
@@ -31,8 +33,8 @@ option=""
main()
{
- [ "${0##*/}" = "lbmk" ] && die "Don't run this script directly."
- [ $# -lt 1 ] && die "Too few arguments. Try: ${0} help"
+ [ "${0##*/}" = "lbmk" ] && err "Don't run this script directly."
+ [ $# -lt 1 ] && err "Too few arguments. Try: ${0} help"
buildpath="./resources/scripts/${0##*/}"
@@ -41,7 +43,7 @@ main()
[ "${mode}" = "help" ] && usage ${0} && exit 0
[ $# -lt 2 ] && usage ${0} && exit 1
if [ "${mode}" = "dependencies" ]; then
- install_dependencies $@ || die "Could not install dependencies"
+ install_dependencies $@ || err "Could not install dependencies"
exit 0
else
./resources/scripts/misc/versioncheck
@@ -62,13 +64,13 @@ main()
*)
if [ ! -d "${buildpath}/${mode}" ]; then
usage $0
- die "Invalid mode '${mode}'. Run: ${0} help"
+ err "Invalid mode '${mode}'. Run: ${0} help"
elif [ ! -f "${buildpath}/${mode}/${option}" ]; then
usage $0
printf "Invalid option for '%s'." ${mode}
- die "Run: ${0} ${mode} list'."
+ err "Run: ${0} ${mode} list'."
fi
- "${buildpath}/${mode}/${option}" $@ || die "lbmk error"
+ "${buildpath}/${mode}/${option}" $@ || err "lbmk error"
esac
./.gitcheck clean
@@ -76,12 +78,12 @@ main()
install_dependencies()
{
- [ -f "resources/dependencies/${2}" ] || die "Unsupported target"
+ [ -f "resources/dependencies/${2}" ] || err "Unsupported target"
aur_notice=""
. "resources/dependencies/${2}"
- ${pkg_add} ${pkglist} || die "Error installing dependencies"
+ ${pkg_add} ${pkglist} || err "Error installing dependencies"
[ "${aur_notice}" != "" ] && \
printf "You must install these AUR packages: %s\n" \
"${aur_notice}" 1>&2
@@ -120,11 +122,4 @@ listmodes()
done
}
-die()
-{
- ./.gitcheck clean
- printf "Error: %s\n" "${@}" 1>&2
- exit 1
-}
-
main $@
diff --git a/resources/scripts/build/boot/roms b/resources/scripts/build/boot/roms
index 44b7cb8e..f634918e 100755
--- a/resources/scripts/build/boot/roms
+++ b/resources/scripts/build/boot/roms
@@ -29,6 +29,8 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
+. "include/err.sh"
+
projectname="$(cat projectname)"
opts=""
boards=
@@ -116,9 +118,4 @@ buildrom() {
./build boot roms_helper ${1}${opts}
}
-err() {
- printf '%s\n' "${1}" 1>&2
- exit 1
-}
-
main $@
diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper
index f78c7cc8..462b9403 100755
--- a/resources/scripts/build/boot/roms_helper
+++ b/resources/scripts/build/boot/roms_helper
@@ -30,11 +30,7 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
-err()
-{
- printf "ERROR: build/boot/roms: %s\n" "${1}" 1>&2
- exit 1
-}
+. "include/err.sh"
projectname="$(cat projectname)"
diff --git a/resources/scripts/build/clean/crossgcc b/resources/scripts/build/clean/crossgcc
index 8c61dd5f..76de1e19 100755
--- a/resources/scripts/build/clean/crossgcc
+++ b/resources/scripts/build/clean/crossgcc
@@ -22,6 +22,8 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
+. "include/err.sh"
+
main()
{
printf "Cleaning crossgcc builds in all coreboot archives\n"
@@ -34,10 +36,4 @@ main()
done
}
-err()
-{
- printf "%s: %s\n" $0 $1
- exit 1
-}
-
main $@
diff --git a/resources/scripts/build/descriptors/ich9m b/resources/scripts/build/descriptors/ich9m
index 221131af..40d95d42 100755
--- a/resources/scripts/build/descriptors/ich9m
+++ b/resources/scripts/build/descriptors/ich9m
@@ -19,6 +19,8 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
+. "include/err.sh"
+
ich9gen="util/ich9utils/ich9gen"
main()
@@ -36,10 +38,4 @@ main()
)
}
-err()
-{
- printf "%s: %s\n" $0 $1
- exit 1
-}
-
main $@
diff --git a/resources/scripts/build/grub/utils b/resources/scripts/build/grub/utils
index 3e379472..dbe14bc0 100755
--- a/resources/scripts/build/grub/utils
+++ b/resources/scripts/build/grub/utils
@@ -22,6 +22,8 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
+. "include/err.sh"
+
main()
{
printf "Building GRUB\n"
@@ -41,10 +43,4 @@ build_grub()
)
}
-err()
-{
- printf "%s: error: %s\n" $0 $1
- exit 1
-}
-
main $@
diff --git a/resources/scripts/build/release/roms b/resources/scripts/build/release/roms
index ca0e9fe7..2f9524c5 100755
--- a/resources/scripts/build/release/roms
+++ b/resources/scripts/build/release/roms
@@ -21,6 +21,8 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
+. "include/err.sh"
+
projectname="$(cat projectname)"
version="version-unknown"
versiondate="version-date-unknown"
@@ -165,10 +167,4 @@ strip_rom_image()
${cbfstool} "${romfile}" remove -n "pci10de,06eb.rom" || exit 1
}
-err()
-{
- printf "%s: %s\n" $0 $1
- exit 1
-}
-
main $@
diff --git a/resources/scripts/build/release/src b/resources/scripts/build/release/src
index ba09a3d3..3f9feb9b 100755
--- a/resources/scripts/build/release/src
+++ b/resources/scripts/build/release/src
@@ -21,6 +21,8 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
+. "include/err.sh"
+
projectname="$(cat projectname)"
trees_fetch_list="coreboot u-boot"
@@ -161,9 +163,4 @@ create_release_archive()
)
}
-err()
-{
- printf "%s: %s\n" $0 $1
-}
-
main $@
diff --git a/resources/scripts/build/src/for b/resources/scripts/build/src/for
index 6761f160..57459952 100755
--- a/resources/scripts/build/src/for
+++ b/resources/scripts/build/src/for
@@ -21,6 +21,8 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
+. "include/err.sh"
+
mode=""
project=""
@@ -61,10 +63,4 @@ main()
|| err "cannot clean project src, ${project}"
}
-err()
-{
- printf "ERROR: build/src: %s\n" "${1}" 1>&2
- exit 1
-}
-
main $@
diff --git a/resources/scripts/handle/config/file b/resources/scripts/handle/config/file
index b8f9bea0..f488dccb 100755
--- a/resources/scripts/handle/config/file
+++ b/resources/scripts/handle/config/file
@@ -24,6 +24,8 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
+. "include/err.sh"
+
projectname="$(cat projectname)"
our_version="$(cat version)"
@@ -58,20 +60,20 @@ main()
mode="menuconfig"
shift ;;
*)
- err "Invalid option" ;;
+ fail "Invalid option" ;;
esac
project="${OPTARG}"
shift
done
- [ -z "${mode}" ] && err "mode not given (-m, -u or -b)"
+ [ -z "${mode}" ] && fail "mode not given (-m, -u or -b)"
elfdir="elf/${project}"
cfgsdir="resources/${project}"
- [ -d "${cfgsdir}" ] || err "directory, ${cfgsdir}, does not exist"
+ [ -d "${cfgsdir}" ] || fail "directory, ${cfgsdir}, does not exist"
listfile="${cfgsdir}/build.list"
- [ -f "${listfile}" ] || err "list file, ${listfile}, does not exist"
+ [ -f "${listfile}" ] || fail "list file, ${listfile}, does not exist"
# Build for all targets if no argument is given
if [ "$#" -eq 0 ]; then
@@ -90,7 +92,7 @@ main()
printf "Running 'make %s' for project '%s, target '%s''\n" \
"${mode}" "${project}" "${target}"
[ "${project}" != "coreboot" ] || [ "${mode}" != "all" ] || \
- ./update blobs download ${target} || err "blobutil"
+ ./update blobs download ${target} || fail "blobutil"
handle_defconfig || exit 1
done
@@ -125,15 +127,15 @@ handle_dependencies()
arch="undefined"
[ ! -f "${target_dir}/target.cfg" ] && \
- err "build/${project} ${target}: Missing target.cfg"
+ fail "build/${project} ${target}: Missing target.cfg"
# Override the above defaults using target.cfg
. "${target_dir}/target.cfg" # source
[ "${tree}" = "undefined" ] && \
- err "build/${project} %{target}: tree undefined"
+ fail "build/${project} %{target}: tree undefined"
[ "${arch}" = "undefined" ] && \
- err "build/${project} ${target}: undefined cpu type"
+ fail "build/${project} ${target}: undefined cpu type"
codedir="${project}/${tree}"
[ -d "${codedir}" ] || \
@@ -141,7 +143,7 @@ handle_dependencies()
# u-boot and coreboot are both compiled with coreboot's crossgcc
if [ "${project}" = "coreboot" ] || [ "${project}" = "u-boot" ]; then
- [ "${mode}" != "all" ] || check_cross_compiler || err "crossgcc"
+ [ "${mode}" != "all" ] || check_cross_compiler || fail "crossgcc"
fi
}
@@ -162,7 +164,7 @@ check_cross_compiler()
# only true if not building coreboot:
[ -d "${cbdir}" ] || \
./fetch_trees coreboot ${cbdir#coreboot/} || \
- err "check_cross_compiler"
+ fail "check_cross_compiler"
if [ "${arch}" = "x86_32" ] || [ "${arch}" = "x86_64" ]; then
[ -d "${cbdir}/util/crossgcc/xgcc/i386-elf/" ] || \
@@ -201,7 +203,7 @@ check_cross_compiler()
check_config()
{
[ ! -f "${config}" ] && \
- err "build/${project} ${target}: configs missing"
+ fail "build/${project} ${target}: configs missing"
dest_dir="${elfdir}/${target}/${config_name}"
for elftest in "${dest_dir}"/*; do
@@ -215,15 +217,15 @@ check_config()
run_make_command()
{
- make -C "${codedir}" distclean || err "run_make_command"
+ make -C "${codedir}" distclean || fail "run_make_command"
- cp "${config}" "${codedir}/.config" || err "run_make_command"
+ cp "${config}" "${codedir}/.config" || fail "run_make_command"
[ "${mode}" != "all" ] || make -C "${codedir}" silentoldconfig || \
make -C "${codedir}" oldconfig || : # don't error on oldconfig
[ "${project}" = "coreboot" ] && [ "${mode}" = "all" ] && \
printf "%s\n" "${our_version}" > "${codedir}/.coreboot-version"
- make -C "${codedir}" -j$(nproc) ${mode} || err "run_make_command"
+ make -C "${codedir}" -j$(nproc) ${mode} || fail "run_make_command"
}
copy_elf()
@@ -233,17 +235,16 @@ copy_elf()
done
make -C "${codedir}" distclean || \
- make -C "${codedir}" clean || err "copy_elf"
+ make -C "${codedir}" clean || fail "copy_elf"
}
-err()
+fail()
{
[ -z "${codedir}" ] || \
make -C "${codedir}" distclean \
|| make -C "${codedir}" clean || :
- printf "build/defconfig error %s\n" "${1}" 1>&2
- exit 1
+ err "build/defconfig error ${1}"
}
main $@
diff --git a/resources/scripts/update/blobs/download b/resources/scripts/update/blobs/download
index cad40895..f3ba3052 100755
--- a/resources/scripts/update/blobs/download
+++ b/resources/scripts/update/blobs/download
@@ -5,6 +5,8 @@
# SPDX-FileCopyrightText: 2023 Leah Rowe <info@minifree.org>
# SPDX-License-Identifier: GPL-3.0-only
+. "include/err.sh"
+
agent="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
ec_url=""
@@ -54,9 +56,9 @@ main()
boarddir="${cbcfgsdir}/${board}"
[ ! -d "${boarddir}" ] && \
- fail "Board target, ${board}, not defined"
+ err "Board target, ${board}, not defined"
[ ! -f "${boarddir}/target.cfg" ] && \
- fail "Target missing target.cfg"
+ err "Target missing target.cfg"
no_config="printf \"No config for target, %s\\n\" ${board} 1>&2; exit 0"
for x in "${boarddir}"/config/*; do
@@ -153,16 +155,16 @@ build_dependencies()
{
[ -d ${cbdir} ] || \
./fetch_trees coreboot ${cbdir##*/} || \
- fail "can't download to ${cbdir}"
+ err "can't download to ${cbdir}"
for d in uefitool biosutilities bios_extract me_cleaner; do
[ -d "${d}" ] && continue
- ./fetch ${d} || fail "can't download ${d}"
+ ./fetch ${d} || err "can't download ${d}"
done
[ -f uefitool/uefiextract ] || \
- ./build src for -b uefitool || fail "can't build uefitool"
+ ./build src for -b uefitool || err "can't build uefitool"
[ -f ${cbdir}/util/kbc1126/kbc1126_ec_dump ] || \
make -BC ${cbdir}/util/kbc1126 || \
- fail "can't build kbc1126_ec_dump"
+ err "can't build kbc1126_ec_dump"
}
download_blobs()
@@ -183,7 +185,7 @@ download_blobs()
done
[ -z ${_failed+x} ] || \
- fail "failed to obtain ${_failed}\nTry manual extraction?"
+ err "failed to obtain ${_failed}\nTry manual extraction?"
}
download_blob_intel_me()
@@ -214,10 +216,10 @@ extract_blob_intel_me()
innoextract ${dl_path} -d ${appdir} || \
7z x ${dl_path} -o${appdir} || \
unar "${dl_path}" -o "${appdir}" || \
- fail "Could not extract vendor update"
+ err "Could not extract vendor update"
bruteforce_extract_blob_intel_me "$(pwd)/${_me_destination}" \
- "$(pwd)/${appdir}" || fail "Could not extract Intel ME firmware"
+ "$(pwd)/${appdir}" || err "Could not extract Intel ME firmware"
printf "Truncated and cleaned me output to ${_me_destination}\n"
}
@@ -314,7 +316,7 @@ extract_blob_kbc1126_ec()
mv Rom.bin ec.bin
fi
- [ -f ec.bin ] || fail "could not extract ec.bin for board, ${board}"
+ [ -f ec.bin ] || err "could not extract ec.bin for board, ${board}"
"${kbc1126_ec_dump}" ec.bin
)
@@ -367,10 +369,10 @@ extract_e6400vga()
tail -c +${e6400_vga_offset} "${dl_path##*/}" \
| gunzip > bios.bin
[ -f "bios.bin" ] || \
- fail "Could not extract bios.bin from Dell E6400 update"
+ err "Could not extract bios.bin from Dell E6400 update"
"${e6400_unpack}" bios.bin || printf "TODO: fix dell extract util\n"
[ -f "${e6400_vga_romname}" ] || \
- fail "Could not extract VGA ROM from Dell E6400 BIOS update"
+ err "Could not extract VGA ROM from Dell E6400 BIOS update"
)
cp "${appdir}"/"${e6400_vga_romname}" "${_vga_destination}"
@@ -483,10 +485,4 @@ vendor_checksum()
fi
}
-fail()
-{
- printf "\nERROR: $@\n"
- exit 1
-}
-
main $@
diff --git a/resources/scripts/update/blobs/extract b/resources/scripts/update/blobs/extract
index 6b18e962..d7a68bf3 100755
--- a/resources/scripts/update/blobs/extract
+++ b/resources/scripts/update/blobs/extract
@@ -5,6 +5,8 @@
# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
# SPDX-License-Identifier: GPL-3.0-only
+. "include/err.sh"
+
sname=""
board=""
vendor_rom=""
@@ -29,7 +31,7 @@ _ifd_destination=""
main()
{
sname=${0}
- [ $# -lt 2 ] && fail "Missing arguments (fewer than two)."
+ [ $# -lt 2 ] && err "Missing arguments (fewer than two)."
board="${1}"
vendor_rom="${2}"
@@ -43,21 +45,21 @@ main()
check_board()
{
[ -f "${vendor_rom}" ] || \
- fail "file does not exist: ${vendor_rom}"
+ err "file does not exist: ${vendor_rom}"
[ -d "${boarddir}" ] || \
- fail "build/roms ${board}: target not defined"
+ err "build/roms ${board}: target not defined"
[ -f "${boarddir}/target.cfg" ] || \
- fail "build/roms ${board}: missing target.cfg"
+ err "build/roms ${board}: missing target.cfg"
}
build_dependencies()
{
[ -d me_cleaner ] || \
- ./fetch me_cleaner || fail "can't fetch me_cleaner"
+ ./fetch me_cleaner || err "can't fetch me_cleaner"
[ -d ${cbdir} ] || \
- ./fetch_trees coreboot default || fail "can't fetch coreboot"
+ ./fetch_trees coreboot default || err "can't fetch coreboot"
[ -f ${ifdtool} ] || \
- make -C "${ifdtool%/ifdtool}" || fail "can't build ifdtool"
+ make -C "${ifdtool%/ifdtool}" || err "can't build ifdtool"
}
extract_blobs()
@@ -69,7 +71,7 @@ extract_blobs()
. "${boarddir}/target.cfg"
[ "$CONFIG_HAVE_MRC" != "y" ] || \
- ./update blobs mrc || fail "could not download mrc"
+ ./update blobs mrc || err "could not download mrc"
_me_destination=${CONFIG_ME_BIN_PATH#../../}
_gbe_destination=${CONFIG_GBE_BIN_PATH#../../}
@@ -81,7 +83,7 @@ extract_blobs()
# Cleans up other files extracted with ifdtool
rm -f flashregion*.bin 2> /dev/null
- [ -f ${_ifd_destination} ] || fail "Could not extract IFD"
+ [ -f ${_ifd_destination} ] || err "Could not extract IFD"
printf "gbe, ifd, and me extracted to %s\n" \
${_me_destination%/*}
}
@@ -94,7 +96,7 @@ extract_blob_intel_me()
-M ${_me_destination} ${vendor_rom} -t -r -S || \
${me7updateparser} \
-O ${_me_destination} ${vendor_rom} || \
- fail "me_cleaner failed to extract blobs from rom"
+ err "me_cleaner failed to extract blobs from rom"
}
extract_blob_intel_gbe_nvm()
@@ -102,14 +104,7 @@ extract_blob_intel_gbe_nvm()
printf "extracting gigabit ethernet firmware"
./${ifdtool} -x ${vendor_rom}
mv flashregion*gbe.bin ${_gbe_destination} || \
- fail 'could not extract gbe'
-}
-
-fail()
-{
- print_help
- printf "\n%s: ERROR: %s\n" ${sname} $@
- exit 1
+ err 'could not extract gbe'
}
print_help()
diff --git a/resources/scripts/update/blobs/inject b/resources/scripts/update/blobs/inject
index 696cd74d..496d845c 100755
--- a/resources/scripts/update/blobs/inject
+++ b/resources/scripts/update/blobs/inject
@@ -5,6 +5,8 @@
# SPDX-FileCopyrightText: 2023 Leah Rowe <info@minifree.org>
# SPDX-License-Identifier: GPL-3.0-only
+. "include/err.sh"
+
sname=""
archive=""
_filetype=""
@@ -41,7 +43,7 @@ main()
{
sname="${0}"
- [ $# -lt 1 ] && fail "No options specified."
+ [ $# -lt 1 ] && err "No options specified."
[ "${1}" = "listboards" ] && listboards && exit 0
archive="${1}"
@@ -72,21 +74,21 @@ check_board()
{
if ! check_release ${archive} ; then
[ -f "${rom}" ] || \
- fail "${rom} is not a valid path"
+ err "${rom} is not a valid path"
[ -z ${rom+x} ] && \
- fail 'no rom specified'
+ err 'no rom specified'
[ ! -z ${board+x} ] || \
board=$(detect_board ${rom}) || \
- fail 'no board specified'
+ err 'no board specified'
else
release=true
releasearchive="${archive}"
board=$(detect_board ${archive}) || \
- fail 'Could not detect board type'
+ err 'Could not detect board type'
fi
boarddir="${cbcfgsdir}/${board}"
- [ -d "${boarddir}" ] || fail "board ${board} not found"
+ [ -d "${boarddir}" ] || err "board ${board} not found"
}
check_release()
@@ -120,9 +122,9 @@ detect_board()
build_dependencies()
{
[ -d "${cbdir}" ] || ./fetch_trees coreboot default
- ./build coreboot utils default || fail "could not build cbutils"
+ ./build coreboot utils default || err "could not build cbutils"
./update blobs download ${board} || \
- fail "Could not download blobs for ${board}"
+ err "Could not download blobs for ${board}"
}
inject_blobs()
@@ -139,17 +141,17 @@ patch_release_roms()
{
_tmpdir=$(mktemp -d "/tmp/${board}_tmpXXXX")
tar xf "${releasearchive}" -C "${_tmpdir}" || \
- fail 'could not extract release archive'
+ err 'could not extract release archive'
for x in ${_tmpdir}/bin/*/*.rom ; do
echo "patching rom $x"
- patch_rom ${x} || fail "could not patch ${x}"
+ patch_rom ${x} || err "could not patch ${x}"
done
(
cd ${_tmpdir}/bin/*
sha1sum --status -c blobhashes || \
- fail 'ROMs did not match expected hashes'
+ err 'ROMs did not match expected hashes'
)
if [ "${modifygbe}" = "true" ]; then
@@ -223,11 +225,11 @@ inject_blob_intel_me()
rom="${1}"
[ -z ${CONFIG_ME_BIN_PATH} ] && \
- fail "CONFIG_ME_BIN_PATH not set"
+ err "CONFIG_ME_BIN_PATH not set"
_me_location=${CONFIG_ME_BIN_PATH#../../}
[ ! -f "${_me_location}" ] && \
- fail "CONFIG_ME_BIN_PATH points to missing file"
+ err "CONFIG_ME_BIN_PATH points to missing file"
${ifdtool} -i me:${_me_location} ${rom} -O ${rom} || exit 1
}
@@ -310,19 +312,19 @@ modify_gbe()
rom=${1}
[ -z ${CONFIG_GBE_BIN_PATH} ] && \
- fail "CONFIG_GBE_BIN_PATH not set"
+ err "CONFIG_GBE_BIN_PATH not set"
_gbe_location=${CONFIG_GBE_BIN_PATH#../../}
[ -f "${_gbe_location}" ] || \
- fail "CONFIG_GBE_BIN_PATH points to missing file"
+ err "CONFIG_GBE_BIN_PATH points to missing file"
[ -f ${nvmutil} ] || \
- make -C util/nvmutil || fail 'failed to build nvmutil'
+ make -C util/nvmutil || err 'failed to build nvmutil'
_gbe_tmp=$(mktemp -t gbeXXXX.bin)
cp ${_gbe_location} ${_gbe_tmp}
${nvmutil} "${_gbe_tmp}" setmac ${new_mac} || \
- fail 'failed to modify mac address'
+ err 'failed to modify mac address'
${ifdtool} -i GbE:${_gbe_tmp} "${rom}" -O "${rom}" || exit 1
@@ -339,14 +341,6 @@ listboards()
done
}
-fail()
-{
- [ -z ${@+x} ] || \
- printf "\n%s: ERROR: ${@}\n" ${sname}
- usage
- exit 1
-}
-
usage()
{
cat <<- EOF
diff --git a/resources/scripts/update/blobs/mrc b/resources/scripts/update/blobs/mrc
index 14a1d2b6..b4502c14 100755
--- a/resources/scripts/update/blobs/mrc
+++ b/resources/scripts/update/blobs/mrc
@@ -17,6 +17,9 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
+
+. "include/err.sh"
+
export PATH="${PATH}:/sbin"
# This file is forked from util/chromeos/crosfirmware.sh in coreboot cfc26ce278
@@ -51,8 +54,8 @@ main()
printf "Downloading Intel MRC blobs\n"
check_existing && exit 0
- build_dependencies || fail "could not build dependencies"
- fetch_mrc || fail "could not fetch mrc.bin"
+ build_dependencies || err "could not build dependencies"
+ fetch_mrc || err "could not fetch mrc.bin"
}
check_existing()
@@ -85,7 +88,7 @@ fetch_mrc()
[ -f ${_file} ] || \
download_image ${_url2} ${_file} ${_sha1sum}
[ -f $_file ] || \
- fail "%{_file} not downloaded / verification failed."
+ err "%{_file} not downloaded / verification failed."
extract_partition ROOT-A ${_file} root-a.ext2
extract_shellball root-a.ext2 chromeos-firmwareupdate-${_board}
@@ -93,7 +96,7 @@ fetch_mrc()
extract_coreboot chromeos-firmwareupdate-${_board}
../../${cbfstool} coreboot-*.bin extract -f mrc.bin -n mrc.bin \
- -r RO_SECTION || fail "Could not fetch mrc.bin"
+ -r RO_SECTION || err "Could not fetch mrc.bin"
rm -f "chromeos-firmwareupdate-${_board}" coreboot-*.bin \
"${_file}" "root-a.ext2"
@@ -166,11 +169,4 @@ extract_coreboot()
rm -r "${_unpacked}"
}
-fail()
-{
- printf "%s: ERROR: %s\n"
- ${sname} ${1}
- exit 1
-}
-
main $@