Re: EVR comparison and how to sort them?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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}

Try it on a test system and see what happens.  IIRC, these scripts
will be executed, even if the old version is removed in the same
transaction.

But if multiple old packages are wiped out, you don't know the order
(but you can do tricky things in the scripts, of course ;-), left as
an exercise to the reader...).

-- 
--    Jos Vos <jos@xxxxxx>
--    X/OS Experts in Open Systems BV   |   Phone: +31 20 6938364
--    Amsterdam, The Netherlands        |     Fax: +31 20 6948204
_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux