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?
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
来源:https://stackoverflow.com/questions/27894553/how-to-package-a-tar-gz-file-into-rpm-package