diff --git a/sdk_container/src/third_party/portage-stable/eclass/unpacker.eclass b/sdk_container/src/third_party/portage-stable/eclass/unpacker.eclass index 370f0a9c59..4c0641d59c 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/unpacker.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/unpacker.eclass @@ -1,9 +1,10 @@ -# Copyright 1999-2017 Gentoo Foundation +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: unpacker.eclass # @MAINTAINER: # base-system@gentoo.org +# @SUPPORTED_EAPIS: 5 6 7 8 # @BLURB: helpers for extraneous file formats and consistent behavior across EAPIs # @DESCRIPTION: # Some extraneous file formats are not part of PMS, or are only in certain @@ -14,10 +15,18 @@ # - merge rpm unpacking # - support partial unpacks? +case ${EAPI:-0} in + [5678]) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + if [[ -z ${_UNPACKER_ECLASS} ]]; then _UNPACKER_ECLASS=1 +inherit toolchain-funcs + # @ECLASS-VARIABLE: UNPACKER_BZ2 +# @USER_VARIABLE # @DEFAULT_UNSET # @DESCRIPTION: # Utility to use to decompress bzip2 files. Will dynamically pick between @@ -25,6 +34,7 @@ _UNPACKER_ECLASS=1 # Note: this is meant for users to set, not ebuilds. # @ECLASS-VARIABLE: UNPACKER_LZIP +# @USER_VARIABLE # @DEFAULT_UNSET # @DESCRIPTION: # Utility to use to decompress lzip files. Will dynamically pick between @@ -279,7 +289,7 @@ unpack_deb() { done } < "${deb}" else - ar x "${deb}" + $(tc-getBUILD_AR) x "${deb}" || die fi unpacker ./data.tar* @@ -325,6 +335,47 @@ unpack_zip() { [[ $? -le 1 ]] || die "unpacking ${zip} failed (arch=unpack_zip)" } +# @FUNCTION: unpack_7z +# @USAGE: <7z file> +# @DESCRIPTION: +# Unpack 7z archives. +unpack_7z() { + [[ $# -eq 1 ]] || die "Usage: ${FUNCNAME} " + + local p7z=$(find_unpackable_file "$1") + unpack_banner "${p7z}" + local output="$(7z x -y "${p7z}")" + + if [ $? -ne 0 ]; then + echo "${output}" >&2 + die "unpacking ${p7z} failed (arch=unpack_7z)" + fi +} + +# @FUNCTION: unpack_rar +# @USAGE: +# @DESCRIPTION: +# Unpack RAR archives. +unpack_rar() { + [[ $# -eq 1 ]] || die "Usage: ${FUNCNAME} " + + local rar=$(find_unpackable_file "$1") + unpack_banner "${rar}" + unrar x -idq -o+ "${rar}" || die "unpacking ${rar} failed (arch=unpack_rar)" +} + +# @FUNCTION: unpack_lha +# @USAGE: +# @DESCRIPTION: +# Unpack LHA/LZH archives. +unpack_lha() { + [[ $# -eq 1 ]] || die "Usage: ${FUNCNAME} " + + local lha=$(find_unpackable_file "$1") + unpack_banner "${lha}" + lha xfq "${lha}" || die "unpacking ${lha} failed (arch=unpack_lha)" +} + # @FUNCTION: _unpacker # @USAGE: # @INTERNAL @@ -354,6 +405,8 @@ _unpacker() { *.lz) : ${UNPACKER_LZIP:=$(type -P plzip || type -P pdlzip || type -P lzip)} comp="${UNPACKER_LZIP} -dc" ;; + *.zst) + comp="zstd -dfc" ;; esac # then figure out if there are any archiving aspects @@ -383,6 +436,18 @@ _unpacker() { arch="unpack_zip" ;; esac + # 7z, rar and lha/lzh are handled by package manager in EAPI < 8 + if [[ ${EAPI} != [567] ]]; then + case ${m} in + *.7z) + arch="unpack_7z" ;; + *.rar|*.RAR) + arch="unpack_rar" ;; + *.LHA|*.LHa|*.lha|*.lzh) + arch="unpack_lha" ;; + esac + fi + # finally do the unpack if [[ -z ${arch}${comp} ]] ; then unpack "$1" @@ -444,9 +509,6 @@ unpacker_src_uri_depends() { case ${uri} in *.cpio.*|*.cpio) d="app-arch/cpio" ;; - *.deb) - # platforms like AIX don't have a good ar - d="kernel_AIX? ( app-arch/deb2targz )" ;; *.rar|*.RAR) d="app-arch/unrar" ;; *.7z) @@ -457,6 +519,10 @@ unpacker_src_uri_depends() { d="app-arch/unzip" ;; *.lz) d="|| ( app-arch/plzip app-arch/pdlzip app-arch/lzip )" ;; + *.zst) + d="app-arch/zstd" ;; + *.LHA|*.LHa|*.lha|*.lzh) + d="app-arch/lha" ;; esac deps+=" ${d}" done