Gentoo Archives: gentoo-portage-dev

From: Alec Warner <antarus@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?
Date: Thu, 27 Nov 2008 07:08:07
Message-Id: b41005390811262308l5eb29ff9hf2eb45c73ed208ae@mail.gmail.com
In Reply to: Re: [gentoo-portage-dev] How to extract the version/revision of an installed package? by Amit Dor-Shifer
1 On Wed, Nov 26, 2008 at 3:13 AM, Amit Dor-Shifer <amitds@××××××.com> wrote:
2 > Is there syntax in eix for querying: "is package X installed with a version
3 > X.Y or higher?"
4 > Amit
5
6 portageq has_version / <ATOM>
7
8 >
9 > René 'Necoro' Neumann wrote:
10 >>
11 >> Amit Dor-Shifer schrieb:
12 >> > Thanks :)
13 >>
14 >> > Reason I thought this is relevant is: I'm basically looking for an API
15 >> > to get an installed package's version/rev. I prefer that over making
16 >> > syntactical assumptions on the way portage names packages.
17 >>
18 >> > Taking RPM for example, there's such an API: something like rpm -q
19 >> > --queryformat '%{VERSION}|' PKG_NAME if I remember correctly.|
20 >>
21 >> > Amit
22 >>
23 >> You could also use eix ... though I needed quite a time to figure it out
24 >> ;)
25 >>
26 >> # PRINT_SLOTS="false" eix -e -I sys-devel/automake --pure-packages
27 >> --format "<installedversionsshort>"
28 >> 1.9.6-r2 1.10.1-r1
29 >>
30 >> Note however, that if you a package has multiple installed versions,
31 >> they are seperated by space. One could use
32 >>
33 >>
34 >> # PRINT_SLOTS="false" eix -e -I sys-devel/automake --pure-packages
35 >> --format "<installedversionsshort:\n>"
36 >>
37 >> But this prints an additional empty line at the beginning.
38 >>
39 >> > Andrew Gaffney wrote:
40 >> >> Amit Dor-Shifer wrote:
41 >> >>> Given the following:
42 >> >>> # qlist -Iv sys-apps/portage
43 >> >>> sys-apps/portage-2.1.4.5
44 >> >>>
45 >> >>> How do I safely extract the "2.1.4.5"?
46 >> >> That's probably offtopic for this list, since it really has nothing to
47 >> >> do with portage itself. However, you probably want something like:
48 >> >>
49 >> >> qlist -Iv sys-apps/portage | sed -e 's:^.*-\([0-9][^-_]*\).*$:\1:'
50 >> >>
51 >>
52 >
53 >
54 >