1.打包准备
有时候为了方便源码包的安装,和我们自己订制软件包的需求,我们会把一些源码包按照我们的需求来做成rpm包,当有了源码包就可以直接编译得到二进制安装包和其他任意包。spec file是制作rpm包最核心的部分,rpm包的制作就是根据spec file来实现的。在制作自定义rpm包的时候最好不要使用管理员进行,因为管理员权限过大,如果一个命令写错了,结果可能是灾难性的,而制件一个rpm包普通用户完全可以实现
1. 定义工作车间(可以通过rpmbuild --showrc | grep topdir查看当前的工作车间)
vim ~/.rpmmacros
%_topdir /root/myrpmbuild
wq!
2. 创建打包目录
mkdir -pv {BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
3. 安装打包工具
yum -y install rpm-build
2.打包过程(以nginx打包实例来说明打包过程)
1. 下载源码包到~/SOURCES
cd ~/myrpmbuild/SOURCES
wget http://nginx.org/download/nginx-1.8.1.tar.gz
2. 编写nginx启动脚本(nginx.init放到~/myrpmbuild/SOURCES)
1 | #!/bin/sh |
3. fastcgi(同上)
1 | fastcgi_params 参数 |
4. spec文件
1 | cd rpmbuild/SPECS/ |
rpmbuild -ba nginx.spec 表示既制作二进制包又制作src格式包`
6. 参考
- 本文作者: ChuLinx
- 本文链接: http://yoursite.com/2019/11/30/RpmBuild打包总结/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!