基于FPM构建企业RPM包
1、支持的源类型包
dir:将目录打包成需要的类型,可以用于源码编译安装的软件包
rpm:对rpm进行转换
gem:对rubygem包进行转换
python:将python模块打包成相应的类型
2、支持目标类包
rpm:转换为rpm包
deb:转换为deb包
solaris:转换为solaris包
puppet:转换为puppet包
3、FPM常用参数
-s:指定源类型
-t:指定目标类型,即想要制作什么包
-n:指定包的名字
-v:指定包的版本号
-C:指定打包的相对类型
-d:指定依赖于哪些包
-f:第二次打包时,如果目录下有同名的包,则覆盖
-p:制作的rpm安装包存放的路径,不想放在当前目录下就要指定路径
--post-install:软件包安装完成之后所要运行的脚本:同offer-install
--pre-install:软件包安装完成之前所要运行的脚本:同before-install
--post-uninstall:软件包卸载安装完成之后所要运行的脚本:同offer-remove
--pre-uninstall:软件包卸载安装完成之前所要运行的脚本:同before-remove
--prefix:制作好的rpm包默认安装路径
4、基于FPM构建企业RPM包
4.1搭建Epel Yum源
把epel-release-latest-7.noarch.rpm rz进来
[root@localhost ~]# rpm -ivh epel-release-latest-7.noarch.rpm
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mv a/CentOS-Base.repo CentOS-Media.repo ./
[root@localhost yum.repos.d]# ls
a CentOS-Base.repo CentOS-Media.repo epel.repo epel-testing.repo
[root@localhost ~]# gem install rubygems-update -v 2.3.0
[root@localhost ~]# gem update --system
[root@localhost ~]# gem sources -a http://mirrors.aliyun.com/rubygems/       //添加国内源
[root@localhost ~]# gem sources --remove https://rubygems.org/       //移除国外源
[root@localhost ~]# gem sources -l      /查看当前源
*** CURRENT SOURCES ***

http://mirrors.aliyun.com/rubygems/
[root@localhost ~]# gem install fpm      //安装fpm工具

4.2编写nginx脚本

vim nginx.sh

#!/bin/bash

#创建运行用户和组

useradd -M -s /sbin/nologin nginx

#创建链接文件

ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/

#指定测试网页

echo www.crushlinux.com > /usr/local/nginx/html/index.html

#起服务

nginx

4.3制作软件包

fpm -s dir -t rpm -n nginx -v (nginx版本号) -d 'pcre-devel,zlib-devel' -f --post-install /root/nginx.sh /usr/local/nginx/