1

I'm creating an RPM package (let's call it package A). I need to react if another package (package B) is reinstalled or updated. So I created a trigger inside package B specfile:

%triggerin -- B
#myscript

Unfortunately trigger is activated even when I install or update package A and package B is already in the system. I need to execute trigger code only if package A is installed and package B is reinstalled or updated. How can I differentiate between these two types of activation?

2 Answers 2

3

%triggerin gets executed after your RPM is installed if the target is already installed, and after the target gets installed while your RPM is installed

%triggerun gets executed before your RPM is uninstalled if the target is installed, and before the target gets uninstalled while your RPM is installed

%triggerpostun gets executed after the target is uninstalled while your RPM is installed, but does not run if your RPM is uninstalled

That said you could use %triggerin with a conditional to avoid executing the code when you install A. You could achieve this by assigning a value to a variable in the %pre section.

something like this:

%define install_ed %(rpm -qa | grep A)

%triggerin

if [ $install_ed ne "A" ]; then ...

I am not on a rpm based machine now so I cannot test the solution, but it should work

1
  • Great solution! I've already did it creating a temporary file in %pre, that I'm checking in %triggerin but using %define is far more elegant.
    – dulek
    May 15, 2014 at 10:43
0

Can you try checking for the %{installtime:date} in your trigger. Only do things if it is recent enough.

2
  • This is an ugly solution. If I will be forced to use something like that I rather create a temp file in preinst and don't run the code in trigger if file exist (and then delete the file). But I hope that there is more elegant solution.
    – dulek
    Apr 28, 2014 at 15:49
  • I agree with it being an ugly solution, I was just throwing an idea out there.
    – DavidGamba
    Apr 28, 2014 at 16:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .