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 |
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 |
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 |
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:' |
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----- |
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. :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" 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----- |
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 |
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}' |
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:' >> |
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:' >> >> >> > > > |
| All times are GMT. The time now is 09:04 AM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.