Olivier,
Le 05/11/2011 16:19, Ned Slider a écrit :
On 05/11/11 14:40, Olivier BONHOMME wrote:
Rather than making the Requires specific to a package:
Requires(postun): fusiondirectory>= %{version}
try making it specific to the script that needs to be run. For example:
Requires(postun): /full/path/to/script.sh
Recently, I ran into a similar issue with package removal order, and solved it by using the method shown below. (My platform is RHEL 5.x / CentOS 5.x, using RPM version 4.4.2.3)
For each of the sub-packages, I included this in the sub-package header section:
Requires(postun): <Main-Package>
where <Main-Package> is the package name of the master. In the main package, I created a %postun section as below:
%postun exit 0
I placed a similar %postun section in the sub-packages:
%postun exit 0
These are basically "NOP" scripts, replace them with more code if your sub-package actually needs to do a post-uninstall stage. The sections do need to exist in the master and sub-packages to help RPM determine the dependencies properly.
To help debug the package removal process, use the following:
# rpm -e <Main-Package> -vv 2>&1 | tee destroy.log
This will turn on extra debugging output from rpm and capture it into a log file that you can view to see exactly how RPM is determining the order in which packages need to be removed. Look for something like this:
D: ========== tsorting packages (order, #predecessors, #succesors, tree, depth, breadth) D: 0 0 0 7 1 0 -MyPkg-util-1.0.2-2.i386 D: ========== successors only (0 bytes) D: 1 0 0 0 1 1 -MyPkg-1.0.2-2.i386 D: 2 0 0 1 1 2 -MyPkg-metro-1.0.2-2.i386 D: 3 0 0 2 1 3 -MyPkg-tomcat6-1.0.2-2.i386 D: 4 0 0 3 1 4 -MyPkg-api-1.0.2-2.i386 D: 5 0 0 4 1 5 -MyPkg-webapp-1.0.2-2.i386 D: 6 0 0 5 1 6 -MyPkg-default-1.0.2-2.i386 D: 7 0 0 6 1 7 -MyPkg-site1-1.0.2-2.i386
In my scenario, I have seven other sub-packages that depend on each other as well as the master package. As the MyPkg-site1 sub-package depends on the MyPkg, MyPkg-webapp, MyPkg-api, and MyPkg-tomcat6; I made sure to list all three of these packages in the Requires(postun): line in the MyPkg-site1 sub-package. The removal stage %preun for MyPkg-site1 depends on running a script which exists in the MyPkg master, so if the MyPkg master was removed, the MyPkg-site1 sub-package failed to properly uninstall (unless I used rpm -e --noscripts). Applying the steps above solved this and now the packages are removed in the correct order.
Refer to the RPM manual for more details on addressing package dependencies: http://www.rpm.org/max-rpm-snapshot/s1-rpm-depend-manual-dependencies.html
"RPM enforces the above dependencies _until_ the specified script has been run, not _at_ that time. In other words, it will allow erasing a dependency that was marked for eg. the %post script for an already installed package, but will not allow erasing one that is required for a %postun script for such a package."
rpm -i: %pre script runs -> installs files & dirs -> %post script runs rpm -e: %preun script runs -> removes files & dirs -> %postun script runs
Cheers!
Simba Engineering