On Sun, 31 Aug 2003, Steffen Barszus wrote:

> Hi !
> 
> I have a problem here. I tried to use the above mentioned macro. It 
> seems i fail to find the right syntax. 
> 
> I have tried 
> 
> %_pre_useradd vdr /var/lib/vdr
> 
> but that seems not to work. I had then a look at the rpm macros and the 
> user-helper script. 
> 
> Thats is the macro: 
> %_add_user_helper /usr/share/rpm-helper/add-user
> %_pre_useradd() %_add_user_helper %{name} $1 %{1} %{2} %{3} \
> %{nil}
> 
> I suppose %nil to be an empty string. But with that , the following 
> script would not work. 
> 
> if [ $# -lt 5 ]; then
>     echo "usage: $0 <pkg name> <num installed> <user name> <home dir> 
> <shell>" 1>&2
>     exit 1
> fi
> 
> pkg=$1                          # name of the package
> num=$2                          # number of packages installed
> name=$3                         # name of the user
> dir=$4                          # home directory
> shell=$5                        # shell
> 
> 
> 
> So shouldn't it be 
> 
> %_pre_useradd() %_add_user_helper %{name} $1 %{1} %{2} %{3} %{4} 
> 
> then ? 
> 
> Further I don't know which number i should give fro %{1}, i suppose from 
> reading rpm howto, that 1 is the right, as the user should only be 
> created if the package is installed the first time. Is this right ? 

$1 is supplied to all package scripts by rpm, and is the number of 
packages that will be installed at the end of the transaction, thus it is 
1 for new installation, 2 for upgrade (rpm first installes the new 
package, then removes any files from the old package) and 0 for removal.

%{1} etc are the arguments given to the macro. So in your case, vdr ends 
up being $name.

> 
> Sorry if this is just dump, i try hard to learn how all these things 
> work ;) 
> 

It helps to do 'rpm -qp --scripts mypackage.rpm' to see what rpm has done 
to the script (replacing the macros).

> Hope somebody could shed some light on this as it seems i can't get it 
> to work. 

It should work as you have it, otherwise maybe you need a 3rd argument 
(shell)?

Regards,
Buchan

-- 
|----------------Registered Linux User #182071-----------------|
Buchan Milne                Mechanical Engineer, Network Manager
Cellphone * Work            +27 82 472 2231 * +27 21 8828820x121
Stellenbosch Automotive Engineering         http://www.cae.co.za
GPG Key                   http://ranger.dnsalias.com/bgmilne.asc
1024D/60D204A7 2919 E232 5610 A038 87B1 72D6 AC92 BA50 60D2 04A7
*****************************************************************
Please click on http://www.cae.co.za/disclaimer.htm to read our
e-mail disclaimer or send an e-mail to [EMAIL PROTECTED] for a copy.
*****************************************************************

Reply via email to