Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 828136 - sys-apps/portage mishandles ebuilds containing two identical || blocks
Summary: sys-apps/portage mishandles ebuilds containing two identical || blocks
Status: CONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Dependencies (show other bugs)
Hardware: All Linux
: Normal major (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 155723
  Show dependency tree
 
Reported: 2021-12-04 18:54 UTC by Michał Górny
Modified: 2023-01-16 16:03 UTC (History)
2 users (show)

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


Attachments
unit test case which demonstrates the unnecessary slot upgrade (test_unecessary_slot_upgrade.py,1.45 KB, text/x-python)
2021-12-04 23:08 UTC, Zac Medico
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-12-04 18:54:42 UTC
Let's say I have dev-lang/python:3.9 installed.

If the ebuild has the following dependency:

  BDEPEND="|| ( dev-lang/python:3.10 dev-lang/python:3.9 )"

Then Portage considers it satisfied.

However, if I duplicate the || block:

  BDEPEND="
    || ( dev-lang/python:3.10 dev-lang/python:3.9 )
    || ( dev-lang/python:3.10 dev-lang/python:3.9 )"

Portage suddenly wants to pull python:3.10.
Comment 1 Zac Medico gentoo-dev 2021-12-04 20:13:33 UTC
Since upgrades are generally desirable, we might consider the behavior for the duplicate || blocks to be the correct one.
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-12-04 22:10:00 UTC
In general, if do not request -u or --deep/--complete-graph, I'd say the desirable behavior is not to install anything extra if dependencies are satisfied already.
Comment 3 Zac Medico gentoo-dev 2021-12-04 23:08:38 UTC
Created attachment 757444 [details]
unit test case which demonstrates the unnecessary slot upgrade
Comment 4 Zac Medico gentoo-dev 2021-12-04 23:36:19 UTC
It looks like we need it to separate these choices into separate bins before it sorts them to find upgrades. Currently, it's putting all the choices into the same bin and the attributes of the choices in the bin look like this:

[
    {
        "atoms": ["dev-lang/python:3.9", "dev-lang/python:3.9"],
        "all_available": True,
        "all_installed_slots": True,
        "new_slot_count": 0,
        "all_in_graph": False,
        "want_update": False,
    },
    {
        "atoms": ["dev-lang/python:3.10", "dev-lang/python:3.10"],
        "all_available": True,
        "all_installed_slots": False,
        "new_slot_count": 1,
        "all_in_graph": False,
        "want_update": False,
    },
    {
        "atoms": ["dev-lang/python:3.10", "dev-lang/python:3.9"],
        "all_available": True,
        "all_installed_slots": False,
        "new_slot_count": 1,
        "all_in_graph": False,
        "want_update": False,
    },
    {
        "atoms": ["dev-lang/python:3.9", "dev-lang/python:3.10"],
        "all_available": True,
        "all_installed_slots": False,
        "new_slot_count": 1,
        "all_in_graph": False,
        "want_update": False,
    },
]
Comment 5 Larry the Git Cow gentoo-dev 2021-12-07 04:00:04 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=a7289ac0eaaa0d435bf6d9bfb2724a6b39adcbee

commit a7289ac0eaaa0d435bf6d9bfb2724a6b39adcbee
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2021-12-04 23:54:47 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2021-12-05 18:40:44 +0000

    dep_zapdeps: avoid new slots when appropriate (bug 828136)
    
    Place choices that do not pull in new slots into a preferred
    choice bin, so that they will not be mixed with choices that
    contain unnecessary upgrades. This fixes the included test
    case so that an unnecessary new python slot is not pulled in.
    
    Bug: https://bugs.gentoo.org/828136
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/portage/dep/dep_check.py                       |  6 ++-
 .../tests/resolver/test_unecessary_slot_upgrade.py | 62 ++++++++++++++++++++++
 2 files changed, 67 insertions(+), 1 deletion(-)
Comment 6 Zac Medico gentoo-dev 2022-03-05 19:42:07 UTC
(In reply to Larry the Git Cow from comment #5)
> The bug has been referenced in the following commit(s):
> 
> https://gitweb.gentoo.org/proj/portage.git/commit/
> ?id=a7289ac0eaaa0d435bf6d9bfb2724a6b39adcbee
> 
> commit a7289ac0eaaa0d435bf6d9bfb2724a6b39adcbee
> Author:     Zac Medico <zmedico@gentoo.org>
> AuthorDate: 2021-12-04 23:54:47 +0000
> Commit:     Zac Medico <zmedico@gentoo.org>
> CommitDate: 2021-12-05 18:40:44 +0000
> 
>     dep_zapdeps: avoid new slots when appropriate (bug 828136)
>     
>     Place choices that do not pull in new slots into a preferred
>     choice bin, so that they will not be mixed with choices that
>     contain unnecessary upgrades. This fixes the included test
>     case so that an unnecessary new python slot is not pulled in.
>     
>     Bug: https://bugs.gentoo.org/828136
>     Signed-off-by: Zac Medico <zmedico@gentoo.org>
> 
>  lib/portage/dep/dep_check.py                       |  6 ++-
>  .../tests/resolver/test_unecessary_slot_upgrade.py | 62
> ++++++++++++++++++++++
>  2 files changed, 67 insertions(+), 1 deletion(-)

This is now reverted since it triggered bug 833014.