【APP】简单制作RPM二进包实例
2012-07-17 15:13
525 查看
最近有好多朋友问到怎么制作rpm包,可不可把其它服务器上编译好的软件目录复杂到其它服务器上直接应用等等。。。这里做个简单的介绍,高级复杂的不会。。。
此方法是通过编写spec文件,使用rpmbuild来完成一个rpm的打包。以nginx为例进行介绍制作平台:centos 5.x X86_64四步走:第一步:建立目录结构mkdir /usr/src/redhat/{SOURCES,SPECS,BUILD,RPMS,SRPMS} -p相关目录介绍:/usr/src/redhat/SOURCES #存放源代码、补丁等文件
/usr/src/redhat/SPECS #存放用于管理rpm制作进程的spec文件
/usr/src/redhat/BUILD #解压后的文件存放目录
/usr/src/redhat/RPMS #存放由rpmbuild制作好的二进制包
/usr/src/redhat/SRPMS #存放由rpmbuild制作好的源码包
第二步:把源码包放在SOURCES目录下cd /usr/src/redhat/SOURCESwget http://nginx.org/download/nginx-1.2.0.tar.gz第三步:生成nginx.spec文件cd /usr/src/redhat/SPECS
cat nginx.spec
#
# spec file for nginx
# Build 2012-07-17
# By opsren
#
Summary: High performance web server
Name: Nginx
Version: 1.2
Release: 0.el5.ngx
License: 2-clause BSD-like license
Group: Applications/Server
Source: http://nginx.org/download/nginx-1.2.0.tar.gz
URL: http://nginx.org
Distribution: Centos/Redhat
Packager: qiuzhijun <250621008@qq.com>
%description
Nginx ("engine x") is a high performance HTTP and reverse proxy server, as well as a mail(IMAP/POP3/SMTP) proxy server.
%prep
tar zxf $RPM_SOURCE_DIR/nginx-1.2.0.tar.gz
%build
cd nginx-1.2.0
./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre --lock-path=/var/run/nginx.lock --pid-path=/var/run/nginx.pid
make
%install
cd nginx-1.2.0
make install
%preun
if [ -z "`ps aux | grep nginx | grep -v grep`" ];then
pkill nginx >/dev/null
exit 0
fi
%files
/usr/local/webserver/nginx
第四步:RPM包制作首先系统要安装好必备的制作工具:gcc、rpmbuild等yum -y install gcc rpm-build pcre-devel
cd /usr/src/redhat/SPECS/
rpmbuild -bb nginx.spec
通过上面这条命令,会在/usr/src/redhat/RPMS/x86_64/下面生成nginx-1.2.0-1.el5.ngx.x86_64.rpm这个文件-bb 这个选项就是制作二进制包(build binary package only from <specfile>)对spec文件内容进行简单说明:spec文件是制作rpm包的核心!以#开头的是注释信息;
Summary:对相关软件进行简单描述说明
Name:定义rpm包的名称
Version:定义软件的版本号
Release:发行版本
License:定义许可证
Group:说明软件属于哪种应用类型
Source:软件源码下载地址
URL:软件相关官方站点
Distribution: 发行版系列
Packager: 制作人的简单信息
%description:软件详细描述信息
%prep:软件编译之前的处理
%build:编译软件
%install:安装软件
%preun:定义卸载之前的动作
%files:指定要打包的软件包,这里是/usr/local/webserver/nginx
对于更详细的说明请参考官方资料:http://www.rpm.org/max-rpm/ch-rpm-inside.html下面是apache的spec文件实例:#
# spec file for apache
# Build 2012-07-17
# By opsren
#
Summary: High stability web server
Name: Apache
Version: 2.2
Release: 22.el5
License: 2-clause BSD-like license
Group: Applications/Server
Source: http://apache.etoak.com/httpd/httpd-2.2.22.tar.gz
URL: http://apache.org
Distribution: Centos/Redhat
Packager: qiuzhijun <250621008@qq.com>
%description
Apache is a first web server
%prep
tar zxf $RPM_SOURCE_DIR/httpd-2.2.22.tar.gz
%build
cd httpd-2.2.22
./configure --prefix=/usr/local/webserver/apache --enable-so --enable-deflate --enable-headers --enable-mods-shared=all --enable-rewrite
make
%install
cd httpd-2.2.22
make install
%preun
if [ -z "`ps aux | grep httpd | grep -v grep`" ];then
pkill httpd >/dev/null
exit 0
fi
%files
/usr/local/webserver/apache
以后对于相同或类似平台可以到其它服务器上进行rpm安装部署。另外还有一种rpm打包的方法:rpm_create这是一种新的打rpm的工具,不用spec语言,只需要会简单的shell命令,即可完成打包操作,非常方便,结合了spec语言和checkinstall,相比spec方法要简单很多!官方站点:http://code.google.com/p/rpmcreate/下载站点:wget http://rpmcreate.googlecode.com/files/rpm_create-1.7.5-9.x86_64.rpm大家可以去官方站点参考!
此方法是通过编写spec文件,使用rpmbuild来完成一个rpm的打包。以nginx为例进行介绍制作平台:centos 5.x X86_64四步走:第一步:建立目录结构mkdir /usr/src/redhat/{SOURCES,SPECS,BUILD,RPMS,SRPMS} -p相关目录介绍:/usr/src/redhat/SOURCES #存放源代码、补丁等文件
/usr/src/redhat/SPECS #存放用于管理rpm制作进程的spec文件
/usr/src/redhat/BUILD #解压后的文件存放目录
/usr/src/redhat/RPMS #存放由rpmbuild制作好的二进制包
/usr/src/redhat/SRPMS #存放由rpmbuild制作好的源码包
第二步:把源码包放在SOURCES目录下cd /usr/src/redhat/SOURCESwget http://nginx.org/download/nginx-1.2.0.tar.gz第三步:生成nginx.spec文件cd /usr/src/redhat/SPECS
cat nginx.spec
#
# spec file for nginx
# Build 2012-07-17
# By opsren
#
Summary: High performance web server
Name: Nginx
Version: 1.2
Release: 0.el5.ngx
License: 2-clause BSD-like license
Group: Applications/Server
Source: http://nginx.org/download/nginx-1.2.0.tar.gz
URL: http://nginx.org
Distribution: Centos/Redhat
Packager: qiuzhijun <250621008@qq.com>
%description
Nginx ("engine x") is a high performance HTTP and reverse proxy server, as well as a mail(IMAP/POP3/SMTP) proxy server.
%prep
tar zxf $RPM_SOURCE_DIR/nginx-1.2.0.tar.gz
%build
cd nginx-1.2.0
./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre --lock-path=/var/run/nginx.lock --pid-path=/var/run/nginx.pid
make
%install
cd nginx-1.2.0
make install
%preun
if [ -z "`ps aux | grep nginx | grep -v grep`" ];then
pkill nginx >/dev/null
exit 0
fi
%files
/usr/local/webserver/nginx
第四步:RPM包制作首先系统要安装好必备的制作工具:gcc、rpmbuild等yum -y install gcc rpm-build pcre-devel
cd /usr/src/redhat/SPECS/
rpmbuild -bb nginx.spec
通过上面这条命令,会在/usr/src/redhat/RPMS/x86_64/下面生成nginx-1.2.0-1.el5.ngx.x86_64.rpm这个文件-bb 这个选项就是制作二进制包(build binary package only from <specfile>)对spec文件内容进行简单说明:spec文件是制作rpm包的核心!以#开头的是注释信息;
Summary:对相关软件进行简单描述说明
Name:定义rpm包的名称
Version:定义软件的版本号
Release:发行版本
License:定义许可证
Group:说明软件属于哪种应用类型
Source:软件源码下载地址
URL:软件相关官方站点
Distribution: 发行版系列
Packager: 制作人的简单信息
%description:软件详细描述信息
%prep:软件编译之前的处理
%build:编译软件
%install:安装软件
%preun:定义卸载之前的动作
%files:指定要打包的软件包,这里是/usr/local/webserver/nginx
对于更详细的说明请参考官方资料:http://www.rpm.org/max-rpm/ch-rpm-inside.html下面是apache的spec文件实例:#
# spec file for apache
# Build 2012-07-17
# By opsren
#
Summary: High stability web server
Name: Apache
Version: 2.2
Release: 22.el5
License: 2-clause BSD-like license
Group: Applications/Server
Source: http://apache.etoak.com/httpd/httpd-2.2.22.tar.gz
URL: http://apache.org
Distribution: Centos/Redhat
Packager: qiuzhijun <250621008@qq.com>
%description
Apache is a first web server
%prep
tar zxf $RPM_SOURCE_DIR/httpd-2.2.22.tar.gz
%build
cd httpd-2.2.22
./configure --prefix=/usr/local/webserver/apache --enable-so --enable-deflate --enable-headers --enable-mods-shared=all --enable-rewrite
make
%install
cd httpd-2.2.22
make install
%preun
if [ -z "`ps aux | grep httpd | grep -v grep`" ];then
pkill httpd >/dev/null
exit 0
fi
%files
/usr/local/webserver/apache
以后对于相同或类似平台可以到其它服务器上进行rpm安装部署。另外还有一种rpm打包的方法:rpm_create这是一种新的打rpm的工具,不用spec语言,只需要会简单的shell命令,即可完成打包操作,非常方便,结合了spec语言和checkinstall,相比spec方法要简单很多!官方站点:http://code.google.com/p/rpmcreate/下载站点:wget http://rpmcreate.googlecode.com/files/rpm_create-1.7.5-9.x86_64.rpm大家可以去官方站点参考!
相关文章推荐
- 简单制作用手机app控制台灯开关
- rhel7 rpmbuild 制作二进制程序安装包(.rpm) 简单示例
- Hbuider制作app升级包的简单办法
- android如何制作出一个简单的聊天app
- Android中使用GridLayout网格布局来制作简单的计算器App
- salesforce 零基础学习(二十)简单APP制作
- 简单制作rpm包
- Android实现APP欢迎页面简单制作思路
- Hbuider制作app升级包的简单办法 (升级官方提供的案例)
- 制作APP?零编程积木式搭建,在应用公园就是真么简单
- 简单制作RPM二进包实例(转)
- rpm制作实例 简单打包
- 非常简单的linux下RPM包制作
- rpm制作实例 简单打包
- Android实现APP欢迎页面 - 简单制作思路
- 简单5步说清App软件在线开发、App制作多少钱?
- Hbuider制作app升级包的简单办法 (升级官方提供的案例)
- 如何使电商APP制作变得简单易懂,容易上手?
- 超简单APP图标制作
- 简单 RPM 包制作