[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
Void's Forums • View topic - Identifying revs

Identifying revs

Discuss Programming

Identifying revs

Postby caveman » Sun Jun 19, 2005 1:51 pm

Hi.

Anybody have an algorithm to identify the version of an installed package?

eg. in most cases a dash followed by a number is the start of
the version eg. "abiword-2.2.8-1"
so looking for "-[0-9]" should give the start of the version "2.2.8-1"

but then some packages are installed as eg. "cdparanoia-alpha9.8-24"
so to above rule will give "24" as the version
or "widelands-b8-1.1.fc3.rf" will give "1.1.fc3.rf" as the version

enhancing the rule to include "-alpha[0-9]" and "-b[0-9]" might (NOT) be
ambigious?

Any help or place to go light a candle?

<edit>
I know it is possible to get the relevant info with the proper switches
to the program eg. rpm -qai or pkginfo -qi etc.
But unfortunatly the input is a file I receive and I have no control
over the contents.
</edit>
caveman
programmer
programmer
 
Posts: 130
Joined: Sun Feb 09, 2003 1:08 pm
Location: Midrand Gauteng, South Africa

Postby Void Main » Sun Jun 19, 2005 2:09 pm

I think you want to use the "--queryformat" parameter. For instance, if you do a regular query:

$ rpm -q sendmail

you get this:

sendmail-8.13.4-2

If you wanted the same thing using queryformat you would:

$ rpm -q sendmail --queryformat "%{NAME}-%{VERSION}-%{RELEASE}\n"

If you wanted just the version and release you would obviously:

$ rpm -q sendmail --queryformat "%{VERSION}-%{RELEASE}\n"

If you didn't want the carriage return at the end just take out the "\n".

By the way, there are a LOT more things you can query than just those few database items. Check out the list:

http://www.rpm.org/max-rpm/ch-queryformat-tags.html
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby caveman » Sun Jun 19, 2005 5:23 pm

Tx Void

Reckon I edited the post to late :oops:

like I said i know about and have used the queryformat etc.
but my problem is that I have no control over the content of the file
and so have to make do with some rules to pull the fields apart.
I get a similiar file for all the *nix boxes on site - and they all have
about the same layout.

To get the file content changed will involve a long winded explanation,
and i really don't feel like getting into that.
it is on the cards - but not for a long time at least. (depending on
how quickly we can actually change the clients' mind-set)
caveman
programmer
programmer
 
Posts: 130
Joined: Sun Feb 09, 2003 1:08 pm
Location: Midrand Gauteng, South Africa

Postby Void Main » Sun Jun 19, 2005 5:53 pm

I guess I just don't have enough information to compute. I'm not exactly sure what you are asking. If you could give me a sample and let me know how it needs to be used I can probably come up with an answer for you. I have had to do something similar to what I *think* you are asking using regular expressions in a script.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

a52dec-0.7.4-7.1.fc3.rf a52dec-devel-0.7.4-7.1.fc3.rf aali

Postby caveman » Sun Jun 19, 2005 8:25 pm

here goes

For each *nix machine I get a file with something like the following
####
a52dec-0.7.4-7.1.fc3.rf
a52dec-devel-0.7.4-7.1.fc3.rf
aalib-1.4.0-5.1.fc3.rf
abiword-2.2.8-1
abiword-plugins-impexp-2.2.8-1
.
.
####

This I have to check against a default control file for the type
of installation to see if the current version of the package is equal
or later to that in the control file.

The control file consists of 3 fields (which fortunatly I can set up) eg.
####
a52dec 0.7.4 7.1.fc3.rf
a52dec-devel 0.7.4 7.1.fc3.rf
aalib 1.4.0 5.1.fc3.rf
abiword 2.2.8 1
####

So I need to be able to split the input file into at least
the package base name and the version to be able to compare them.

Hope this makes sense :)
caveman
programmer
programmer
 
Posts: 130
Joined: Sun Feb 09, 2003 1:08 pm
Location: Midrand Gauteng, South Africa

Postby Void Main » Sun Jun 19, 2005 9:19 pm

User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron