ABS - the Arch Build System
翻译:xiaoma
Arch Build System(以下简称ABS)用于:
①制作新的软件包
②根据自己的需要定制软件包(使用enabling或disabling选项)
③用你自己的编译选项重新编译整个系统(就像gentoo一样了)
对于Arch Linux来说,ABS不是必须的,但很有用。
本文将简要介绍ABS及Arch的软件包,这不是一个完全参考指南!如果您想详细了解,您应该去读一读手册页。
1.安装软件包
使用ABS之前,你必须先安装cvsup及wget:
pacman -Sy cvsup wget
如果你已将软件包下载到一个名为foo的目录中:
cd foo
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz
2.什么是软件包文件?
a.一般地,软件包文件就是一个名如foo.pkg.tar.gz的文件。
b.实际上,软件包文件只是一个用gzip压缩的tar档,包含:
①需安装的文件
②.PKGINFO :包含pacman处理该软件包的所有信息,依赖关系等等
③.FILELIST :软件包中所有文件的列表,用来删除软件或检查文件冲突
④.INSTALL :存放在安装/升级/删除软件后执行的命令(只有在PKGBUILD中指定,才会有此文件)。
3.PKGBUILD是什么?它包含哪些内容?
PKGBUILD文件包含软件包有关的一些信息,它只是一个简单的纯文本文件。这儿有一个例子:
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $
# Maintainer: judd
# Contributor: Judd Vinet
pkgname=foo
pkgver=0.99
pkgrel=1
pkgdesc="short description of foo"
url="http://www.foo.org"
groups=
provides=
depends=('qt' 'python')
makedepends=('guile')
conflicts=('yafoo')
replaces=('mffoo')
backup=('/etc/foo/foo.conf')
install=('foo.install')
source=('http://www.foo.org/download/$pkgname-$pkgver.tar.gz')
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')
build() {
cd $startdir/src/$pkgname-$pkgver
./configure --prefix=/usr
make || return 1
make prefix=$startdir/pkg/usr install
}
以下是说明:
# :#后为注释
# $Id: PKGBUILD,v ... : 该软件包的cvs-tag(cvs标记),是由archlinux-cvs系统建立的。
# Maintainer : 维护者。维护者负责维护此软件包的官方版本。
# Contributor : 贡献人。为这个软件包写第一个PKGBUILD的人。
pkgname : 该软件包的名字。
pkgver : 该软件包的版本号。
pkgrel : Arch软件包的发布号。它与版本号是不同的,发布号随PKGBUILD的修改而改变。有很多原因导致修改PKGBUILD,例如,你可能会为打开compile-time支持而改变PKGBUILD。
pkgdesc : 该软件包的主要描述,这就是你在浏览软件包数据库(http://archlinux.org/packages.php)时所看到的。
url : 包中软件的主页(当你在浏览软件包数据库时,点击软件包名就进入包中的软件的主页)。
groups : 用于软件包组。例如,当你试图安装kde时,所有属于kde组的软件包都将被安装。
provides : 表示该软件包作为另一个软件包的补充。例如,kernel-scsi作为kernel的补充。
depends : 软件包的依赖关系(它需要哪些软件包)。
makedepends : 编译该软件包时才需要的包,一旦完成编译就不再需要了。
conflicts : 相冲突的包,这些包不能同时安装。本例中,foo与yafoo相冲突。
replaces : 该软件包所取代的旧包。本例中,foo取代了mffoo,并且不再提供对mffoo的支持。
backup : 当软件包被卸载时需备份的文件(备份后的文件加上.pacsave后缀,形如file.pacsave)。
install : 软件包中的安装脚本(必须与PKGBUILD在同一目录中)。
source : 软件包的下载地址,可以是本地、也可以是通过"http"或"ftp"访问的远程地址。软件包以pkgname和pkgver两个变量来命名,以免每次升级都要改变源码。
md5sums : 软件包的MD5校验和。
下面是函数的说明:
build : 建立软件包所需的所有步骤(下文将详细说明)。
现在,你可以发现PKGBUILD文件所包含的信息是软件包管理者所必须的,它是pacman与abs的核心。
还有安装脚本,上例中,PKGBUILD指定"foo.install"作为安装脚本。举例如下:
post_install() {
/bin/true
}
post_upgrade() {
/bin/true
}
pre_remove() {
/bin/true
}
op=$1
shift
$op $*
说明:
post_install : 这段脚本在文件安装后立即执行,它只有一个参数:软件包的版本。
post_upgrade : 这段脚本在所有文件升级后执行,它有两个参数:
①新的软件包的版本
②老的软件包的版本
pre_remove : 这段脚本在文件被删除之前执行(例如,停止一个守护进程),它也只有一个参数:软件包的版本
最后三行是每个安装脚本都必须的,因此,它们都会被执行。
4.build函数
如果你对建立软件包不太熟悉,你应该知道大多数(不是全部)软件包可以这样建立:
①源文件解压
tar -xzf foo-0.99.tar.gz
tar -xjf foo-0.99.tar.bz2
②进入源码目录
cd foo-0.99
③配置软件包 : 一般来说,源码目录中有一个名为configure的短小脚本文件,这就是用来配置软件包的(添加或删除支持信息,选择安装目的目录等等)。检查你的系统,确保已安装此软件所需的所有包,然后执行:
./configure [option]
在正式配置之前,你应该试试help选项,以便更好地理解如何配置:
./configure --help
④编译源码
make
⑤安装
make install
不论怎样,你都应该看看INSTALL文件,搞清软件应怎样配置和安装!并不所有的软件都可以configure; make; make install这样配置安装的!
那么,我们来看一看一个“标准的”build函数:
build() {
cd $startdir/src/$pkgname-$pkgver
./configure --prefix=/usr
make || return 1
make prefix=$startdir/pkg/usr install
}
我们所做的是:
①进入解压后的源码目录:
cd $startdir/src/$pkgname-$pkgver
但如果你尝试去建立自己的软件包,注意一定要进入正确的目录。有时,解压后的目录名是不同的:
tar -xzf foo-0.99.tar.gz
执行ls会返回:
.
..
foo-0.99.tar.gz
foo/
并不是
.
..
foo-0.99.tar.gz
foo-0.99/
②配置,安装目录为/usr:
./configure --prefix=/usr
③编译
make || return 1
④安装,不是在/usr中,而是在$startdir/pkg/usr目录中,这样,pacman就可以控制这些文件。
make prefix=$startdir/pkg/usr install
我们所要做的是建立软件包,而不是要安装它。所以,我们告诉make将所有文件放在我们指定的目录:$startdir/pkg/usr,而不是安装到标准位置/usr。这样,makepkg就可以查找并发现哪些文件是软件包要安装的,并将他们压缩进Arch软件包。
注意:有时Makefile中并没有prefix选项,通常使用DESTDIR代替。如果所生成的文件数明显少于应有的数目(译注:也就是说有文件已经被安装进你的系统),试试make DESTDIR=$startdir/pkg install。如果仍旧不行,你就必须仔细查找以“make <...> install”形式执行的install命令的参数。
5.The ABS tree
当你第一次运行abs命令时:
root @ localhost # abs
它将使用CVS,确保“the ABS tree(以下称为ABS树)”与arch服务器同步。那么,ABS树到底是什么?它位于/var/abs目录下,看起来如下图:
| -- base/
| |-- autoconf/
| |-- automake/
| |-- ...
| -- devel/
| -- ...
| -- extra/
| | -- deamons/
| | | -- acpid/
| | | | -- PKGBUILD
... ... ... ...
ABS树的结构与软件包数据库的结构精确地相同:
①第一级目录代表类别
②第二级目录代表软件包
③PKGBUILD文件包含软件包所需的所有信息
不管怎样,/var/abs下还有一个特定的目录:local,这个目录是你的。你可以在此目录中做任何事——但你不应该改变ABS树的其他部份。
注意:第一次下载的ABS树大一点,接下来就只需要下载升级的部份就可以了。所以即使你是用56k的小猫,也不必担心:这些只是文本文件,并且在传输过程中是被压缩的。
现在你知道什么是ABS树了,那我们怎么利用它呢?
6.第一次使用ABS:定制软件包
这种情况比你想到的要多得多:官方软件包编译的选项仅仅是--enable或--disable,并没有你所必需的选项。
举个例子:foo软件的arts支持被禁止了,假如我们要打开arts支持,可以按下面的方法来做:
①找到foo包
在http://archlinux.org/packages.php查找foo
使用find命令:
find /var/abs -name "foo"
使用slocate命令:
slocate foo | grep /var/abs
无论如何,你会发现foo是extra中multimedia的一部份(仅仅是举例)
②拷贝foo的PKGBUILD文件至/var/abs/local/foo:
mkdir /var/abs/local/foo
cp /var/abs/extra/multimedia/foo/PKGBUILD /var/abs/local/foo
cd /var/abs/local/foo
③修改PKGBUILD文件,加入我们需要的arts支持:
将
build() {
cd $startdir/src/$pkgname-$pkgver
./configure --prefix=/usr
make || return 1
make prefix=$startdir/pkg/usr install
}
改成
build() {
cd $startdir/src/$pkgname-$pkgver
./configure --enable-arts --prefix=/usr
make || return 1
make prefix=$startdir/pkg/usr install
}
④运行makepkg:
makepkg
⑤用下面的两条命令中的一条来安装(-A表示安装,-U表示升级已安装的软件包):
pacman -A foo-*.pkg.tar.gz
pacman -U foo-*.pkg.tar.gz
7.ABS的其他用途
WiKi上还有两篇文章,所述更深入:
* The Arch package making HOW-TO - with guidelines
* Custom local repository with ABS and gensync
评论
Jeremy Shockey Jersey
Unblocked around the end, DE ElvisDumervil had a bone-crunching sack of Brady late in the game They played him different to keep him in the pocket, and as a result, he got passing lanes he may not get in the pros I guess you could say New Wholesale NFL Jerseys England is smart for taking him, but they also waited until the fourth round, so a lot of teams passed on a great player and one of the best tight ends in the league in my opinionNewton came in needing 18 yards to break the record and did it with a 7-yard completion to Brandon LaFell on the game's first drive Their lawsuit isone of about a half-dozen suits filed against the NFL in recent months by pastplayers who say the league did not do enough to protect them from concussions
Tottenham's appeals for handball against Cole were waved away by referee Howard Webb"Really I don't want to get into any of the specifics CardinalsAndre Roberts, Cardinals Replica Cedric Benson Jersey at BengalsDeion Branch, Patriots vs Another starter, safety Husain Charles Woodson Jersey Abdullah, was placed on injured Authentic Charles Woodson Jersey reserve earlier this month due to lingering post-concussion symptomsTags: Giants-Jets, Numbers Never Live, Jeremy Shockey Jersey Michael Smith, Charissa ThompsonCountdown Daily Prediction: Giants-JetsCountdown Daily Prediction: Giants-JetsThe NFL Live crew makes their picks for the New York Giants at the New York JetsTags: Countdown Daily, NFL, prediction, picks, expert picks, playoffs, wild card, Giants, JetsPITTSBURGH -- Despite Ben Roethlisberger's mobility issues, coach Mike Tomlin said Tuesday he never considered pulling his quarterback late Monday night with the game against the 49ers seemingly out of reach
The Texans are much better than people realize, with a deceptively good defense, a punishing running attack and perhaps football's best offensive lineVeteran left tackle Chad Clifton returned to practice this week, but it's not clear when he'll be ready to play That should put them Authentic Pierre Thomas Jersey in a position to nab this kid and it will be a huge mistake if they do notIt was not from exhaustionThe ticket prices led to series organizers having difficulty selling outgames at the 54,000-seat Rogers Centre
As for the 2012 Pro Bowl, there were more than a few players, you could argue, in the NFC and AFC who got snubbed The results, though, havenot been the sameBut per the report, the school was "flexible” with the Vikings, reducing the original bill by a little Replica Carson Palmer Jersey more than $85,000 and recently "making Authentic Roman Harper Jersey a further reductionThe offense struggled mightily last week against New Orleans,recording six three-and-outs in 13 drives 5 seed
Sanchez vs The bottom line is I tell my players I'm Sugar Ray Robinson As for Colston, the guy has posted 100+ receiving yards in two of his last four starts and is coming off an impressive two touchdown performance against the Tennessee Titans in Week 14After consecutive wins over Carolina and Jacksonville, the Falcons had started to believe theycould go on an improbable playoff run from a wild-card positionthis season, just like the Green Bay Packers did last season They've overcome second-halfdeficits in all seven wins, gaining confidence as they've gone along
Romo is going to play and Felix Jones is going to play and we are going to have to beat them "It's not starting all over again In fact, he declined to take an opportunity to apologize Authentic Jeremy Shockey Jersey publicly to Dietrich-Smith Seattle Seahawks place Mike Williams on injured reserve RENTON, Wash'It's a Darren Sharper Jersey little bit crazy
6 percent of his passes for 1,924 yards, with 11 touchdowns and 10 interceptionsI've had 10-plus sack seasons Rookie CB Justin Rogers provided wholesale NFL Jerseys shop a spark on kickoff returns, but that's about it On the backwas the Replica DeSean Jackson Jersey name Eric LeGrand, a very small No Alamo Bowl: Baylor vs
8 million deal as a restricted freeagent, the fifth-year pro from Central Florida Pierre Thomas Jersey was charged with drunken drivingand fleeing the scene of an accident on Aug Pittsburgh likely needs to win this one to have a shot at Authentic Heath Miller Jersey the AFC North crown "And a lot of us know the feeling of watching the playoffs at Authentic Darren Sharper Jersey home"The Patriots also have Heath Miller Jersey a dangerous offensive threat to handle Authentic Danny Woodhead Jersey "This is the great thing about football
They do both and that's part of the Danny Woodhead Jersey problem; you don'tknow when you're going to get one thing or get another Ryan said he wasn't going to officially declare DeVito out yet4 yards per carry Right now, we're just glad Roman Harper Jersey he's OK and we'll continue to monitor him, evaluate him Three offensive linemen are on injured Replica Asante Samuel Jersey reserve, making it even tougher to get first downs, let alone touchdowns, and the top three cornerbacks are on injured reserve
Props to the Niners for the win and keeping their edge for the coveted No9 yards rushing per game, whichranks 13th in the league"Just to see the way that they're being coached to where it's not an individual player but a position is really good," Lynch said"That's not only classless but it's also small and beneath aplayer of Urlacher's caliber, something a kid says when he's angryhe lost a game to what he considers an inferior opponent