Building RPM from binary files in tarball

Hi all,

Our devs have build tools that they want to have installed on all new machines that we roll out. All we (sysadmins) get is tarball containing “projectname” directory with thousands of binary/*.so files inside. Basically what is required is to extract this “projecname” directory into /usr/local/. That’s all rpm should do.
I’ve been killing myself for past 3 hours trying to accomplish this seemingly simple task… so please help me out.
What i gathered in spec file i do not need basically anything except %install part where i have to put untar (/usr/bin/tar xf source.tar) command.
This is my spec:
Name: projectname
Version: 2017_1
Release: %{?dist}
Summary: Project specific program
Group: prjectteam
License: Company
Source0: %{name}.tar.gz

%prep
%setup -n %{name}

%install
/usr/bin/tar xf %{name}.tar.gz -C /usr/local/

I get errors about not finding projectname.tar.gz… according to documentation %prep should actually decompress tarball, but i couldn’t figure out how can i put that extracted directory into the /usr/local/

Hi
The tarball is already extracted in %prep to your buildroot, so check this for all the files, then it would just be a copy to your install location;


%install
mkdir -p %{buildroot}/usr/local/lib
cp -ar *.so %{buildroot}/usr/local/lib/

%post /sbin/ldconfig

%postun /sbin/ldconfig

%files
%defattr(-,root,root,-)
%dir /usr/local/lib
/usr/local/lib/*.so

Change lib to your target directory as required and/or the cp to a directory if required.

thnx malcolmlewis… i have missed following:

%dir /usr/local/lib

I thought having only

%files
%defattr(-,root,root,-)
/usr/local/lib/

would be enough… looking at it now makes it very obvious.
thanks again.