From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 153F0158094 for ; Sun, 25 Sep 2022 18:25:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F14DF2BC0AA; Sun, 25 Sep 2022 18:23:31 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id AAB842BC0A7 for ; Sun, 25 Sep 2022 18:23:31 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH 08/15] unpacker.eclass: Move decompressor recognition into a function Date: Sun, 25 Sep 2022 20:23:10 +0200 Message-Id: <20220925182317.1559529-9-mgorny@gentoo.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220925182317.1559529-1-mgorny@gentoo.org> References: <20220925182317.1559529-1-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 2bd43ab1-e9ba-47f2-ab6b-ed373b894713 X-Archives-Hash: 9c7445805506b94edef033b2373a0e89 Signed-off-by: Michał Górny --- eclass/unpacker.eclass | 44 +++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass index ca6761488100..8fb1c2abd1cf 100644 --- a/eclass/unpacker.eclass +++ b/eclass/unpacker.eclass @@ -379,6 +379,31 @@ unpack_lha() { lha xfq "${lha}" || die "unpacking ${lha} failed (arch=unpack_lha)" } +# @FUNCTION: _unpacker_get_decompressor +# @INTERNAL +# @USAGE: +# @DESCRIPTION: +# Get decompressor command for specified filename. +_unpacker_get_decompressor() { + case ${1} in + *.bz2|*.tbz|*.tbz2) + local bzcmd=${PORTAGE_BZIP2_COMMAND:-$(type -P pbzip2 || type -P bzip2)} + local bzuncmd=${PORTAGE_BUNZIP2_COMMAND:-${bzcmd} -d} + : ${UNPACKER_BZ2:=${bzuncmd}} + echo "${UNPACKER_BZ2} -c" + ;; + *.z|*.gz|*.tgz) + echo "gzip -dc" ;; + *.lzma|*.xz|*.txz) + echo "xz -dc" ;; + *.lz) + : ${UNPACKER_LZIP:=$(type -P plzip || type -P pdlzip || type -P lzip)} + echo "${UNPACKER_LZIP} -dc" ;; + *.zst) + echo "zstd -dc" ;; + esac +} + # @FUNCTION: _unpacker # @USAGE: # @INTERNAL @@ -393,24 +418,7 @@ _unpacker() { a=$(find_unpackable_file "${a}") # first figure out the decompression method - local comp="" - case ${m} in - *.bz2|*.tbz|*.tbz2) - local bzcmd=${PORTAGE_BZIP2_COMMAND:-$(type -P pbzip2 || type -P bzip2)} - local bzuncmd=${PORTAGE_BUNZIP2_COMMAND:-${bzcmd} -d} - : ${UNPACKER_BZ2:=${bzuncmd}} - comp="${UNPACKER_BZ2} -c" - ;; - *.z|*.gz|*.tgz) - comp="gzip -dc" ;; - *.lzma|*.xz|*.txz) - comp="xz -dc" ;; - *.lz) - : ${UNPACKER_LZIP:=$(type -P plzip || type -P pdlzip || type -P lzip)} - comp="${UNPACKER_LZIP} -dc" ;; - *.zst) - comp="zstd -dc" ;; - esac + local comp=$(_unpacker_get_decompressor "${m}") # then figure out if there are any archiving aspects local arch="" -- 2.37.3