fpm是一個(gè)ruby實(shí)現(xiàn)的對(duì)rpmbuild進(jìn)行封裝的打包工具,方便linux系統(tǒng)下定制軟件包管理,如下為Nginx打包示例供參考。
工具準(zhǔn)備
- 安裝fpm依賴包
yum -y install ruby-devel gcc make rpm-build rubygems
- 安裝fpm
gem install fpm
fpm --version
Nginx打包
-
準(zhǔn)備工作
安裝pcre和openssl包yum install pcre pcre-devel openssl openssl-devel
目錄準(zhǔn)備:
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安裝包后執(zhí)行腳本(可根據(jù)需求定制):
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 參數(shù)下目錄結(jié)構(gòu)為包實(shí)際安裝目錄瓶殃。
當(dāng)前目錄生成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