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
scriptlets.
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
invoked.
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
like
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
hardly
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
scriptlet.
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
something)
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
here
https://lists.dulug.duke.edu/pipermail/rpm-maint/2008-July/
001054.html
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
scriptlets,
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
exports
at the beginning of the scriptlet to override $1 and $2 for legacy
compatibility,
meanwhile enhancing the information passed into envvar's.
There's the further wrinkle of non-shell scriptlets, like using lua
(which
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
weekend
unless I hear some other Newer! Better! Bestest! scheme for passing
information from rpm to scriptlet's.
Opinions?
73 de Jeff
Received on Mon Sep 22 22:55:59 2008