summaryrefslogtreecommitdiff
path: root/resources/scripts/update/blobs
diff options
context:
space:
mode:
Diffstat (limited to 'resources/scripts/update/blobs')
-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
4 files changed, 53 insertions, 72 deletions
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 $@