Posted on 2012-07-06 13:41
Milo的海域 阅读(405)
评论(0) 编辑 收藏 所属分类:
Linux
The scriptlets also take an argument, passed into them by the controlling rpmbuild process. This argument, accessed via $1 is the number of packages of this name which will be left on the system when the action completes, except for %pretrans and %posttrans which are always run with $1 as 0 (%pretrans and %posttrans are available in rpm 4.4 and later). So for the common case of install, upgrade, and uninstall we have:
| install | upgrade | uninstall |
%pretrans | $1 == 0 | $1 == 0 | (N/A) |
%pre | $1 == 1 | $1 == 2 | (N/A) |
%post | $1 == 1 | $1 == 2 | (N/A) |
%preun | (N/A) | $1 == 1 | $1 == 0 |
%postun | (N/A) | $1 == 1 | $1 == 0 |
%posttrans | $1 == 0 | $1 == 0 | (N/A) |
Scriptlets ordering
The scriptlets in %pre and %post are respectively run before and after a package is installed.
The scriptlets %preun and %postun are run before and after a package is uninstalled. The
scriptlets %pretrans and %posttrans are run at start and end of a transaction.
On upgrade, the scripts are run in the following order:
%pretrans of new package
%pre of new package
(package install)
%post of new package
%triggerin of other packages (set off by installing new package)
%triggerin of new package (if any are true)
%triggerun of old package (if it's set off by uninstalling the old package)
%triggerun of other packages (set off by uninstalling old package)
%preun of old package
(removal of old package)
%postun of old package
%triggerpostun of old package (if it's set off by uninstalling the old package)
%triggerpostun of other packages (if they're setu off by uninstalling the old package)
%posttrans of new package
For detail, will ref:
http://fedoraproject.org/wiki/Packaging:ScriptletSnippets