支持的源類型包:python
支持的目標類型包:nginx
將源碼包打成rpm包:
開啓yum緩存c++
[root@db02 ~]# vim /etc/yum.conf keepcache=1
安裝fpmvim
fpm-1.3.3.x86_64.tar.gz
有epel源緩存
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
安裝fpm的依賴(ruby環境和gem命令)ruby
[root@db04 ~]# yum install -y ruby-devel rubygems
查看當前源app
[root@db04~]# gem source list *** CURRENT SOURCES *** http://rubygems.org/
添加華爲的ruby源工具
[root@db04 ~]# gem sources --add https://mirrors.huaweicloud.com/repository/rubygems/ [root@db04 ~]# gem source --list *** CURRENT SOURCES *** https://rubygems.org/ https://mirrors.huaweicloud.com/repository/rubygems/
移除國外源post
[root@db04 ~]# gem source --remove https://rubygems.org/ https://rubygems.org/ removed from sources
移動fpm安裝包,解壓ui
[root@db04 ~]# mv fpm-1.3.3.x86_64.tar.gz /server/tools/ [root@db04 ~]# cd /server/tools/ [root@db04 tools]# tar xf fpm-1.3.3.x86_64.tar.gz
安裝gem,以及依賴
[root@db04 tools]# gem install *.gem 11 gems installed [root@db04 tools]# yum install -y gcc-c++ gcc glibc zlib-devel pcre-devel openssl-devel automake
安裝遇到問題:
1.Need executable 'rpmbuild' to convert dir to rpm {:level=>:error} 解決方法: [root@localhost]``# yum install -y rpm-build 2.若是裏面有gcc make的錯誤. 解決方法: yum install -y gcc
FPM經常使用參數:
-s:指定源類型 -t:指定目標類型,即想要製做爲何包 -n:指定包的名字 -v:指定包的版本號 -C:指定打包的相對路徑 -d:指定依賴於哪些包 -f:第二次包時目錄下若是有同名安裝包存在,則覆蓋它 -p:輸出的安裝包的目錄,不想放在當前目錄下就須要指定 --post-install:軟件包安裝完成以後所要運行的腳本;同--offer-install --pre-install:軟件包安裝完成以前所要運行的腳本;同--before-install --post-uninstall:軟件包卸載完成以後所要運行的腳本;同--offer-remove --pre-uninstall:軟件包卸載完成以前所要運行的腳本;同—before-remove
fpm打包Nginx
[root@localhost opt]# fpm -s dir -t rpm -n nginx -v 1.6.1 -d 'pcre-devel,openssl-devel' --post-install /opt/nginx_rpm.sh -f /opt/nginx/ <br> no value for epoch is set, defaulting to nil {:level=>:warn} no value for epoch is set, defaulting to nil {:level=>:warn} Created package {:path=>"nginx-1.6.1-1.x86_64.rpm"}
fpm相對路徑打包
[root@localhost~]# fpm -s dir -t rpm -n opt -v 1.1.1.1 -d 'gcc,gcc+' -C ../opt/ no value for epoch is set, defaulting to nil {:level=>:warn} no value for epoch is set, defaulting to nil {:level=>:warn} Created package {:path=>"opt-1.1.1.1-1.x86_64.rpm"}
保存nignx的依賴包
[root@db04 tools]# mkdir /nginx [root@db04 tools]# find /var/cache/yum/ -name '*.rpm'|grep -v ruby|xargs cp -t /nginx/
解壓
[root@db04 ~]# tar xf nginx-1.16.0.tar.gz [root@db04 ~]# mkdir /app -p [root@db04 nginx-1.16.0]# ./configure --prefix=/app/nginx-1.16.0 [root@db04 nginx-1.16.0]# echo $? 0 [root@db04 nginx-1.16.0]# make && make install make[1]: Leaving directory `/root/nginx-1.16.0'