I believe you will have a variable $1 that will be equal to '2' in the %pre routine if doing an upgrade -- and 1 in the %postun.
Found the table below at: http://fedoraproject.org/wiki/Packaging/ScriptletSnippets 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) The table headings are off by one - can't seem to cut and paste it correctly.. the 2nd column is the install value, the 3rd the upgrade, the last the uninstall... Hope this helps - Scott Rohling On Thu, Oct 14, 2010 at 9:34 AM, Neale Ferguson <ne...@sinenomine.net>wrote: > I have built an RPM that during installation needs to add an entry to > /etc/passwd and /etc/group. This is easy to do using the %pre section: > > %pre > egrep -q "^njeanon" /etc/group; \ > if [ $? != 0 ]; then \ > groupadd nje 2>/dev/null; \ > groupadd njeanon 2>/dev/null; \ > useradd njeanon -g njeanon; \ > fi > > Similarly, when the RPM is being uninstalled I need to get rid of those > entries. Again, easily done with %postun: > > %postun > rm -rf %{nobodyhome} > userdel njeanon 2>/dev/null > groupdel njeanon 2>/dev/null > groupdel nje 2>/dev/null > > However, if I am upgrading using -Uhv then I get the %pre and %postun > sections run as part of the upgrade. This means that the work done in %pre > gets undone by %postun. If I was simply doing a rpm --erase I would be > satisfied but doing -U then this is not what I want. > > So my question is, how do I prevent -Uhv undoing the %pre work (to be > pedantique if it's doing an upgrade then the groupadds aren't issued > because > the check tells me the entries are already there). > > Neale > > ---------------------------------------------------------------------- > For LINUX-390 subscribe / signoff / archive access instructions, > send email to lists...@vm.marist.edu with the message: INFO LINUX-390 or > visit > http://www.marist.edu/htbin/wlvindex?LINUX-390 > ---------------------------------------------------------------------- > For more information on Linux on System z, visit > http://wiki.linuxvm.org/ > ---------------------------------------------------------------------- For LINUX-390 subscribe / signoff / archive access instructions, send email to lists...@vm.marist.edu with the message: INFO LINUX-390 or visit http://www.marist.edu/htbin/wlvindex?LINUX-390 ---------------------------------------------------------------------- For more information on Linux on System z, visit http://wiki.linuxvm.org/