FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Portage Developer

 
 
LinkBack Thread Tools
 
Old 11-25-2008, 03:05 PM
Amit Dor-Shifer
 
Default How to extract the version/revision of an installed package?

Given the following:
# qlist -Iv sys-apps/portage
sys-apps/portage-2.1.4.5

How do I safely extract the "2.1.4.5"?

(I don't necessarily need to use qlist. Just want to get the version of
an installed package within a bash script)


10x
Amit
 
Old 11-25-2008, 03:13 PM
Andrew Gaffney
 
Default How to extract the version/revision of an installed package?

Amit Dor-Shifer wrote:

Given the following:
# qlist -Iv sys-apps/portage
sys-apps/portage-2.1.4.5

How do I safely extract the "2.1.4.5"?


That's probably offtopic for this list, since it really has nothing to do with
portage itself. However, you probably want something like:


qlist -Iv sys-apps/portage | sed -e 's:^.*-([0-9][^-_]*).*$:1:'

--
Andrew Gaffney http://dev.gentoo.org/~agaffney/
Gentoo Linux Developer Catalyst/Genkernel + Release Engineering Lead
 
Old 11-25-2008, 03:19 PM
Andrew Gaffney
 
Default How to extract the version/revision of an installed package?

Andrew Gaffney wrote:

Amit Dor-Shifer wrote:

Given the following:
# qlist -Iv sys-apps/portage
sys-apps/portage-2.1.4.5

How do I safely extract the "2.1.4.5"?


That's probably offtopic for this list, since it really has nothing to
do with portage itself. However, you probably want something like:


qlist -Iv sys-apps/portage | sed -e 's:^.*-([0-9][^-_]*).*$:1:'


And if you want the full version (with RC position and revision):

qlist -Iv sys-apps/portage | sed -e 's:^.*-([0-9].*)$:1:'

--
Andrew Gaffney http://dev.gentoo.org/~agaffney/
Gentoo Linux Developer Catalyst/Genkernel + Release Engineering Lead
 
Old 11-25-2008, 03:43 PM
Amit Dor-Shifer
 
Default How to extract the version/revision of an installed package?

Thanks

Reason I thought this is relevant is: I'm basically looking for an API
to get an installed package's version/rev. I prefer that over making
syntactical assumptions on the way portage names packages.


Taking RPM for example, there's such an API: something like rpm -q
--queryformat '%{VERSION}|' PKG_NAME if I remember correctly.|


Amit

Andrew Gaffney wrote:

Amit Dor-Shifer wrote:

Given the following:
# qlist -Iv sys-apps/portage
sys-apps/portage-2.1.4.5

How do I safely extract the "2.1.4.5"?


That's probably offtopic for this list, since it really has nothing to
do with portage itself. However, you probably want something like:


qlist -Iv sys-apps/portage | sed -e 's:^.*-([0-9][^-_]*).*$:1:'
 
Old 11-25-2008, 04:03 PM
René 'Necoro' Neumann
 
Default How to extract the version/revision of an installed package?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Amit Dor-Shifer schrieb:
> Thanks
>
> Reason I thought this is relevant is: I'm basically looking for an API
> to get an installed package's version/rev. I prefer that over making
> syntactical assumptions on the way portage names packages.
>
> Taking RPM for example, there's such an API: something like rpm -q
> --queryformat '%{VERSION}|' PKG_NAME if I remember correctly.|
>
> Amit

You could also use eix ... though I needed quite a time to figure it out

# PRINT_SLOTS="false" eix -e -I sys-devel/automake --pure-packages
- --format "<installedversionsshort>"
1.9.6-r2 1.10.1-r1

Note however, that if you a package has multiple installed versions,
they are seperated by space. One could use


# PRINT_SLOTS="false" eix -e -I sys-devel/automake --pure-packages
- --format "<installedversionsshort:
>"

But this prints an additional empty line at the beginning.

> Andrew Gaffney wrote:
>> Amit Dor-Shifer wrote:
>>> Given the following:
>>> # qlist -Iv sys-apps/portage
>>> sys-apps/portage-2.1.4.5
>>>
>>> How do I safely extract the "2.1.4.5"?
>>
>> That's probably offtopic for this list, since it really has nothing to
>> do with portage itself. However, you probably want something like:
>>
>> qlist -Iv sys-apps/portage | sed -e 's:^.*-([0-9][^-_]*).*$:1:'
>>
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkksL/sACgkQ4UOg/zhYFuCgIwCdFUhQxUOMuTSqBVgSeb6SgdNd
PLYAniyZJKrxqtt1LBPFq9Nr56wvGSz8
=y6nB
-----END PGP SIGNATURE-----
 
Old 11-26-2008, 03:54 AM
Zac Medico
 
Default How to extract the version/revision of an installed package?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ned Ludd wrote:
> On Tue, 2008-11-25 at 14:03 -0800, Brian Harring wrote:
>> On Tue, Nov 25, 2008 at 06:05:21PM +0200, Amit Dor-Shifer wrote:
>>> Given the following:
>>> # qlist -Iv sys-apps/portage
>>> sys-apps/portage-2.1.4.5
>>>
>>> How do I safely extract the "2.1.4.5"?
>>>
>>> (I don't necessarily need to use qlist. Just want to get the version of an
>>> installed package within a bash script)
>> This *really* should be folded into portageq offhand- it's the initial
>> step towards shifting versionator logic (yet another standalone
>> parser/comparison implementation) into the PM.
>>
>> Counter arguements?
>> ~brian
>
> Yes. he said a bash script. portageq still takes a few seconds to load
> and invokes far far to many instructions for very simple info.
>
> The 3 execve's I just posted are still faster than one portageq call.
> So.. foo.c wins again.

Well, I think portageq will be fine if it's limited to a small
number of calls. Here's a simple test, with portage-2.2_rc16:

# time python -c "import portage.versions"

real 0m0.141s
user 0m0.124s
sys 0m0.016s

It's not so bad if it only has to be called a few times. For cases
where a large number need to be split, they could be processed in a
batch by a single portageq call, by either passing all the inputs in
as arguments or writing them to stdin.
- --
Thanks,
Zac
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAkks1oQACgkQ/ejvha5XGaM/fgCfQwG2gD0viF5qjcN0WBewlCxi
08sAoKBZYQy3Ttkb4KhFIChPVsbFjpQR
=fc1x
-----END PGP SIGNATURE-----
 
Old 11-26-2008, 07:29 AM
Fabian Groffen
 
Default How to extract the version/revision of an installed package?

On 25-11-2008 16:15:09 -0800, Ned Ludd wrote:
> On Tue, 2008-11-25 at 18:05 +0200, Amit Dor-Shifer wrote:
> > Given the following:
> > # qlist -Iv sys-apps/portage
> > sys-apps/portage-2.1.4.5
> >
> > How do I safely extract the "2.1.4.5"?
> >
> > (I don't necessarily need to use qlist. Just want to get the version of
> > an installed package within a bash script)
>
> qatom $(qlist -ICv sys-apps/portage) | awk '{print $3}'

I happen to do it in bash for my update script, it hasn't broke yet:

get_ebuildversion() {
if [[ -z $1 ]] ; then
return
fi

# strip extension
t=${1%.ebuild}
# abort if this is not an ebuild
if [[ $t == $1 ]] ; then
return
fi
# strip package name
t=${t#*-}
# sometimes there are dashes in the package name
while [[ ${t:0:1} < "0" || ${t:0:1} > "9" ]] ; do
[[ $t != ${t#*-} ]]
&& t=${t#*-}
|| break
done

echo ${t}
}

you might want to remove the .ebuild check and strip the category ($1#*/})


--
Fabian Groffen
Gentoo on a different level
 
Old 11-26-2008, 08:29 AM
Amit Dor-Shifer
 
Default How to extract the version/revision of an installed package?

Great! the usage of -C escaped me, and I was wondering why I was
getting bad output...

Thanks,
Amit

Ned Ludd wrote:

On Tue, 2008-11-25 at 18:05 +0200, Amit Dor-Shifer wrote:


Given the following:
# qlist -Iv sys-apps/portage
sys-apps/portage-2.1.4.5

How do I safely extract the "2.1.4.5"?

(I don't necessarily need to use qlist. Just want to get the version of
an installed package within a bash script)






qatom $(qlist -ICv sys-apps/portage) | awk '{print $3}'
 
Old 11-26-2008, 10:13 AM
Amit Dor-Shifer
 
Default How to extract the version/revision of an installed package?

Is there syntax in eix for querying: "is package X installed with a
version X.Y or higher?"

Amit

René 'Necoro' Neumann wrote:

Amit Dor-Shifer schrieb:
> Thanks

> Reason I thought this is relevant is: I'm basically looking for an API
> to get an installed package's version/rev. I prefer that over making
> syntactical assumptions on the way portage names packages.

> Taking RPM for example, there's such an API: something like rpm -q
> --queryformat '%{VERSION}|' PKG_NAME if I remember correctly.|

> Amit

You could also use eix ... though I needed quite a time to figure it
out


# PRINT_SLOTS="false" eix -e -I sys-devel/automake --pure-packages
--format "<installedversionsshort>"
1.9.6-r2 1.10.1-r1

Note however, that if you a package has multiple installed versions,
they are seperated by space. One could use


# PRINT_SLOTS="false" eix -e -I sys-devel/automake --pure-packages
--format "<installedversionsshort:
>"

But this prints an additional empty line at the beginning.

> Andrew Gaffney wrote:
>> Amit Dor-Shifer wrote:
>>> Given the following:
>>> # qlist -Iv sys-apps/portage
>>> sys-apps/portage-2.1.4.5
>>>
>>> How do I safely extract the "2.1.4.5"?
>> That's probably offtopic for this list, since it really has nothing to
>> do with portage itself. However, you probably want something like:
>>
>> qlist -Iv sys-apps/portage | sed -e 's:^.*-([0-9][^-_]*).*$:1:'
>>
 
Old 11-27-2008, 06:08 AM
"Alec Warner"
 
Default How to extract the version/revision of an installed package?

On Wed, Nov 26, 2008 at 3:13 AM, Amit Dor-Shifer <amitds@oversi.com> wrote:
> Is there syntax in eix for querying: "is package X installed with a version
> X.Y or higher?"
> Amit

portageq has_version / <ATOM>

>
> René 'Necoro' Neumann wrote:
>>
>> Amit Dor-Shifer schrieb:
>> > Thanks
>>
>> > Reason I thought this is relevant is: I'm basically looking for an API
>> > to get an installed package's version/rev. I prefer that over making
>> > syntactical assumptions on the way portage names packages.
>>
>> > Taking RPM for example, there's such an API: something like rpm -q
>> > --queryformat '%{VERSION}|' PKG_NAME if I remember correctly.|
>>
>> > Amit
>>
>> You could also use eix ... though I needed quite a time to figure it out
>>
>>
>> # PRINT_SLOTS="false" eix -e -I sys-devel/automake --pure-packages
>> --format "<installedversionsshort>"
>> 1.9.6-r2 1.10.1-r1
>>
>> Note however, that if you a package has multiple installed versions,
>> they are seperated by space. One could use
>>
>>
>> # PRINT_SLOTS="false" eix -e -I sys-devel/automake --pure-packages
>> --format "<installedversionsshort:
>"
>>
>> But this prints an additional empty line at the beginning.
>>
>> > Andrew Gaffney wrote:
>> >> Amit Dor-Shifer wrote:
>> >>> Given the following:
>> >>> # qlist -Iv sys-apps/portage
>> >>> sys-apps/portage-2.1.4.5
>> >>>
>> >>> How do I safely extract the "2.1.4.5"?
>> >> That's probably offtopic for this list, since it really has nothing to
>> >> do with portage itself. However, you probably want something like:
>> >>
>> >> qlist -Iv sys-apps/portage | sed -e 's:^.*-([0-9][^-_]*).*$:1:'
>> >>
>>
>
>
>
 

Thread Tools




All times are GMT. The time now is 08:58 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org