Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 196561 - [PMS] meaning of ~ operator doesn't match portage behaviour
Summary: [PMS] meaning of ~ operator doesn't match portage behaviour
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: PMS/EAPI (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: PMS/EAPI
URL:
Whiteboard:
Keywords:
: 264587 (view as bug list)
Depends on: 227225
Blocks: 563798
  Show dependency tree
 
Reported: 2007-10-20 23:21 UTC by Jakub Moc (RETIRED)
Modified: 2022-04-14 05:23 UTC (History)
4 users (show)

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


Attachments
Patch for dependencies.tex (0001-Fix-definition-of-tilde-operator-bug-196561.patch,1.21 KB, patch)
2013-08-24 12:59 UTC, Ulrich Müller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Moc (RETIRED) gentoo-dev 2007-10-20 23:21:18 UTC
portage/pkgcore: ~cat/foo-${PVR} is treated like ~cat/foo-${PV}, i.e., the -r* part is ignored.

paludis/PMS: ~cat/foo-${PVR} is treated kinda like =cat/foo-${PV}-r* !<cat/foo-${PV} (yeah I know the first atom is invalid :P)

Also the wording is pretty awkward in PMS. Well anyway, I don't think that either behaviour makes sense, and would suggest that ~cat/foo-${PVR} should be invalid atom. :) 

Given the current portage behaviour, it cannot be safely used with the meaning described in PMS anyway, because it won't work that way, and it's not used anywhere in gentoo-x86 in this way. FWIW, this is what devmanual says and this matches how's ~ been used for ages, i.e., with ${PV} only and never with ${PVR}.

~app-misc/foo-1.23  	Version 1.23 (or any 1.23-r*) is required.
Comment 1 Ciaran McCreesh 2007-10-20 23:45:31 UTC
The wording in PMS for this is deliberate... Portage's behaviour when -r is present is silly and illogical; the described behaviour is sensible and useful. This is one of the differences where Portage should be fixed to match the spec.
Comment 2 Jakub Moc (RETIRED) gentoo-dev 2007-10-21 00:18:25 UTC
The point is - it can't be (and isn't) used as described in PMS with EAPI=0 - because it simply doesn't work that way. PMS clearly describes this as EAPI=0 behaviour - it's not, never worked this way.
Comment 3 Ciaran McCreesh 2007-10-21 12:27:08 UTC
PMS describes Portage's behaviour, except where Portage's behaviour is clearly nonsensical or wrong. Ignoring part of the spec is clearly nonsensical.
Comment 4 Marius Mauch (RETIRED) gentoo-dev 2007-10-21 12:42:55 UTC
Nice circular reasoning.
Comment 5 Ciaran McCreesh 2007-10-21 12:48:36 UTC
Uh, there's no circular reasoning there...
Comment 6 Marius Mauch (RETIRED) gentoo-dev 2007-10-21 13:15:09 UTC
"spec descripes implementation behavior, except where it's nonsensical"
"implementation behavior is nonsensical because it ignores the spec"
Comment 7 Ciaran McCreesh 2007-10-21 13:18:18 UTC
No no. Other meaning of spec. It's nonsensical because it ignores part of the cat/pkg-pv-r -- specifically, the -r part.
Comment 8 Alec Warner (RETIRED) archtester gentoo-dev Security 2007-10-21 16:10:16 UTC
Assuming for the moment that the spec is adhered to, who is going to fix all the non-conforming dependency strings?  It seems a tall order to change this in EAPI-0 since it forces tree-wide changes, IMHO.  Would it not be better served in a future EAPI?
Comment 9 Ciaran McCreesh 2007-10-21 16:58:09 UTC
So far as I can see, there's exactly one package in the tree where this matters, and it looks like it's after the behaviour described in PMS anyway...

#include <paludis/paludis.hh>
#include <iostream>

using namespace paludis;

namespace
{
    struct FindB0rkedVisitor :
        ConstVisitor<DependencySpecTree>,
        ConstVisitor<DependencySpecTree>::VisitConstSequence<FindB0rkedVisitor, AllDepSpec>,
        ConstVisitor<DependencySpecTree>::VisitConstSequence<FindB0rkedVisitor, AnyDepSpec>,
        ConstVisitor<DependencySpecTree>::VisitConstSequence<FindB0rkedVisitor, UseDepSpec>
    {
        std::string bad;

        void visit_leaf(const PackageDepSpec & s)
        {
            if (s.version_requirements_ptr())
                for (VersionRequirements::ConstIterator v(s.version_requirements_ptr()->begin()),
                        v_end(s.version_requirements_ptr()->end()) ; v != v_end ; ++v)
                    if (v->version_operator == vo_tilde)
                        if (v->version_spec.revision_only() != "r0")
                            bad.append(stringify(s) + " ");
        }

        void visit_leaf(const BlockDepSpec & s)
        {
            visit_leaf(*s.blocked_spec());
        }

        void visit_leaf(const NamedSetDepSpec &)
        {
        }

        void visit_leaf(const DependencyLabelsDepSpec &)
        {
        }

        using ConstVisitor<DependencySpecTree>::VisitConstSequence<FindB0rkedVisitor, AllDepSpec>::visit_sequence;
        using ConstVisitor<DependencySpecTree>::VisitConstSequence<FindB0rkedVisitor, AnyDepSpec>::visit_sequence;
        using ConstVisitor<DependencySpecTree>::VisitConstSequence<FindB0rkedVisitor, UseDepSpec>::visit_sequence;
    };
}

int main(int, char *[])
{
    tr1::shared_ptr<const Environment> env(EnvironmentMaker::get_instance()->make_from_spec(""));
    tr1::shared_ptr<const PackageIDSequence> ids(
            env->package_database()->query(query::Repository(RepositoryName("gentoo")), qo_whatever));

    for (IndirectIterator<PackageIDSequence::ConstIterator>
            i(ids->begin()), i_end(ids->end()) ;
            i != i_end ; ++i)
    {
        FindB0rkedVisitor v;
        if (i->build_dependencies_key())
            i->build_dependencies_key()->value()->accept(v);
        if (i->run_dependencies_key())
            i->run_dependencies_key()->value()->accept(v);
        if (i->post_dependencies_key())
            i->post_dependencies_key()->value()->accept(v);
        if (! v.bad.empty())
            std::cout << *i << ": " << v.bad << std::endl;
    }
}

Gives:

app-office/gnucash-2.0.5:0::gentoo: ~dev-scheme/slib-3.1.1-r1 ~dev-scheme/slib-3.1.1-r1 
Comment 10 Matthias Langer 2007-10-21 20:20:35 UTC
i think what PMS should actually say is (modified from PMS, r172, page 33, section 9.2.1):

"
...
Equal to the specified version, except the revision part of the matching package may be greater **or equal** than the revision part of the specified version
...
"

this is at least what paludis-0.24.6 implements and should be preferred because  it gives the operator a greater expressiveness (how would you say "the same package and version regardless of the revision with the '<' meaning) while it leaves the meaning of the operator intact if used without PR.
Comment 11 Matthias Langer 2007-10-22 10:05:42 UTC
(In reply to comment #9)
> So far as I can see, there's exactly one package in the tree where this
> matters, and it looks like it's after the behaviour described in PMS anyway...
> 
> #include <paludis/paludis.hh>
> #include <iostream>
> 
[...]
> 
> Gives:
> 
> app-office/gnucash-2.0.5:0::gentoo: ~dev-scheme/slib-3.1.1-r1
> ~dev-scheme/slib-3.1.1-r1 

just a side-note:
there might also be candidates in the profiles dir...
Comment 12 Ciaran McCreesh 2008-03-17 11:09:15 UTC
(In reply to comment #10)
> "
> ...
> Equal to the specified version, except the revision part of the matching
> package may be greater **or equal** than the revision part of the specified
> version
> ...
> "

No, the "or equal" isn't necessary or useful. We say "may", not "must".
Comment 13 Matthias Langer 2008-03-17 12:07:54 UTC
(In reply to comment #12)
> No, the "or equal" isn't necessary or useful. We say "may", not "must".

Right... now that I know what it means, I've a hard time to imagine how I could have misread this in the first place. But maybe this is exactly the point I should make: Sentences like the above, that are easily understood by people who already know what they are meaning, might still be misread by people who don't, so being overly explicit here and there won't do any harm.

Whatever, I don't plan to write an essay about a single damn sentence, nor is it worth to discuss this any further. As far as I'm concerned, feel free to close with ${YOUR_RESOLUTION}.
Comment 14 Ulrich Müller gentoo-dev 2009-04-02 17:13:21 UTC
*** Bug 264587 has been marked as a duplicate of this bug. ***
Comment 15 Ulrich Müller gentoo-dev 2009-04-02 17:26:34 UTC
(In reply to comment #1)
> The wording in PMS for this is deliberate... Portage's behaviour when -r
> is present is silly and illogical; the described behaviour is sensible and
> useful.

I don't see anything "silly" or "illogical" with ~ meaning something like "approximately equal". Obviously you can define it one way or the other, and both ways are consistent and meaningful.

Portage chose to ignore the revision part, so PMS should document it in this way.

(In reply to comment #7)
> It's nonsensical because it ignores part of the cat/pkg-pv-r -- specifically,
> the -r part.

If the -r part is important, then there is the = operator. The point of ~ *is* that the -r part is ignored. One could also argue that it is inconsistent to disregard -r only for one and not for both operands of the comparison.
Comment 16 Ciaran McCreesh 2009-04-02 17:27:49 UTC
Last time we looked, everything using ~ with a revision in the tree was expecting the documented behaviour, not Portage's behaviour. This strongly suggests Portage should be fixed.
Comment 17 Ulrich Müller gentoo-dev 2009-04-02 18:45:44 UTC
(In reply to comment #16)
> Last time we looked, everything using ~ with a revision in the tree was
> expecting the documented behaviour, not Portage's behaviour.

Which were how many ebuilds? Exactly *one* according to comment #9. And this is gone from the tree.

AFAICS, nothing in the current tree is using ~ together with -r. (Which is no wonder since it would break either Portage or Paludis.)
Comment 18 Mart Raudsepp gentoo-dev 2009-10-17 22:45:12 UTC
In my opinion PMS should be documenting what portage implements as EAPI-0. It is not up to individuals that are not Gentoo developers to decide what is nonsensical or not and misdocument things to not match portage behaviour at the time.

That said, I see some value in the currently documented behaviour as an EAPI-4 feature, because then we can express ( >=cat/foo-2.0-r2 <=cat/foo-2.0-r9999 )
Comment 19 David Leverton 2009-10-18 00:40:53 UTC
Since nothing in the tree relies on this anymore, and zmedico kindly committed my repoman patch to avoid it happening in future, I think there's no reason not to change PMS now.
Comment 20 Brian Harring (RETIRED) gentoo-dev 2009-10-18 01:18:24 UTC
If the PMS wording of this is desired, jam it into eapi3/eapi4 w/ a mention that it's disallowed for <=eapi2...

I'd be more inclined to open up '~' so that >=/<= and friends can be used with it also.  Specifically such that

~>=dev-util/diffball-1.0-r2 

would mean "any version of 1.0, w/ a rev of 2 or higher".  GLSA's already have something similar to this- they'd likely benefit from expanded syntax.

Syntax is a bit fugly, but so it goes.
Comment 21 Ulrich Müller gentoo-dev 2013-08-24 12:59:55 UTC
Created attachment 356862 [details, diff]
Patch for dependencies.tex

(In reply to David Leverton from comment #19)
> Since nothing in the tree relies on this anymore, and zmedico kindly
> committed my repoman patch to avoid it happening in future, I think there's
> no reason not to change PMS now.

See attached patch.
Comment 22 Ulrich Müller gentoo-dev 2013-08-29 07:55:35 UTC
I see no objections. Pushed.