How to package a .tar.gz file into rpm package
Asked Answered
B

1

6


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?

Barong answered 12/1, 2015 at 2:32 Comment(0)
H
5

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

Holna answered 18/1, 2015 at 13:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.