通过fpm将源码打包成rpm
【fpm】--需要ruby 1.8.7版本以上,这个是当一个软件通过源码形式安装好了之后在用fpm进行封装成rpm的
创新互联建站是一家专注于网站建设、成都网站制作与策划设计,岚山网站建设哪家好?创新互联建站做网站,专注于网站建设10年,网设计领域的专业建站公司;建站业务涵盖:岚山等地区。岚山做网站价格咨询:13518219792
直接去官网下载1.8.7版本以上的ruby源码包,然后安装
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7.tar.bz2
tar -xf ruby-1.8.7.tar.bz2
./configure && make && make install
ruby -v,看看版本信息对不对
#make的时候会出错:
make: *** [math.o] Error 1
修改math.c,把37行的define改成defined就行了,然后继续Make
【gem】--接下来安装gem
wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
解压后,进入目录,执行 ruby setup.rb 进行安装
gem update --system
# 添加淘宝的Ruby仓库
gem sources -a http://ruby.taobao.org/
# 移除原生的Ruby仓库
gem sources --remove http://rubygems.org/
# 安装fpm
gem install fpm
# gem sources -l
*** CURRENT SOURCES ***
http://ruby.taobao.org # 请确保只有 ruby.taobao.org
如果有其他url的话,则用remove把它移除
先说明一下,FPM打包路径是相对路径,这个我捣鼓半天才弄明白,比如,我打包这台机器编译好的MySQL目录是在/usr/local/mysql下,如果你想让打出来的rpm包在其他机器上安装路径是/usr/local/mysql,那么你就:
2.fpm的常用命令格式
$ fpm -s -t [options]
source type:dir,rpm,gem,python
target type:rpm,deb,solaris,puppet
常用的options:
-n 生成的package名字
-p 生成的package文件输出位置
-v 生成的package版本
-d 生成的package依赖于什么软件,通常为-d 'name' 或这 -d 'name > version'
-a 系统架构名称,如果是noarch则为'-a all' 或者 '-a native'
--description 软件包描述
--conflicts 与其他什么软件冲突
fpm -f -s dir -t rpm --epoch 5 --iteration 1.el6 -v 5.3.16 -n php_5.3 -C / -p /root --verbose --category 'Development/Languages' --description 'php-5.3' --url 'php.net' --license 'BSD' -m 'inbank' usr/local/php/
Setting from flags: category=Development/Languages {:level=>:info}
Setting from flags: description=navy mysql {:level=>:info}
Setting from flags: epoch=5 {:level=>:info}
Setting from flags: iteration=1.el6 {:level=>:info}
Setting from flags: license=BSD {:level=>:info}
Setting from flags: maintainer=navy {:level=>:info}
Setting from flags: name=php_5.3 {:level=>:info}
Setting from flags: url=kingsoft.com {:level=>:info}
Setting from flags: version=5.5.16 {:level=>:info}
Converting dir to rpm {:level=>:info}
Reading template {:level=>:info, :path=>"/usr/local/lib/ruby/gems/1.8/gems/fpm-0.4.39/templates/rpm.erb"}
Running rpmbuild {:level=>:info, :args=>["rpmbuild", "-bb", "--define", "buildroot /tmp/package-rpm-build20130712-23168-1i209n6/BUILD", "--define", "_topdir /tmp/package-rpm-build20130712-23168-1i209n6", "--define", "_sourcedir /tmp/package-rpm-build20130712-23168-1i209n6", "--define", "_rpmdir /tmp/package-rpm-build20130712-23168-1i209n6/RPMS", "/tmp/package-rpm-build20130712-23168-1i209n6/SPECS/php_5.3.spec"]}
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.74227 {:level=>:info}
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.74227 {:level=>:info}
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.74227 {:level=>:info}
Processing files: php_5.3-5.5.16-1.el6 {:level=>:info}
Wrote: /tmp/package-rpm-build20130712-23168-1i209n6/RPMS/x86_64/php_5.3-5.5.16-1.el6.x86_64.rpm {:level=>:info}
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.55341 {:level=>:info}
Created rpm {:path=>"/root"}
[root@client /]# ll /root/
[root@client /]# ll /root/ |grep php
-rw-r--r-- 1 root root 13512860 Jul 12 17:06 php_5.3-5.5.16-1.el6.x86_64.rpm
[root@client ~]# rpm -qpi php_5.3-5.3.36-1.el6.x86_64.rpm
Name : php_5.3 Relocations: /
Version : 5.3.36 Vendor: root@client
Release : 1.el6 Build Date: Fri 12 Jul 2013 06:16:48 PM CST
Install Date: (not installed) Build Host: client
Group : Development/Languages Source RPM: php_5.3-5.3.36-1.el6.src.rpm
Size : 46383231 License: BSD
Signature : (none)
Packager : inbank
URL : pp
Summary : php-5.3
Description :
php-5.3
【错误】
Need executable 'rpmbuild' to convert dir to rpm {:level=>:error}
--出现这种情况就是需要安装rpm-build
新闻标题:通过fpm将源码打包成rpm
文章地址:http://azwzsj.com/article/ghegpp.html