fpm打包工具

版权归属原作者,原文转自:https://www.cnblogs.com/saneri/p/5265661.html

date:2018-10-12  18:48:25

 

支持的源类型包:

  •  dir: 将目录打包成所需要的类型,可以用于源码编译安装的软件包
  •  rpm: 对rpm进行转换
  •  gem: 对rubygem包进行转换
  •  python: 将Python模块打包成相应的类型

支持的目标类型包:

  • rpm: 转换为rpm包
  • deb: 转换为deb包
  • solaris: 转换为solaris包
  • puppet: 转换为puppet包

FPM的安装:

安装ruby环境和gem命令:

1
yum - y install ruby rubygems ruby - devel

gem命令是从rubygem仓库安装软件类似yum从yum仓库安装软件

 查看当前源:

1
2
3
[root@localhost~] # gem source list
* * * CURRENT SOURCES * * *
http: / / rubygems.org /

添加国内源:

1
[root@localhost~] # gem sources -a http://mirrors.aliyun.com/rubygems/

移除国外源:

1
[root@localhost~] # gem sources --remove http://rubygems.org/

安装FPM工具:

1
[root@localhost~] # gem install fpm
1
[root@loaclhost~] #sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf    //开启yum缓存

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

安装遇到问题:

1
2
3
4
5
6
7
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打包实例:

1.fpm打包Nginx

1
2
3
4
[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" }

2.fpm相对路径打包:

1
2
3
4
[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" }

3.使用fpm将生成包指定到/tmp下:

1
2
3
4
5
[root@bogon ~] # fpm -s dir -t rpm -n ansible-v 1.1.1.1 -d 'gcc,gcc+' -f ansible-p /tmp/
 
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 = > "/tmp/ansible-1.1.1.1-1.x86_64.rpm" }

查看rpm包信息:

1.查看rpm执行的脚本

1
2
3
4
[root@localhost opt] # rpm -qp --scripts nginx-1.6.1-1.x86_64.rpm       
postinstallscriptlet (using / bin / sh):
#!/bin/bash
useraddnginx - M - s / sbin / nologin

2.查看rpm包的依赖

1
2
3
4
5
[root@localhost opt] # rpm -qpR nginx-1.6.1-1.x86_64.rpm 
openssl - devel
/ bin / sh
rpmlib(PayloadFilesHavePrefix) < = 4.0 - 1
rpmlib(CompressedFileNames) < = 3.0 . 4 - 1

3.查看rpm包中的内容:

1
rpm - qpl zabbix - 3.0 - 1.x86_64 .rpm

镜像同步公网YUM源:

1
2
3
4
centos官方标准源:
rsync: / / mirrors.ustc.edu.cn / centos / 6 / os / x86_64 /
rsync: / / mirrors.ustc.edu.cn / centos / 6 / extras / x86_64 /
rsync: / / mirrors.ustc.edu.cn / centos / 6 / updates / x86_64 /

epel源:

1
rsync: / / mirrors.ustc.edu.cn / epel / 6 / x86_64 /

命令:reposync

转载于:https://www.cnblogs.com/kaishirenshi/p/9780156.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值