On 22 April 2010 22:18, Steve Thompson <smt at vgersoft.com>
wrote:> CentOS, RHEL, all versions.
>
> Suppose I am upgrading a package foo-1.0 to foo-2.0 (assume foo is not
> relocatable), and both packages have %preun sections in their .spec files.
> It appears that foo-1.0's %preun is run after foo-2.0 has been
installed.
> So what happens if foo-1.0 needs to run a binary that was provided as part
> of foo-1.0 during its %preun stage, and a binary of the same name is
> provided with foo-2.0? The installed binary is now foo-2.0's, right? So
> how to run foo-1.0's binaries during its %preun stage? Is the old
binary
> available under a different name before it gets erased?
>
> -steve
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
>
Correct...
the order in an upgrade is...
new %pre
new %install
new %post
old %preun
old %files removed
old %postun
Check the rpm spec documentation online for the specific details but
the four % scripts have a single argument supplied to them which you
can test. It is a numerical value equivalent to the number of times a
package appears in the RPM database after the package is
installed/erased at that point.
So on a fresh install....
%pre $1 = 1
%post $1 = 1
%preun and %postun unused
On an upgrade...
%pre $1 = 2
%post $1 = 2
%preun $1 = 1
%postun $1 = 1
On a remove....
%pre and %post not used
%preun $1 = 0
%postun $1 = 0
If you have an old package without tests and you are concerned that
the scripts will conflict with each other you can always do...
rpm -e --nodeps <pacakage>
rpm -i <package
That will remove and install in an order you might prefer for the
scripts until they are fixed...
See: http://www.rpm.org/max-rpm/s1-rpm-inside-scripts.html
James