tags:

views:

84

answers:

1

I added the following "Pre" section to my rpm installer's build.spec. When I install the rpm no new group or user is created?

If I paste this into a script and run, then it works as expected. What am I missing?

Thanks in advance,

-Ed

RHEL 5.2

#######################
# pre
#######################
%pre

# This works when run as a script by root.  Why not from the RPM?
if grep ^frontier: /etc/group >> /dev/null ; then
 : # group already exists
else
 %{_sbindir}/groupadd frontier -g 2000
fi

if ! id diagnostics >& /dev/null; then 
 %{_sbindir}/adduser diagnostics -g diaguser -d /home/diagnostics -u 2001 -p secretPassword
 usermod -a -G frontier diagnostics
fi
A: 

Use

%_sbindir/groupadd

instead of

%{_sbindir}

Check your RPMs after they build with something like mc, extract the pre script and you'll be able to check that your expansion works right.

In fact, %_sbindir is not needed there. If you take a look how RedHat built httpd....rpm you'll see they just use groupadd and useradd without the full path.

m1tk4
Thank you for your reply.I am not sure what you mean when you say "check that your expansion works right". Midnight Commander (mc) is a file manager correct? Is this similar to using Archive Manager by using it to open the rpm and browse the files it contains? My problem was I located the groupadd instructions in the wrong section. My build spec created a main package plus additional packages. I intended groupadd to be part of the additional packages but did not understand that I needed to append "-n myAdditionalPackage" to the %pre or %post section. Sorry for the dumb mistake.-Ed
Ed
expansion = macro expansion i.e. that %_sbindir is actually expanded to /usr/sbin/ in the scripts written into the RPM.mc is a file manager, and it I am guessing it is similar to the AM based on what you describe.
m1tk4