fpm是一个ruby实现的对rpmbuild进行封装的打包工具,方便linux系统下定制软件包管理,如下为Nginx打包示例供参考。
工具准备
- 安装fpm依赖包
yum -y install ruby-devel gcc make rpm-build rubygems
- 安装fpm
gem install fpm
fpm --version
Nginx打包
-
准备工作
安装pcre和openssl包yum install pcre pcre-devel openssl openssl-devel
目录准备:
mkdir -p /root/build/src
mkdir -p /root/install/opt
cd /root/build/src/
wget http://nginx.org/download/nginx-1.13.4.tar.gz安装nginx:
tar -xvf nginx-1.13.4.tar.gz
cd nginx-1.13.4
./configure --prefix=/root/install/opt/nginx
make && make install安装包后执行脚本(可根据需求定制):
cat /root/build/post-install.sh
#!/bin/bash
useradd nginx -M -s /sbin/nologin
chown nginx:nginx /opt/nginx -R
2.打包
fpm -s dir -t rpm -C /root/install -n nginx -v 1.13.4
--license BSD --url "https://www.nginx.com/"
--post-install /root/build/post-install.sh --iteration 1
--vendor "admin@gmail.com"
--description "Nginx v1.13.4 build in 2017/08/26"
-d "pcre,pcre-devel,openssl,openssl-devel"
注:fpm -C 参数下目录结构为包实际安装目录。
当前目录生成nginx-1.13.4-1.x86_64.rpm包
rpm -ivh nginx-1.13.4-1.x86_64.rpm
[root@centos7-linux build]# rpm -qa| grep nginx
nginx-1.13.4-1.x86_64
[root@centos7-linux build]# ll /opt/nginx/
total 4
drwxr-xr-x. 2 nginx nginx 4096 Aug 26 09:01 conf
drwxr-xr-x. 2 nginx nginx 40 Aug 26 09:01 html
drwxr-xr-x. 2 nginx nginx 6 Aug 26 09:00 logs
drwxr-xr-x. 2 nginx nginx 19 Aug 26 09:01 sbin
[root@centos7-linux ~]# rpm -qi nginx
Name : nginx
Version : 1.13.4
Release : 1
Architecture: x86_64
Install Date: Sat 26 Aug 2017 12:04:42 PM EDT
Group : default
Size : 3755485
License : BSD
Signature : (none)
Source RPM : nginx-1.13.4-1.src.rpm
Build Date : Sat 26 Aug 2017 12:03:55 PM EDT
Build Host : centos7-linux.shared
Relocations : /
Packager : root@centos7-linux.shared
Vendor : admin@gmail.com
URL : https://www.nginx.com/
Summary : Nginx v1.13.4 build in 2017/08/26
Description : Nginx v1.13.4 build in 2017/08/26
网友评论