RPM Community Forums

Mailing List Message of <rpm-users>

Re: Finding out triggered package version

From: Jeff Johnson <n3npq@mac.com>
Date: Thu 15 Jul 2010 - 03:28:41 CEST
Message-id: <EAF3E4F2-E218-4C40-8646-47AA90960D36@mac.com>

On Jul 14, 2010, at 8:26 PM, Jefferson Ogata wrote:

> I'm trying to write a SPEC file for a package that will be triggered on kernel upgrades. Its trigger scriptlet will execute a script to install a kernel module. The script needs to know the version of the new kernel.
> 
> Is there any way for a trigger scriptlet to discover the version of the triggered package that is being installed?
> 

I'm gonna assume rpm-5.x behavior (because different than @rpm.org).

There is a means iirc (but I can't remember offhand which of these methods "works")

First try adding an env(1) call to the script that is being triggered. There
may (or may not) be an envvar that contains the name of the package that
caused the trigger to be run. That is the ancient traditional means
of passing info to scriptlet's, but has been replaced by macros instead.

Second try adding either
	%%dump
or
	echo "name: %%name"

Note the doubled %% which is needed to move macro
expansion from build -> install for the expansion.
If you don't double the %% character, the expansion
occurs while building which isn't what you are seeking.

rpm -qp --scripts foo*.rpm should show a single % character ready to be expanded
while installing in the trigger script.

The %%dump will be noisy, but should show everything that is defined
at the time the script is run. The other form assumes that per-package
macros like %name, %version, %epoch, %release are defined. But if they are
not defined (or defined incorrectly) then %dump will show what _IS_ defined.

Finally if all of the above fails, you can just run rpm --query.

The package that was just installed is what fired the trigger
script. Perhaps easiest to get the last package installed is
	rpm -qa --last | gead -n 1
but there's likely simpler if I thought a bit.

Its a little bit trickier to deduce some of the other trigger firings
using --query because for certain cases the header  hasn't been installed
or is already erased. But I don't know what type of trigger you are
attempting so I'll assume the trigger immediately after installation.

Ask if you have trouble (and tell me what version of rpm you use) and
I'll actually try and see what works.

hth

73 de Jeff
Received on Thu Jul 15 03:29:14 2010
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.