Gentoo Archives: gentoo-portage-dev

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

Replies