Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 9910 - Checking versions in Ebuilds
Summary: Checking versions in Ebuilds
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Nicholas Jones (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-29 12:28 UTC by CJ Kucera
Modified: 2011-10-30 22:18 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
version (version,271 bytes, text/plain)
2002-10-29 12:29 UTC, CJ Kucera
Details
version v2 (version,267 bytes, text/plain)
2002-10-29 14:46 UTC, CJ Kucera
Details

Note You need to log in before you can comment on or make changes to this bug.
Description CJ Kucera 2002-10-29 12:28:00 UTC
I've run across a few instances where it would be very helpful to know which
versions of a package were installed, came across another such instance today,
and decided to do something about it.

I created a small Python script which takes one argument, and will return true
or false back to the shell depending on if the specified package exists.  I
called it "version," but obviously that's just semantics.  You can use the
standard Gentoo convention for version ranges, ie:

version ">=kdelibs-3.0"
version "<kde-base/kdelibs-3.0"
version ">=gcc-3.0"
version gcc

Etc.  That last one would just check for the presence of GCC in any version.  If
you're using any > or < characters, you'll have to either escape them or put 'em
in quotes.  I know a *lot* of packages check for GCC versions using very kludgy
methods; I feel this could clean up a lot of ebuilds.  The script is meant to be
put into /usr/lib/portage/bin, along with the rest of the utilities used in
ebuilds.  So you can do things like this in your ebuilds:

  version ">=gcc-3.0" && apply_gcc_3_patch()

Or whatnot.

As always, let me know what you think, and feel free to hack it up for your own
nefarious uses.  :)
Comment 1 CJ Kucera 2002-10-29 12:29:02 UTC
Created attachment 5180 [details]
version

The "version" script, to be placed (hopefully) in /usr/lib/portage/bin
Comment 2 CJ Kucera 2002-10-29 12:30:29 UTC
I just noticed that I used

  #!/usr/bin/env python

in the first line, instead of forcing the Python path.  Force of habit, see? 
That should probably get changed if this does make it in.
Comment 3 CJ Kucera 2002-10-29 14:46:23 UTC
Created attachment 5183 [details]
version v2

Okay, so I noticed that it should also probably return False when you don't
supply an argument, so I changed that plus the path-to-Python thing.
Comment 4 SpanKY gentoo-dev 2003-01-08 13:44:03 UTC
we have `has_version` and `best_version` in ebuild.sh