Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 2/5] unpacker.eclass: Reuse _unpacker_get_decompressor for makeself
Date: Wed, 28 Sep 2022 20:59:55
Message-Id: 20220928205907.15979-3-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/5] unpacker.eclass: makeself improvements + tests by "Michał Górny"
1 Signed-off-by: Michał Górny <mgorny@g.o>
2 ---
3 eclass/unpacker.eclass | 18 ++++++++++--------
4 1 file changed, 10 insertions(+), 8 deletions(-)
5
6 diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass
7 index 86641621c949..660cafce5105 100644
8 --- a/eclass/unpacker.eclass
9 +++ b/eclass/unpacker.eclass
10 @@ -243,30 +243,32 @@ unpack_makeself() {
11 esac
12
13 # lets grab the first few bytes of the file to figure out what kind of archive it is
14 - local filetype tmpfile="${T}/${FUNCNAME}"
15 + local decomp= filetype suffix tmpfile="${T}/${FUNCNAME}"
16 "${exe[@]}" 2>/dev/null | head -c 512 > "${tmpfile}"
17 filetype=$(file -b "${tmpfile}") || die
18 case ${filetype} in
19 *tar\ archive*)
20 - "${exe[@]}" | tar --no-same-owner -xf -
21 + decomp=cat
22 ;;
23 bzip2*)
24 - "${exe[@]}" | bzip2 -dc | tar --no-same-owner -xf -
25 + suffix=bz2
26 ;;
27 gzip*)
28 - "${exe[@]}" | tar --no-same-owner -xzf -
29 + suffix=gz
30 ;;
31 compress*)
32 - "${exe[@]}" | gunzip | tar --no-same-owner -xf -
33 + suffix=z
34 ;;
35 XZ*)
36 - "${exe[@]}" | unxz | tar --no-same-owner -xf -
37 + suffix=xz
38 ;;
39 *)
40 - eerror "Unknown filetype \"${filetype}\" ?"
41 - false
42 + die "Unknown filetype \"${filetype}\", for makeself ${src##*/} ('${ver}' +${skip})"
43 ;;
44 esac
45 +
46 + [[ -z ${decomp} ]] && decomp=$(_unpacker_get_decompressor ".${suffix}")
47 + "${exe[@]}" | ${decomp} | tar --no-same-owner -xf -
48 assert "failure unpacking (${filetype}) makeself ${src##*/} ('${ver}' +${skip})"
49 }
50
51 --
52 2.37.3