Gentoo Archives: gentoo-dev

From: Sam James <sam@g.o>
To: gentoo-dev@l.g.o
Cc: base-system@g.o, mgorny@g.o, Sam James <sam@g.o>
Subject: [gentoo-dev] [PATCH 1/2] unpacker.eclass: flatten unpacker_src_uri_depends dependencies
Date: Mon, 16 Jan 2023 17:44:08
Message-Id: 20230116174327.3926794-2-sam@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/2] unpacker.eclass: avoid duplicate unpacker_src_uri_depends deps by Sam James
1 Populate an associative array as we iterate over SRC_URI to collect needed
2 dependencies to avoid recording the same dependencies twice.
3
4 This still doesn't handle USE flags, but it's significantly better than before,
5 as we won't repeatedly emit the same dependency if there's more than one distfile
6 in SRC_URI with the same suffix.
7
8 Closes: https://bugs.gentoo.org/891133
9 Thanks-to: Ionen Wolkens <ionen@g.o>
10 Signed-off-by: Sam James <sam@g.o>
11 ---
12 eclass/unpacker.eclass | 29 ++++++++++++++---------------
13 1 file changed, 14 insertions(+), 15 deletions(-)
14
15 diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass
16 index 326b2fa675249..44ff2af5acf39 100644
17 --- a/eclass/unpacker.eclass
18 +++ b/eclass/unpacker.eclass
19 @@ -596,7 +596,8 @@ unpacker_src_unpack() {
20 #
21 # Note: USE flags are not yet handled.
22 unpacker_src_uri_depends() {
23 - local uri deps d
24 + local uri
25 + local -A deps
26
27 if [[ $# -eq 0 ]] ; then
28 # Disable path expansion for USE conditionals. #654960
29 @@ -606,20 +607,19 @@ unpacker_src_uri_depends() {
30 fi
31
32 for uri in "$@" ; do
33 - local m=${uri,,}
34 - case ${m} in
35 + case ${uri,,} in
36 *.cpio.*|*.cpio)
37 - d="app-arch/cpio" ;;
38 + deps[cpio]="app-arch/cpio" ;;
39 *.rar)
40 - d="app-arch/unrar" ;;
41 + deps[rar]="app-arch/unrar" ;;
42 *.7z)
43 - d="app-arch/p7zip" ;;
44 + deps[7z]="app-arch/p7zip" ;;
45 *.xz)
46 - d="app-arch/xz-utils" ;;
47 + deps[xz]="app-arch/xz-utils" ;;
48 *.zip)
49 - d="app-arch/unzip" ;;
50 + deps[zip]="app-arch/unzip" ;;
51 *.lz)
52 - d="
53 + deps[lz]="
54 || (
55 >=app-arch/xz-utils-5.4.0
56 app-arch/plzip
57 @@ -629,18 +629,17 @@ unpacker_src_uri_depends() {
58 "
59 ;;
60 *.zst)
61 - d="app-arch/zstd" ;;
62 + deps[zst]="app-arch/zstd" ;;
63 *.lha|*.lzh)
64 - d="app-arch/lha" ;;
65 + deps[lhah]="app-arch/lha" ;;
66 *.lz4)
67 - d="app-arch/lz4" ;;
68 + deps[lz4]="app-arch/lz4" ;;
69 *.lzo)
70 - d="app-arch/lzop" ;;
71 + deps[lzo]="app-arch/lzop" ;;
72 esac
73 - deps+=" ${d}"
74 done
75
76 - echo "${deps}"
77 + echo "${deps[*]}"
78 }
79
80 EXPORT_FUNCTIONS src_unpack
81 --
82 2.39.0