summaryrefslogtreecommitdiff
path: root/script/update/blobs
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-09-28 00:29:54 +0100
committerLeah Rowe <leah@libreboot.org>2023-09-28 00:29:54 +0100
commit9aef57dfb760bb58e29c8febdac4fa550ab76cf1 (patch)
tree60523ea57b9871b8faf8aee9eabe129417129b89 /script/update/blobs
parent74c48a881df378a83e261c2785012609d81d801e (diff)
blobs/download: unified archive extraction
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'script/update/blobs')
-rwxr-xr-xscript/update/blobs/download42
1 files changed, 14 insertions, 28 deletions
diff --git a/script/update/blobs/download b/script/update/blobs/download
index 72c58341..5276d763 100755
--- a/script/update/blobs/download
+++ b/script/update/blobs/download
@@ -95,8 +95,7 @@ extract_blob_intel_me()
printf "Extracting neutered ME for %s\n" "${board}"
_me_destination=${CONFIG_ME_BIN_PATH#../../}
- mk_blobdir "${_me_destination}" "extract_blob_intel_me" || return 0
- mk_appdir "extract_blob_intel_me"
+ mkdirs "${_me_destination}" "extract_blob_intel_me" || return 0
bruteforce_extract_blob_intel_me "$(pwd)/${_me_destination}" \
"$(pwd)/${appdir}" || \
err "extract_blob_intel_me: could not extract Intel ME firmware"
@@ -170,8 +169,7 @@ extract_blob_kbc1126_ec()
printf "Extracting KBC1126 EC firmware for board: %s\n" ${board}
_ec_destination=${CONFIG_KBC1126_FW1#../../}
- mk_blobdir "${_ec_destination}" "extract_blob_kbc1126_ec" || return 0
- mk_appdir "extract_blob_kbc1126_ec"
+ mkdirs "${_ec_destination}" "extract_blob_kbc1126_ec" || return 0
(
cd "${appdir}/" || \
err "extract_blob_kbc1126_ec: !cd \"${appdir}/\""
@@ -217,8 +215,7 @@ extract_e6400vga()
printf "Extracting Nvidia VGA ROM for ${board}\n"
_vga_destination=${CONFIG_VGA_BIOS_FILE#../../}
- mk_blobdir "${_vga_destination}" "extract_e6400vga" || return 0
- mk_appdir "extract_e6400vga"
+ mkdirs "${_vga_destination}" "extract_e6400vga" || return 0
[ "${E6400_VGA_offset}" = "" ] && \
err "extract_e6400vga: E6400 VGA offset not defined"
@@ -260,8 +257,7 @@ extract_sch5545ec()
rm -Rf "${dl_path}_extracted" || err "!rm ${dl_path}_extracted"
_sch5545ec_destination=${CONFIG_SMSC_SCH5545_EC_FW_FILE#../../}
- mk_blobdir "${_sch5545ec_destination}" "extract_sch5545ec" || return 0
- mk_appdir "extract_sch5545ec"
+ mkdirs "${_sch5545ec_destination}" "extract_sch5545ec" || return 0
# full system ROM (UEFI), to extract with UEFIExtract:
_bios="${dl_path}_extracted/Firmware"
@@ -295,8 +291,7 @@ fetch_update()
for x in "${dl}" "${dl_bkup}"; do
[ "${dl_fail}" = "n" ] && break
[ -z "${x}" ] && continue
- rm -f "${dl_path}" || \
- err "fetch_update: !rm -f ${dl_path}"
+ rm -f "${dl_path}" || err "fetch_update: !rm -f ${dl_path}"
wget --tries 3 -U "${agent}" "${x}" -O "${dl_path}" || continue
vendor_checksum "${dlsum}" && dl_fail="n"
done
@@ -309,8 +304,7 @@ fetch_update()
vendor_checksum()
{
if [ ! -f "${dl_path}" ]; then
- printf "Vendor update not found on disk for: %s\n" "${board}" \
- 1>&2
+ printf "Vendor update not found for: %s\n" "${board}" 1>&2
return 1
elif [ "$(sha512sum ${dl_path} | awk '{print $1}')" != "${1}" ]; then
printf "Bad checksum on vendor update for: %s\n" "${board}" 1>&2
@@ -318,29 +312,21 @@ vendor_checksum()
fi
}
-mk_blobdir()
+mkdirs()
{
[ -f "${1}" ] && \
- printf "${2} firmware already downloaded\n" 1>&2 && return 1
- if [ ! -d "${1%/*}" ]; then
- mkdir -p "${1%/*}" || err "${2}: mkdir ${1%/*}"
- fi
-}
-
-mk_appdir()
-{
- [ ! -d "${appdir}" ] || rm -Rf "${appdir}" || \
- err "${1}: can't remove ${appdir}"
- mkdir -p "${appdir}/" || err "${1}: !mkdir ${appdir}"
+ printf "mkdirs ${1} ${2}: already downloaded\n" 1>&2 && return 1
+ mkdir -p "${1%/*}" || err "mkdirs ${1} ${2}: !mkdir ${1%/*}"
+ rm -Rf "${appdir}" || err "mkdirs ${1} ${2}: can't remove ${appdir}"
+ mkdir -p "${appdir}/" || err "mkdirs ${1} ${2}: !mkdir ${appdir}"
extract_archive "${dl_path}" "${appdir}" || \
- [ "${1}" = "extract_e6400vga" ] || err "${1}: can't extract update"
+ [ "${2}" = "extract_e6400vga" ] || err "mkdirs ${1} ${2}: !extract"
}
extract_archive()
{
- innoextract "${1}" -d "${2}" || 7z x "${1}" -o"${2}" || \
- unar "${1}" -o "${2}" || \
- python "${pfs_extract}" "${1}" -e || return 1
+ innoextract "${1}" -d "${2}" || python "${pfs_extract}" "${1}" -e || \
+ 7z x "${1}" -o"${2}" || unar "${1}" -o "${2}" || return 1
}
main $@