Neale Ferguson píše v Čt 14. 10. 2010 v 10:34 -0500:
> 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).
you should add the account if "$1 == 1" and remove the account only if
"[ $1 == 0 ]" is true in the scriptlet, please see
https://fedoraproject.org/wiki/Packaging/ScriptletSnippets
https://fedoraproject.org/wiki/Packaging:UsersAndGroups
for more details and tricks
Dan
----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [email protected] 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/