Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to package a .tar.gz file into rpm package


I worked on Redhat Linux, I have a tar.gz file. I want to package this tar.gz file to a rpm package file.
In the rpm package phase, I just want to extract the tar.gz file and package all of the staff into the rpm package, when I install the rpm package in linux server, it will just simply copy all of the files into the destination folder.
I have tried a lot. Here goes some code for my SPEC file, but it has problems:

%prep

%build
pwd

%install

rm -rf /usr/local/sample
mkdir /usr/local/sample
cd %{_sourcedir}
tar -xzvf sample.tar.gz -C /usr/local/sample

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%doc

%changelog

I can successfully package the rpm file, but the rpm package didn't contains the content of the tar.gz file.
If I install the rpm file on other server, it will failed.
How can I fix this issue?

like image 845
FlurryWInd Avatar asked Sep 30 '22 00:09

FlurryWInd


1 Answers

THere are two problems:

1) rpmbuild packages files found in %{buildroot}. You need to populate that directory either by copying from %{_sourcdir}, or by extracting into %{build root}/usr/local/sample

2) the files you wish to be packaged need to be mentioned in the %files manifest

like image 62
Jeff Johnson Avatar answered Oct 05 '22 06:10

Jeff Johnson