生活随笔
收集整理的這篇文章主要介紹了
Linux--轻松定义自己的RPM/DEB软件包
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
? ? ?[前言]?Linux管理員大多數(shù)時(shí)候都是通過(guò)源碼包編譯安裝軟件,在安裝過(guò)程中不斷的遇到問(wèn)題,不斷解決;為了從重復(fù)的編譯安裝操作中解脫,很多人都會(huì)選擇制作自己的RPM/DEB包,然后可以很方便的安裝,但是要制作RPM或者DEB包就不得不學(xué)習(xí)如何編寫(xiě)SPECS或debian控制文件,如何build。最近發(fā)現(xiàn)了FPM這個(gè)工具,它可以讓你省去閱讀漫長(zhǎng)的文檔時(shí)間,直接可以制作自己的軟件包。?
給感興趣的人:
RPM包制作:?http://www.rpm.org/max-rpm/??
DEB包制作:?http://www.debian.org/doc/manuals/maint-guide/
?
目錄:
1. FPM介紹
2. FPM安裝
3. 編譯安裝Mysql
4. FPM制作RPM/DEB包
5. FPM參數(shù)詳解
?
FPM介紹
FPM的作者是jordansissel?
關(guān)于FPM的介紹
https://docs.google.com/present/view?id=0Aa9liCTsAyzRZGNtd3dkOTRfMTdmczY2azlkcg&hl=en?
FPM功能簡(jiǎn)單說(shuō)就是將一種類型的包轉(zhuǎn)換成另一種類型。
支持的源類型包:“dir”:將目錄打包成所需要的類型,可以用于源碼編譯安裝的軟件包
“rpm”:對(duì)rpm進(jìn)行轉(zhuǎn)換
“gem”:對(duì)rubygem包進(jìn)行轉(zhuǎn)換
“python”:將python模塊打包成相應(yīng)的類型
支持的目標(biāo)類型包:
“rpm”:轉(zhuǎn)換為rpm包
“deb”:轉(zhuǎn)換為deb包
? ? ? ? ? ? ? ? ? “solaris”:轉(zhuǎn)換為solaris包
“puppet”:轉(zhuǎn)換為puppet模塊
這里主要介紹如何將源碼安裝的包轉(zhuǎn)換為RPM/DEB包,其他功能感興趣的可以試試。
?
FPM安裝
FPM的安裝非常簡(jiǎn)單,安裝FPM前需要先安裝ruby,rubygem
?
[root@client1?~]??Building?native?extensions.??This?could?take?a?while...?Successfully?installed?json-1.6.6?Successfully?installed?cabin-0.4.4?Successfully?installed?backports-2.3.0?Successfully?installed?arr-pm-0.0.7?Successfully?installed?clamp-0.3.1?Successfully?installed?fpm-0.4.6?6?gems?installed?Installing?ri?documentation?for?json-1.6.6...?Installing?ri?documentation?for?cabin-0.4.4...?Installing?ri?documentation?for?backports-2.3.0...?Installing?ri?documentation?for?arr-pm-0.0.7...?Installing?ri?documentation?for?clamp-0.3.1...?Installing?ri?documentation?for?fpm-0.4.6...?Installing?RDoc?documentation?for?json-1.6.6...?Installing?RDoc?documentation?for?cabin-0.4.4...?Installing?RDoc?documentation?for?backports-2.3.0...?Installing?RDoc?documentation?for?arr-pm-0.0.7...?Installing?RDoc?documentation?for?clamp-0.3.1...?Installing?RDoc?documentation?for?fpm-0.4.6...??
編譯安裝Mysql
下載mysql源碼包,下載地址:http://dev.mysql.com/downloads/
解壓源碼包:
[root@client1?tmp]?編譯安裝:
[root@client1?tmp]??[root@client1?mysql-5.1.41]??[root@client1?mysql-5.1.41]??[root@client1?mysql-5.1.41]??
安裝中遇到的錯(cuò)誤:
錯(cuò)誤一:
checking for termcap functions library... configure: error: No curses/termcap library found
是因?yàn)闆](méi)有安裝ncurses包導(dǎo)致的
[root@client1?mysql-5.1.41]??ncurses.x86_64???????????????????????5.7-3.20090208.el6????????@base/$releasever??ncurses-base.x86_64??????????????????5.7-3.20090208.el6????????@base/$releasever??ncurses-libs.x86_64??????????????????5.7-3.20090208.el6????????@base/$releasever??ncurses-devel.i686???????????????????5.7-3.20090208.el6????????base???????????????ncurses-devel.x86_64?????????????????5.7-3.20090208.el6????????base???????????????ncurses-libs.i686????????????????????5.7-3.20090208.el6????????base???????????????ncurses-static.x86_64????????????????5.7-3.20090208.el6????????base???????????????ncurses-term.x86_64??????????????????5.7-3.20090208.el6????????base???????????????php-pecl-ncurses.x86_64??????????????1.0.1-1.el6???????????????epel????[root@client1?mysql-5.1.41]??
報(bào)錯(cuò)二:
../depcomp: line 571: exec: g++: not found
錯(cuò)誤原因沒(méi)有安裝gcc-c++包
[root@client1?mysql-5.1.41]?報(bào)錯(cuò)三
./include/my_global.h:1099: 錯(cuò)誤:對(duì) C++ 內(nèi)建類型 ‘bool’ 的重聲明
這個(gè)錯(cuò)誤是因?yàn)橄?/congfigure 又裝的gcc-c++之后又make 導(dǎo)致的,解決方法是重新./configure,make,make install就可以恢復(fù)
?
FPM制作RPM/DEB包
開(kāi)始打包安裝好的mysql,并轉(zhuǎn)換為rpm包,命令如下,具體參數(shù)解釋在文章的最后:
[root@client1?mysql-5.1.41]??[root@client1?tmp]??/usr/lib/ruby/gems/1.8/gems/fpm-0.4.6/lib/fpm/package/deb.rb:19:?warning:?already?initialized?constant?SCRIPT_MAP??/usr/lib/ruby/gems/1.8/gems/fpm-0.4.6/lib/fpm/package/rpm.rb:23:?warning:?already?initialized?constant?DIGEST_ALGORITHM_MAP??/usr/lib/ruby/gems/1.8/gems/fpm-0.4.6/lib/fpm/package/rpm.rb:29:?warning:?already?initialized?constant?COMPRESSION_MAP??Executing(%prep):?/bin/sh?-e?/var/tmp/rpm-tmp.XPQ8av??Executing(%build):?/bin/sh?-e?/var/tmp/rpm-tmp.j4a8lh??Executing(%install):?/bin/sh?-e?/var/tmp/rpm-tmp.sH6nx3??Processing?files:?mysql_waydee-1.0-1.x86_64??Wrote:?/tmp/package-rpm-build20120413-13147-1by0r75/RPMS/x86_64/mysql_waydee-1.0-1.x86_64.rpm??Executing(%clean):?/bin/sh?-e?/var/tmp/rpm-tmp.9qzvuf??Created?rpm?{"path":"mysql_waydee-1.0-1.x86_64.rpm"}?查看制作的rpm包,并傳到另一臺(tái)服務(wù)器執(zhí)行安裝
[root@client1?tmp]??-rw-r--r--?1?root?root?24893316??4月?13?15:15?mysql_waydee-1.0-1.x86_64.rpm?使用rpm命令查看生成的rpm包文件
[root@client1?tmp]??/opt/mysql/bin/innochecksum??/opt/mysql/bin/msql2mysql??/opt/mysql/bin/my_print_defaults??/opt/mysql/bin/myisam_ftdump??/opt/mysql/bin/myisamchk??/opt/mysql/bin/myisamlog??/opt/mysql/bin/myisampack??/opt/mysql/bin/mysql??/opt/mysql/bin/mysql_client_test??/opt/mysql/bin/mysql_config?將生成的rpm包傳輸?shù)搅硗庖慌_(tái)測(cè)試服務(wù)器,并安裝
[root@client1?tmp]??The?authenticity?of?host?'192.168.2.102?(192.168.2.102)'?can't?be?established.??RSA?key?fingerprint?is?7d:96:53:c2:ba:f3:e6:7b:b2:d2:f9:b1:3e:48:9a:88.??Are?you?sure?you?want?to?continue?connecting?(yes/no)??yes??Warning:?Permanently?added?'192.168.2.102'?(RSA)?to?the?list?of?known?hosts.??root@192.168.2.102's?password:???mysql_waydee-1.0-1.x86_64.rpm??????????????????????????????????????????????????????????????????????????????????????????????????????????????????100%???24MB??23.7MB/s???00:01?????[root@client2?~]??Preparing...?????????????????????1:mysql_waydee????????????可以順利安裝,當(dāng)然在制作RPM包的時(shí)候可以增加想要的dependences,這個(gè)看個(gè)人要求。
下面是將安裝好的mysql包制作為DEB包,省去不少時(shí)間
[root@client1?tmp]??/usr/lib/ruby/gems/1.8/gems/fpm-0.4.6/lib/fpm/package/deb.rb:19:?warning:?already?initialized?constant?SCRIPT_MAP??/usr/lib/ruby/gems/1.8/gems/fpm-0.4.6/lib/fpm/package/rpm.rb:23:?warning:?already?initialized?constant?DIGEST_ALGORITHM_MAP??/usr/lib/ruby/gems/1.8/gems/fpm-0.4.6/lib/fpm/package/rpm.rb:29:?warning:?already?initialized?constant?COMPRESSION_MAP??Created?deb?package?{"path":"/tmp/mysql-waydee_1.0_amd64.deb"}?查看打包好的deb包
[root@client1?tmp]??-rw-r--r--?1?root?root?25185038??4月?13?15:17?mysql-waydee_1.0_amd64.deb??
FPM參數(shù)詳解
Usage:?fpm?[options]??-p,?--package?PACKAGEFILE????????管理的軟件包??-n,?--name?PACKAGENAME???????????定義生成的軟件包的名字??-v,?--version?VERSION????????????定義生成的軟件包的版本??????--iteration?ITERATION????????(可選)?為軟件包設(shè)置?iteration值?('release'?for?RPM).??????--epoch?EPOCH????????????????(可選)?為軟件包設(shè)置?epoch值??-d,?—depends?DEPENDENCY?????設(shè)置軟件包的依賴關(guān)系??????--category?SECTION_OR_GROUP??????--provides?PROVIDES??????--conflicts?CONFLICTS??????--replaces?REPLACES??????--config-files?PATH??????????(optional)?Treat?path?as?a?configuration?file.?Uses?conffiles?in?deb?or?%config???????????????????????????????????in?rpm.?(/etc/package.conf)??-a,?--architecture?ARCHITECTURE??-m,?--maintainer?MAINTAINER??-C?DIRECTORY????????????????????在搜索files前先進(jìn)入該目錄??-t?PACKAGE_TYPE?????????????????設(shè)置目標(biāo)包的類型??-s?SOURCE_TYPE???????????????????設(shè)置需要轉(zhuǎn)換的包類型??-S?PACKAGE_SUFFIX????????????????which?suffix?to?append?to?package?and?dependencies??????--prefix?PREFIX??????????????A?path?to?prefix?files?with?when?building?the?target?package.?This?may?not?be???????????????????????????????????necessary?for?all?source?types.?For?example,?the?'gem'?type?will?prefix?with???????????????????????????????????your?gem?directory?(gem?env?|?grep?-A1?PATHS:)??-e,?--edit???????????????????????Edit?the?specfile?before?building??-x,?--exclude?PATTERN????????????Exclude?paths?matching?pattern?(according?to?tar?--exclude)??????--post-install?SCRIPTPATH????Add?a?post-install?action.?This?script?will?be?included?in?the?resulting?package??????--pre-install?SCRIPTPATH?????Add?a?pre-install?action.?This?script?will?be?included?in?the?resulting?package??????--pre-uninstall?SCRIPTPATH???Add?a?pre-uninstall?action.?This?script?will?be?included?in?the?resulting?package??????--post-uninstall?SCRIPTPATH??Add?a?post-uninstall?action.?This?script?will?be?included?in?the?resulting?package??????--description?DESCRIPTION????Add?a?description?for?this?package.??????--url?URL????????????????????Add?a?url?for?this?package.??????--inputs?FILEPATH????????????The?path?to?a?file?containing?a?newline-separated?list?of?files?and?dirs?to?package.???????????????????????????????????Pass?-?as?the?only?argument?to?have?the?list?of?files?and?dirs?read?from?STDIN?(e.g.???????????????????????????????????fpm?-s?dir?-t?deb?-?<?FILELIST)??????--gem-bin-path?DIRECTORY?????(gem?source?only)?The?directory?to?install?gem?executables??????--gem-package-prefix?PREFIX??(gem?source?only)?Prefix?for?gem?packages??????--gem-gem?PATH_TO_GEM????????(gem?source?only)?The?path?to?the?'gem'?tool?(defaults?to?'gem'?and?searches???????????????????????????????????your?$PATH)??????--python-bin?PYTHON_BINARY_LOCATION???????????????????????????????????(python?source?only)?The?path?to?the?python?you?want?to?run.?Default?is?'python'??????--python-easyinstall?EASY_INSTALL_PATH???????????????????????????????????(python?source?only)?The?path?to?your?easy_install?tool.?Default?is?'easy_install'??????--python-pypi?PYPI_SERVER????(python?source?only)?PyPi?Server?uri?for?retrieving?packages.?Default???????????????????????????????????is?'http://pypi.python.org/simple'??????--python-package-prefix?PREFIX???????????????????????????????????(python?source?only)?Prefix?for?python?packages??????--deb-ignore-iteration-in-dependencies???????????????????????????????????(deb?target?only)?For?=?dependencies,?allow?iterations?on?the?specified???????????????????????????????????version.??Default?is?to?be?specific.??????--deb-pre-depends?DEPENDENCY?(deb?target?only)?Add?DEPENDENCY?as?Pre-Depends.??????--deb-custom-control?FILEPATH???????????????????????????????????(deb?target?only)?Custom?version?of?the?Debian?control?file.? 本文轉(zhuǎn)自 waydee 51CTO博客,原文鏈接:http://blog.51cto.com/waydee/834002,如需轉(zhuǎn)載請(qǐng)自行聯(lián)系原作者
總結(jié)
以上是生活随笔為你收集整理的Linux--轻松定义自己的RPM/DEB软件包的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。