RPM Spec File - %define into %pre section

Bruno Galindro da Costa bruno.galindro at gmail.com
Mon Aug 17 19:02:25 UTC 2009


Hi!
  I´m building a RPM package and I need to check if a user exists before
install the package. If user exists, the script will create him in the
system. Before I compile then, I´ve  tried to install it, but the following
error is displayed. Is this because I´ve putted a %define into the %pre
section? How can I define a variable that I can use on the %defattr
directive inside %pre section?

--------ERROR-----------
*# rpm -ivh noarch/BinName-1.2-4.noarch.rpm
Preparing...                ###########################################
[100%]
/var/tmp/rpm-tmp.47444: line 5: syntax error near unexpected token `fi'
/var/tmp/rpm-tmp.47444: line 5: `    fi'
error: %pre(BinName-1.2-4.noarch) scriptlet failed, exit status 2
error:   install: %pre scriptlet failed (2), skipping BinName-1.2-4*


------SPEC_FILE---------------
Summary: Bin Summary
Name: BinName
Version: 1.2
Release: 4
Source0: %{name}.sh
Source1: %{name}.conf
License: Commercial
Group: Applications/Databases
BuildArch: noarch

%description
Bin desc

%define oracle_group oinstall
%define script_path /opt/jobs/%{name}

%pre
if ! grep oracle /etc/passwd > /dev/null; then
   useradd -m -g %{oracle_group} oracle
else
*   %define oracle_group %(groups oracle |awk -F : '{print $2}' |awk '{print
$1}')*
fi

%install
mkdir -p %{script_path}
cp -pfv %{name}.sh %{name}.conf %{script_path}

%files
%defattr(0644,oracle,%{oracle_group})
%dir %{script_path}
%attr(0755,oracle,%{oracle_group})%{script_path}/%{name}.sh
%config %{script_path}/%{name}.conf



-- 
Att.
Bruno Galindro da Costa
bruno.galindro at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20090817/ed137fb1/attachment-0001.htm>


More information about the fedora-list mailing list