Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Tue, 27 Sep 2022 20:28:58
Message-Id: 1664310481.ecbde653596d010fb095a4f9d05cbe5f18412658.mgorny@gentoo
1 commit: ecbde653596d010fb095a4f9d05cbe5f18412658
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sat Sep 24 14:02:45 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Tue Sep 27 20:28:01 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ecbde653
7
8 unpacker.eclass: Move decompressor recognition into a function
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 eclass/unpacker.eclass | 44 ++++++++++++++++++++++++++------------------
13 1 file changed, 26 insertions(+), 18 deletions(-)
14
15 diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass
16 index ca6761488100..8fb1c2abd1cf 100644
17 --- a/eclass/unpacker.eclass
18 +++ b/eclass/unpacker.eclass
19 @@ -379,6 +379,31 @@ unpack_lha() {
20 lha xfq "${lha}" || die "unpacking ${lha} failed (arch=unpack_lha)"
21 }
22
23 +# @FUNCTION: _unpacker_get_decompressor
24 +# @INTERNAL
25 +# @USAGE: <filename>
26 +# @DESCRIPTION:
27 +# Get decompressor command for specified filename.
28 +_unpacker_get_decompressor() {
29 + case ${1} in
30 + *.bz2|*.tbz|*.tbz2)
31 + local bzcmd=${PORTAGE_BZIP2_COMMAND:-$(type -P pbzip2 || type -P bzip2)}
32 + local bzuncmd=${PORTAGE_BUNZIP2_COMMAND:-${bzcmd} -d}
33 + : ${UNPACKER_BZ2:=${bzuncmd}}
34 + echo "${UNPACKER_BZ2} -c"
35 + ;;
36 + *.z|*.gz|*.tgz)
37 + echo "gzip -dc" ;;
38 + *.lzma|*.xz|*.txz)
39 + echo "xz -dc" ;;
40 + *.lz)
41 + : ${UNPACKER_LZIP:=$(type -P plzip || type -P pdlzip || type -P lzip)}
42 + echo "${UNPACKER_LZIP} -dc" ;;
43 + *.zst)
44 + echo "zstd -dc" ;;
45 + esac
46 +}
47 +
48 # @FUNCTION: _unpacker
49 # @USAGE: <one archive to unpack>
50 # @INTERNAL
51 @@ -393,24 +418,7 @@ _unpacker() {
52 a=$(find_unpackable_file "${a}")
53
54 # first figure out the decompression method
55 - local comp=""
56 - case ${m} in
57 - *.bz2|*.tbz|*.tbz2)
58 - local bzcmd=${PORTAGE_BZIP2_COMMAND:-$(type -P pbzip2 || type -P bzip2)}
59 - local bzuncmd=${PORTAGE_BUNZIP2_COMMAND:-${bzcmd} -d}
60 - : ${UNPACKER_BZ2:=${bzuncmd}}
61 - comp="${UNPACKER_BZ2} -c"
62 - ;;
63 - *.z|*.gz|*.tgz)
64 - comp="gzip -dc" ;;
65 - *.lzma|*.xz|*.txz)
66 - comp="xz -dc" ;;
67 - *.lz)
68 - : ${UNPACKER_LZIP:=$(type -P plzip || type -P pdlzip || type -P lzip)}
69 - comp="${UNPACKER_LZIP} -dc" ;;
70 - *.zst)
71 - comp="zstd -dc" ;;
72 - esac
73 + local comp=$(_unpacker_get_decompressor "${m}")
74
75 # then figure out if there are any archiving aspects
76 local arch=""