FPM的github:https://github.com/jordansiss...html
1.支持的源类型包:python
dir: 将目录打包成所须要的类型,能够用于源码编译安装的软件包
rpm: 对rpm进行转换
gem: 对rubygem包进行转换
python: 将Python模块打包成相应的类型ios
yum install -y gcc yum -y install ruby rubygems ruby-devel rpm-build gem sources -a http://mirrors.aliyun.com/rubygems/ gem sources --remove http://mirrors.aliyun.com/rubygems/ gem sources --remove https://rubygems.org/ #fpm 是 ruby写的,所以系统环境须要ruby,且版本必须大于1.8.5
2.查看当前ruby源:nginx
root># gem sources -l *** CURRENT SOURCES *** http://mirrors.aliyun.com/rubygems/
3.安装FPM工具:git
# 安装fpm,gem从rubygem仓库安装软件相似yum从yum仓库安装软件。首先安装低版本的json,高版本的json须要ruby2.0以上,而后安装低版本的fpm,够用。 gem install json -v 1.8.3 gem install fpm -v 1.3.3 gpg2 --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3 curl -L get.rvm.io | bash -s stable source /etc/profile.d/rvm.sh rvm install 1.9.3 https://www.cnblogs.com/iosdev/p/3320671.html # 上面的2步安装仅适合CentOS6系统,CentOS7系统直接使用gem install fpm一步搞定。
4.FPM经常使用参数:github
-s:指定源类型 -t:指定目标类型,即想要制做为何包 -n:指定包的名字 -v:指定包的版本号 -C:指定打包的相对路径 -d:指定依赖于哪些包 -f:第二次包时目录下若是有同名安装包存在,则覆盖它 -p:输出的安装包的目录,不想放在当前目录下就须要指定 --post-install:软件包安装完成以后所要运行的脚本;同--offer-install --pre-install:软件包安装完成以前所要运行的脚本;同--before-install --post-uninstall:软件包卸载完成以后所要运行的脚本;同--offer-remove --pre-uninstall:软件包卸载完成以前所要运行的脚本;同—before-remove
5.定制nginx的RPM包实例json
一、在打包机器上先安装一次nginxvim
yum -y install pcre-developenssl-devel useradd nginx -M -s /sbin/nologin tar xf nginx-1.8.0.tar.gz cd nginx-1.8.0 ./configure --user=nginx --group=nginx --prefix=/application/nginx-1.8.0 --with-http_ssl_module--with-http_stub_status_module make && make install ln -s /application/nginx-1.8.0/application/nginx
二、编写脚本ruby
mkdir /server/scripts/ -p cd /server/scripts/
软件包卸载前、卸载后的脚本,能够根据状况是否编写,不编写问题也不大。可是rpm安装后的脚本是必须的。bash
vim nginx_post_install.sh #编写一个rpm安装后须要执行的脚本