gentoo ebuild FUQ :-)

发表于:2007-05-26来源:作者:点击数: 标签:
这个FUQ=Gentoo Frequently Unanswered Questions(FUQ) 主要是受到这个页面的启发 http://gentoo.zhware.net/fuq.html 这里说得很杂,我只结合自己的使用说说portage系统的一些技巧。 0. 定位ebuild 基础知识,比如 $emerge -s gcal * app-misc/gcal Latest
这个FUQ=Gentoo Frequently Unanswered Questions(FUQ)

主要是受到这个页面的启发
http://gentoo.zhware.net/fuq.html
这里说得很杂,我只结合自己的使用说说portage系统的一些技巧。

0. 定位ebuild
基础知识,比如
$emerge -s gcal
* app-misc/gcal
Latest version available: 3.01
Latest version installed: [ Not Installed ]
Size of downloaded files: 2,315 kB
Homepage: http://www.gnu.org/software/gcal/gcal.html
Description: The GNU Calendar - a replacement for cal

那么gcal这个软件的ebuild就在/usr/portage/app-misc/gcal/下面
在这个目录下,一般能看到很多ebuild文件,分别对应不同版本号

1. 怎么继续前次的ebuild操作?
比如,emerge到一半,发现一个错误,你google/去论坛搜了一圈,找出了解决办法,难道非要从头开始么? 解决办法其实很多了,说几个最常用的
a. 使用clearcase/" target="_blank" >ccache
每个人都应该把它打开
emerge ccache之后,在/etc/make.conf里面
找到FEATURES设置,加上
FEATURES="ccache"
以及CCACHE_SIZE="2G"
默认好像是2G,我觉得如果硬盘空间足够,多多益善。
下次emerge的时候,你会发现编译的速度快了很多。这样间接起到了中断继续的效果。个人推荐这个方法,最简单。

b.继续make
emerge也就是一个用源码编译/安装的过程,而gnu make系统也保证了它实际上是可以"断点续传"的。而gentoo的portage系统在每次开始新的emerge的时候,会自己删掉以前的临时目录,重新生成,造成中断的emerge过程不可恢复。
你只要进入到临时目录,一般是
/var/tmp/portage/ebuild名称/work/ebuild名称/
下继续make,然后make install就行
不用怀疑,这样已经装好了。。但是,这样安装的软件包不会被记载在portage的world file里面。。所以,更优雅的办法是
0. 找到ebuild文件,比如abc-1.0.1.ebuild
1. ebuild abc-1.0.1.ebuild compile
2. ebuild abc-1.0.1.ebuild install
3. ebuild abc-1.0.1.ebuild qmerge

2. 作自己的ebuild
ebuild文件只是按照一定规律写的shell script而已,一般来说,它们是非常简单的(只限于100行以内条理清晰的 xfree的ebuild就是个很好的例外 ) 可以看看gentoo的ebuild guide,
http://www.gentoo.org/doc/en/gentoo-howto.xml
大概而言,只要知道
$A/$P等几个变量的含义就可以了。
从头写ebuild还是有点麻烦的,对于一个普通用户来说也没必要,但是
对于大多数软件的版本升级,你只要复制+改名+做digest就可以了
比如stardict最近出了2.2.1,但是ebuild只到2.2.0
代码:
fancyworld stardict # cp stardict-2.2.0.ebuild stardict-2.2.1.ebuild
fancyworld stardict # ebuild stardict-2.2.1.ebuild digest
>>> Downloading ftp://ftp.ussg.iu.edu/pub/linux/gentoo/distfiles/stardict-2.2.1.tar.bz2
--22:26:57-- ftp://ftp.ussg.iu.edu/pub/linux/gentoo/distfiles/stardict-2.2.1.tar.bz2
=> `/usr/portage/distfiles/stardict-2.2.1.tar.bz2'
Resolving ftp.ussg.iu.edu... done.
Connecting to ftp.ussg.iu.edu[129.79.6.12]:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD /pub/linux/gentoo/distfiles ... done.
==> PASV ... done. ==> RETR stardict-2.2.1.tar.bz2 ...
No such file `stardict-2.2.1.tar.bz2'.

>>> Downloading http://aleron.dl.sourceforge.net/sourceforge/stardict/stardict-2.2.1.tar.bz2
--22:26:58-- http://aleron.dl.sourceforge.net/sourceforge/stardict/stardict-2.2.1.tar.bz2
=> `/usr/portage/distfiles/stardict-2.2.1.tar.bz2'
Resolving aleron.dl.sourceforge.net... done.
Connecting to aleron.dl.sourceforge.net[204.157.3.229]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 608,829 [application/x-bzip2]

100%[====================================>] 608,829 144.56K/s ETA 00:00

22:28:02 (144.56 KB/s) - `/usr/portage/distfiles/stardict-2.2.1.tar.bz2' saved [608829/608829]

>>> Generating digest file...
<<< stardict-2.2.1.tar.bz2
>>> Generating manifest file...
<<< stardict-2.0.0.ebuild
<<< stardict-2.2.1.ebuild
<<< stardict-2.2.0.ebuild
<<< ChangeLog
<<< files/stardict-gentoo.patch
<<< files/stardict-config.sh
<<< files/digest-stardict-2.0.0
<<< files/digest-stardict-2.2.0
<<< files/digest-stardict-2.2.1
>>> Computed message digests.


然后试着emerge stardict-2.2.1.ebuild看看?

当然大多数时候,没有这么简单,可能会做一些小修改。我的标准步骤是
cp xxx.1.ebuild xxx.2.ebuild
ebuild xxx.2.ebuild digest
ebuild xxx.2.ebuild unpack
如果到这里一帆风顺,那么估计后面也没问题了,否则,仔细检查,看看是哪里出错了。出错的原因很多,但是一般都是因为几个变量的写法,或者是下载地址变 更,再就是老的ebuild里的patch,在新版本上无法使用。总之,看看ebuild guide,自己多熟悉一下,升级软件真的很简单。




_____________________________________
1600+/512M/250G/64M R8500/1702FP/Audigy2/HD-457

PM725/1024M/60G/128M R9600/WSXGA+/802.11g/Audigy2ZS/PXC-250

XP sp2/Gentoo Dual Boot on both

lucida离线中
回复时引用此帖 快速回复此帖
资 料:
注册会员
注册日期: Oct 2002
来自: .:DRL:.
帖子: 2,351
精华: 9
  向版主反映此帖   第 3 帖  
发帖时间: 03-07-01, 14:02


3. 加patch
做法有两种,参考前面提到的介绍
a. 在临时目录里面修改

从1.知道,临时文件在/var/tmp/portage/下面
以fontconfig 2.2.1+firefly的patch为例

代码:
fancyworld superkaramba # emerge -p fontconfig

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild N ] media-libs/fontconfig-2.2.0-r2

fancyworld superkaramba # cd /usr/portage/media-libs/fontconfig/
fancyworld fontconfig # ebuild fontconfig-2.2.1.ebuild unpack
fancyworld fontconfig # ebuild fontconfig-2.2.1.ebuild unpack
>>> md5 src_uri ;-) fontconfig-2.2.1.tar.gz
>>> Unpacking source...
>>> Unpacking fontconfig-2.2.1.tar.gz to /var/tmp/portage/fontconfig-2.2.1/work
* Applying fontconfig-2.1-slighthint.patch... [ ok ]
* Applying fontconfig-2.2-local_fontdir-r1.patch... [ ok ]
* Applying fontconfig-2.2-blacklist.patch... [ ok ]
* Applying fontconfig-2.2-remove_subpixel_test.patch... [ ok ]
>>> Source unpacked.
fancyworld fontconfig # cd /var/tmp/portage/fontconfig-2.2.1/work/fontconfig-2.2.1/
fancyworld fontconfig-2.2.1 # wget http://firefly.idv.tw/setfont-xft/p...-20030618.patch http://firefly.idv.tw/setfont-xft/p...030626.patch.gz http://firefly.idv.tw/setfont-xft/p...-20030617.patch

fancyworld fontconfig-2.2.1 # patch -p1 < fontconfig-2.2.1-fclang-miss_1_percent-20030617.patch
patching file src/fclang.c

.............

然后
fancyworld fontconfig-2.2.1 # ebuild /usr/portage/media-libs/fontconfig/fontconfig-2.2.1.ebuild merge

这个merge操作会保留临时目录,在这个基础上进行./configure, make, make install的动作

b. 修改ebuild

gentoo的portage系统恐怕是最适合patch 的包管理系统了
还是以上为例
fancyworld fontconfig-2.2.1 # cd /usr/portage/media-libs/fontconfig/files/
下载patch
fancyworld files # wget http://firefly.idv.tw/setfont-xft/p...-20030618.patch http://firefly.idv.tw/setfont-xft/p...030626.patch.gz http://firefly.idv.tw/setfont-xft/p...-20030617.patch
解压.gz(特例,因为这个patch太大了,所以firefly把它打包了一下)
gunzip fontconfig-2.2.1-include_CJK_charmaps-20030626.patch.gz
得到fontconfig-2.2.1-include_CJK_charmaps-20030626.patch
回到上一级,修改ebuild
fancyworld files # cd ..
fancyworld fontconfig # vi fontconfig-2.2.1.ebuild
可以看到
代码:
src_unpack() {
unpack $
cd $

local PPREFIX="$/patch/$"

# Some patches from Redhat
epatch $-2.1-slighthint.patch
# Add our local fontpaths (duh dont forget!)
epatch $-2.2-local_fontdir-r1.patch
# Blacklist some fonts that break fontconfig
epatch $-2.2-blacklist.patch
# Remove the subpixel test from local.conf (#12757)
epatch $-2.2-remove_subpixel_test.patch

# The date can be troublesome
sed -i "s:\`date\`::" configure
}


这里的$就等于 /usr/portage/media-libs/fontconfig/files/目录
$表示的是完整软件名+版本号,这里是fontconfig-2.2.1
$就只是单纯的软件名,这里是fontconfig
注意 epatch $-2.2-local_fontdir-r1.patch
和 firefly的patch部分冲突,把它去掉。
为了避免不必要的困扰,你的ebuild没有必要写的那么漂亮,所以,修改如下

src_unpack() {
unpack $
cd $

local PPREFIX="$/patch/$"

# Some patches from Redhat
epatch $-2.1-slighthint.patch
# Add our local fontpaths (duh dont forget!)
# epatch $-2.2-local_fontdir-r1.patch
# Blacklist some fonts that break fontconfig
epatch $-2.2-blacklist.patch
# Remove the subpixel test from local.conf (#12757)
epatch $-2.2-remove_subpixel_test.patch


# CJK font patch by firefly
epatch $/fontconfig-2.2.1-fclang-miss_1_percent-20030617.patch
epatch $/fontconfig-2.2.1-include_CJK_charmaps-20030626.patch
epatch $/fontconfig-2.2.1-multifamily-20030618.patch

# The date can be troublesome
sed -i "s:\`date\`::" configure
}

epatch是个eclass,它的特点就是屏蔽了patch的细节,让你无需考虑patch的参数问题。
最后直接emerge这个修改过的ebuild文件就行了。

这一部分说起来有点长,自己做一次就知道其实非常简单了。


原文转自:http://www.ltesting.net