I’m trying to check the version of an app, in this case openoffice.org. I am doing so by parsing a txt file that we dump the rpm database to. Here is the relevance I use to query the rpm txt file:
if (exists file “rpmtxtfile” whose (modification time of it < now - 2 * day)) and (exists line whose (it starts with “openoffice.org3-”) of file “rpmtxtfile”) then (((following text of firsts “openoffice.org3-” of lines whose (it contains “openoffice.org3-”) of file “rpmtxtfile”) as version) < (“3.2.1” as version)) else (exists package “openoffice.org3” whose (version of it < " of it) of rpm)
The issue I am having is that there are multiple instances of “openoffice.org3-” in the rpm txt file:
openoffice.org3-base-3.3.0-9567.x86_64
openoffice.org3-dict-fr-3.3.0-9567.x86_64
openoffice.org3-en-US-3.3.0-9567.x86_64
openoffice.org3-calc-3.3.0-9567.x86_64
openoffice.org3-3.3.0-9567.x86_64
q: following texts of firsts “openoffice.org3-” of lines whose (it contains “openoffice.org3-”) of file “rpmtxtfile” as version
a: base-3.3.0-9567.x86_64
What I need to have returned is the last value in the list: “openoffice.org3-3.3.0-9567.x86_64”, but more specifically, “3.3.0-9567.x86_64”
Any ideas on how to return the version information from the exact filename I need to use?
I’m looking for the instance without the -en, -calc, etc… And this is not the only example, so if there is a generic way to accomplish this, that would be great.
You might use regular expressions, but it gets tricky…
Can you rely on the fact that there are always two “-” in the lines that you want?
q: following texts of firsts “-” of lines whose (number of substrings “-” of it = 2) of file "C:\temp\test.txt"
A: 21.3-224.17.x86_64.rpm
A: 5.8.8-14.10.x86_64.rpm
I came up with this, but was concerned about other cases which might not work. If you let me know what result you get from running this, then we can try to tweak it a bit more. The ‘32bit’ part of one of the Perl entries made me have to rethink my initial strategy, but I found a way to work around it:
Q: (item 0 of it, preceding text of first “-” of item 1 of it, following text of first “-” of item 1 of it) of (it, preceding texts of firsts “.x86” of it) of lines whose(“0123456789” contains first 1 of following text of first “-” of it AND “0123456789” contains last 1 of preceding text of first “-” of following text of first “-” of it) of file “c:\temp\test\rpmfilelist.txt”