EVR comparison and how to sort them?

Farkas Levente lfarkas at lfarkas.org
Tue Dec 23 17:44:00 UTC 2008

Jos Vos wrote:
> On Tue, Dec 23, 2008 at 12:50:31PM +0100, Farkas Levente wrote:
>> i'd like to write an automated upgrade script to our packages and i'd
>> like to know how to retrieve and order EVR's from rpm. suppose i've got
>> packages with these EVRs:
>> 1.2.3
>> 1.2.4
>> 1.2.5
>> 1.3.0
>> 1.3.1
>> 1:1.4
>> 1:1.5
>> from each version to the next there is a given script which should have
>> to run (eg. update config files, database schemes etc) eg:
>> upgrade-1.2.3-1.2.4
>> upgrade-1.2.4-1.2.5
>> upgrade-1.2.5-1.3.0
>> ...
>> and there are many different server which runs different version of the
>> given packages. some of them 1.2.3 some of them 1.3.1 and 1:1.4 and now
> Do some systems have multiple versions installed at the same time?


>> i'd like to upgrade them to 1:1.5. so in 1:1.5's %post script i'd like
>> to run all upgrade-x.y.z-a.b.c script in the right order.
>> how can i do that?
>> - i'd like to know which was the previously installed version?
>> - i'd like to select those upgrade-x.y.z-a.b.c scripts which has to be run.
>> - i'd like to run them in the right order. and of course simple sort is
>> not enough what's more lexicographical order also not too useful.
>> is there any way how can i do that with rpm?
>> is there any tool which can help me? anything better then:
>> rpm -q --qf "%|SERIAL?{%{SERIAL}:}:{}|%{VERSION}-%{RELEASE}\n"
>> nobody else has the same problem so far? or everybody do this manually?
>> it can be done on a few server bug how can be done on hundreds of servers?
> Try something with trigger scripts:
> Add to your newest package:
> %triggerpostun -- %{name} = 1.2.3
> # run script (or include it here it it is small) upgrade-1.2.3-%{version}
> %triggerpostun -- %{name} = 1.2.4
> # run script (or include it here it it is small) upgrade-1.2.4-%{version}

in this case i'd have to write all update path combination (which i'd
not like to do:-) ie. upgrade-1.2.3-1.2.4 and upgrade-1.2.3-1.2.5 too:-(
ans since i now (at least hope) there is always only one version of each
packages in my case there no reason for triggerXYZ scripts over XYZ. or
do i misunderstood something?

  Levente                               "Si vis pacem para bellum!"

More information about the Rpm-list mailing list