Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 891133 - unpacker.eclass: unpacker_src_uri_depends emits redundant dependencies
Summary: unpacker.eclass: unpacker_src_uri_depends emits redundant dependencies
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-16 15:57 UTC by Sam James
Modified: 2023-01-16 20:55 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-01-16 15:57:42 UTC
We noticed sys-apps/ed-1.19 was causing substantial slowdowns for world upgrades and emerging even ed-1.19 itself, but ed-1.18 is fine.

```
$ diff -ruN ed-1.{18,19}
--- ed-1.18	2023-01-13 08:28:35.632365180 +0000
+++ ed-1.19	2023-01-13 08:29:28.822655700 +0000
@@ -1,13 +1,13 @@
-BDEPEND=sys-apps/texinfo || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) verify-sig? ( sec-keys/openpgp-keys-antoniodiazdiaz ) verify-sig? ( app-crypt/gnupg >=app-portage/gemato-16 )
+BDEPEND=sys-apps/texinfo || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) verify-sig? ( sec-keys/openpgp-keys-antoniodiazdiaz ) verify-sig? ( app-crypt/gnupg >=app-portage/gemato-16 )
 DEFINED_PHASES=configure unpack
 DESCRIPTION=Your basic line editor
-EAPI=7
+EAPI=8
 HOMEPAGE=https://www.gnu.org/software/ed/
-INHERIT=toolchain-funcs unpacker verify-sig
+INHERIT=edo toolchain-funcs unpacker verify-sig
 IUSE=verify-sig
-KEYWORDS=~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris
+KEYWORDS=~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris
 LICENSE=GPL-2+
 SLOT=0
-SRC_URI=mirror://gnu/ed/ed-1.18.tar.lz verify-sig? ( mirror://gnu/ed/ed-1.18.tar.lz.sig )
-_eclasses_=toolchain-funcs	ec8bbc28394c7305b43ea07164bd8f5f	multilib	5ca4e49abed8e3a2f7b56920eadee157	multiprocessing	b4e253ab22cef7b1085e9b67c7a3b730	unpacker	8bbea377a8dd2b5d5c8bc0d834ae6157	verify-sig	afb98fe4696292e4234ce36713fd4e9e
-_md5_=bf63ad1b4806a01a7000e3fe6ce90271
+SRC_URI=mirror://gnu/ed/ed-1.19.tar.lz https://download.savannah.gnu.org/releases/ed/ed-1.19.tar.lz verify-sig? ( mirror://gnu/ed/ed-1.19.tar.lz.sig https://download.savannah.gnu.org/releases/ed/ed-1.19.tar.lz.sig )
+_eclasses_=edo	c0eb9cbe6b0bd01fcb4918f12598a4d3	toolchain-funcs	ec8bbc28394c7305b43ea07164bd8f5f	multilib	5ca4e49abed8e3a2f7b56920eadee157	multiprocessing	b4e253ab22cef7b1085e9b67c7a3b730	unpacker	8bbea377a8dd2b5d5c8bc0d834ae6157	verify-sig	afb98fe4696292e4234ce36713fd4e9e
+_md5_=3f460bcb7087cbbadf886cad16e886c9
```

unpacker.eclass's unpacker_src_uri_depends emits repeated || ( ... ) groups even ignoring USE flags. It should de-duplicate/flatten.

Obviously there's a Portage bug here too in not merging the groups though.
Comment 1 Larry the Git Cow gentoo-dev 2023-01-16 16:05:14 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2575ec6caaa80ed8d3c9361312c797837c7c2ec3

commit 2575ec6caaa80ed8d3c9361312c797837c7c2ec3
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-01-16 16:04:22 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-01-16 16:05:08 +0000

    sys-apps/ed: workaround unpacker.eclass/Portage dep resolution bug
    
    1. unpacker_src_uri_depends doesn't flatten the deps (bug #891133) and emits
    several || ( ... ) blocks (4).
    
    2. Portage doesn't handle several repeated identical || ( ...) blocks correctly
    and takes ages to resolve (bug #891137). It should merge them together.
    
    Bug: https://bugs.gentoo.org/891137
    Bug: https://bugs.gentoo.org/891133
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/ed/{ed-1.19.ebuild => ed-1.19-r1.ebuild} | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
Comment 2 Ionen Wolkens gentoo-dev 2023-01-16 16:10:31 UTC
It could use an assoc array rather than appending to be simple

e.g.
    local -A deps

    *.zip)
        deps[zip]="app-arch/unzip" ;;
    *.lz)
        deps[lz]="|| ( ... )" ;;

    echo "${deps[*]}"
Comment 3 Ionen Wolkens gentoo-dev 2023-01-16 16:14:36 UTC
(In reply to Ionen Wolkens from comment #2)
> It could use an assoc array rather than appending to be simple
...or if don't want to use hash order, could use numbers with a normal array instead I guess.
Comment 4 Larry the Git Cow gentoo-dev 2023-01-16 20:55:46 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ea08b1a398b28d8e03fee32787c70b227f763b02

commit ea08b1a398b28d8e03fee32787c70b227f763b02
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-01-16 17:24:37 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-01-16 20:55:05 +0000

    unpacker.eclass: flatten unpacker_src_uri_depends dependencies
    
    Populate an associative array as we iterate over SRC_URI to collect needed
    dependencies to avoid recording the same dependencies twice.
    
    This still doesn't handle USE flags, but it's significantly better than before,
    as we won't repeatedly emit the same dependency if there's more than one distfile
    in SRC_URI with the same suffix.
    
    Closes: https://bugs.gentoo.org/891133
    Thanks-to: Ionen Wolkens <ionen@gentoo.org>
    Signed-off-by: Sam James <sam@gentoo.org>

 eclass/unpacker.eclass | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

Additionally, it has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bf5cff8a6edd64fee318440582d3da3aa83a9043

commit bf5cff8a6edd64fee318440582d3da3aa83a9043
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-01-16 17:26:50 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-01-16 20:55:05 +0000

    sys-apps/ed: use unpacker_src_uri_depends again
    
    Now that unpacker_src_uri_depends is fixed to not emit duplicates, start
    using it again.
    
    (Note that unlike when we dropped it, no revbump needed to restore it,
    because the result should be the same now the eclass is fixed, rather
    than before where we were correcting the bad large deps.)
    
    Bug: https://bugs.gentoo.org/891133
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/ed/ed-1.19-r1.ebuild | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)