RPM Community Forums

Mailing List Message of <rpm-devel>

Changing install scriptlet <=> rpm info passing

From: Jeff Johnson <n3npq@mac.com>
Date: Mon 22 Sep 2008 - 22:55:32 CEST
Message-id: <E78F3C07-ADE6-4BFD-8F7D-931ADA362A48@mac.com>
Now that triggers are starting to fire on file paths, its time
to address the other piece of the puzzle, how information
is passed to (and eventually from) install scriptlets.

Hysterically, rpm sets a few (not enough imho) envvar's
conventionally, and passes 2 (or more) arguments to

rpm has supported the ability to pass arguments
to scriptlets for quite some time with spec file syntax like

     %post -p "/sbin/ldconfig -n /usr/lib"

The interpreter is split into an argv array and the scriptlet is  

Unfortunately, the functionality interacts badly with $1 and $2, though
I suppose someone could use the functionality nonetheless.

The envvar's are ancient hysteria, with useless (but necessary)  
hardwired conventions
     export "PATH=%{_install_script_path}"
     export "RPM_INSTALL_PREFIX=/whatever
and the modern variant, exporting RPM_INSTALL_PREFIXn with the values
for multiple prefixes. Of course multiple prefixes forces one to  
investigate which
prefix ends up in what numerically named envvar, painful enough that  
anyone has used the mechanism.

But I've been asked twice in the last 2 weeks for better. One request  
is from Alexey,
who wants the directory name of a pattern match passed into the  

The other proposal suggests adding a 3rd (or 4th or 5th ...) argument to
be passed to scriptlets:

     ... A better option would be to leave that one argument as it,
     then add some additional arguments.  Something like this might  
be nice:

	$1 = Number of packages when done
	$2 = Number of packages when done FOR THIS ARCH ONLY.  This is at least
	much more useful on multilib platforms without getting into the
	complexity of the rest I have listed here.
	$3 = Install, Erase, Upgrade-Install (passed to the script that is the
	new package being installed during an upgrade), Upgrade-Erase  
(passed to
	any and all packages needing removed as part of an upgrade), Re-Install
	(although shouldn't get used as we currently don't run scripts on
	Re-Install, that's not to say that couldn't change in the future or

There's also a proposal to double the number of arguments in order to
pass arch neutral and per-arch package counts to scriptlets discussed


The original bug report is buried also in an ancient RedHat bugzilla  
bug against
rpm from <fitzsim@redhat.com>, I've lost track of the number.

None of the above schemes are particularly appealing imho.

What has worked for rpmbuild, and will likely work for install  
is adding a pre/post wrapper through a scriptlet template in order
to prepend envvar exports before a scritlet body.

If done carefully, the $1 and $2 convention can be done within the  
at the beginning of the scriptlet to override $1 and $2 for legacy  
meanwhile enhancing the information passed into envvar's.

There's the further wrinkle of non-shell scriptlets, like using lua  
has a persistent store shared by all lua invocations), or using other
interpreters like python or perl or ruby or ocaml or ...

I'm very likely to attempt templating for install scriptlets this  
unless I hear some other Newer! Better! Bestest! scheme for passing
information from rpm to scriptlet's.


73 de Jeff
Received on Mon Sep 22 22:55:59 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.