Circa 2004-02-18 13:57:45 -0500 dixit Christoph Doerbeck a242369: : : Is it appropriate to use $1 in %post and %postun to determine : install/update vs. remove. : : The packages I've built have some different behavior based on whether : it is being upgraded or removed. I determined from sparse documentation : that $1 represents the remaining instances of the package at the completion : of the current operation. : : $1 = 0 (erase) : $1 = 1 (erase phase of upgrade/ install) : $1 = 2 (install phase of upgrade) : : This has tested successfully, but I'd like to know if this is a dependable : test.... Actually, for %pre, %preun, %post, and %postun scriptlets, the first argument to the scriptlet ($1 for /bin/sh) is the number of instances of the current package that will remain after the current operation is complete. That is: Scriptlet $1 is %pre, %post = 1 for a fresh install > 1 if a prior instance exists %preun, %postun = 0 if this is the last package > 0 if other instances exist Be careful not to test for equality to 2, because more than one instance of the package may already be installed. Generally, all you need is this: %post # This works for %pre as well if [ x"$1" = x"1" ]; then # No prior instance of this package exists. else # This is either an upgrade, or a multiple install. fi %preun # Works for %postun as well if [ x"$1" = x"0" ]; then # We're erasing the last instance of the package. else # This was an upgrade, or we're erasing one of multiple # package instances. fi This is explained in more detail with some examples in the dated but still relevant 'Maximum RPM' (in PostScript format, viewable with Ghostscript): http://www.rpm.org/ http://www.rpm.org/local/maximum-rpm.ps.gz Triggers get slightly more complicated; see the text documentation accompanying RPM about triggers for more info and examples. Good luck. -- jim knoble | jmknoble@xxxxxxxxx | http://www.pobox.com/~jmknoble/ (GnuPG fingerprint: 31C4:8AAC:F24E:A70C:4000::BBF4:289F:EAA8:1381:1491) ..................................................................... :"The methods now being used to merchandise the political candidate : : as though he were a deodorant positively guarantee the electorate : : against ever hearing the truth about anything." --Aldous Huxley : :...................................................................:
Attachment:
pgp00034.pgp
Description: PGP signature