Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-26 Thread Alec Warner
On Wed, Nov 26, 2008 at 3:13 AM, Amit Dor-Shifer <[EMAIL PROTECTED]> wrote:
> Is there syntax in eix  for querying: "is package X installed with a version
> X.Y or higher?"
> Amit

portageq has_version / 

>
> 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 ""
>> 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 ""
>>
>> 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:'
>> >>
>>
>
>
>


Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-26 Thread Brian Harring
On Tue, Nov 25, 2008 at 08:54:29PM -0800, Zac Medico wrote:
> 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. :p
> 
> 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"
> 
> real0m0.141s
> user0m0.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.

So.. eapi3 meanwhile?
~brian


pgpKSvBtWJRoM.pgp
Description: PGP signature


Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-26 Thread Amit Dor-Shifer
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 ""
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 ""

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:'
>>






Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-26 Thread Amit Dor-Shifer
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}'



  




Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-26 Thread Fabian Groffen
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



Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-25 Thread Zac Medico
-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. :p

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"

real0m0.141s
user0m0.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-



Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-25 Thread Ned Ludd
On Tue, 2008-11-25 at 16:31 -0800, Brian Harring wrote:
> On Tue, Nov 25, 2008 at 04:18:22PM -0800, 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. :p
> 
> Curious, does qatom handle use deps?  Slot deps?  Plans to add 
> repository deps (admittedly they've not landed)?

Nope. I'm sticking with EAPI=0 behaviorism's and the development of
those utils has pretty much stopped. Well I did slip in some :slot
handling a little while ago due to the syntax of the world file changing
a while back after being annoyed.

> The point of shifting it into portageq isn't speed based; it's to 
> transfer responsibility for atom parsing from multiple authorities 
> into a single one.

It's still a good idea to expend the functionality of portageq. But for
scripting from bash, reality wins as most everything python-portage
related falls a little short due to the sheer number of file i/o calls
python makes looking for files that might not pertain at all to the info
the user is after. Granted today it's a heck of a lot faster than it
used to be a few years ago when the loading problem was first noticed. 

> Besides, just because portageq is slow for heavy data ops doesn't mean 
> it's going to be slow for doing simple atom splitting.  Quick test 
> locally, cold cache pegs it at 3s- with minor use of snakeoil 
> demandload that's likely halvable.
> 
> ~brian


I'm all in favor of using the right tool for the task at hand whatever
that may be.




Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-25 Thread Brian Harring
On Tue, Nov 25, 2008 at 04:18:22PM -0800, 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. :p

Curious, does qatom handle use deps?  Slot deps?  Plans to add 
repository deps (admittedly they've not landed)?

The point of shifting it into portageq isn't speed based; it's to 
transfer responsibility for atom parsing from multiple authorities 
into a single one.

Besides, just because portageq is slow for heavy data ops doesn't mean 
it's going to be slow for doing simple atom splitting.  Quick test 
locally, cold cache pegs it at 3s- with minor use of snakeoil 
demandload that's likely halvable.

~brian


pgp3mI8uOPTxQ.pgp
Description: PGP signature


Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-25 Thread Ned Ludd

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. :p




-- 
Ned Ludd <[EMAIL PROTECTED]>
Gentoo Linux




Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-25 Thread Ned Ludd
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}'



-- 
Ned Ludd <[EMAIL PROTECTED]>
Gentoo Linux




Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-25 Thread Brian Harring
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


pgpxv73MMnzsm.pgp
Description: PGP signature


Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-25 Thread Andrew Gaffney

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 DeveloperCatalyst/Genkernel + Release Engineering Lead



Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-25 Thread René 'Necoro' Neumann
-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 ""
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 ""

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-



Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-25 Thread Amit Dor-Shifer

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:'





Re: [gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-25 Thread Andrew Gaffney

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 DeveloperCatalyst/Genkernel + Release Engineering Lead



[gentoo-portage-dev] How to extract the version/revision of an installed package?

2008-11-25 Thread Amit Dor-Shifer

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