如何将 .tar.gz 文件打包成 rpm 包 [英] How to package a .tar.gz file into rpm package

查看:49
本文介绍了如何将 .tar.gz 文件打包成 rpm 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在 Redhat Linux 上工作过,我有一个 tar.gz 文件.我想把这个tar.gz文件打包成一个rpm包文件.
在rpm包阶段,我只是想解压tar.gz文件,把所有人员打包到rpm包中,当我在linux服务器上安装rpm包时,它只会简单地将所有文件复制到目标文件夹中.
我已经尝试了很多.这是我的 SPEC 文件的一些代码,但它有问题:


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

我可以成功打包rpm文件,但是rpm包中没有tar.gz文件的内容.
如果我在其他服务器上安装rpm文件,会失败.
我该如何解决这个问题?

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) 在 %{buildroot} 中找到的 rpmbuild 包文件.您需要通过从 %{_sourcdir} 复制或提取到 %{build root}/usr/local/sample

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) 你要打包的文件需要在%files manifest中提及

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

这篇关于如何将 .tar.gz 文件打包成 rpm 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆