blobs/download: move helpers to include/blobutil

mkdirs() should be in include/blobutil.sh, as should
extract_archive(), because that is primarily where
they are used.

script/update/blobs/download calls these functions
aswell, but it sources include/blobutil.sh so it's OK.

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-09-29 23:40:57 +01:00
parent 416704fb4e
commit 9f5a5450af
2 changed files with 18 additions and 18 deletions

View File

@ -96,3 +96,21 @@ vendor_checksum()
return 1
fi
}
mkdirs()
{
[ -f "${1}" ] && \
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}" "${appdir}" || \
[ "${2}" = "extract_e6400vga" ] || err "mkdirs ${1} ${2}: !extract"
}
extract_archive()
{
innoextract "${1}" -d "${2}" || python "${pfs_extract}" "${1}" -e || \
7z x "${1}" -o"${2}" || unar "${1}" -o "${2}" || \
unzip "${1}" -d "${2}" || return 1
}

View File

@ -186,22 +186,4 @@ extract_sch5545ec()
err "extract_sch5545ec: cannot copy sch5545ec firmware file"
}
mkdirs()
{
[ -f "${1}" ] && \
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}" "${appdir}" || \
[ "${2}" = "extract_e6400vga" ] || err "mkdirs ${1} ${2}: !extract"
}
extract_archive()
{
innoextract "${1}" -d "${2}" || python "${pfs_extract}" "${1}" -e || \
7z x "${1}" -o"${2}" || unar "${1}" -o "${2}" || \
unzip "${1}" -d "${2}" || return 1
}
main $@