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. :)
Created attachment 5180 [details] version The "version" script, to be placed (hopefully) in /usr/lib/portage/bin
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.
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.
we have `has_version` and `best_version` in ebuild.sh