Arch Build System: Unterschied zwischen den Versionen
Wtfoo (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Wtfoo (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
Zeile 6: | Zeile 6: | ||
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen | * Vorhande Pakete an die eigenen Bedürfnisse anzupassen | ||
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!) | * Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!) | ||
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich. | ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich. | ||
Zeile 79: | Zeile 80: | ||
* '''pkgver''' : Die Paketversion | * '''pkgver''' : Die Paketversion | ||
* '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion. | * '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion. | ||
* '''pkgdesc''' : | * '''pkgdesc''' : Eine Kurzbeschreibung des Paketes. Du siehst sie, in der [http://archlinux.org/packages.php Paket Datenbank] | ||
* '''arch''' : | * '''arch''' : Die Architekturen, auf denen das Paket kompiliert und getestet wurde. | ||
* '''url''' : | * '''url''' : Die Homepage des Programmes | ||
* '''groups''' : | * '''groups''' : Wird genutzt um Pakete zu Gruppen zusammen zu fassen. Wenn du z.B. KDE installieren willst, werden alle Pakete installiert, die zur Gruppe 'KDE' gehören | ||
* '''provides''' : | * '''provides''' : Wird genutzt, wenn das Paket ein anderes Paket enthält. z.B. enthält 'kernel-scsi' 'kernel' | ||
* '''depends''' : | * '''depends''' : Liste der Abhängigkeiten um das Programm auszuführen. | ||
* '''makedepends''' : | * '''makedepends''' : Liste der Abhängigkeiten um das Programm zu kompilieren. | ||
* '''conflicts''' : | * '''conflicts''' : Pakete, die nicht zusammen mit diesem Programm installiert sein können. In unserem Fall steht <i>foo</i> in Konflikt zu <i>yafoo (yet another foo)</i>. | ||
* '''replaces''' : the new package replaces the old one. Here, <i>mffoo (my first foo)</i> is no more supported and being replaced with <i>foo</i> | * '''replaces''' : the new package replaces the old one. Here, <i>mffoo (my first foo)</i> is no more supported and being replaced with <i>foo</i> | ||
* '''backup''' : which files to backup (as file.pacsave) when the package is removed | * '''backup''' : which files to backup (as file.pacsave) when the package is removed |
Version vom 8. August 2006, 17:20 Uhr
Einführung
Das Arch Build System (ABS) wird genutzt um:
- Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind
- Vorhande Pakete an die eigenen Bedürfnisse anzupassen
- Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.
Dieses How-To versucht dir eine Übersicht über ABS und Arch Pakete zu geben, es ist keine komplette Referenz! Wenn du mehr willst, solltest du einen Blick in die man-pages werfen.
Vorbereitung
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:
pacman -Sy cvsup wget
Oder, wenn du die Pakete z.B. im Ordner 'foo' gespeichert hast:
cd foo pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz
Was ist ein Paket ?
Ein Paket ist eine Datei, die meist foo.pkg.tar.gz genannt ist.
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:
- Die zu installierenden Dateien
- .PKGINFO : enthält alle Metadaten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.
- .FILELIST : enthält alle Dateien des Archives. Nötig um ein Paket zu deinstallieren oder um ggf. Abhängigkeitskonflikte festzustellen
- .INSTALL : enthält Befehle, die nach dem Installieren/Upgraden/Deinstallieren ausgeführt werden. (Nur vorhanden, wenn es in PKGBUILD definiert wurde)
Was ist PKGBUILD und was enthält es?
Wie schon gesagt, enthält PKGBUILD die Metadaten über ein Paket. Es ist eine einfache Textdatei, die z.B. so aussehen könnte:
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $ # Maintainer: judd <jvinet@zeroflux.org> # Contributor: Judd Vinet <jvinet@zeroflux.org> pkgname=foo pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10' pkgrel=1 pkgdesc="short description of foo" arch=(i686 x86_64) 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 }
Erklärung für jede Zeile:
- # text : Kommentare
- # $Id: PKGBUILD,v ... : Das CVS-Tag für dieses Paket (Vom Archlinux-CVS System erstellt).
- # Maintainer : Der Verantwortliche für dieses Paket in den offiziellen Repo's.
- # Contributor : Der Verfasser der ersten PKGBUILD für dieses Paket.
- pkgname : Der Paketname
- pkgver : Die Paketversion
- pkgrel : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion.
- pkgdesc : Eine Kurzbeschreibung des Paketes. Du siehst sie, in der Paket Datenbank
- arch : Die Architekturen, auf denen das Paket kompiliert und getestet wurde.
- url : Die Homepage des Programmes
- groups : Wird genutzt um Pakete zu Gruppen zusammen zu fassen. Wenn du z.B. KDE installieren willst, werden alle Pakete installiert, die zur Gruppe 'KDE' gehören
- provides : Wird genutzt, wenn das Paket ein anderes Paket enthält. z.B. enthält 'kernel-scsi' 'kernel'
- depends : Liste der Abhängigkeiten um das Programm auszuführen.
- makedepends : Liste der Abhängigkeiten um das Programm zu kompilieren.
- conflicts : Pakete, die nicht zusammen mit diesem Programm installiert sein können. In unserem Fall steht foo in Konflikt zu yafoo (yet another foo).
- replaces : the new package replaces the old one. Here, mffoo (my first foo) is no more supported and being replaced with foo
- backup : which files to backup (as file.pacsave) when the package is removed
- install : specifies a special install script that is to be included in the package (it has to be in the same directory as PKGBUILD)
- source : this specifies from where to download the package's source code. It can be a local package as well as a "http" of "ftp" one. It is named using pkgname and pkgver in order to avoid changing the source each time the version changes.
- md5sums : md5sums of the source to check their integrity
So now, let's explain the function :
- build : all the actions needed to build the package (it will be explained with more attention later in this document)
Well, you see that the PKGBUILD file contains all the information that might be needed by the package manager. It is the heart of pacman and abs.
There are also install files. This PKGBUILD specifies 'foo.install' as the package's install file. Here is an example install file:
post_install() { /bin/true } post_upgrade() { /bin/true } pre_remove() { /bin/true } op=$1 shift $op "$@"
Here are the function explainations :
- post_install : this script is run right after files are installed, it takes one argument :
- the package version
- post_upgrade : this script is run after all files have been upgraded, it takes two arguments :
- the new package version
- the old package version
- pre_remove : this script is run right before files are removed (stop a daemon for example) and takes one argument :
- the package version
The three lines at the bottom are needed in every install file so that they run properly.
The build function
If you're not familiar with building packages, you should know that most packages (but not all) can be built this way :
- uncompress the source file :
tar -xzf foo-0.99.tar.gz tar -xjf foo-0.99.tar.bz2
- enter the directory
cd foo-0.99
- configure the package : generally, there is a little script called
configure
in the source directory which is used to configure the package (add or remove support for things, choose the install destination, ...) and check that your computer has all the software needed by the package. it can be run by :
./configure [[option]]
You should first try the help to better understand how it works :
./configure --help
- compile the sources :
make
- install
make install
However, you should always read the INSTALL
file to know how the package should be built and install ! Not all packages use the configure; make; make install
system!
So let's take a look at a "standard" build function :
build() { cd $startdir/src/$pkgname-$pkgver ./configure --prefix=/usr make || return 1 make prefix=$startdir/pkg/usr install }
What we do is :
- enter the directory where sources were uncompressed :
cd $startdir/src/$pkgname-$pkgver
But if you try to build your package, be carefull that this is the right directory : sometimes the uncompressed directory might be named differently :
tar -xzf foo-0.99.tar.gz
and a ls
might return :
. .. foo-0.99.tar.gz foo/
and not :
. .. foo-0.99.tar.gz foo-0.99/
- configure the package, and tell it to install in the
/usr
directory :
./configure --prefix=/usr
- compile
make || return 1
- install the software but not in
/usr
, in$startdir/pkg/usr
so that pacman has control of the files.
make prefix=$startdir/pkg/usr install
What we want to do is build the package not to install it, so instead of installing to the standard place (/usr
), we tell make
to put all files in our special directory : $startdir/pkg/usr
. Thus, makepkg can look and see which files the package installs, and then compress them into the Arch package.
NOTE: It is sometimes the case where prefix
is not used in the Makefile
; often DESTDIR
is used instead. If the package is built with autoconf/automake, use DESTDIR
, this is what is documented in the manuals. Check if the generated filelist
is a lot shorter than it should be, and if so, try building with make DESTDIR=$startdir/pkg install
. If that does not work, you'll have to look further into the install commands that are executed by "make <...> install=
".
The ABS tree
When you run abs for the first time :
root @ localhost # abs
it synchronizes what can be called "the ABS tree" whith the arch server using the cvs system. So what exactly is the ABS tree ? It is located under /var/abs and looks like this :
|- | -- base/ |- | ||-- autoconf/ |- | ||-- automake/ |- | ||-- ... |- | -- devel/ |- | -- ... |- | -- extra/ |- | || -- deamons/ |- | || || -- acpid/ |- | || || || -- PKGBUILD ... ... ... ...
So the ABS tree has exactly the same structure as the package database :
- first level directory represent categories
- second level directories represent the packages
- PKGBUILD files contains every information needed concerning the package
However, there is one special directory : local. This directory is yours, this is where you'll do everything : you should never modify the rest of the tree.
NOTE: The first download of the abs tree is the biggest, then only minor updates are needed, so don't be afraid about the data to download if you've got only a 56k connection : it's only text files and it's compressed during the transfer
Now that you know what the ABS tree is, how can we use it ?
First use of ABS : customizing a package
This situation can arise more often than you may think : official packages are compiled choosing a certain number of --enable
or --disable
options, and these are not necessarily the ones you would have chosen.
To illustrate it, I'll take an example : foo The foo package is built with arts support disabled. Imagine that we want to enable arts. Here is how to do it :
- find where is the foo package located. you can do this by :
search for foo at [1] use the find command :
find /var/abs -name "foo"
use the slocate command :
slocate foo | grep ^/var/abs
In any case, you'll find that foo is part of extra
and multimedia
(for example)
- copy the foo
PKGBUILD
file to/var/abs/local/foo
mkdir /var/abs/local/foo cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo cd /var/abs/local/foo
- modify the
PKGBUILD
file : we'll add support for arts :
build() { cd $startdir/src/$pkgname-$pkgver ./configure --prefix=/usr make || return 1 make prefix=$startdir/pkg/usr install }
becomes :
build() { cd $startdir/src/$pkgname-$pkgver ./configure --enable-arts --prefix=/usr make || return 1 make prefix=$startdir/pkg/usr install }
- launch
makepkg
:
makepkg
- install the new package using one of the following commands (
-A
for install,-U
to upgrade an already installed package):
pacman -A foo-*.pkg.tar.gz pacman -U foo-*.pkg.tar.gz
Compiler Flags and Customizing makepkg
The configuration file for makepkg
is /etc/makepkg.conf
. Here you can set environment variables for gcc
and make
, as well as some for makepkg
itself. The following is an example of /etc/makepkg.conf
.
# The FTP/HTTP download utility that makepkg will use to acquire sources export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3" # Information passed to gcc about what type of computer this is. export CARCH="i686" export CHOST="i686-pc-linux-gnu" # Flags passed to gcc when a package is being compiled export CFLAGS "-march athlon-tbird -O2 -pipe" export CXXFLAGS "-march athlon-tbird -02 -pipe" # Flags passed to make when a package is being compiled export MAKEFLAGS="-j 2" # Enable colorized output messages export USE_COLOR="y" # The remaining variables only affect the behavior of makepkg # Enable fakeroot for building packages as a non-root user. # See 'man fakeroot' for more information on fakeroot export USE_FAKEROOT="y" # The directory where all packages will be placed (default is ./) export PKGDEST=/home/packages # Base of the ABS tree (default is /var/abs) export ABSROOT=/var/abs # Set this if you want your name to show up in the packages you build export PACKAGER="John Doe <nowhere@microsoft.com>"
A word of caution: Users should be sure of any changes they may make to the variables CFLAGS
, CXXFLAGS
, and MAKEFLAGS
as they can cause packages to be unstable or impossible to compile. Also, the average Arch Linux user will not need to change the values for CARCH
, CHOST
, and USE_FAKEROOT
.
References for gcc and make flags
Other uses of ABS
Well here are two more wiki pages, whose goal is to go deeper in ABS :