Scenario : There are 3 rpms A,B and C.
When we are installing rpm A we are installing rpm B and C as well.So first time installation is working fine.When we install a newer version of rpm A that's during upgradation we want to delete rpm B and C which were installed by previous rpm A.
Requirement : Before installing new rpm A, check if B and C are installed . If yes uninstall B and C.So that new rpm A can install new rpm B and C.
What we tried :
A's spec file %pre section:
%pre
if rpm -qa | grep B; then
rpm -e B;
fi
if rpm -qa | grep C; then
rpm -e C;
fi
We are using puppet. When we run puppet agent -t --debug, before installing rpm A it's getting hanged at below line!
Debug: Executing '/usr/bin/yum -d 0 -e 0 -y install A'
Any idea why we aren't able to uninstall those rpms?
Edit : Let me explain the proper scenario :
Its a legacy code where we are fixing an issue which happens during upgradation !
In puppet we have mentioned if we are installing rpm A, ensure rpm B and C are present.
Steps :
1. We upload rpm A,B and C to our puppet server.
2. Run puppet agent –t in our puppet client.
3. It installs all the rpms
4. Rpm A’s .spec file : in %pre section they are doing rm –rf /m/n/current and in %install section they are doing mkdir /m/n and extracting contents of rpm A in this folder.
5. Rpm B’s .spec file : in %install section they are doing mkdir /m/n/current/filesofBAndC and and extracting a file from rpm B in this folder
6. Rpm C’s .spec file : in %install section they are doing mkdir /m/n/current/filesofBAndC and and extracting a file from rpm C in this folder
7. Everything works fine in below scenarios
• First time installation
• Uninstalling rpm A and installing newer version of A (nothing but fresh installation)
• Upgrading A (there is version change in B and C )
8. Problem is if we are installing newer version of A(withough unistalling previous version of A) without any version change in rpm B and C, it’ll install only rpm A (since there are no version change in rpm B and C). During rpm A installation we are deleting folder /m/n/current which means our /m/n/current/filesofBAndC is also getting deleted.
Deletion of folder filesofBAndC is creating issue. So if we uninstall rpm B and C before installing rpm A, puppet will take care of installing those rpms again during installation of rpm A and/m/n/current/filesofBAndC will be created again with the required files.
We should not modify the folder structure ( like /m/n/filesofBAndC ) due to some dependencies.
%fileslist? Are you installing the files yourself (from a tarball or something that you list in%files)? Because that's a mistake too. That's not how this should work. Doing that is why you are having these problems. If you didn't do that you wouldn't need to play therm -rfgames in%preand packages wouldn't interfere with one another this way. Why does removing and reinstalling A work? Are you checking for upgrade of A before doing therm -rf? - Etan Reisner