From 778904f14cd059327453557a26eaabc3c42ddc5c Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Sat, 24 Sep 2022 16:27:09 +0200 Subject: unpacker.eclass: Add on-the-fly .gpkg.tar unpacking support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- eclass/unpacker.eclass | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'eclass/unpacker.eclass') diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass index a64c5eae18aa..70a46ac19709 100644 --- a/eclass/unpacker.eclass +++ b/eclass/unpacker.eclass @@ -408,6 +408,42 @@ _unpacker_get_decompressor() { esac } +# @FUNCTION: unpack_gpkg +# @USAGE: +# @DESCRIPTION: +# Unpack the image subarchive of a GPKG package on-the-fly, preserving +# the original directory structure (i.e. into /image). +unpack_gpkg() { + [[ $# -eq 1 ]] || die "Usage: ${FUNCNAME} " + + local gpkg=$(find_unpackable_file "$1") + unpack_banner "${gpkg}" + + local l images=() + while read -r l; do + case ${l} in + */image.tar*.sig) + ;; + */image.tar*) + images+=( "${l}" ) + ;; + esac + done < <(tar -tf "${gpkg}" || die "unable to list ${gpkg}") + + if [[ ${#images[@]} -eq 0 ]]; then + die "No image.tar found in ${gpkg}" + elif [[ ${#images[@]} -gt 1 ]]; then + die "More than one image.tar found in ${gpkg}" + fi + + local decomp=$(_unpacker_get_decompressor "${images[0]}") + local dirname=${images[0]%/*} + mkdir -p "${dirname}" || die + tar -xOf "${gpkg}" "${images[0]}" | ${decomp:-cat} | + tar --no-same-owner -xC "${dirname}" + assert "Unpacking ${gpkg} failed" +} + # @FUNCTION: _unpacker # @USAGE: # @INTERNAL @@ -427,6 +463,8 @@ _unpacker() { # then figure out if there are any archiving aspects local arch="" case ${m} in + *.gpkg.tar) + arch="unpack_gpkg" ;; *.tgz|*.tbz|*.tbz2|*.txz|*.tar.*|*.tar) arch="tar --no-same-owner -xof" ;; *.cpio.*|*.cpio) -- cgit v1.2.3-65-gdbad