-
把源码转换为rpm - rpm不能自定义,把源码转换为rpm
-
要求: -
- 安装rpm-build软件包
- [root@localhost ~]# yum -y install rpm-build
- [root@localhost ~]# rpmbuild -ba nginx.spec
错误:stat /root/nginx.spec 失败:没有那个文件或目录 - 在当前目录会生成一个rpmbuild目录,和6个子目录
- [root@localhost ~]# ls rpmbuild/
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS - SOURCES放置源码包,SPECS放配置文件,RPMS放生成结果
- 准备工作,将源码软件复制到SOURCES目录
- [root@localhost ~]# cp /opt/nginx-1.12.2.tar.gz rpmbuild/SOURCES/
-
- 创建并修改SPEC配置文件
- [root@localhost ~]# cd rpmbuild/SPECS/
[root@localhost SPECS]# vim nginx.spec 1 Name:nginx 2 Version: 1.12.2 3 Release: 1%{?dist} 4 Summary: This is a web server. 5 6 #Group: 7 License: GPL 8 URL: www.baidu.com 9 Source0: nginx-1.12.2.tar.gz 10 11 #BuildRequires: 12 #Requires: 13 14 %description 15 This is a web server toooo. name,version,source0,必填 17 %post 18 useradd -s /sbin/nologin nginx 19//脚本后添加nginx用户 20 %prep 21 %setup -q 22//自动解压源码包,并cd进入目录 23 24 %build 25 ./configure 26 make %{?_smp_mflags} 27 28 29 %install 30 make install DESTDIR=%{buildroot} 31 32 33 %files 34 %doc 35 /usr/local/nginx/* //打包nignx下的所有文件 -
- 使用rmpbuild创建rpm软件包
- [root@localhost SPECS]# rpmbuild -ba /root/rpmbuild/SPECS/nginx.spec
- [root@localhost x86_64]# ls
nginx-1.12.2-1.el7.x86_64.rpm nginx-debuginfo-1.12.2-1.el7.x86_64.rpm [root@localhost x86_64]# pwd /root/rpmbuild/RPMS/x86_64
|