commit: 3684ec70b53db1d9eb5c25d6e2f2ecf096a6336b
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 28 08:53:56 2022 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Oct 1 17:19:32 2022 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3684ec70
unpacker.eclass: Reuse _unpacker_get_decompressor for makeself
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
eclass/unpacker.eclass | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass
index 1fda7a89f3c2..f54d0c3626ab 100644
--- a/eclass/unpacker.eclass
+++ b/eclass/unpacker.eclass
@@ -243,30 +243,32 @@ unpack_makeself() {
esac
# lets grab the first few bytes of the file to figure out what kind of
archive it is
- local filetype tmpfile="${T}/${FUNCNAME}"
+ local decomp= filetype suffix tmpfile="${T}/${FUNCNAME}"
"${exe[@]}" 2>/dev/null | head -c 512 > "${tmpfile}"
filetype=$(file -b "${tmpfile}") || die
case ${filetype} in
*tar\ archive*)
- "${exe[@]}" | tar --no-same-owner -xf -
+ decomp=cat
;;
bzip2*)
- "${exe[@]}" | bzip2 -dc | tar --no-same-owner -xf -
+ suffix=bz2
;;
gzip*)
- "${exe[@]}" | tar --no-same-owner -xzf -
+ suffix=gz
;;
compress*)
- "${exe[@]}" | gunzip | tar --no-same-owner -xf -
+ suffix=z
;;
XZ*)
- "${exe[@]}" | unxz | tar --no-same-owner -xf -
+ suffix=xz
;;
*)
- eerror "Unknown filetype \"${filetype}\" ?"
- false
+ die "Unknown filetype \"${filetype}\", for makeself
${src##*/} ('${ver}' +${skip})"
;;
esac
+
+ [[ -z ${decomp} ]] && decomp=$(_unpacker_get_decompressor ".${suffix}")
+ "${exe[@]}" | ${decomp} | tar --no-same-owner -xf -
assert "failure unpacking (${filetype}) makeself ${src##*/} ('${ver}'
+${skip})"
}