Gentoo Archives: gentoo-dev

From: Sam James <sam@g.o>
To: gentoo-dev@l.g.o
Cc: base-system@g.o, Sam James <sam@g.o>
Subject: [gentoo-dev] [PATCH] unpacker.eclass: support >=app-arch/xz-utils-5.4.0 for lzip decompression
Date: Wed, 14 Dec 2022 08:22:39
Message-Id: 20221214082224.269374-1-sam@gentoo.org
1 >=app-arch/xz-utils-5.4.0 supports lzip decompression (not compression).
2
3 Add support for unpacker.eclass to handle it for .lz files.
4
5 Note that xz-utils is part of @system (and PMS requires that .xz is unpackable),
6 while most users do not have lzip and friends installed.
7
8 (Note that xz does not (currently, but does not plan on either) implement
9 parallel decompression for .lz, but most .lz distfiles are small, so this
10 isn't an issue.)
11
12 Historically, we've often repacked .lz distfiles for important packages
13 to avoid users needing to install app-arch/lzip for a single distfile,
14 so this avoids the need for that (although I've not done it out of
15 principle for things like sys-apps/ed).
16
17 Bug: https://bugs.gentoo.org/249059
18 Bug: https://bugs.gentoo.org/485462
19 Bug: https://bugs.gentoo.org/501912
20 Bug: https://bugs.gentoo.org/502990
21 Bug: https://bugs.gentoo.org/545344
22 Signed-off-by: Sam James <sam@g.o>
23 ---
24 eclass/unpacker.eclass | 31 +++++++++++++++++++++++++++----
25 1 file changed, 27 insertions(+), 4 deletions(-)
26
27 diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass
28 index 3d8bf7a8452d0..11f04fde72260 100644
29 --- a/eclass/unpacker.eclass
30 +++ b/eclass/unpacker.eclass
31 @@ -30,7 +30,7 @@ inherit multiprocessing toolchain-funcs
32 # @DEFAULT_UNSET
33 # @DESCRIPTION:
34 # Utility to use to decompress bzip2 files. Will dynamically pick between
35 -# `lbzip2`, `pbzip2` and `bzip2`. Make sure your choice accepts the "-dc"
36 +# `lbzip2`, `pbzip2`, and `bzip2`. Make sure your choice accepts the "-dc"
37 # options.
38 # Note: this is meant for users to set, not ebuilds.
39
40 @@ -39,7 +39,7 @@ inherit multiprocessing toolchain-funcs
41 # @DEFAULT_UNSET
42 # @DESCRIPTION:
43 # Utility to use to decompress lzip files. Will dynamically pick between
44 -# `plzip`, `pdlzip` and `lzip`. Make sure your choice accepts the "-dc" options.
45 +# `xz`, `plzip`, `pdlzip`, and `lzip`. Make sure your choice accepts the "-dc" options.
46 # Note: this is meant for users to set, not ebuilds.
47
48 # for internal use only (unpack_pdv and unpack_makeself)
49 @@ -429,7 +429,22 @@ _unpacker_get_decompressor() {
50 *.lzma|*.xz|*.txz)
51 echo "xz -T$(makeopts_jobs) -dc" ;;
52 *.lz)
53 - : ${UNPACKER_LZIP:=$(type -P plzip || type -P pdlzip || type -P lzip)}
54 + find_lz_unpacker() {
55 + local has_version_arg="-b"
56 +
57 + [[ ${EAPI} == 6 ]] && has_version_arg="--host-root"
58 + if has_version "${has_version_arg}" ">=app-arch/xz-utils-5.4.0" ; then
59 + echo xz
60 + return
61 + fi
62 +
63 + local x
64 + for x in plzip pdlzip lzip ; do
65 + type -P ${x} && break
66 + done
67 + }
68 +
69 + : ${UNPACKER_LZIP:=$(find_lz_unpacker)}
70 echo "${UNPACKER_LZIP} -dc" ;;
71 *.zst)
72 echo "zstd -dc" ;;
73 @@ -604,7 +619,15 @@ unpacker_src_uri_depends() {
74 *.zip)
75 d="app-arch/unzip" ;;
76 *.lz)
77 - d="|| ( app-arch/plzip app-arch/pdlzip app-arch/lzip )" ;;
78 + d="
79 + || (
80 + >=app-arch/xz-utils-5.4.0
81 + app-arch/plzip
82 + app-arch/pdlzip
83 + app-arch/lzip
84 + )
85 + "
86 + ;;
87 *.zst)
88 d="app-arch/zstd" ;;
89 *.lha|*.lzh)
90 --
91 2.39.0

Replies