blobs/download: unified archive extraction
Signed-off-by: Leah Rowe <leah@libreboot.org>btrfsvols
parent
74c48a881d
commit
9aef57dfb7
|
@ -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 $@
|
||||
|
|
Loading…
Reference in New Issue