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

守給你的承諾、 提交于 2019-12-21 20:00:12

问题



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?


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!