Gentoo Archives: gentoo-commits

From: Stephan Hartmann <sultan@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Wed, 01 Sep 2021 21:04:29
Message-Id: 1630530201.64a5f18e204ef2eb98abc2814956f78d340d7986.sultan@gentoo
1 commit: 64a5f18e204ef2eb98abc2814956f78d340d7986
2 Author: Stephan Hartmann <sultan <AT> gentoo <DOT> org>
3 AuthorDate: Thu Aug 26 06:27:50 2021 +0000
4 Commit: Stephan Hartmann <sultan <AT> gentoo <DOT> org>
5 CommitDate: Wed Sep 1 21:03:21 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=64a5f18e
7
8 unpacker.eclass: enable EAPI 8
9
10 Add support for 7z, RAR and LHA/LZH.
11
12 Signed-off-by: Stephan Hartmann <sultan <AT> gentoo.org>
13
14 eclass/unpacker.eclass | 59 ++++++++++++++++++++++++++++++++++++++++++++++++--
15 1 file changed, 57 insertions(+), 2 deletions(-)
16
17 diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass
18 index c9dab4345c9..74899fd77b7 100644
19 --- a/eclass/unpacker.eclass
20 +++ b/eclass/unpacker.eclass
21 @@ -4,7 +4,7 @@
22 # @ECLASS: unpacker.eclass
23 # @MAINTAINER:
24 # base-system@g.o
25 -# @SUPPORTED_EAPIS: 5 6 7
26 +# @SUPPORTED_EAPIS: 5 6 7 8
27 # @BLURB: helpers for extraneous file formats and consistent behavior across EAPIs
28 # @DESCRIPTION:
29 # Some extraneous file formats are not part of PMS, or are only in certain
30 @@ -16,7 +16,7 @@
31 # - support partial unpacks?
32
33 case ${EAPI:-0} in
34 - [567]) ;;
35 + [5678]) ;;
36 *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
37 esac
38
39 @@ -335,6 +335,47 @@ unpack_zip() {
40 [[ $? -le 1 ]] || die "unpacking ${zip} failed (arch=unpack_zip)"
41 }
42
43 +# @FUNCTION: unpack_7z
44 +# @USAGE: <7z file>
45 +# @DESCRIPTION:
46 +# Unpack 7z archives.
47 +unpack_7z() {
48 + [[ $# -eq 1 ]] || die "Usage: ${FUNCNAME} <file>"
49 +
50 + local p7z=$(find_unpackable_file "$1")
51 + unpack_banner "${p7z}"
52 + local output="$(7z x -y "${p7z}")"
53 +
54 + if [ $? -ne 0 ]; then
55 + echo "${output}" >&2
56 + die "unpacking ${p7z} failed (arch=unpack_7z)"
57 + fi
58 +}
59 +
60 +# @FUNCTION: unpack_rar
61 +# @USAGE: <rar file>
62 +# @DESCRIPTION:
63 +# Unpack RAR archives.
64 +unpack_rar() {
65 + [[ $# -eq 1 ]] || die "Usage: ${FUNCNAME} <file>"
66 +
67 + local rar=$(find_unpackable_file "$1")
68 + unpack_banner "${rar}"
69 + unrar x -idq -o+ "${rar}" || die "unpacking ${rar} failed (arch=unpack_rar)"
70 +}
71 +
72 +# @FUNCTION: unpack_lha
73 +# @USAGE: <lha file>
74 +# @DESCRIPTION:
75 +# Unpack LHA/LZH archives.
76 +unpack_lha() {
77 + [[ $# -eq 1 ]] || die "Usage: ${FUNCNAME} <file>"
78 +
79 + local lha=$(find_unpackable_file "$1")
80 + unpack_banner "${lha}"
81 + lha xfq "${lha}" || die "unpacking ${lha} failed (arch=unpack_lha)"
82 +}
83 +
84 # @FUNCTION: _unpacker
85 # @USAGE: <one archive to unpack>
86 # @INTERNAL
87 @@ -395,6 +436,18 @@ _unpacker() {
88 arch="unpack_zip" ;;
89 esac
90
91 + # 7z, rar and lha/lzh are handled by package manager in EAPI < 8
92 + if [[ ${EAPI} != [567] ]]; then
93 + case ${m} in
94 + *.7z)
95 + arch="unpack_7z" ;;
96 + *.rar|*.RAR)
97 + arch="unpack_rar" ;;
98 + *.LHA|*.LHa|*.lha|*.lzh)
99 + arch="unpack_lha" ;;
100 + esac
101 + fi
102 +
103 # finally do the unpack
104 if [[ -z ${arch}${comp} ]] ; then
105 unpack "$1"
106 @@ -471,6 +524,8 @@ unpacker_src_uri_depends() {
107 d="|| ( app-arch/plzip app-arch/pdlzip app-arch/lzip )" ;;
108 *.zst)
109 d="app-arch/zstd" ;;
110 + *.LHA|*.LHa|*.lha|*.lzh)
111 + d="app-arch/lha" ;;
112 esac
113 deps+=" ${d}"
114 done