以前打个rpm包尼玛太多的不容易,写SPEC文件写半天,还各种出错,今天同事给介绍了FPM可以打rpm包,并且可以把一个目录打成rpm包,很激动,尝试了一把:

一、FPM安装:

# FPM是Ruby模块yum -y install ruby rubygems ruby-devel# 添加淘宝的Ruby仓库gem sources -a http://ruby.taobao.org/# 移除原生的Ruby仓库gem sources --remove http://rubygems.org/# 安装fpmgem install fpm

二、把我已经编译好的mysql目录打成rpm包:

1、先说明一下,FPM打包路径是相对路径,这个我捣鼓半天才弄明白,比如,我打包这台机器编译好的mysql目录是在/usr/local/mysql下,如果你想让打出来的rpm包在其他机器上安装路径是/usr/local/mysql,那么你就:

fpm -f -s dir  -t rpm --epoch 5 --iteration 1.el6 -v 5.5.16 -n mysql_navy -C / -p /root --verbose --category 'Development/Languages'   --description 'navy mysql' --url 'kingsoft.com' --license 'BSD' -m 'navy' usr/local/mysql/

2、查看包信息:

[root@kingsoft-navy ~]# rpm -qpi mysql_navy-5.5.16-1.el6.x86_64.rpmName        : mysql_navy                   Relocations: /Version     : 5.5.16                            Vendor: root@kingsoft-navyRelease     : 1.el6                         Build Date: 2013年07月11日 星期四 08时36分01秒Install Date: (not installed)               Build Host: kingsoft-navyGroup       : Development/Languages         Source RPM: mysql_navy-5.5.16-1.el6.src.rpmSize        : 555461869                        License: BSDSignature   : (none)Packager    : navyURL         : kingsoft.comSummary     : mysqlDescription :navy mysql

3、在其他机器安装:

[root@kingsoft-navy ~]# rpm -ivh mysql_navy-5.5.16-1.el6.x86_64.rpmPreparing...                ########################################### [100%]1:mysql_navy             ########################################### [100%

6、查看安装的路径:

[root@kingsoft-navy ~]# rpm -ql mysql_navy | more/usr/local/mysql/COPYING/usr/local/mysql/INSTALL-BINARY/usr/local/mysql/README/usr/local/mysql/bin/innochecksum/usr/local/mysql/bin/msql2mysql/usr/local/mysql/bin/my_print_defaults/usr/local/mysql/bin/myisam_ftdump/usr/local/mysql/bin/myisamchk/usr/local/mysql/bin/myisamlog/usr/local/mysql/bin/myisampack/usr/local/mysql/bin/mysql/usr/local/mysql/bin/mysql_client_test/usr/local/mysql/bin/mysql_config/usr/local/mysql/bin/mysql_convert_table_format/usr/local/mysql/bin/mysql_find_rows/usr/local/mysql/bin/mysql_fix_extensions/usr/local/mysql/bin/mysql_secure_installation/usr/local/mysql/bin/mysql_setpermission/usr/local/mysql/bin/mysql_tzinfo_to_sql/usr/local/mysql/bin/mysql_upgrade/usr/local/mysql/bin/mysql_waitpid/usr/local/mysql/bin/mysql_zap/usr/local/mysql/bin/mysqlaccess/usr/local/mysql/bin/mysqlaccess.conf

OK,先到这来,以后在写如何如何把一个源码包打成rpm包。