https://wiki.archlinux.de/api.php?action=feedcontributions&user=Wtfoo&feedformat=atomwiki.archlinux.de - Benutzerbeiträge [de]2024-03-29T13:48:32ZBenutzerbeiträgeMediaWiki 1.41.0https://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1463Arch Build System2006-08-08T18:15:49Z<p>Wtfoo: /* Vorbereitung */</p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -S cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. im Verzeichnis 'foo' gespeichert hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meist ''foo''.pkg.tar.gz genannt ist.<br />
<br />
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:<br />
<br />
* Die zu installierenden Dateien<br />
<br />
*.PKGINFO : enthält alle Metadaten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.<br />
<br />
*.FILELIST : enthält alle Dateien des Archives. Nötig um ein Paket zu deinstallieren oder um ggf. Abhängigkeitskonflikte festzustellen<br />
<br />
*.INSTALL : enthält Befehle, die nach dem Installieren/Upgraden/Deinstallieren ausgeführt werden. (Nur vorhanden, wenn es in PKGBUILD definiert wurde)<br />
<br />
==== Was ist PKGBUILD und was enthält es? ====<br />
<br />
Wie schon gesagt, enthält PKGBUILD die Metadaten über ein Paket. Es ist eine einfache Textdatei, die z.B. so aussehen könnte:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Erklärung für jede Zeile:<br />
<br />
* '''# text''' : Kommentare<br />
* '''# $Id: PKGBUILD,v ...''' : Das CVS-Tag für dieses Paket (Vom Archlinux-CVS System erstellt).<br />
* '''# Maintainer''' : Der Verantwortliche für dieses Paket in den offiziellen Repo's.<br />
* '''# Contributor''' : Der Verfasser der ersten PKGBUILD für dieses Paket.<br />
* '''pkgname''' : Der Paketname<br />
* '''pkgver''' : Die Paketversion<br />
* '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion.<br />
* '''pkgdesc''' : Eine Kurzbeschreibung des Paketes. Du siehst sie, in der [http://archlinux.org/packages.php Paket Datenbank]<br />
* '''arch''' : Die Architekturen, auf denen das Paket kompiliert und getestet wurde.<br />
* '''url''' : Die Homepage des Programmes<br />
* '''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<br />
* '''provides''' : Wird genutzt, wenn das Paket ein anderes Paket enthält. z.B. enthält 'kernel-scsi' 'kernel'<br />
* '''depends''' : Liste der Abhängigkeiten um das Programm auszuführen.<br />
* '''makedepends''' : Liste der Abhängigkeiten um das Programm zu kompilieren.<br />
* '''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>. <br />
* '''replaces''' : Das neue Paket ersetzt das Alte. In unserem Fall wird <i>mffoo (my first foo)</i> nicht mehr unterstützt und wird durch <i>foo</i> ersetzt.<br />
* '''backup''' : Dateien, die gesichert werden (als .pacsave), wenn das Programm deinstalliert wird.<br />
* '''install''' : Spezifiziert ein Installationsskript, das im Paket enthalten ist. (Muss sich mit PKGBUILD im selben Verzeichnis befinden)<br />
* '''source''' : Die Bezugsquelle des Quelltextes. Kann sowohl ein lokales Paket, als auch ein remote "http" oder "ftp" Paket sein. Der Dateiname wird aus <i>pkgname</i> und <i>pkgver</i> erstellt, damit der Pfad nicht bei jeder neuen Version angepasst werden muss.<br />
* '''md5sums''' : MD5 Summen der Quelltexte um beschädigte Dateien auszuschließen.<br />
<br />
Nun die Funktionen:<br />
<br />
* build : Alle Schritte, die nötig sind um das Paket zu kompilieren. (Darauf gehen wir später besser ein).<br />
<br />
Wie du siehst enthält PKGBUILD alle Informationen die von der Paketverwaltung gebraucht werden könnten. Es ist das Herzstück von pacman und ABS.<br />
<br />
Es sind auch Installationsdateien vorhanden. Unser PKGBUILD gibt 'foo.install' als Installationsdatei an. Es könnte z.B. folgendes enthalten:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Erklärungen:<br />
<br />
* post_install : Wird nach der Installation ausgeführt. Es wird ein Argument übergeben:<br />
** Die Paketversion<br />
* post_upgrade : Wird ausgeführt, nachdem alle Dateien aktualisiert wurden <em> Es werden zwei Argumente übergeben</em>:<br />
** Die neue Paketversion<br />
** Die alte Paketversion<br />
* pre_remove : Wird ausgeführt, bevor Dateien gelöscht werden (beendet z.B. daemonen) und übergibt ein Argument:<br />
** Die Paketversion<br />
<br />
Damit die Installationsdateien funktionieren, müssen diese drei Zeilen am Ende jeder Installationsdatei vorhanden sein.<br />
<br />
==== Die build Funktion====<br />
<br />
Wenn du dich nicht mit dem Bauen von Paketen auskennst, solltest du wissen, dass die meisten Pakete über den 'Dreisatz' erstellt werden können:<br />
<br />
* Paketdateien dekomprimieren : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* In das Verzeichnis wechseln<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* configure (1/3): normalerweise ist ein kleines Script <code>configure</code> im Quelltextverzeichniss vorhanden. Es wird genutzt um das Paket zu konfigurieren (hinzufügen von Unterstützungen, Installationsverzeichnis festlegen, ...) und sicher zu stellen, dass alle Abhängigkeiten aufgelöst sind.<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
Du solltest zuerst einen Blick in die 'help' Option werfen:<br />
<br />
<pre>./configure --help</pre><br />
<br />
* make (2/3) : Kompilieren der Quelltexte<br />
<br />
<pre>make</pre><br />
<br />
* install (3/3)<br />
<br />
<pre>make install</pre><br />
<br />
Du solltest immer die <code>INSTALL</code> Datei lesen, um zu erfahren, wie das Paket erstellt und installiert werden sollte , denn nicht alle Pakete nutzen den Dreisatz 'configure; make; make install'!<br />
<br />
Schauen wir uns eine 'standart' build Funktion an :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Im Detail :<br />
* In das Verzeichnis der entpackten Quelltexte wechseln :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
* Konfigurieren des Paketes mit dem Installationsverzeichnis <code>/usr</code> :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* installiere das Programm nicht in <code>/usr</code> sondern in <code>$startdir/pkg/usr</code>, sodass pacman Kontrolle über die Dateien hat :<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
Wir wollen das Paket erstellen, aber nicht installiren, also installieren wir es nicht standartmäßig (<code>/usr</code>), sondern nach <code>$startdir/pkg/usr</code>. So kann makepkg sehen, welche Dateien das Paket installiert und daraus ein Arch Paket erstellen.<br />
<br />
'''BEACHTE''': Teilweise wird <code>prefix</code> nicht im <code>Makefile</code> genutzt; meist wird stattdessen <code>DESTDIR</code> verwendet. Wenn das Paket mit Hilfe von autofoo (autoconf/automake) erstellt wird, solltest du <code>DESTDIR</code> nutzen, denn so wird es in der [http://sources.redhat.com/automake/automake.html#Install Dokumentation] angegeben. Überprüfe, ob die generierte <code>filelist</code> um einiges kürzer ist, als sie sein sollte. Ist dies der Fall, versuche das Paket mit <code>make DESTDIR=$startdir/pkg install</code> zu erstellen.<br />
Fall auch das nicht funktioniert, wirst du dir die Befehle, die "<code>make <...> install=</code>" ausführt genauer anschauen müssen.<br />
<br />
==== Der ABS Verzeichnisbaum ====<br />
<br />
Wenn du abs das erste Mal nutzt :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
so synchronisierst du deinen "ABS Verzeichnisbaum" mit einem Arch Server über das CVS-System.<br />
Was genau ist der ABS Verzeichnisbaum? Er befindet sich in <code>/var/abs</code> und sieht so aus :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
Also ist der ABS Verzeichnisbaum genauso aufgebaut, wie die Paketdatenbank :<br />
* erste Verzeichnisebene: Kategorien<br />
* zweite Verzeichnisebene: Paketverzeichnisse<br />
* PKGBUILD Dateien mit Paketinformationen<br />
<br />
Allerdings gibt es ein spezielles Verzeichnis: '''local'''. Es ist ''dein'' Verzeichnis, in dem du Pakete erstellst, du solltest niemals etwas in den restlichen Verzeichnissen ändern.<br />
<br />
'''BEACHTE:''' Der erste Download des ABS Verzeichnisbaumes ist der größte, danach sind nur kleinere Updates nötig. Du brauchst auch mit kleinerer Bandbreite oder Volumentarif keine Angst haben : es sind nur Textdateien, die bei der Übertragung auch noch komprimiert sind.<br />
<br />
Nun weißt du, was der ABS Verzeichnisbaum ist, aber wie nutzt man ihn?<br />
<br />
==== Erste Verwendung von ABS : Anpassen von Paketen ====<br />
<br />
Diese Situation kann öfter erscheinen, als man meint : offizielle Pakete sind mit <code>--enable</code> oder <code>--disable</code> Optionen erstellt, die nicht deinen Anorderungen entsprechen.<br />
<br />
Nehmen wir als Beispiel : ''foo'' Das Paket ''foo'' wurde mit deaktivierte '''arts''' Unterstützung erstellt. Um '''arts''' Unterstützung zu aktivieren muss folgendes getan werden :<br />
<br />
* finde heraus, wo das Paket ''foo'' liegt :<br />
<br />
suche ''foo'' in [http://archlinux.org/packages.php]<br />
<br />
per ''find'' :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
per slocate :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In jedem Fall wirst du sehen, dass ''foo'' Bestandteil von <code>extra</code> und <code>multimedia</code> ist (Beispiel).<br />
<br />
* kopiere das ''foo'' <code>PKGBUILD</code> in dein Arbeitsverzeichnis <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* Anpassung des <code>PKGBUILD</code> : In unserem Fall '''arts''' Unterstützung :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
wird zu :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* Paket erstellen :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* Paket installieren (<code>-A</code> zum installieren, <code>-U</code>zum upgraden eines installierten Paketes):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Tuning: Compiler Flags und Anpassung von makepkg====<br />
<br />
Die Konfigurationsdatei von <code>makepkg</code> liegt in <code>/etc/makepkg.conf</code>. Hier kannst du Umgebungsvariablen sowohl für <code>gcc</code> und <code>make</code> als auch für <code>makepkg</code> selbst definieren. Hier eine Beispiel <code>/etc/makepkg.conf</code> :<br />
<br />
<pre><br />
# Das FTP/HTTP download Programm, das makepkg zum laden der Quelltexte nutzt<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Informationen für GCC über den Prozessortyp<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags für GCC, wenn ein Paket kompiliert wird<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags für make, wenn ein Paket kompiliert wird<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Aktiviere farbige Ausgabe<br />
export USE_COLOR="y"<br />
<br />
## Folgende Variablen betreffen nur makepkg<br />
<br />
# Aktiviere fakeroot um Pakete als normaler User zu erstellen<br />
export USE_FAKEROOT="y"<br />
<br />
# Das Verzeichnis, in dem das erstellte Paket erstellt wird (normalerweise ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Pfad zum ABS Verzeichnisbaum (normalerweise /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Aktiviere dies, um deinen Namen in erstellte Pakete zu schreiben<br />
export PACKAGER="John Doe <nowhere@devnull.com>"<br />
</pre><br />
<br />
'''BEACHTE:''' User wissen, was die Änderungen an den <code>CFLAGS, CXXFLAGS, MAKEFLAGS</code> Variablen bewirken, da sie Unstabilität oder Fehler bewirken können. Außerdem sollte der normale Arch Linux User die Werte für <code>CARCH</code> und <code>USE_FAKEROOT</code> nichtt ändern.<br />
<br />
Referenzen zu gcc und make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1462Arch Build System2006-08-08T18:07:42Z<p>Wtfoo: /* Other uses of ABS */</p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. im Verzeichnis 'foo' gespeichert hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meist ''foo''.pkg.tar.gz genannt ist.<br />
<br />
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:<br />
<br />
* Die zu installierenden Dateien<br />
<br />
*.PKGINFO : enthält alle Metadaten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.<br />
<br />
*.FILELIST : enthält alle Dateien des Archives. Nötig um ein Paket zu deinstallieren oder um ggf. Abhängigkeitskonflikte festzustellen<br />
<br />
*.INSTALL : enthält Befehle, die nach dem Installieren/Upgraden/Deinstallieren ausgeführt werden. (Nur vorhanden, wenn es in PKGBUILD definiert wurde)<br />
<br />
==== Was ist PKGBUILD und was enthält es? ====<br />
<br />
Wie schon gesagt, enthält PKGBUILD die Metadaten über ein Paket. Es ist eine einfache Textdatei, die z.B. so aussehen könnte:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Erklärung für jede Zeile:<br />
<br />
* '''# text''' : Kommentare<br />
* '''# $Id: PKGBUILD,v ...''' : Das CVS-Tag für dieses Paket (Vom Archlinux-CVS System erstellt).<br />
* '''# Maintainer''' : Der Verantwortliche für dieses Paket in den offiziellen Repo's.<br />
* '''# Contributor''' : Der Verfasser der ersten PKGBUILD für dieses Paket.<br />
* '''pkgname''' : Der Paketname<br />
* '''pkgver''' : Die Paketversion<br />
* '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion.<br />
* '''pkgdesc''' : Eine Kurzbeschreibung des Paketes. Du siehst sie, in der [http://archlinux.org/packages.php Paket Datenbank]<br />
* '''arch''' : Die Architekturen, auf denen das Paket kompiliert und getestet wurde.<br />
* '''url''' : Die Homepage des Programmes<br />
* '''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<br />
* '''provides''' : Wird genutzt, wenn das Paket ein anderes Paket enthält. z.B. enthält 'kernel-scsi' 'kernel'<br />
* '''depends''' : Liste der Abhängigkeiten um das Programm auszuführen.<br />
* '''makedepends''' : Liste der Abhängigkeiten um das Programm zu kompilieren.<br />
* '''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>. <br />
* '''replaces''' : Das neue Paket ersetzt das Alte. In unserem Fall wird <i>mffoo (my first foo)</i> nicht mehr unterstützt und wird durch <i>foo</i> ersetzt.<br />
* '''backup''' : Dateien, die gesichert werden (als .pacsave), wenn das Programm deinstalliert wird.<br />
* '''install''' : Spezifiziert ein Installationsskript, das im Paket enthalten ist. (Muss sich mit PKGBUILD im selben Verzeichnis befinden)<br />
* '''source''' : Die Bezugsquelle des Quelltextes. Kann sowohl ein lokales Paket, als auch ein remote "http" oder "ftp" Paket sein. Der Dateiname wird aus <i>pkgname</i> und <i>pkgver</i> erstellt, damit der Pfad nicht bei jeder neuen Version angepasst werden muss.<br />
* '''md5sums''' : MD5 Summen der Quelltexte um beschädigte Dateien auszuschließen.<br />
<br />
Nun die Funktionen:<br />
<br />
* build : Alle Schritte, die nötig sind um das Paket zu kompilieren. (Darauf gehen wir später besser ein).<br />
<br />
Wie du siehst enthält PKGBUILD alle Informationen die von der Paketverwaltung gebraucht werden könnten. Es ist das Herzstück von pacman und ABS.<br />
<br />
Es sind auch Installationsdateien vorhanden. Unser PKGBUILD gibt 'foo.install' als Installationsdatei an. Es könnte z.B. folgendes enthalten:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Erklärungen:<br />
<br />
* post_install : Wird nach der Installation ausgeführt. Es wird ein Argument übergeben:<br />
** Die Paketversion<br />
* post_upgrade : Wird ausgeführt, nachdem alle Dateien aktualisiert wurden <em> Es werden zwei Argumente übergeben</em>:<br />
** Die neue Paketversion<br />
** Die alte Paketversion<br />
* pre_remove : Wird ausgeführt, bevor Dateien gelöscht werden (beendet z.B. daemonen) und übergibt ein Argument:<br />
** Die Paketversion<br />
<br />
Damit die Installationsdateien funktionieren, müssen diese drei Zeilen am Ende jeder Installationsdatei vorhanden sein.<br />
<br />
==== Die build Funktion====<br />
<br />
Wenn du dich nicht mit dem Bauen von Paketen auskennst, solltest du wissen, dass die meisten Pakete über den 'Dreisatz' erstellt werden können:<br />
<br />
* Paketdateien dekomprimieren : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* In das Verzeichnis wechseln<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* configure (1/3): normalerweise ist ein kleines Script <code>configure</code> im Quelltextverzeichniss vorhanden. Es wird genutzt um das Paket zu konfigurieren (hinzufügen von Unterstützungen, Installationsverzeichnis festlegen, ...) und sicher zu stellen, dass alle Abhängigkeiten aufgelöst sind.<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
Du solltest zuerst einen Blick in die 'help' Option werfen:<br />
<br />
<pre>./configure --help</pre><br />
<br />
* make (2/3) : Kompilieren der Quelltexte<br />
<br />
<pre>make</pre><br />
<br />
* install (3/3)<br />
<br />
<pre>make install</pre><br />
<br />
Du solltest immer die <code>INSTALL</code> Datei lesen, um zu erfahren, wie das Paket erstellt und installiert werden sollte , denn nicht alle Pakete nutzen den Dreisatz 'configure; make; make install'!<br />
<br />
Schauen wir uns eine 'standart' build Funktion an :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Im Detail :<br />
* In das Verzeichnis der entpackten Quelltexte wechseln :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
* Konfigurieren des Paketes mit dem Installationsverzeichnis <code>/usr</code> :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* installiere das Programm nicht in <code>/usr</code> sondern in <code>$startdir/pkg/usr</code>, sodass pacman Kontrolle über die Dateien hat :<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
Wir wollen das Paket erstellen, aber nicht installiren, also installieren wir es nicht standartmäßig (<code>/usr</code>), sondern nach <code>$startdir/pkg/usr</code>. So kann makepkg sehen, welche Dateien das Paket installiert und daraus ein Arch Paket erstellen.<br />
<br />
'''BEACHTE''': Teilweise wird <code>prefix</code> nicht im <code>Makefile</code> genutzt; meist wird stattdessen <code>DESTDIR</code> verwendet. Wenn das Paket mit Hilfe von autofoo (autoconf/automake) erstellt wird, solltest du <code>DESTDIR</code> nutzen, denn so wird es in der [http://sources.redhat.com/automake/automake.html#Install Dokumentation] angegeben. Überprüfe, ob die generierte <code>filelist</code> um einiges kürzer ist, als sie sein sollte. Ist dies der Fall, versuche das Paket mit <code>make DESTDIR=$startdir/pkg install</code> zu erstellen.<br />
Fall auch das nicht funktioniert, wirst du dir die Befehle, die "<code>make <...> install=</code>" ausführt genauer anschauen müssen.<br />
<br />
==== Der ABS Verzeichnisbaum ====<br />
<br />
Wenn du abs das erste Mal nutzt :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
so synchronisierst du deinen "ABS Verzeichnisbaum" mit einem Arch Server über das CVS-System.<br />
Was genau ist der ABS Verzeichnisbaum? Er befindet sich in <code>/var/abs</code> und sieht so aus :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
Also ist der ABS Verzeichnisbaum genauso aufgebaut, wie die Paketdatenbank :<br />
* erste Verzeichnisebene: Kategorien<br />
* zweite Verzeichnisebene: Paketverzeichnisse<br />
* PKGBUILD Dateien mit Paketinformationen<br />
<br />
Allerdings gibt es ein spezielles Verzeichnis: '''local'''. Es ist ''dein'' Verzeichnis, in dem du Pakete erstellst, du solltest niemals etwas in den restlichen Verzeichnissen ändern.<br />
<br />
'''BEACHTE:''' Der erste Download des ABS Verzeichnisbaumes ist der größte, danach sind nur kleinere Updates nötig. Du brauchst auch mit kleinerer Bandbreite oder Volumentarif keine Angst haben : es sind nur Textdateien, die bei der Übertragung auch noch komprimiert sind.<br />
<br />
Nun weißt du, was der ABS Verzeichnisbaum ist, aber wie nutzt man ihn?<br />
<br />
==== Erste Verwendung von ABS : Anpassen von Paketen ====<br />
<br />
Diese Situation kann öfter erscheinen, als man meint : offizielle Pakete sind mit <code>--enable</code> oder <code>--disable</code> Optionen erstellt, die nicht deinen Anorderungen entsprechen.<br />
<br />
Nehmen wir als Beispiel : ''foo'' Das Paket ''foo'' wurde mit deaktivierte '''arts''' Unterstützung erstellt. Um '''arts''' Unterstützung zu aktivieren muss folgendes getan werden :<br />
<br />
* finde heraus, wo das Paket ''foo'' liegt :<br />
<br />
suche ''foo'' in [http://archlinux.org/packages.php]<br />
<br />
per ''find'' :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
per slocate :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In jedem Fall wirst du sehen, dass ''foo'' Bestandteil von <code>extra</code> und <code>multimedia</code> ist (Beispiel).<br />
<br />
* kopiere das ''foo'' <code>PKGBUILD</code> in dein Arbeitsverzeichnis <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* Anpassung des <code>PKGBUILD</code> : In unserem Fall '''arts''' Unterstützung :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
wird zu :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* Paket erstellen :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* Paket installieren (<code>-A</code> zum installieren, <code>-U</code>zum upgraden eines installierten Paketes):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Tuning: Compiler Flags und Anpassung von makepkg====<br />
<br />
Die Konfigurationsdatei von <code>makepkg</code> liegt in <code>/etc/makepkg.conf</code>. Hier kannst du Umgebungsvariablen sowohl für <code>gcc</code> und <code>make</code> als auch für <code>makepkg</code> selbst definieren. Hier eine Beispiel <code>/etc/makepkg.conf</code> :<br />
<br />
<pre><br />
# Das FTP/HTTP download Programm, das makepkg zum laden der Quelltexte nutzt<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Informationen für GCC über den Prozessortyp<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags für GCC, wenn ein Paket kompiliert wird<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags für make, wenn ein Paket kompiliert wird<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Aktiviere farbige Ausgabe<br />
export USE_COLOR="y"<br />
<br />
## Folgende Variablen betreffen nur makepkg<br />
<br />
# Aktiviere fakeroot um Pakete als normaler User zu erstellen<br />
export USE_FAKEROOT="y"<br />
<br />
# Das Verzeichnis, in dem das erstellte Paket erstellt wird (normalerweise ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Pfad zum ABS Verzeichnisbaum (normalerweise /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Aktiviere dies, um deinen Namen in erstellte Pakete zu schreiben<br />
export PACKAGER="John Doe <nowhere@devnull.com>"<br />
</pre><br />
<br />
'''BEACHTE:''' User wissen, was die Änderungen an den <code>CFLAGS, CXXFLAGS, MAKEFLAGS</code> Variablen bewirken, da sie Unstabilität oder Fehler bewirken können. Außerdem sollte der normale Arch Linux User die Werte für <code>CARCH</code> und <code>USE_FAKEROOT</code> nichtt ändern.<br />
<br />
Referenzen zu gcc und make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1461Arch Build System2006-08-08T18:06:30Z<p>Wtfoo: /* Compiler Flags and Customizing makepkg */</p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. im Verzeichnis 'foo' gespeichert hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meist ''foo''.pkg.tar.gz genannt ist.<br />
<br />
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:<br />
<br />
* Die zu installierenden Dateien<br />
<br />
*.PKGINFO : enthält alle Metadaten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.<br />
<br />
*.FILELIST : enthält alle Dateien des Archives. Nötig um ein Paket zu deinstallieren oder um ggf. Abhängigkeitskonflikte festzustellen<br />
<br />
*.INSTALL : enthält Befehle, die nach dem Installieren/Upgraden/Deinstallieren ausgeführt werden. (Nur vorhanden, wenn es in PKGBUILD definiert wurde)<br />
<br />
==== Was ist PKGBUILD und was enthält es? ====<br />
<br />
Wie schon gesagt, enthält PKGBUILD die Metadaten über ein Paket. Es ist eine einfache Textdatei, die z.B. so aussehen könnte:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Erklärung für jede Zeile:<br />
<br />
* '''# text''' : Kommentare<br />
* '''# $Id: PKGBUILD,v ...''' : Das CVS-Tag für dieses Paket (Vom Archlinux-CVS System erstellt).<br />
* '''# Maintainer''' : Der Verantwortliche für dieses Paket in den offiziellen Repo's.<br />
* '''# Contributor''' : Der Verfasser der ersten PKGBUILD für dieses Paket.<br />
* '''pkgname''' : Der Paketname<br />
* '''pkgver''' : Die Paketversion<br />
* '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion.<br />
* '''pkgdesc''' : Eine Kurzbeschreibung des Paketes. Du siehst sie, in der [http://archlinux.org/packages.php Paket Datenbank]<br />
* '''arch''' : Die Architekturen, auf denen das Paket kompiliert und getestet wurde.<br />
* '''url''' : Die Homepage des Programmes<br />
* '''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<br />
* '''provides''' : Wird genutzt, wenn das Paket ein anderes Paket enthält. z.B. enthält 'kernel-scsi' 'kernel'<br />
* '''depends''' : Liste der Abhängigkeiten um das Programm auszuführen.<br />
* '''makedepends''' : Liste der Abhängigkeiten um das Programm zu kompilieren.<br />
* '''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>. <br />
* '''replaces''' : Das neue Paket ersetzt das Alte. In unserem Fall wird <i>mffoo (my first foo)</i> nicht mehr unterstützt und wird durch <i>foo</i> ersetzt.<br />
* '''backup''' : Dateien, die gesichert werden (als .pacsave), wenn das Programm deinstalliert wird.<br />
* '''install''' : Spezifiziert ein Installationsskript, das im Paket enthalten ist. (Muss sich mit PKGBUILD im selben Verzeichnis befinden)<br />
* '''source''' : Die Bezugsquelle des Quelltextes. Kann sowohl ein lokales Paket, als auch ein remote "http" oder "ftp" Paket sein. Der Dateiname wird aus <i>pkgname</i> und <i>pkgver</i> erstellt, damit der Pfad nicht bei jeder neuen Version angepasst werden muss.<br />
* '''md5sums''' : MD5 Summen der Quelltexte um beschädigte Dateien auszuschließen.<br />
<br />
Nun die Funktionen:<br />
<br />
* build : Alle Schritte, die nötig sind um das Paket zu kompilieren. (Darauf gehen wir später besser ein).<br />
<br />
Wie du siehst enthält PKGBUILD alle Informationen die von der Paketverwaltung gebraucht werden könnten. Es ist das Herzstück von pacman und ABS.<br />
<br />
Es sind auch Installationsdateien vorhanden. Unser PKGBUILD gibt 'foo.install' als Installationsdatei an. Es könnte z.B. folgendes enthalten:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Erklärungen:<br />
<br />
* post_install : Wird nach der Installation ausgeführt. Es wird ein Argument übergeben:<br />
** Die Paketversion<br />
* post_upgrade : Wird ausgeführt, nachdem alle Dateien aktualisiert wurden <em> Es werden zwei Argumente übergeben</em>:<br />
** Die neue Paketversion<br />
** Die alte Paketversion<br />
* pre_remove : Wird ausgeführt, bevor Dateien gelöscht werden (beendet z.B. daemonen) und übergibt ein Argument:<br />
** Die Paketversion<br />
<br />
Damit die Installationsdateien funktionieren, müssen diese drei Zeilen am Ende jeder Installationsdatei vorhanden sein.<br />
<br />
==== Die build Funktion====<br />
<br />
Wenn du dich nicht mit dem Bauen von Paketen auskennst, solltest du wissen, dass die meisten Pakete über den 'Dreisatz' erstellt werden können:<br />
<br />
* Paketdateien dekomprimieren : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* In das Verzeichnis wechseln<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* configure (1/3): normalerweise ist ein kleines Script <code>configure</code> im Quelltextverzeichniss vorhanden. Es wird genutzt um das Paket zu konfigurieren (hinzufügen von Unterstützungen, Installationsverzeichnis festlegen, ...) und sicher zu stellen, dass alle Abhängigkeiten aufgelöst sind.<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
Du solltest zuerst einen Blick in die 'help' Option werfen:<br />
<br />
<pre>./configure --help</pre><br />
<br />
* make (2/3) : Kompilieren der Quelltexte<br />
<br />
<pre>make</pre><br />
<br />
* install (3/3)<br />
<br />
<pre>make install</pre><br />
<br />
Du solltest immer die <code>INSTALL</code> Datei lesen, um zu erfahren, wie das Paket erstellt und installiert werden sollte , denn nicht alle Pakete nutzen den Dreisatz 'configure; make; make install'!<br />
<br />
Schauen wir uns eine 'standart' build Funktion an :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Im Detail :<br />
* In das Verzeichnis der entpackten Quelltexte wechseln :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
* Konfigurieren des Paketes mit dem Installationsverzeichnis <code>/usr</code> :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* installiere das Programm nicht in <code>/usr</code> sondern in <code>$startdir/pkg/usr</code>, sodass pacman Kontrolle über die Dateien hat :<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
Wir wollen das Paket erstellen, aber nicht installiren, also installieren wir es nicht standartmäßig (<code>/usr</code>), sondern nach <code>$startdir/pkg/usr</code>. So kann makepkg sehen, welche Dateien das Paket installiert und daraus ein Arch Paket erstellen.<br />
<br />
'''BEACHTE''': Teilweise wird <code>prefix</code> nicht im <code>Makefile</code> genutzt; meist wird stattdessen <code>DESTDIR</code> verwendet. Wenn das Paket mit Hilfe von autofoo (autoconf/automake) erstellt wird, solltest du <code>DESTDIR</code> nutzen, denn so wird es in der [http://sources.redhat.com/automake/automake.html#Install Dokumentation] angegeben. Überprüfe, ob die generierte <code>filelist</code> um einiges kürzer ist, als sie sein sollte. Ist dies der Fall, versuche das Paket mit <code>make DESTDIR=$startdir/pkg install</code> zu erstellen.<br />
Fall auch das nicht funktioniert, wirst du dir die Befehle, die "<code>make <...> install=</code>" ausführt genauer anschauen müssen.<br />
<br />
==== Der ABS Verzeichnisbaum ====<br />
<br />
Wenn du abs das erste Mal nutzt :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
so synchronisierst du deinen "ABS Verzeichnisbaum" mit einem Arch Server über das CVS-System.<br />
Was genau ist der ABS Verzeichnisbaum? Er befindet sich in <code>/var/abs</code> und sieht so aus :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
Also ist der ABS Verzeichnisbaum genauso aufgebaut, wie die Paketdatenbank :<br />
* erste Verzeichnisebene: Kategorien<br />
* zweite Verzeichnisebene: Paketverzeichnisse<br />
* PKGBUILD Dateien mit Paketinformationen<br />
<br />
Allerdings gibt es ein spezielles Verzeichnis: '''local'''. Es ist ''dein'' Verzeichnis, in dem du Pakete erstellst, du solltest niemals etwas in den restlichen Verzeichnissen ändern.<br />
<br />
'''BEACHTE:''' Der erste Download des ABS Verzeichnisbaumes ist der größte, danach sind nur kleinere Updates nötig. Du brauchst auch mit kleinerer Bandbreite oder Volumentarif keine Angst haben : es sind nur Textdateien, die bei der Übertragung auch noch komprimiert sind.<br />
<br />
Nun weißt du, was der ABS Verzeichnisbaum ist, aber wie nutzt man ihn?<br />
<br />
==== Erste Verwendung von ABS : Anpassen von Paketen ====<br />
<br />
Diese Situation kann öfter erscheinen, als man meint : offizielle Pakete sind mit <code>--enable</code> oder <code>--disable</code> Optionen erstellt, die nicht deinen Anorderungen entsprechen.<br />
<br />
Nehmen wir als Beispiel : ''foo'' Das Paket ''foo'' wurde mit deaktivierte '''arts''' Unterstützung erstellt. Um '''arts''' Unterstützung zu aktivieren muss folgendes getan werden :<br />
<br />
* finde heraus, wo das Paket ''foo'' liegt :<br />
<br />
suche ''foo'' in [http://archlinux.org/packages.php]<br />
<br />
per ''find'' :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
per slocate :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In jedem Fall wirst du sehen, dass ''foo'' Bestandteil von <code>extra</code> und <code>multimedia</code> ist (Beispiel).<br />
<br />
* kopiere das ''foo'' <code>PKGBUILD</code> in dein Arbeitsverzeichnis <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* Anpassung des <code>PKGBUILD</code> : In unserem Fall '''arts''' Unterstützung :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
wird zu :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* Paket erstellen :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* Paket installieren (<code>-A</code> zum installieren, <code>-U</code>zum upgraden eines installierten Paketes):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Tuning: Compiler Flags und Anpassung von makepkg====<br />
<br />
Die Konfigurationsdatei von <code>makepkg</code> liegt in <code>/etc/makepkg.conf</code>. Hier kannst du Umgebungsvariablen sowohl für <code>gcc</code> und <code>make</code> als auch für <code>makepkg</code> selbst definieren. Hier eine Beispiel <code>/etc/makepkg.conf</code> :<br />
<br />
<pre><br />
# Das FTP/HTTP download Programm, das makepkg zum laden der Quelltexte nutzt<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Informationen für GCC über den Prozessortyp<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags für GCC, wenn ein Paket kompiliert wird<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags für make, wenn ein Paket kompiliert wird<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Aktiviere farbige Ausgabe<br />
export USE_COLOR="y"<br />
<br />
## Folgende Variablen betreffen nur makepkg<br />
<br />
# Aktiviere fakeroot um Pakete als normaler User zu erstellen<br />
export USE_FAKEROOT="y"<br />
<br />
# Das Verzeichnis, in dem das erstellte Paket erstellt wird (normalerweise ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Pfad zum ABS Verzeichnisbaum (normalerweise /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Aktiviere dies, um deinen Namen in erstellte Pakete zu schreiben<br />
export PACKAGER="John Doe <nowhere@devnull.com>"<br />
</pre><br />
<br />
'''BEACHTE:''' User wissen, was die Änderungen an den <code>CFLAGS, CXXFLAGS, MAKEFLAGS</code> Variablen bewirken, da sie Unstabilität oder Fehler bewirken können. Außerdem sollte der normale Arch Linux User die Werte für <code>CARCH</code> und <code>USE_FAKEROOT</code> nichtt ändern.<br />
<br />
Referenzen zu gcc und make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]<br />
<br />
==== Other uses of ABS====<br />
<br />
Well here are two more wiki pages, whose goal is to go deeper in ABS :<br />
* [[The Arch package making HOW-TO - with guidelines]]<br />
* [[Custom local repository with ABS and gensync]]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1460Arch Build System2006-08-08T17:55:06Z<p>Wtfoo: /* Erste Möglichkeit von ABS : Anpassen von Paketen */</p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. im Verzeichnis 'foo' gespeichert hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meist ''foo''.pkg.tar.gz genannt ist.<br />
<br />
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:<br />
<br />
* Die zu installierenden Dateien<br />
<br />
*.PKGINFO : enthält alle Metadaten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.<br />
<br />
*.FILELIST : enthält alle Dateien des Archives. Nötig um ein Paket zu deinstallieren oder um ggf. Abhängigkeitskonflikte festzustellen<br />
<br />
*.INSTALL : enthält Befehle, die nach dem Installieren/Upgraden/Deinstallieren ausgeführt werden. (Nur vorhanden, wenn es in PKGBUILD definiert wurde)<br />
<br />
==== Was ist PKGBUILD und was enthält es? ====<br />
<br />
Wie schon gesagt, enthält PKGBUILD die Metadaten über ein Paket. Es ist eine einfache Textdatei, die z.B. so aussehen könnte:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Erklärung für jede Zeile:<br />
<br />
* '''# text''' : Kommentare<br />
* '''# $Id: PKGBUILD,v ...''' : Das CVS-Tag für dieses Paket (Vom Archlinux-CVS System erstellt).<br />
* '''# Maintainer''' : Der Verantwortliche für dieses Paket in den offiziellen Repo's.<br />
* '''# Contributor''' : Der Verfasser der ersten PKGBUILD für dieses Paket.<br />
* '''pkgname''' : Der Paketname<br />
* '''pkgver''' : Die Paketversion<br />
* '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion.<br />
* '''pkgdesc''' : Eine Kurzbeschreibung des Paketes. Du siehst sie, in der [http://archlinux.org/packages.php Paket Datenbank]<br />
* '''arch''' : Die Architekturen, auf denen das Paket kompiliert und getestet wurde.<br />
* '''url''' : Die Homepage des Programmes<br />
* '''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<br />
* '''provides''' : Wird genutzt, wenn das Paket ein anderes Paket enthält. z.B. enthält 'kernel-scsi' 'kernel'<br />
* '''depends''' : Liste der Abhängigkeiten um das Programm auszuführen.<br />
* '''makedepends''' : Liste der Abhängigkeiten um das Programm zu kompilieren.<br />
* '''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>. <br />
* '''replaces''' : Das neue Paket ersetzt das Alte. In unserem Fall wird <i>mffoo (my first foo)</i> nicht mehr unterstützt und wird durch <i>foo</i> ersetzt.<br />
* '''backup''' : Dateien, die gesichert werden (als .pacsave), wenn das Programm deinstalliert wird.<br />
* '''install''' : Spezifiziert ein Installationsskript, das im Paket enthalten ist. (Muss sich mit PKGBUILD im selben Verzeichnis befinden)<br />
* '''source''' : Die Bezugsquelle des Quelltextes. Kann sowohl ein lokales Paket, als auch ein remote "http" oder "ftp" Paket sein. Der Dateiname wird aus <i>pkgname</i> und <i>pkgver</i> erstellt, damit der Pfad nicht bei jeder neuen Version angepasst werden muss.<br />
* '''md5sums''' : MD5 Summen der Quelltexte um beschädigte Dateien auszuschließen.<br />
<br />
Nun die Funktionen:<br />
<br />
* build : Alle Schritte, die nötig sind um das Paket zu kompilieren. (Darauf gehen wir später besser ein).<br />
<br />
Wie du siehst enthält PKGBUILD alle Informationen die von der Paketverwaltung gebraucht werden könnten. Es ist das Herzstück von pacman und ABS.<br />
<br />
Es sind auch Installationsdateien vorhanden. Unser PKGBUILD gibt 'foo.install' als Installationsdatei an. Es könnte z.B. folgendes enthalten:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Erklärungen:<br />
<br />
* post_install : Wird nach der Installation ausgeführt. Es wird ein Argument übergeben:<br />
** Die Paketversion<br />
* post_upgrade : Wird ausgeführt, nachdem alle Dateien aktualisiert wurden <em> Es werden zwei Argumente übergeben</em>:<br />
** Die neue Paketversion<br />
** Die alte Paketversion<br />
* pre_remove : Wird ausgeführt, bevor Dateien gelöscht werden (beendet z.B. daemonen) und übergibt ein Argument:<br />
** Die Paketversion<br />
<br />
Damit die Installationsdateien funktionieren, müssen diese drei Zeilen am Ende jeder Installationsdatei vorhanden sein.<br />
<br />
==== Die build Funktion====<br />
<br />
Wenn du dich nicht mit dem Bauen von Paketen auskennst, solltest du wissen, dass die meisten Pakete über den 'Dreisatz' erstellt werden können:<br />
<br />
* Paketdateien dekomprimieren : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* In das Verzeichnis wechseln<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* configure (1/3): normalerweise ist ein kleines Script <code>configure</code> im Quelltextverzeichniss vorhanden. Es wird genutzt um das Paket zu konfigurieren (hinzufügen von Unterstützungen, Installationsverzeichnis festlegen, ...) und sicher zu stellen, dass alle Abhängigkeiten aufgelöst sind.<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
Du solltest zuerst einen Blick in die 'help' Option werfen:<br />
<br />
<pre>./configure --help</pre><br />
<br />
* make (2/3) : Kompilieren der Quelltexte<br />
<br />
<pre>make</pre><br />
<br />
* install (3/3)<br />
<br />
<pre>make install</pre><br />
<br />
Du solltest immer die <code>INSTALL</code> Datei lesen, um zu erfahren, wie das Paket erstellt und installiert werden sollte , denn nicht alle Pakete nutzen den Dreisatz 'configure; make; make install'!<br />
<br />
Schauen wir uns eine 'standart' build Funktion an :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Im Detail :<br />
* In das Verzeichnis der entpackten Quelltexte wechseln :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
* Konfigurieren des Paketes mit dem Installationsverzeichnis <code>/usr</code> :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* installiere das Programm nicht in <code>/usr</code> sondern in <code>$startdir/pkg/usr</code>, sodass pacman Kontrolle über die Dateien hat :<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
Wir wollen das Paket erstellen, aber nicht installiren, also installieren wir es nicht standartmäßig (<code>/usr</code>), sondern nach <code>$startdir/pkg/usr</code>. So kann makepkg sehen, welche Dateien das Paket installiert und daraus ein Arch Paket erstellen.<br />
<br />
'''BEACHTE''': Teilweise wird <code>prefix</code> nicht im <code>Makefile</code> genutzt; meist wird stattdessen <code>DESTDIR</code> verwendet. Wenn das Paket mit Hilfe von autofoo (autoconf/automake) erstellt wird, solltest du <code>DESTDIR</code> nutzen, denn so wird es in der [http://sources.redhat.com/automake/automake.html#Install Dokumentation] angegeben. Überprüfe, ob die generierte <code>filelist</code> um einiges kürzer ist, als sie sein sollte. Ist dies der Fall, versuche das Paket mit <code>make DESTDIR=$startdir/pkg install</code> zu erstellen.<br />
Fall auch das nicht funktioniert, wirst du dir die Befehle, die "<code>make <...> install=</code>" ausführt genauer anschauen müssen.<br />
<br />
==== Der ABS Verzeichnisbaum ====<br />
<br />
Wenn du abs das erste Mal nutzt :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
so synchronisierst du deinen "ABS Verzeichnisbaum" mit einem Arch Server über das CVS-System.<br />
Was genau ist der ABS Verzeichnisbaum? Er befindet sich in <code>/var/abs</code> und sieht so aus :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
Also ist der ABS Verzeichnisbaum genauso aufgebaut, wie die Paketdatenbank :<br />
* erste Verzeichnisebene: Kategorien<br />
* zweite Verzeichnisebene: Paketverzeichnisse<br />
* PKGBUILD Dateien mit Paketinformationen<br />
<br />
Allerdings gibt es ein spezielles Verzeichnis: '''local'''. Es ist ''dein'' Verzeichnis, in dem du Pakete erstellst, du solltest niemals etwas in den restlichen Verzeichnissen ändern.<br />
<br />
'''BEACHTE:''' Der erste Download des ABS Verzeichnisbaumes ist der größte, danach sind nur kleinere Updates nötig. Du brauchst auch mit kleinerer Bandbreite oder Volumentarif keine Angst haben : es sind nur Textdateien, die bei der Übertragung auch noch komprimiert sind.<br />
<br />
Nun weißt du, was der ABS Verzeichnisbaum ist, aber wie nutzt man ihn?<br />
<br />
==== Erste Verwendung von ABS : Anpassen von Paketen ====<br />
<br />
Diese Situation kann öfter erscheinen, als man meint : offizielle Pakete sind mit <code>--enable</code> oder <code>--disable</code> Optionen erstellt, die nicht deinen Anorderungen entsprechen.<br />
<br />
Nehmen wir als Beispiel : ''foo'' Das Paket ''foo'' wurde mit deaktivierte '''arts''' Unterstützung erstellt. Um '''arts''' Unterstützung zu aktivieren muss folgendes getan werden :<br />
<br />
* finde heraus, wo das Paket ''foo'' liegt :<br />
<br />
suche ''foo'' in [http://archlinux.org/packages.php]<br />
<br />
per ''find'' :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
per slocate :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In jedem Fall wirst du sehen, dass ''foo'' Bestandteil von <code>extra</code> und <code>multimedia</code> ist (Beispiel).<br />
<br />
* kopiere das ''foo'' <code>PKGBUILD</code> in dein Arbeitsverzeichnis <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* Anpassung des <code>PKGBUILD</code> : In unserem Fall '''arts''' Unterstützung :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
wird zu :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* Paket erstellen :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* Paket installieren (<code>-A</code> zum installieren, <code>-U</code>zum upgraden eines installierten Paketes):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Compiler Flags and Customizing makepkg====<br />
<br />
The configuration file for <code>makepkg</code> is <code>/etc/makepkg.conf</code>. Here you can set environment variables for <code>gcc</code> and <code>make</code>, as well as some for <code>makepkg</code> itself. The following is an example of <code>/etc/makepkg.conf</code>.<br />
<br />
<pre><br />
# The FTP/HTTP download utility that makepkg will use to acquire sources<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Information passed to gcc about what type of computer this is.<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags passed to gcc when a package is being compiled<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags passed to make when a package is being compiled<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Enable colorized output messages<br />
export USE_COLOR="y"<br />
<br />
# The remaining variables only affect the behavior of makepkg<br />
# Enable fakeroot for building packages as a non-root user.<br />
# See 'man fakeroot' for more information on fakeroot<br />
export USE_FAKEROOT="y"<br />
<br />
# The directory where all packages will be placed (default is ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Base of the ABS tree (default is /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Set this if you want your name to show up in the packages you build<br />
export PACKAGER="John Doe <nowhere@microsoft.com>"<br />
</pre><br />
<br />
A word of caution: Users should be sure of any changes they may make to the variables <code>CFLAGS</code>, <code>CXXFLAGS</code>, and <code>MAKEFLAGS</code> 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 <code>CARCH</code>, <code>CHOST</code>, and <code>USE_FAKEROOT</code>.<br />
<br />
References for gcc and make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]<br />
<br />
==== Other uses of ABS====<br />
<br />
Well here are two more wiki pages, whose goal is to go deeper in ABS :<br />
* [[The Arch package making HOW-TO - with guidelines]]<br />
* [[Custom local repository with ABS and gensync]]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1459Arch Build System2006-08-08T17:46:18Z<p>Wtfoo: /* First use of ABS : customizing a package */</p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. im Verzeichnis 'foo' gespeichert hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meist ''foo''.pkg.tar.gz genannt ist.<br />
<br />
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:<br />
<br />
* Die zu installierenden Dateien<br />
<br />
*.PKGINFO : enthält alle Metadaten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.<br />
<br />
*.FILELIST : enthält alle Dateien des Archives. Nötig um ein Paket zu deinstallieren oder um ggf. Abhängigkeitskonflikte festzustellen<br />
<br />
*.INSTALL : enthält Befehle, die nach dem Installieren/Upgraden/Deinstallieren ausgeführt werden. (Nur vorhanden, wenn es in PKGBUILD definiert wurde)<br />
<br />
==== Was ist PKGBUILD und was enthält es? ====<br />
<br />
Wie schon gesagt, enthält PKGBUILD die Metadaten über ein Paket. Es ist eine einfache Textdatei, die z.B. so aussehen könnte:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Erklärung für jede Zeile:<br />
<br />
* '''# text''' : Kommentare<br />
* '''# $Id: PKGBUILD,v ...''' : Das CVS-Tag für dieses Paket (Vom Archlinux-CVS System erstellt).<br />
* '''# Maintainer''' : Der Verantwortliche für dieses Paket in den offiziellen Repo's.<br />
* '''# Contributor''' : Der Verfasser der ersten PKGBUILD für dieses Paket.<br />
* '''pkgname''' : Der Paketname<br />
* '''pkgver''' : Die Paketversion<br />
* '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion.<br />
* '''pkgdesc''' : Eine Kurzbeschreibung des Paketes. Du siehst sie, in der [http://archlinux.org/packages.php Paket Datenbank]<br />
* '''arch''' : Die Architekturen, auf denen das Paket kompiliert und getestet wurde.<br />
* '''url''' : Die Homepage des Programmes<br />
* '''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<br />
* '''provides''' : Wird genutzt, wenn das Paket ein anderes Paket enthält. z.B. enthält 'kernel-scsi' 'kernel'<br />
* '''depends''' : Liste der Abhängigkeiten um das Programm auszuführen.<br />
* '''makedepends''' : Liste der Abhängigkeiten um das Programm zu kompilieren.<br />
* '''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>. <br />
* '''replaces''' : Das neue Paket ersetzt das Alte. In unserem Fall wird <i>mffoo (my first foo)</i> nicht mehr unterstützt und wird durch <i>foo</i> ersetzt.<br />
* '''backup''' : Dateien, die gesichert werden (als .pacsave), wenn das Programm deinstalliert wird.<br />
* '''install''' : Spezifiziert ein Installationsskript, das im Paket enthalten ist. (Muss sich mit PKGBUILD im selben Verzeichnis befinden)<br />
* '''source''' : Die Bezugsquelle des Quelltextes. Kann sowohl ein lokales Paket, als auch ein remote "http" oder "ftp" Paket sein. Der Dateiname wird aus <i>pkgname</i> und <i>pkgver</i> erstellt, damit der Pfad nicht bei jeder neuen Version angepasst werden muss.<br />
* '''md5sums''' : MD5 Summen der Quelltexte um beschädigte Dateien auszuschließen.<br />
<br />
Nun die Funktionen:<br />
<br />
* build : Alle Schritte, die nötig sind um das Paket zu kompilieren. (Darauf gehen wir später besser ein).<br />
<br />
Wie du siehst enthält PKGBUILD alle Informationen die von der Paketverwaltung gebraucht werden könnten. Es ist das Herzstück von pacman und ABS.<br />
<br />
Es sind auch Installationsdateien vorhanden. Unser PKGBUILD gibt 'foo.install' als Installationsdatei an. Es könnte z.B. folgendes enthalten:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Erklärungen:<br />
<br />
* post_install : Wird nach der Installation ausgeführt. Es wird ein Argument übergeben:<br />
** Die Paketversion<br />
* post_upgrade : Wird ausgeführt, nachdem alle Dateien aktualisiert wurden <em> Es werden zwei Argumente übergeben</em>:<br />
** Die neue Paketversion<br />
** Die alte Paketversion<br />
* pre_remove : Wird ausgeführt, bevor Dateien gelöscht werden (beendet z.B. daemonen) und übergibt ein Argument:<br />
** Die Paketversion<br />
<br />
Damit die Installationsdateien funktionieren, müssen diese drei Zeilen am Ende jeder Installationsdatei vorhanden sein.<br />
<br />
==== Die build Funktion====<br />
<br />
Wenn du dich nicht mit dem Bauen von Paketen auskennst, solltest du wissen, dass die meisten Pakete über den 'Dreisatz' erstellt werden können:<br />
<br />
* Paketdateien dekomprimieren : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* In das Verzeichnis wechseln<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* configure (1/3): normalerweise ist ein kleines Script <code>configure</code> im Quelltextverzeichniss vorhanden. Es wird genutzt um das Paket zu konfigurieren (hinzufügen von Unterstützungen, Installationsverzeichnis festlegen, ...) und sicher zu stellen, dass alle Abhängigkeiten aufgelöst sind.<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
Du solltest zuerst einen Blick in die 'help' Option werfen:<br />
<br />
<pre>./configure --help</pre><br />
<br />
* make (2/3) : Kompilieren der Quelltexte<br />
<br />
<pre>make</pre><br />
<br />
* install (3/3)<br />
<br />
<pre>make install</pre><br />
<br />
Du solltest immer die <code>INSTALL</code> Datei lesen, um zu erfahren, wie das Paket erstellt und installiert werden sollte , denn nicht alle Pakete nutzen den Dreisatz 'configure; make; make install'!<br />
<br />
Schauen wir uns eine 'standart' build Funktion an :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Im Detail :<br />
* In das Verzeichnis der entpackten Quelltexte wechseln :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
* Konfigurieren des Paketes mit dem Installationsverzeichnis <code>/usr</code> :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* installiere das Programm nicht in <code>/usr</code> sondern in <code>$startdir/pkg/usr</code>, sodass pacman Kontrolle über die Dateien hat :<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
Wir wollen das Paket erstellen, aber nicht installiren, also installieren wir es nicht standartmäßig (<code>/usr</code>), sondern nach <code>$startdir/pkg/usr</code>. So kann makepkg sehen, welche Dateien das Paket installiert und daraus ein Arch Paket erstellen.<br />
<br />
'''BEACHTE''': Teilweise wird <code>prefix</code> nicht im <code>Makefile</code> genutzt; meist wird stattdessen <code>DESTDIR</code> verwendet. Wenn das Paket mit Hilfe von autofoo (autoconf/automake) erstellt wird, solltest du <code>DESTDIR</code> nutzen, denn so wird es in der [http://sources.redhat.com/automake/automake.html#Install Dokumentation] angegeben. Überprüfe, ob die generierte <code>filelist</code> um einiges kürzer ist, als sie sein sollte. Ist dies der Fall, versuche das Paket mit <code>make DESTDIR=$startdir/pkg install</code> zu erstellen.<br />
Fall auch das nicht funktioniert, wirst du dir die Befehle, die "<code>make <...> install=</code>" ausführt genauer anschauen müssen.<br />
<br />
==== Der ABS Verzeichnisbaum ====<br />
<br />
Wenn du abs das erste Mal nutzt :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
so synchronisierst du deinen "ABS Verzeichnisbaum" mit einem Arch Server über das CVS-System.<br />
Was genau ist der ABS Verzeichnisbaum? Er befindet sich in <code>/var/abs</code> und sieht so aus :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
Also ist der ABS Verzeichnisbaum genauso aufgebaut, wie die Paketdatenbank :<br />
* erste Verzeichnisebene: Kategorien<br />
* zweite Verzeichnisebene: Paketverzeichnisse<br />
* PKGBUILD Dateien mit Paketinformationen<br />
<br />
Allerdings gibt es ein spezielles Verzeichnis: '''local'''. Es ist ''dein'' Verzeichnis, in dem du Pakete erstellst, du solltest niemals etwas in den restlichen Verzeichnissen ändern.<br />
<br />
'''BEACHTE:''' Der erste Download des ABS Verzeichnisbaumes ist der größte, danach sind nur kleinere Updates nötig. Du brauchst auch mit kleinerer Bandbreite oder Volumentarif keine Angst haben : es sind nur Textdateien, die bei der Übertragung auch noch komprimiert sind.<br />
<br />
Nun weißt du, was der ABS Verzeichnisbaum ist, aber wie nutzt man ihn?<br />
<br />
==== Erste Möglichkeit von ABS : Anpassen von Paketen ====<br />
<br />
Diese Situation kann öfter erscheinen, als man meint : offizielle Pakete sind mit <code>--enable</code> oder <code>--disable</code> Optionen erstellt, die nicht deinen Anorderungen entsprechen.<br />
<br />
Nehmen wir als Beispiel : ''foo'' Das Paket ''foo'' wurde mit deaktivierte '''arts''' Unterstützung erstellt. Um '''arts''' Unterstützung zu aktivieren muss folgendes getan werden :<br />
<br />
* finde heraus, wo das Paket ''foo'' liegt :<br />
<br />
suche ''foo'' in [http://archlinux.org/packages.php]<br />
<br />
per ''find'' :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
per slocate :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In jedem Fall wirst du sehen, dass ''foo'' Bestandteil von <code>extra</code> und <code>multimedia</code> ist (Beispiel).<br />
<br />
* kopiere das ''foo'' <code>PKGBUILD</code> in dein Arbeitsverzeichnis <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* modify the <code>PKGBUILD</code> file : we'll add support for '''arts''' :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
becomes :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* launch <code>makepkg</code> :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* install the new package using one of the following commands (<code>-A</code> for install, <code>-U</code> to upgrade an already installed package):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Compiler Flags and Customizing makepkg====<br />
<br />
The configuration file for <code>makepkg</code> is <code>/etc/makepkg.conf</code>. Here you can set environment variables for <code>gcc</code> and <code>make</code>, as well as some for <code>makepkg</code> itself. The following is an example of <code>/etc/makepkg.conf</code>.<br />
<br />
<pre><br />
# The FTP/HTTP download utility that makepkg will use to acquire sources<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Information passed to gcc about what type of computer this is.<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags passed to gcc when a package is being compiled<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags passed to make when a package is being compiled<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Enable colorized output messages<br />
export USE_COLOR="y"<br />
<br />
# The remaining variables only affect the behavior of makepkg<br />
# Enable fakeroot for building packages as a non-root user.<br />
# See 'man fakeroot' for more information on fakeroot<br />
export USE_FAKEROOT="y"<br />
<br />
# The directory where all packages will be placed (default is ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Base of the ABS tree (default is /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Set this if you want your name to show up in the packages you build<br />
export PACKAGER="John Doe <nowhere@microsoft.com>"<br />
</pre><br />
<br />
A word of caution: Users should be sure of any changes they may make to the variables <code>CFLAGS</code>, <code>CXXFLAGS</code>, and <code>MAKEFLAGS</code> 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 <code>CARCH</code>, <code>CHOST</code>, and <code>USE_FAKEROOT</code>.<br />
<br />
References for gcc and make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]<br />
<br />
==== Other uses of ABS====<br />
<br />
Well here are two more wiki pages, whose goal is to go deeper in ABS :<br />
* [[The Arch package making HOW-TO - with guidelines]]<br />
* [[Custom local repository with ABS and gensync]]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1458Arch Build System2006-08-08T17:37:32Z<p>Wtfoo: /* The ABS tree */ Vielleicht eine Alternative zu 'ABS Verzeichnisbaum' finden?</p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. im Verzeichnis 'foo' gespeichert hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meist ''foo''.pkg.tar.gz genannt ist.<br />
<br />
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:<br />
<br />
* Die zu installierenden Dateien<br />
<br />
*.PKGINFO : enthält alle Metadaten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.<br />
<br />
*.FILELIST : enthält alle Dateien des Archives. Nötig um ein Paket zu deinstallieren oder um ggf. Abhängigkeitskonflikte festzustellen<br />
<br />
*.INSTALL : enthält Befehle, die nach dem Installieren/Upgraden/Deinstallieren ausgeführt werden. (Nur vorhanden, wenn es in PKGBUILD definiert wurde)<br />
<br />
==== Was ist PKGBUILD und was enthält es? ====<br />
<br />
Wie schon gesagt, enthält PKGBUILD die Metadaten über ein Paket. Es ist eine einfache Textdatei, die z.B. so aussehen könnte:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Erklärung für jede Zeile:<br />
<br />
* '''# text''' : Kommentare<br />
* '''# $Id: PKGBUILD,v ...''' : Das CVS-Tag für dieses Paket (Vom Archlinux-CVS System erstellt).<br />
* '''# Maintainer''' : Der Verantwortliche für dieses Paket in den offiziellen Repo's.<br />
* '''# Contributor''' : Der Verfasser der ersten PKGBUILD für dieses Paket.<br />
* '''pkgname''' : Der Paketname<br />
* '''pkgver''' : Die Paketversion<br />
* '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion.<br />
* '''pkgdesc''' : Eine Kurzbeschreibung des Paketes. Du siehst sie, in der [http://archlinux.org/packages.php Paket Datenbank]<br />
* '''arch''' : Die Architekturen, auf denen das Paket kompiliert und getestet wurde.<br />
* '''url''' : Die Homepage des Programmes<br />
* '''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<br />
* '''provides''' : Wird genutzt, wenn das Paket ein anderes Paket enthält. z.B. enthält 'kernel-scsi' 'kernel'<br />
* '''depends''' : Liste der Abhängigkeiten um das Programm auszuführen.<br />
* '''makedepends''' : Liste der Abhängigkeiten um das Programm zu kompilieren.<br />
* '''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>. <br />
* '''replaces''' : Das neue Paket ersetzt das Alte. In unserem Fall wird <i>mffoo (my first foo)</i> nicht mehr unterstützt und wird durch <i>foo</i> ersetzt.<br />
* '''backup''' : Dateien, die gesichert werden (als .pacsave), wenn das Programm deinstalliert wird.<br />
* '''install''' : Spezifiziert ein Installationsskript, das im Paket enthalten ist. (Muss sich mit PKGBUILD im selben Verzeichnis befinden)<br />
* '''source''' : Die Bezugsquelle des Quelltextes. Kann sowohl ein lokales Paket, als auch ein remote "http" oder "ftp" Paket sein. Der Dateiname wird aus <i>pkgname</i> und <i>pkgver</i> erstellt, damit der Pfad nicht bei jeder neuen Version angepasst werden muss.<br />
* '''md5sums''' : MD5 Summen der Quelltexte um beschädigte Dateien auszuschließen.<br />
<br />
Nun die Funktionen:<br />
<br />
* build : Alle Schritte, die nötig sind um das Paket zu kompilieren. (Darauf gehen wir später besser ein).<br />
<br />
Wie du siehst enthält PKGBUILD alle Informationen die von der Paketverwaltung gebraucht werden könnten. Es ist das Herzstück von pacman und ABS.<br />
<br />
Es sind auch Installationsdateien vorhanden. Unser PKGBUILD gibt 'foo.install' als Installationsdatei an. Es könnte z.B. folgendes enthalten:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Erklärungen:<br />
<br />
* post_install : Wird nach der Installation ausgeführt. Es wird ein Argument übergeben:<br />
** Die Paketversion<br />
* post_upgrade : Wird ausgeführt, nachdem alle Dateien aktualisiert wurden <em> Es werden zwei Argumente übergeben</em>:<br />
** Die neue Paketversion<br />
** Die alte Paketversion<br />
* pre_remove : Wird ausgeführt, bevor Dateien gelöscht werden (beendet z.B. daemonen) und übergibt ein Argument:<br />
** Die Paketversion<br />
<br />
Damit die Installationsdateien funktionieren, müssen diese drei Zeilen am Ende jeder Installationsdatei vorhanden sein.<br />
<br />
==== Die build Funktion====<br />
<br />
Wenn du dich nicht mit dem Bauen von Paketen auskennst, solltest du wissen, dass die meisten Pakete über den 'Dreisatz' erstellt werden können:<br />
<br />
* Paketdateien dekomprimieren : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* In das Verzeichnis wechseln<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* configure (1/3): normalerweise ist ein kleines Script <code>configure</code> im Quelltextverzeichniss vorhanden. Es wird genutzt um das Paket zu konfigurieren (hinzufügen von Unterstützungen, Installationsverzeichnis festlegen, ...) und sicher zu stellen, dass alle Abhängigkeiten aufgelöst sind.<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
Du solltest zuerst einen Blick in die 'help' Option werfen:<br />
<br />
<pre>./configure --help</pre><br />
<br />
* make (2/3) : Kompilieren der Quelltexte<br />
<br />
<pre>make</pre><br />
<br />
* install (3/3)<br />
<br />
<pre>make install</pre><br />
<br />
Du solltest immer die <code>INSTALL</code> Datei lesen, um zu erfahren, wie das Paket erstellt und installiert werden sollte , denn nicht alle Pakete nutzen den Dreisatz 'configure; make; make install'!<br />
<br />
Schauen wir uns eine 'standart' build Funktion an :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Im Detail :<br />
* In das Verzeichnis der entpackten Quelltexte wechseln :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
* Konfigurieren des Paketes mit dem Installationsverzeichnis <code>/usr</code> :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* installiere das Programm nicht in <code>/usr</code> sondern in <code>$startdir/pkg/usr</code>, sodass pacman Kontrolle über die Dateien hat :<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
Wir wollen das Paket erstellen, aber nicht installiren, also installieren wir es nicht standartmäßig (<code>/usr</code>), sondern nach <code>$startdir/pkg/usr</code>. So kann makepkg sehen, welche Dateien das Paket installiert und daraus ein Arch Paket erstellen.<br />
<br />
'''BEACHTE''': Teilweise wird <code>prefix</code> nicht im <code>Makefile</code> genutzt; meist wird stattdessen <code>DESTDIR</code> verwendet. Wenn das Paket mit Hilfe von autofoo (autoconf/automake) erstellt wird, solltest du <code>DESTDIR</code> nutzen, denn so wird es in der [http://sources.redhat.com/automake/automake.html#Install Dokumentation] angegeben. Überprüfe, ob die generierte <code>filelist</code> um einiges kürzer ist, als sie sein sollte. Ist dies der Fall, versuche das Paket mit <code>make DESTDIR=$startdir/pkg install</code> zu erstellen.<br />
Fall auch das nicht funktioniert, wirst du dir die Befehle, die "<code>make <...> install=</code>" ausführt genauer anschauen müssen.<br />
<br />
==== Der ABS Verzeichnisbaum ====<br />
<br />
Wenn du abs das erste Mal nutzt :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
so synchronisierst du deinen "ABS Verzeichnisbaum" mit einem Arch Server über das CVS-System.<br />
Was genau ist der ABS Verzeichnisbaum? Er befindet sich in <code>/var/abs</code> und sieht so aus :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
Also ist der ABS Verzeichnisbaum genauso aufgebaut, wie die Paketdatenbank :<br />
* erste Verzeichnisebene: Kategorien<br />
* zweite Verzeichnisebene: Paketverzeichnisse<br />
* PKGBUILD Dateien mit Paketinformationen<br />
<br />
Allerdings gibt es ein spezielles Verzeichnis: '''local'''. Es ist ''dein'' Verzeichnis, in dem du Pakete erstellst, du solltest niemals etwas in den restlichen Verzeichnissen ändern.<br />
<br />
'''BEACHTE:''' Der erste Download des ABS Verzeichnisbaumes ist der größte, danach sind nur kleinere Updates nötig. Du brauchst auch mit kleinerer Bandbreite oder Volumentarif keine Angst haben : es sind nur Textdateien, die bei der Übertragung auch noch komprimiert sind.<br />
<br />
Nun weißt du, was der ABS Verzeichnisbaum ist, aber wie nutzt man ihn?<br />
<br />
==== First use of ABS : customizing a package====<br />
<br />
This situation can arise more often than you may think : official packages are compiled choosing a certain number of <code>--enable</code> or <code>--disable</code> options, and these are not necessarily the ones you would have chosen.<br />
<br />
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 :<br />
* find where is the ''foo'' package located. you can do this by :<br />
<br />
search for ''foo'' at [http://archlinux.org/packages.php]<br />
use the find command :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
use the slocate command :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In any case, you'll find that foo is part of <code>extra</code> and <code>multimedia</code> (for example)<br />
<br />
* copy the ''foo'' <code>PKGBUILD</code> file to <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* modify the <code>PKGBUILD</code> file : we'll add support for '''arts''' :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
becomes :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* launch <code>makepkg</code> :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* install the new package using one of the following commands (<code>-A</code> for install, <code>-U</code> to upgrade an already installed package):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Compiler Flags and Customizing makepkg====<br />
<br />
The configuration file for <code>makepkg</code> is <code>/etc/makepkg.conf</code>. Here you can set environment variables for <code>gcc</code> and <code>make</code>, as well as some for <code>makepkg</code> itself. The following is an example of <code>/etc/makepkg.conf</code>.<br />
<br />
<pre><br />
# The FTP/HTTP download utility that makepkg will use to acquire sources<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Information passed to gcc about what type of computer this is.<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags passed to gcc when a package is being compiled<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags passed to make when a package is being compiled<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Enable colorized output messages<br />
export USE_COLOR="y"<br />
<br />
# The remaining variables only affect the behavior of makepkg<br />
# Enable fakeroot for building packages as a non-root user.<br />
# See 'man fakeroot' for more information on fakeroot<br />
export USE_FAKEROOT="y"<br />
<br />
# The directory where all packages will be placed (default is ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Base of the ABS tree (default is /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Set this if you want your name to show up in the packages you build<br />
export PACKAGER="John Doe <nowhere@microsoft.com>"<br />
</pre><br />
<br />
A word of caution: Users should be sure of any changes they may make to the variables <code>CFLAGS</code>, <code>CXXFLAGS</code>, and <code>MAKEFLAGS</code> 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 <code>CARCH</code>, <code>CHOST</code>, and <code>USE_FAKEROOT</code>.<br />
<br />
References for gcc and make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]<br />
<br />
==== Other uses of ABS====<br />
<br />
Well here are two more wiki pages, whose goal is to go deeper in ABS :<br />
* [[The Arch package making HOW-TO - with guidelines]]<br />
* [[Custom local repository with ABS and gensync]]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1457Arch Build System2006-08-08T17:25:20Z<p>Wtfoo: /* Die build Funktion */</p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. im Verzeichnis 'foo' gespeichert hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meist ''foo''.pkg.tar.gz genannt ist.<br />
<br />
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:<br />
<br />
* Die zu installierenden Dateien<br />
<br />
*.PKGINFO : enthält alle Metadaten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.<br />
<br />
*.FILELIST : enthält alle Dateien des Archives. Nötig um ein Paket zu deinstallieren oder um ggf. Abhängigkeitskonflikte festzustellen<br />
<br />
*.INSTALL : enthält Befehle, die nach dem Installieren/Upgraden/Deinstallieren ausgeführt werden. (Nur vorhanden, wenn es in PKGBUILD definiert wurde)<br />
<br />
==== Was ist PKGBUILD und was enthält es? ====<br />
<br />
Wie schon gesagt, enthält PKGBUILD die Metadaten über ein Paket. Es ist eine einfache Textdatei, die z.B. so aussehen könnte:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Erklärung für jede Zeile:<br />
<br />
* '''# text''' : Kommentare<br />
* '''# $Id: PKGBUILD,v ...''' : Das CVS-Tag für dieses Paket (Vom Archlinux-CVS System erstellt).<br />
* '''# Maintainer''' : Der Verantwortliche für dieses Paket in den offiziellen Repo's.<br />
* '''# Contributor''' : Der Verfasser der ersten PKGBUILD für dieses Paket.<br />
* '''pkgname''' : Der Paketname<br />
* '''pkgver''' : Die Paketversion<br />
* '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion.<br />
* '''pkgdesc''' : Eine Kurzbeschreibung des Paketes. Du siehst sie, in der [http://archlinux.org/packages.php Paket Datenbank]<br />
* '''arch''' : Die Architekturen, auf denen das Paket kompiliert und getestet wurde.<br />
* '''url''' : Die Homepage des Programmes<br />
* '''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<br />
* '''provides''' : Wird genutzt, wenn das Paket ein anderes Paket enthält. z.B. enthält 'kernel-scsi' 'kernel'<br />
* '''depends''' : Liste der Abhängigkeiten um das Programm auszuführen.<br />
* '''makedepends''' : Liste der Abhängigkeiten um das Programm zu kompilieren.<br />
* '''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>. <br />
* '''replaces''' : Das neue Paket ersetzt das Alte. In unserem Fall wird <i>mffoo (my first foo)</i> nicht mehr unterstützt und wird durch <i>foo</i> ersetzt.<br />
* '''backup''' : Dateien, die gesichert werden (als .pacsave), wenn das Programm deinstalliert wird.<br />
* '''install''' : Spezifiziert ein Installationsskript, das im Paket enthalten ist. (Muss sich mit PKGBUILD im selben Verzeichnis befinden)<br />
* '''source''' : Die Bezugsquelle des Quelltextes. Kann sowohl ein lokales Paket, als auch ein remote "http" oder "ftp" Paket sein. Der Dateiname wird aus <i>pkgname</i> und <i>pkgver</i> erstellt, damit der Pfad nicht bei jeder neuen Version angepasst werden muss.<br />
* '''md5sums''' : MD5 Summen der Quelltexte um beschädigte Dateien auszuschließen.<br />
<br />
Nun die Funktionen:<br />
<br />
* build : Alle Schritte, die nötig sind um das Paket zu kompilieren. (Darauf gehen wir später besser ein).<br />
<br />
Wie du siehst enthält PKGBUILD alle Informationen die von der Paketverwaltung gebraucht werden könnten. Es ist das Herzstück von pacman und ABS.<br />
<br />
Es sind auch Installationsdateien vorhanden. Unser PKGBUILD gibt 'foo.install' als Installationsdatei an. Es könnte z.B. folgendes enthalten:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Erklärungen:<br />
<br />
* post_install : Wird nach der Installation ausgeführt. Es wird ein Argument übergeben:<br />
** Die Paketversion<br />
* post_upgrade : Wird ausgeführt, nachdem alle Dateien aktualisiert wurden <em> Es werden zwei Argumente übergeben</em>:<br />
** Die neue Paketversion<br />
** Die alte Paketversion<br />
* pre_remove : Wird ausgeführt, bevor Dateien gelöscht werden (beendet z.B. daemonen) und übergibt ein Argument:<br />
** Die Paketversion<br />
<br />
Damit die Installationsdateien funktionieren, müssen diese drei Zeilen am Ende jeder Installationsdatei vorhanden sein.<br />
<br />
==== Die build Funktion====<br />
<br />
Wenn du dich nicht mit dem Bauen von Paketen auskennst, solltest du wissen, dass die meisten Pakete über den 'Dreisatz' erstellt werden können:<br />
<br />
* Paketdateien dekomprimieren : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* In das Verzeichnis wechseln<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* configure (1/3): normalerweise ist ein kleines Script <code>configure</code> im Quelltextverzeichniss vorhanden. Es wird genutzt um das Paket zu konfigurieren (hinzufügen von Unterstützungen, Installationsverzeichnis festlegen, ...) und sicher zu stellen, dass alle Abhängigkeiten aufgelöst sind.<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
Du solltest zuerst einen Blick in die 'help' Option werfen:<br />
<br />
<pre>./configure --help</pre><br />
<br />
* make (2/3) : Kompilieren der Quelltexte<br />
<br />
<pre>make</pre><br />
<br />
* install (3/3)<br />
<br />
<pre>make install</pre><br />
<br />
Du solltest immer die <code>INSTALL</code> Datei lesen, um zu erfahren, wie das Paket erstellt und installiert werden sollte , denn nicht alle Pakete nutzen den Dreisatz 'configure; make; make install'!<br />
<br />
Schauen wir uns eine 'standart' build Funktion an :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Im Detail :<br />
* In das Verzeichnis der entpackten Quelltexte wechseln :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
* Konfigurieren des Paketes mit dem Installationsverzeichnis <code>/usr</code> :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* installiere das Programm nicht in <code>/usr</code> sondern in <code>$startdir/pkg/usr</code>, sodass pacman Kontrolle über die Dateien hat :<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
Wir wollen das Paket erstellen, aber nicht installiren, also installieren wir es nicht standartmäßig (<code>/usr</code>), sondern nach <code>$startdir/pkg/usr</code>. So kann makepkg sehen, welche Dateien das Paket installiert und daraus ein Arch Paket erstellen.<br />
<br />
'''BEACHTE''': Teilweise wird <code>prefix</code> nicht im <code>Makefile</code> genutzt; meist wird stattdessen <code>DESTDIR</code> verwendet. Wenn das Paket mit Hilfe von autofoo (autoconf/automake) erstellt wird, solltest du <code>DESTDIR</code> nutzen, denn so wird es in der [http://sources.redhat.com/automake/automake.html#Install Dokumentation] angegeben. Überprüfe, ob die generierte <code>filelist</code> um einiges kürzer ist, als sie sein sollte. Ist dies der Fall, versuche das Paket mit <code>make DESTDIR=$startdir/pkg install</code> zu erstellen.<br />
Fall auch das nicht funktioniert, wirst du dir die Befehle, die "<code>make <...> install=</code>" ausführt genauer anschauen müssen.<br />
<br />
==== The ABS tree====<br />
<br />
When you run abs for the first time :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
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 :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
So the ABS tree has exactly the same structure as the package database :<br />
* first level directory represent categories<br />
* second level directories represent the packages<br />
* PKGBUILD files contains every information needed concerning the package<br />
<br />
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.<br />
<br />
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''<br />
<br />
Now that you know what the ABS tree is, how can we use it ?<br />
<br />
==== First use of ABS : customizing a package====<br />
<br />
This situation can arise more often than you may think : official packages are compiled choosing a certain number of <code>--enable</code> or <code>--disable</code> options, and these are not necessarily the ones you would have chosen.<br />
<br />
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 :<br />
* find where is the ''foo'' package located. you can do this by :<br />
<br />
search for ''foo'' at [http://archlinux.org/packages.php]<br />
use the find command :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
use the slocate command :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In any case, you'll find that foo is part of <code>extra</code> and <code>multimedia</code> (for example)<br />
<br />
* copy the ''foo'' <code>PKGBUILD</code> file to <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* modify the <code>PKGBUILD</code> file : we'll add support for '''arts''' :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
becomes :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* launch <code>makepkg</code> :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* install the new package using one of the following commands (<code>-A</code> for install, <code>-U</code> to upgrade an already installed package):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Compiler Flags and Customizing makepkg====<br />
<br />
The configuration file for <code>makepkg</code> is <code>/etc/makepkg.conf</code>. Here you can set environment variables for <code>gcc</code> and <code>make</code>, as well as some for <code>makepkg</code> itself. The following is an example of <code>/etc/makepkg.conf</code>.<br />
<br />
<pre><br />
# The FTP/HTTP download utility that makepkg will use to acquire sources<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Information passed to gcc about what type of computer this is.<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags passed to gcc when a package is being compiled<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags passed to make when a package is being compiled<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Enable colorized output messages<br />
export USE_COLOR="y"<br />
<br />
# The remaining variables only affect the behavior of makepkg<br />
# Enable fakeroot for building packages as a non-root user.<br />
# See 'man fakeroot' for more information on fakeroot<br />
export USE_FAKEROOT="y"<br />
<br />
# The directory where all packages will be placed (default is ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Base of the ABS tree (default is /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Set this if you want your name to show up in the packages you build<br />
export PACKAGER="John Doe <nowhere@microsoft.com>"<br />
</pre><br />
<br />
A word of caution: Users should be sure of any changes they may make to the variables <code>CFLAGS</code>, <code>CXXFLAGS</code>, and <code>MAKEFLAGS</code> 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 <code>CARCH</code>, <code>CHOST</code>, and <code>USE_FAKEROOT</code>.<br />
<br />
References for gcc and make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]<br />
<br />
==== Other uses of ABS====<br />
<br />
Well here are two more wiki pages, whose goal is to go deeper in ABS :<br />
* [[The Arch package making HOW-TO - with guidelines]]<br />
* [[Custom local repository with ABS and gensync]]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1456Arch Build System2006-08-08T17:08:13Z<p>Wtfoo: /* Die build Funktion */</p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. im Verzeichnis 'foo' gespeichert hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meist ''foo''.pkg.tar.gz genannt ist.<br />
<br />
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:<br />
<br />
* Die zu installierenden Dateien<br />
<br />
*.PKGINFO : enthält alle Metadaten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.<br />
<br />
*.FILELIST : enthält alle Dateien des Archives. Nötig um ein Paket zu deinstallieren oder um ggf. Abhängigkeitskonflikte festzustellen<br />
<br />
*.INSTALL : enthält Befehle, die nach dem Installieren/Upgraden/Deinstallieren ausgeführt werden. (Nur vorhanden, wenn es in PKGBUILD definiert wurde)<br />
<br />
==== Was ist PKGBUILD und was enthält es? ====<br />
<br />
Wie schon gesagt, enthält PKGBUILD die Metadaten über ein Paket. Es ist eine einfache Textdatei, die z.B. so aussehen könnte:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Erklärung für jede Zeile:<br />
<br />
* '''# text''' : Kommentare<br />
* '''# $Id: PKGBUILD,v ...''' : Das CVS-Tag für dieses Paket (Vom Archlinux-CVS System erstellt).<br />
* '''# Maintainer''' : Der Verantwortliche für dieses Paket in den offiziellen Repo's.<br />
* '''# Contributor''' : Der Verfasser der ersten PKGBUILD für dieses Paket.<br />
* '''pkgname''' : Der Paketname<br />
* '''pkgver''' : Die Paketversion<br />
* '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion.<br />
* '''pkgdesc''' : Eine Kurzbeschreibung des Paketes. Du siehst sie, in der [http://archlinux.org/packages.php Paket Datenbank]<br />
* '''arch''' : Die Architekturen, auf denen das Paket kompiliert und getestet wurde.<br />
* '''url''' : Die Homepage des Programmes<br />
* '''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<br />
* '''provides''' : Wird genutzt, wenn das Paket ein anderes Paket enthält. z.B. enthält 'kernel-scsi' 'kernel'<br />
* '''depends''' : Liste der Abhängigkeiten um das Programm auszuführen.<br />
* '''makedepends''' : Liste der Abhängigkeiten um das Programm zu kompilieren.<br />
* '''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>. <br />
* '''replaces''' : Das neue Paket ersetzt das Alte. In unserem Fall wird <i>mffoo (my first foo)</i> nicht mehr unterstützt und wird durch <i>foo</i> ersetzt.<br />
* '''backup''' : Dateien, die gesichert werden (als .pacsave), wenn das Programm deinstalliert wird.<br />
* '''install''' : Spezifiziert ein Installationsskript, das im Paket enthalten ist. (Muss sich mit PKGBUILD im selben Verzeichnis befinden)<br />
* '''source''' : Die Bezugsquelle des Quelltextes. Kann sowohl ein lokales Paket, als auch ein remote "http" oder "ftp" Paket sein. Der Dateiname wird aus <i>pkgname</i> und <i>pkgver</i> erstellt, damit der Pfad nicht bei jeder neuen Version angepasst werden muss.<br />
* '''md5sums''' : MD5 Summen der Quelltexte um beschädigte Dateien auszuschließen.<br />
<br />
Nun die Funktionen:<br />
<br />
* build : Alle Schritte, die nötig sind um das Paket zu kompilieren. (Darauf gehen wir später besser ein).<br />
<br />
Wie du siehst enthält PKGBUILD alle Informationen die von der Paketverwaltung gebraucht werden könnten. Es ist das Herzstück von pacman und ABS.<br />
<br />
Es sind auch Installationsdateien vorhanden. Unser PKGBUILD gibt 'foo.install' als Installationsdatei an. Es könnte z.B. folgendes enthalten:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Erklärungen:<br />
<br />
* post_install : Wird nach der Installation ausgeführt. Es wird ein Argument übergeben:<br />
** Die Paketversion<br />
* post_upgrade : Wird ausgeführt, nachdem alle Dateien aktualisiert wurden <em> Es werden zwei Argumente übergeben</em>:<br />
** Die neue Paketversion<br />
** Die alte Paketversion<br />
* pre_remove : Wird ausgeführt, bevor Dateien gelöscht werden (beendet z.B. daemonen) und übergibt ein Argument:<br />
** Die Paketversion<br />
<br />
Damit die Installationsdateien funktionieren, müssen diese drei Zeilen am Ende jeder Installationsdatei vorhanden sein.<br />
<br />
==== Die build Funktion====<br />
<br />
Wenn du dich nicht mit dem Bauen von Paketen auskennst, solltest du wissen, dass die meisten Pakete über den 'Dreisatz' gebaut werden können:<br />
<br />
* Paketdateien dekomprimieren : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* In das Verzeichnis wechseln<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* configure (1/3): normalerweise ist ein kleines Script <code>configure</code> im Quelltextverzeichniss vorhanden. Es wird genutzt um das Paket zu konfigurieren (hinzufügen von Unterstützungen, Installationsverzeichnis festlegen, ...) und sicher zu stellen, dass alle Abhängigkeiten aufgelöst sind.<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
Du solltest zuerst einen Blick in die 'help' Option werfen:<br />
<br />
<pre>./configure --help</pre><br />
<br />
* make (2/3) : Kompilieren der Quelltexte<br />
<br />
<pre>make</pre><br />
<br />
* install (3/3)<br />
<br />
<pre>make install</pre><br />
<br />
Du solltest immer die <code>INSTALL</code> Datei lesen, um zu erfahren, wie das Paket gebaut und installiert werden sollte denn nicht alle Pakete nutzen den Dreisatz 'configure; make; make install'!<br />
<br />
Schauen wir uns die 'standart' build Funktion an :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Was wir tuen :<br />
* In das Verzeichnis der entpackten Quelltexte wechseln :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
* Konfigurieren des Paketes mit dem Installationsverzeichnis <code>/usr</code> :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* installiere das Programm nicht in <code>/usr</code> sondern in <code>$startdir/pkg/usr</code>, sodass pacman Kontrolle über die Dateien hat :<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
What we want to do is build the package not to install it, so instead of installing to the standard place (<code>/usr</code>), we tell <code>make</code> to put all files in our special directory : <code>$startdir/pkg/usr</code>. Thus, makepkg can look and see which files the package installs, and then compress them into the Arch package.<br />
<br />
'''NOTE''': It is sometimes the case where <code>prefix</code> is not used in the <code>Makefile</code>; often <code>DESTDIR</code> is used instead. If the package is built with autoconf/automake, use <code>DESTDIR</code>, this is what is [http://sources.redhat.com/automake/automake.html#Install documented] in the manuals. Check if the generated <code>filelist</code> is a lot shorter than it should be, and if so, try building with <code>make DESTDIR=$startdir/pkg install</code>. If that does not work, you'll have to look further into the install commands that are executed by "<code>make <...> install=</code>".<br />
<br />
==== The ABS tree====<br />
<br />
When you run abs for the first time :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
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 :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
So the ABS tree has exactly the same structure as the package database :<br />
* first level directory represent categories<br />
* second level directories represent the packages<br />
* PKGBUILD files contains every information needed concerning the package<br />
<br />
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.<br />
<br />
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''<br />
<br />
Now that you know what the ABS tree is, how can we use it ?<br />
<br />
==== First use of ABS : customizing a package====<br />
<br />
This situation can arise more often than you may think : official packages are compiled choosing a certain number of <code>--enable</code> or <code>--disable</code> options, and these are not necessarily the ones you would have chosen.<br />
<br />
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 :<br />
* find where is the ''foo'' package located. you can do this by :<br />
<br />
search for ''foo'' at [http://archlinux.org/packages.php]<br />
use the find command :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
use the slocate command :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In any case, you'll find that foo is part of <code>extra</code> and <code>multimedia</code> (for example)<br />
<br />
* copy the ''foo'' <code>PKGBUILD</code> file to <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* modify the <code>PKGBUILD</code> file : we'll add support for '''arts''' :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
becomes :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* launch <code>makepkg</code> :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* install the new package using one of the following commands (<code>-A</code> for install, <code>-U</code> to upgrade an already installed package):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Compiler Flags and Customizing makepkg====<br />
<br />
The configuration file for <code>makepkg</code> is <code>/etc/makepkg.conf</code>. Here you can set environment variables for <code>gcc</code> and <code>make</code>, as well as some for <code>makepkg</code> itself. The following is an example of <code>/etc/makepkg.conf</code>.<br />
<br />
<pre><br />
# The FTP/HTTP download utility that makepkg will use to acquire sources<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Information passed to gcc about what type of computer this is.<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags passed to gcc when a package is being compiled<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags passed to make when a package is being compiled<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Enable colorized output messages<br />
export USE_COLOR="y"<br />
<br />
# The remaining variables only affect the behavior of makepkg<br />
# Enable fakeroot for building packages as a non-root user.<br />
# See 'man fakeroot' for more information on fakeroot<br />
export USE_FAKEROOT="y"<br />
<br />
# The directory where all packages will be placed (default is ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Base of the ABS tree (default is /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Set this if you want your name to show up in the packages you build<br />
export PACKAGER="John Doe <nowhere@microsoft.com>"<br />
</pre><br />
<br />
A word of caution: Users should be sure of any changes they may make to the variables <code>CFLAGS</code>, <code>CXXFLAGS</code>, and <code>MAKEFLAGS</code> 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 <code>CARCH</code>, <code>CHOST</code>, and <code>USE_FAKEROOT</code>.<br />
<br />
References for gcc and make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]<br />
<br />
==== Other uses of ABS====<br />
<br />
Well here are two more wiki pages, whose goal is to go deeper in ABS :<br />
* [[The Arch package making HOW-TO - with guidelines]]<br />
* [[Custom local repository with ABS and gensync]]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1455Arch Build System2006-08-08T16:50:32Z<p>Wtfoo: /* Was ist PKGBUILD und was enthält es? */</p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. im Verzeichnis 'foo' gespeichert hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meist ''foo''.pkg.tar.gz genannt ist.<br />
<br />
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:<br />
<br />
* Die zu installierenden Dateien<br />
<br />
*.PKGINFO : enthält alle Metadaten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.<br />
<br />
*.FILELIST : enthält alle Dateien des Archives. Nötig um ein Paket zu deinstallieren oder um ggf. Abhängigkeitskonflikte festzustellen<br />
<br />
*.INSTALL : enthält Befehle, die nach dem Installieren/Upgraden/Deinstallieren ausgeführt werden. (Nur vorhanden, wenn es in PKGBUILD definiert wurde)<br />
<br />
==== Was ist PKGBUILD und was enthält es? ====<br />
<br />
Wie schon gesagt, enthält PKGBUILD die Metadaten über ein Paket. Es ist eine einfache Textdatei, die z.B. so aussehen könnte:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Erklärung für jede Zeile:<br />
<br />
* '''# text''' : Kommentare<br />
* '''# $Id: PKGBUILD,v ...''' : Das CVS-Tag für dieses Paket (Vom Archlinux-CVS System erstellt).<br />
* '''# Maintainer''' : Der Verantwortliche für dieses Paket in den offiziellen Repo's.<br />
* '''# Contributor''' : Der Verfasser der ersten PKGBUILD für dieses Paket.<br />
* '''pkgname''' : Der Paketname<br />
* '''pkgver''' : Die Paketversion<br />
* '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion.<br />
* '''pkgdesc''' : Eine Kurzbeschreibung des Paketes. Du siehst sie, in der [http://archlinux.org/packages.php Paket Datenbank]<br />
* '''arch''' : Die Architekturen, auf denen das Paket kompiliert und getestet wurde.<br />
* '''url''' : Die Homepage des Programmes<br />
* '''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<br />
* '''provides''' : Wird genutzt, wenn das Paket ein anderes Paket enthält. z.B. enthält 'kernel-scsi' 'kernel'<br />
* '''depends''' : Liste der Abhängigkeiten um das Programm auszuführen.<br />
* '''makedepends''' : Liste der Abhängigkeiten um das Programm zu kompilieren.<br />
* '''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>. <br />
* '''replaces''' : Das neue Paket ersetzt das Alte. In unserem Fall wird <i>mffoo (my first foo)</i> nicht mehr unterstützt und wird durch <i>foo</i> ersetzt.<br />
* '''backup''' : Dateien, die gesichert werden (als .pacsave), wenn das Programm deinstalliert wird.<br />
* '''install''' : Spezifiziert ein Installationsskript, das im Paket enthalten ist. (Muss sich mit PKGBUILD im selben Verzeichnis befinden)<br />
* '''source''' : Die Bezugsquelle des Quelltextes. Kann sowohl ein lokales Paket, als auch ein remote "http" oder "ftp" Paket sein. Der Dateiname wird aus <i>pkgname</i> und <i>pkgver</i> erstellt, damit der Pfad nicht bei jeder neuen Version angepasst werden muss.<br />
* '''md5sums''' : MD5 Summen der Quelltexte um beschädigte Dateien auszuschließen.<br />
<br />
Nun die Funktionen:<br />
<br />
* build : Alle Schritte, die nötig sind um das Paket zu kompilieren. (Darauf gehen wir später besser ein).<br />
<br />
Wie du siehst enthält PKGBUILD alle Informationen die von der Paketverwaltung gebraucht werden könnten. Es ist das Herzstück von pacman und ABS.<br />
<br />
Es sind auch Installationsdateien vorhanden. Unser PKGBUILD gibt 'foo.install' als Installationsdatei an. Es könnte z.B. folgendes enthalten:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Erklärungen:<br />
<br />
* post_install : Wird nach der Installation ausgeführt. Es wird ein Argument übergeben:<br />
** Die Paketversion<br />
* post_upgrade : Wird ausgeführt, nachdem alle Dateien aktualisiert wurden <em> Es werden zwei Argumente übergeben</em>:<br />
** Die neue Paketversion<br />
** Die alte Paketversion<br />
* pre_remove : Wird ausgeführt, bevor Dateien gelöscht werden (beendet z.B. daemonen) und übergibt ein Argument:<br />
** Die Paketversion<br />
<br />
Damit die Installationsdateien funktionieren, müssen diese drei Zeilen am Ende jeder Installationsdatei vorhanden sein.<br />
<br />
==== Die build Funktion====<br />
<br />
Wenn du dich nicht mit dem Bauen von Paketen auskennst, solltest du wissen, dass die meisten Pakete über den 'Dreisatz' gebaut werden können:<br />
<br />
* Paketdateien dekomprimieren : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* In das Verzeichnis wechseln<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* Paket konfigurieren : normalerweise ist ein kleines Script <code>configure</code> im Quelltextverzeichniss vorhanden. Es wird genutzt um das Paket zu konfigurieren (hinzufügen von Unterstützungen, Installationsverzeichnis festlegen, ...)<br />
* configure the package : generally, there is a little script called <code>configure</code> 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 :<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
You should first try the help to better understand how it works :<br />
<br />
<pre>./configure --help</pre><br />
<br />
* compile the sources :<br />
<br />
<pre>make</pre><br />
<br />
* install<br />
<br />
<pre>make install</pre><br />
<br />
However, you should always read the <code>INSTALL</code> file to know how the package should be built and install ! '''Not all packages use the <code>configure; make; make install</code> system!<br />
<br />
So let's take a look at a "standard" build function :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
What we do is :<br />
* enter the directory where sources were uncompressed :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
But if you try to build your package, be carefull that this is the right directory : sometimes the uncompressed directory might be named differently :<br />
<br />
<pre>tar -xzf foo-0.99.tar.gz</pre><br />
<br />
and a <code>ls</code> might return :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo/</pre><br />
<br />
and not :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo-0.99/</pre><br />
<br />
* configure the package, and tell it to install in the <code>/usr</code> directory :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* install the software but not in <code>/usr</code>, in <code>$startdir/pkg/usr</code> so that pacman has control of the files.<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
What we want to do is build the package not to install it, so instead of installing to the standard place (<code>/usr</code>), we tell <code>make</code> to put all files in our special directory : <code>$startdir/pkg/usr</code>. Thus, makepkg can look and see which files the package installs, and then compress them into the Arch package.<br />
<br />
'''NOTE''': It is sometimes the case where <code>prefix</code> is not used in the <code>Makefile</code>; often <code>DESTDIR</code> is used instead. If the package is built with autoconf/automake, use <code>DESTDIR</code>, this is what is [http://sources.redhat.com/automake/automake.html#Install documented] in the manuals. Check if the generated <code>filelist</code> is a lot shorter than it should be, and if so, try building with <code>make DESTDIR=$startdir/pkg install</code>. If that does not work, you'll have to look further into the install commands that are executed by "<code>make <...> install=</code>".<br />
<br />
==== The ABS tree====<br />
<br />
When you run abs for the first time :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
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 :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
So the ABS tree has exactly the same structure as the package database :<br />
* first level directory represent categories<br />
* second level directories represent the packages<br />
* PKGBUILD files contains every information needed concerning the package<br />
<br />
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.<br />
<br />
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''<br />
<br />
Now that you know what the ABS tree is, how can we use it ?<br />
<br />
==== First use of ABS : customizing a package====<br />
<br />
This situation can arise more often than you may think : official packages are compiled choosing a certain number of <code>--enable</code> or <code>--disable</code> options, and these are not necessarily the ones you would have chosen.<br />
<br />
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 :<br />
* find where is the ''foo'' package located. you can do this by :<br />
<br />
search for ''foo'' at [http://archlinux.org/packages.php]<br />
use the find command :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
use the slocate command :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In any case, you'll find that foo is part of <code>extra</code> and <code>multimedia</code> (for example)<br />
<br />
* copy the ''foo'' <code>PKGBUILD</code> file to <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* modify the <code>PKGBUILD</code> file : we'll add support for '''arts''' :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
becomes :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* launch <code>makepkg</code> :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* install the new package using one of the following commands (<code>-A</code> for install, <code>-U</code> to upgrade an already installed package):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Compiler Flags and Customizing makepkg====<br />
<br />
The configuration file for <code>makepkg</code> is <code>/etc/makepkg.conf</code>. Here you can set environment variables for <code>gcc</code> and <code>make</code>, as well as some for <code>makepkg</code> itself. The following is an example of <code>/etc/makepkg.conf</code>.<br />
<br />
<pre><br />
# The FTP/HTTP download utility that makepkg will use to acquire sources<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Information passed to gcc about what type of computer this is.<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags passed to gcc when a package is being compiled<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags passed to make when a package is being compiled<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Enable colorized output messages<br />
export USE_COLOR="y"<br />
<br />
# The remaining variables only affect the behavior of makepkg<br />
# Enable fakeroot for building packages as a non-root user.<br />
# See 'man fakeroot' for more information on fakeroot<br />
export USE_FAKEROOT="y"<br />
<br />
# The directory where all packages will be placed (default is ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Base of the ABS tree (default is /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Set this if you want your name to show up in the packages you build<br />
export PACKAGER="John Doe <nowhere@microsoft.com>"<br />
</pre><br />
<br />
A word of caution: Users should be sure of any changes they may make to the variables <code>CFLAGS</code>, <code>CXXFLAGS</code>, and <code>MAKEFLAGS</code> 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 <code>CARCH</code>, <code>CHOST</code>, and <code>USE_FAKEROOT</code>.<br />
<br />
References for gcc and make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]<br />
<br />
==== Other uses of ABS====<br />
<br />
Well here are two more wiki pages, whose goal is to go deeper in ABS :<br />
* [[The Arch package making HOW-TO - with guidelines]]<br />
* [[Custom local repository with ABS and gensync]]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1454Arch Build System2006-08-08T16:49:35Z<p>Wtfoo: /* Vorbereitung */</p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. im Verzeichnis 'foo' gespeichert hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meist ''foo''.pkg.tar.gz genannt ist.<br />
<br />
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:<br />
<br />
* Die zu installierenden Dateien<br />
<br />
*.PKGINFO : enthält alle Metadaten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.<br />
<br />
*.FILELIST : enthält alle Dateien des Archives. Nötig um ein Paket zu deinstallieren oder um ggf. Abhängigkeitskonflikte festzustellen<br />
<br />
*.INSTALL : enthält Befehle, die nach dem Installieren/Upgraden/Deinstallieren ausgeführt werden. (Nur vorhanden, wenn es in PKGBUILD definiert wurde)<br />
<br />
==== Was ist PKGBUILD und was enthält es? ====<br />
<br />
Wie schon gesagt, enthält PKGBUILD die Metadaten über ein Paket. Es ist eine einfache Textdatei, die z.B. so aussehen könnte:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Erklärung für jede Zeile:<br />
<br />
* '''# text''' : Kommentare<br />
* '''# $Id: PKGBUILD,v ...''' : Das CVS-Tag für dieses Paket (Vom Archlinux-CVS System erstellt).<br />
* '''# Maintainer''' : Der Verantwortliche für dieses Paket in den offiziellen Repo's.<br />
* '''# Contributor''' : Der Verfasser der ersten PKGBUILD für dieses Paket.<br />
* '''pkgname''' : Der Paketname<br />
* '''pkgver''' : Die Paketversion<br />
* '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion.<br />
* '''pkgdesc''' : Eine Kurzbeschreibung des Paketes. Du siehst sie, in der [http://archlinux.org/packages.php Paket Datenbank]<br />
* '''arch''' : Die Architekturen, auf denen das Paket kompiliert und getestet wurde.<br />
* '''url''' : Die Homepage des Programmes<br />
* '''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<br />
* '''provides''' : Wird genutzt, wenn das Paket ein anderes Paket enthält. z.B. enthält 'kernel-scsi' 'kernel'<br />
* '''depends''' : Liste der Abhängigkeiten um das Programm auszuführen.<br />
* '''makedepends''' : Liste der Abhängigkeiten um das Programm zu kompilieren.<br />
* '''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>. <br />
* '''replaces''' : Das neue Paket ersetzt das Alte. In unserem Fall wird <i>mffoo (my first foo)</i> nicht mehr unterstützt und wird durch <i>foo</i> ersetzt.<br />
* '''backup''' : Dateien, die gesichert werden (als .pacsave), wenn das Programm deinstalliert wird.<br />
* '''install''' : Spezifiziert ein Installationsskript, das im Paket enthalten ist. (Muss sich mit PKGBUILD im selben Ordner befinden)<br />
* '''source''' : Die Bezugsquelle des Quelltextes. Kann sowohl ein lokales Paket, als auch ein remote "http" oder "ftp" Paket sein. Der Dateiname wird aus <i>pkgname</i> und <i>pkgver</i> erstellt, damit der Pfad nicht bei jeder neuen Version angepasst werden muss.<br />
* '''md5sums''' : MD5 Summen der Quelltexte um beschädigte Dateien auszuschließen.<br />
<br />
Nun die Funktionen:<br />
<br />
* build : Alle Schritte, die nötig sind um das Paket zu kompilieren. (Darauf gehen wir später besser ein).<br />
<br />
Wie du siehst enthält PKGBUILD alle Informationen die von der Paketverwaltung gebraucht werden könnten. Es ist das Herzstück von pacman und ABS.<br />
<br />
Es sind auch Installationsdateien vorhanden. Unser PKGBUILD gibt 'foo.install' als Installationsdatei an. Es könnte z.B. folgendes enthalten:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Erklärungen:<br />
<br />
* post_install : Wird nach der Installation ausgeführt. Es wird ein Argument übergeben:<br />
** Die Paketversion<br />
* post_upgrade : Wird ausgeführt, nachdem alle Dateien aktualisiert wurden <em> Es werden zwei Argumente übergeben</em>:<br />
** Die neue Paketversion<br />
** Die alte Paketversion<br />
* pre_remove : Wird ausgeführt, bevor Dateien gelöscht werden (beendet z.B. daemonen) und übergibt ein Argument:<br />
** Die Paketversion<br />
<br />
Damit die Installationsdateien funktionieren, müssen diese drei Zeilen am Ende jeder Installationsdatei vorhanden sein.<br />
<br />
==== Die build Funktion====<br />
<br />
Wenn du dich nicht mit dem Bauen von Paketen auskennst, solltest du wissen, dass die meisten Pakete über den 'Dreisatz' gebaut werden können:<br />
<br />
* Paketdateien dekomprimieren : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* In das Verzeichnis wechseln<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* Paket konfigurieren : normalerweise ist ein kleines Script <code>configure</code> im Quelltextverzeichniss vorhanden. Es wird genutzt um das Paket zu konfigurieren (hinzufügen von Unterstützungen, Installationsverzeichnis festlegen, ...)<br />
* configure the package : generally, there is a little script called <code>configure</code> 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 :<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
You should first try the help to better understand how it works :<br />
<br />
<pre>./configure --help</pre><br />
<br />
* compile the sources :<br />
<br />
<pre>make</pre><br />
<br />
* install<br />
<br />
<pre>make install</pre><br />
<br />
However, you should always read the <code>INSTALL</code> file to know how the package should be built and install ! '''Not all packages use the <code>configure; make; make install</code> system!<br />
<br />
So let's take a look at a "standard" build function :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
What we do is :<br />
* enter the directory where sources were uncompressed :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
But if you try to build your package, be carefull that this is the right directory : sometimes the uncompressed directory might be named differently :<br />
<br />
<pre>tar -xzf foo-0.99.tar.gz</pre><br />
<br />
and a <code>ls</code> might return :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo/</pre><br />
<br />
and not :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo-0.99/</pre><br />
<br />
* configure the package, and tell it to install in the <code>/usr</code> directory :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* install the software but not in <code>/usr</code>, in <code>$startdir/pkg/usr</code> so that pacman has control of the files.<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
What we want to do is build the package not to install it, so instead of installing to the standard place (<code>/usr</code>), we tell <code>make</code> to put all files in our special directory : <code>$startdir/pkg/usr</code>. Thus, makepkg can look and see which files the package installs, and then compress them into the Arch package.<br />
<br />
'''NOTE''': It is sometimes the case where <code>prefix</code> is not used in the <code>Makefile</code>; often <code>DESTDIR</code> is used instead. If the package is built with autoconf/automake, use <code>DESTDIR</code>, this is what is [http://sources.redhat.com/automake/automake.html#Install documented] in the manuals. Check if the generated <code>filelist</code> is a lot shorter than it should be, and if so, try building with <code>make DESTDIR=$startdir/pkg install</code>. If that does not work, you'll have to look further into the install commands that are executed by "<code>make <...> install=</code>".<br />
<br />
==== The ABS tree====<br />
<br />
When you run abs for the first time :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
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 :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
So the ABS tree has exactly the same structure as the package database :<br />
* first level directory represent categories<br />
* second level directories represent the packages<br />
* PKGBUILD files contains every information needed concerning the package<br />
<br />
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.<br />
<br />
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''<br />
<br />
Now that you know what the ABS tree is, how can we use it ?<br />
<br />
==== First use of ABS : customizing a package====<br />
<br />
This situation can arise more often than you may think : official packages are compiled choosing a certain number of <code>--enable</code> or <code>--disable</code> options, and these are not necessarily the ones you would have chosen.<br />
<br />
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 :<br />
* find where is the ''foo'' package located. you can do this by :<br />
<br />
search for ''foo'' at [http://archlinux.org/packages.php]<br />
use the find command :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
use the slocate command :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In any case, you'll find that foo is part of <code>extra</code> and <code>multimedia</code> (for example)<br />
<br />
* copy the ''foo'' <code>PKGBUILD</code> file to <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* modify the <code>PKGBUILD</code> file : we'll add support for '''arts''' :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
becomes :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* launch <code>makepkg</code> :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* install the new package using one of the following commands (<code>-A</code> for install, <code>-U</code> to upgrade an already installed package):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Compiler Flags and Customizing makepkg====<br />
<br />
The configuration file for <code>makepkg</code> is <code>/etc/makepkg.conf</code>. Here you can set environment variables for <code>gcc</code> and <code>make</code>, as well as some for <code>makepkg</code> itself. The following is an example of <code>/etc/makepkg.conf</code>.<br />
<br />
<pre><br />
# The FTP/HTTP download utility that makepkg will use to acquire sources<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Information passed to gcc about what type of computer this is.<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags passed to gcc when a package is being compiled<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags passed to make when a package is being compiled<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Enable colorized output messages<br />
export USE_COLOR="y"<br />
<br />
# The remaining variables only affect the behavior of makepkg<br />
# Enable fakeroot for building packages as a non-root user.<br />
# See 'man fakeroot' for more information on fakeroot<br />
export USE_FAKEROOT="y"<br />
<br />
# The directory where all packages will be placed (default is ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Base of the ABS tree (default is /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Set this if you want your name to show up in the packages you build<br />
export PACKAGER="John Doe <nowhere@microsoft.com>"<br />
</pre><br />
<br />
A word of caution: Users should be sure of any changes they may make to the variables <code>CFLAGS</code>, <code>CXXFLAGS</code>, and <code>MAKEFLAGS</code> 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 <code>CARCH</code>, <code>CHOST</code>, and <code>USE_FAKEROOT</code>.<br />
<br />
References for gcc and make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]<br />
<br />
==== Other uses of ABS====<br />
<br />
Well here are two more wiki pages, whose goal is to go deeper in ABS :<br />
* [[The Arch package making HOW-TO - with guidelines]]<br />
* [[Custom local repository with ABS and gensync]]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1453Arch Build System2006-08-08T16:49:13Z<p>Wtfoo: /* The build function */</p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. im Ordner 'foo' gespeichert hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meist ''foo''.pkg.tar.gz genannt ist.<br />
<br />
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:<br />
<br />
* Die zu installierenden Dateien<br />
<br />
*.PKGINFO : enthält alle Metadaten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.<br />
<br />
*.FILELIST : enthält alle Dateien des Archives. Nötig um ein Paket zu deinstallieren oder um ggf. Abhängigkeitskonflikte festzustellen<br />
<br />
*.INSTALL : enthält Befehle, die nach dem Installieren/Upgraden/Deinstallieren ausgeführt werden. (Nur vorhanden, wenn es in PKGBUILD definiert wurde)<br />
<br />
==== Was ist PKGBUILD und was enthält es? ====<br />
<br />
Wie schon gesagt, enthält PKGBUILD die Metadaten über ein Paket. Es ist eine einfache Textdatei, die z.B. so aussehen könnte:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Erklärung für jede Zeile:<br />
<br />
* '''# text''' : Kommentare<br />
* '''# $Id: PKGBUILD,v ...''' : Das CVS-Tag für dieses Paket (Vom Archlinux-CVS System erstellt).<br />
* '''# Maintainer''' : Der Verantwortliche für dieses Paket in den offiziellen Repo's.<br />
* '''# Contributor''' : Der Verfasser der ersten PKGBUILD für dieses Paket.<br />
* '''pkgname''' : Der Paketname<br />
* '''pkgver''' : Die Paketversion<br />
* '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion.<br />
* '''pkgdesc''' : Eine Kurzbeschreibung des Paketes. Du siehst sie, in der [http://archlinux.org/packages.php Paket Datenbank]<br />
* '''arch''' : Die Architekturen, auf denen das Paket kompiliert und getestet wurde.<br />
* '''url''' : Die Homepage des Programmes<br />
* '''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<br />
* '''provides''' : Wird genutzt, wenn das Paket ein anderes Paket enthält. z.B. enthält 'kernel-scsi' 'kernel'<br />
* '''depends''' : Liste der Abhängigkeiten um das Programm auszuführen.<br />
* '''makedepends''' : Liste der Abhängigkeiten um das Programm zu kompilieren.<br />
* '''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>. <br />
* '''replaces''' : Das neue Paket ersetzt das Alte. In unserem Fall wird <i>mffoo (my first foo)</i> nicht mehr unterstützt und wird durch <i>foo</i> ersetzt.<br />
* '''backup''' : Dateien, die gesichert werden (als .pacsave), wenn das Programm deinstalliert wird.<br />
* '''install''' : Spezifiziert ein Installationsskript, das im Paket enthalten ist. (Muss sich mit PKGBUILD im selben Ordner befinden)<br />
* '''source''' : Die Bezugsquelle des Quelltextes. Kann sowohl ein lokales Paket, als auch ein remote "http" oder "ftp" Paket sein. Der Dateiname wird aus <i>pkgname</i> und <i>pkgver</i> erstellt, damit der Pfad nicht bei jeder neuen Version angepasst werden muss.<br />
* '''md5sums''' : MD5 Summen der Quelltexte um beschädigte Dateien auszuschließen.<br />
<br />
Nun die Funktionen:<br />
<br />
* build : Alle Schritte, die nötig sind um das Paket zu kompilieren. (Darauf gehen wir später besser ein).<br />
<br />
Wie du siehst enthält PKGBUILD alle Informationen die von der Paketverwaltung gebraucht werden könnten. Es ist das Herzstück von pacman und ABS.<br />
<br />
Es sind auch Installationsdateien vorhanden. Unser PKGBUILD gibt 'foo.install' als Installationsdatei an. Es könnte z.B. folgendes enthalten:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Erklärungen:<br />
<br />
* post_install : Wird nach der Installation ausgeführt. Es wird ein Argument übergeben:<br />
** Die Paketversion<br />
* post_upgrade : Wird ausgeführt, nachdem alle Dateien aktualisiert wurden <em> Es werden zwei Argumente übergeben</em>:<br />
** Die neue Paketversion<br />
** Die alte Paketversion<br />
* pre_remove : Wird ausgeführt, bevor Dateien gelöscht werden (beendet z.B. daemonen) und übergibt ein Argument:<br />
** Die Paketversion<br />
<br />
Damit die Installationsdateien funktionieren, müssen diese drei Zeilen am Ende jeder Installationsdatei vorhanden sein.<br />
<br />
==== Die build Funktion====<br />
<br />
Wenn du dich nicht mit dem Bauen von Paketen auskennst, solltest du wissen, dass die meisten Pakete über den 'Dreisatz' gebaut werden können:<br />
<br />
* Paketdateien dekomprimieren : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* In das Verzeichnis wechseln<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* Paket konfigurieren : normalerweise ist ein kleines Script <code>configure</code> im Quelltextverzeichniss vorhanden. Es wird genutzt um das Paket zu konfigurieren (hinzufügen von Unterstützungen, Installationsverzeichnis festlegen, ...)<br />
* configure the package : generally, there is a little script called <code>configure</code> 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 :<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
You should first try the help to better understand how it works :<br />
<br />
<pre>./configure --help</pre><br />
<br />
* compile the sources :<br />
<br />
<pre>make</pre><br />
<br />
* install<br />
<br />
<pre>make install</pre><br />
<br />
However, you should always read the <code>INSTALL</code> file to know how the package should be built and install ! '''Not all packages use the <code>configure; make; make install</code> system!<br />
<br />
So let's take a look at a "standard" build function :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
What we do is :<br />
* enter the directory where sources were uncompressed :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
But if you try to build your package, be carefull that this is the right directory : sometimes the uncompressed directory might be named differently :<br />
<br />
<pre>tar -xzf foo-0.99.tar.gz</pre><br />
<br />
and a <code>ls</code> might return :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo/</pre><br />
<br />
and not :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo-0.99/</pre><br />
<br />
* configure the package, and tell it to install in the <code>/usr</code> directory :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* install the software but not in <code>/usr</code>, in <code>$startdir/pkg/usr</code> so that pacman has control of the files.<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
What we want to do is build the package not to install it, so instead of installing to the standard place (<code>/usr</code>), we tell <code>make</code> to put all files in our special directory : <code>$startdir/pkg/usr</code>. Thus, makepkg can look and see which files the package installs, and then compress them into the Arch package.<br />
<br />
'''NOTE''': It is sometimes the case where <code>prefix</code> is not used in the <code>Makefile</code>; often <code>DESTDIR</code> is used instead. If the package is built with autoconf/automake, use <code>DESTDIR</code>, this is what is [http://sources.redhat.com/automake/automake.html#Install documented] in the manuals. Check if the generated <code>filelist</code> is a lot shorter than it should be, and if so, try building with <code>make DESTDIR=$startdir/pkg install</code>. If that does not work, you'll have to look further into the install commands that are executed by "<code>make <...> install=</code>".<br />
<br />
==== The ABS tree====<br />
<br />
When you run abs for the first time :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
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 :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
So the ABS tree has exactly the same structure as the package database :<br />
* first level directory represent categories<br />
* second level directories represent the packages<br />
* PKGBUILD files contains every information needed concerning the package<br />
<br />
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.<br />
<br />
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''<br />
<br />
Now that you know what the ABS tree is, how can we use it ?<br />
<br />
==== First use of ABS : customizing a package====<br />
<br />
This situation can arise more often than you may think : official packages are compiled choosing a certain number of <code>--enable</code> or <code>--disable</code> options, and these are not necessarily the ones you would have chosen.<br />
<br />
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 :<br />
* find where is the ''foo'' package located. you can do this by :<br />
<br />
search for ''foo'' at [http://archlinux.org/packages.php]<br />
use the find command :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
use the slocate command :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In any case, you'll find that foo is part of <code>extra</code> and <code>multimedia</code> (for example)<br />
<br />
* copy the ''foo'' <code>PKGBUILD</code> file to <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* modify the <code>PKGBUILD</code> file : we'll add support for '''arts''' :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
becomes :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* launch <code>makepkg</code> :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* install the new package using one of the following commands (<code>-A</code> for install, <code>-U</code> to upgrade an already installed package):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Compiler Flags and Customizing makepkg====<br />
<br />
The configuration file for <code>makepkg</code> is <code>/etc/makepkg.conf</code>. Here you can set environment variables for <code>gcc</code> and <code>make</code>, as well as some for <code>makepkg</code> itself. The following is an example of <code>/etc/makepkg.conf</code>.<br />
<br />
<pre><br />
# The FTP/HTTP download utility that makepkg will use to acquire sources<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Information passed to gcc about what type of computer this is.<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags passed to gcc when a package is being compiled<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags passed to make when a package is being compiled<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Enable colorized output messages<br />
export USE_COLOR="y"<br />
<br />
# The remaining variables only affect the behavior of makepkg<br />
# Enable fakeroot for building packages as a non-root user.<br />
# See 'man fakeroot' for more information on fakeroot<br />
export USE_FAKEROOT="y"<br />
<br />
# The directory where all packages will be placed (default is ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Base of the ABS tree (default is /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Set this if you want your name to show up in the packages you build<br />
export PACKAGER="John Doe <nowhere@microsoft.com>"<br />
</pre><br />
<br />
A word of caution: Users should be sure of any changes they may make to the variables <code>CFLAGS</code>, <code>CXXFLAGS</code>, and <code>MAKEFLAGS</code> 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 <code>CARCH</code>, <code>CHOST</code>, and <code>USE_FAKEROOT</code>.<br />
<br />
References for gcc and make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]<br />
<br />
==== Other uses of ABS====<br />
<br />
Well here are two more wiki pages, whose goal is to go deeper in ABS :<br />
* [[The Arch package making HOW-TO - with guidelines]]<br />
* [[Custom local repository with ABS and gensync]]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1452Arch Build System2006-08-08T16:37:31Z<p>Wtfoo: /* Was ist PKGBUILD und was enthält es? */</p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. im Ordner 'foo' gespeichert hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meist ''foo''.pkg.tar.gz genannt ist.<br />
<br />
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:<br />
<br />
* Die zu installierenden Dateien<br />
<br />
*.PKGINFO : enthält alle Metadaten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.<br />
<br />
*.FILELIST : enthält alle Dateien des Archives. Nötig um ein Paket zu deinstallieren oder um ggf. Abhängigkeitskonflikte festzustellen<br />
<br />
*.INSTALL : enthält Befehle, die nach dem Installieren/Upgraden/Deinstallieren ausgeführt werden. (Nur vorhanden, wenn es in PKGBUILD definiert wurde)<br />
<br />
==== Was ist PKGBUILD und was enthält es? ====<br />
<br />
Wie schon gesagt, enthält PKGBUILD die Metadaten über ein Paket. Es ist eine einfache Textdatei, die z.B. so aussehen könnte:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Erklärung für jede Zeile:<br />
<br />
* '''# text''' : Kommentare<br />
* '''# $Id: PKGBUILD,v ...''' : Das CVS-Tag für dieses Paket (Vom Archlinux-CVS System erstellt).<br />
* '''# Maintainer''' : Der Verantwortliche für dieses Paket in den offiziellen Repo's.<br />
* '''# Contributor''' : Der Verfasser der ersten PKGBUILD für dieses Paket.<br />
* '''pkgname''' : Der Paketname<br />
* '''pkgver''' : Die Paketversion<br />
* '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion.<br />
* '''pkgdesc''' : Eine Kurzbeschreibung des Paketes. Du siehst sie, in der [http://archlinux.org/packages.php Paket Datenbank]<br />
* '''arch''' : Die Architekturen, auf denen das Paket kompiliert und getestet wurde.<br />
* '''url''' : Die Homepage des Programmes<br />
* '''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<br />
* '''provides''' : Wird genutzt, wenn das Paket ein anderes Paket enthält. z.B. enthält 'kernel-scsi' 'kernel'<br />
* '''depends''' : Liste der Abhängigkeiten um das Programm auszuführen.<br />
* '''makedepends''' : Liste der Abhängigkeiten um das Programm zu kompilieren.<br />
* '''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>. <br />
* '''replaces''' : Das neue Paket ersetzt das Alte. In unserem Fall wird <i>mffoo (my first foo)</i> nicht mehr unterstützt und wird durch <i>foo</i> ersetzt.<br />
* '''backup''' : Dateien, die gesichert werden (als .pacsave), wenn das Programm deinstalliert wird.<br />
* '''install''' : Spezifiziert ein Installationsskript, das im Paket enthalten ist. (Muss sich mit PKGBUILD im selben Ordner befinden)<br />
* '''source''' : Die Bezugsquelle des Quelltextes. Kann sowohl ein lokales Paket, als auch ein remote "http" oder "ftp" Paket sein. Der Dateiname wird aus <i>pkgname</i> und <i>pkgver</i> erstellt, damit der Pfad nicht bei jeder neuen Version angepasst werden muss.<br />
* '''md5sums''' : MD5 Summen der Quelltexte um beschädigte Dateien auszuschließen.<br />
<br />
Nun die Funktionen:<br />
<br />
* build : Alle Schritte, die nötig sind um das Paket zu kompilieren. (Darauf gehen wir später besser ein).<br />
<br />
Wie du siehst enthält PKGBUILD alle Informationen die von der Paketverwaltung gebraucht werden könnten. Es ist das Herzstück von pacman und ABS.<br />
<br />
Es sind auch Installationsdateien vorhanden. Unser PKGBUILD gibt 'foo.install' als Installationsdatei an. Es könnte z.B. folgendes enthalten:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Erklärungen:<br />
<br />
* post_install : Wird nach der Installation ausgeführt. Es wird ein Argument übergeben:<br />
** Die Paketversion<br />
* post_upgrade : Wird ausgeführt, nachdem alle Dateien aktualisiert wurden <em> Es werden zwei Argumente übergeben</em>:<br />
** Die neue Paketversion<br />
** Die alte Paketversion<br />
* pre_remove : Wird ausgeführt, bevor Dateien gelöscht werden (beendet z.B. daemonen) und übergibt ein Argument:<br />
** Die Paketversion<br />
<br />
Damit die Installationsdateien funktionieren, müssen diese drei Zeilen am Ende jeder Installationsdatei vorhanden sein.<br />
<br />
==== The build function====<br />
<br />
If you're not familiar with building packages, you should know that most packages (but not all) can be built this way :<br />
* uncompress the source file : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* enter the directory<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* configure the package : generally, there is a little script called <code>configure</code> 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 :<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
You should first try the help to better understand how it works :<br />
<br />
<pre>./configure --help</pre><br />
<br />
* compile the sources :<br />
<br />
<pre>make</pre><br />
<br />
* install<br />
<br />
<pre>make install</pre><br />
<br />
However, you should always read the <code>INSTALL</code> file to know how the package should be built and install ! '''Not all packages use the <code>configure; make; make install</code> system!<br />
<br />
So let's take a look at a "standard" build function :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
What we do is :<br />
* enter the directory where sources were uncompressed :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
But if you try to build your package, be carefull that this is the right directory : sometimes the uncompressed directory might be named differently :<br />
<br />
<pre>tar -xzf foo-0.99.tar.gz</pre><br />
<br />
and a <code>ls</code> might return :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo/</pre><br />
<br />
and not :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo-0.99/</pre><br />
<br />
* configure the package, and tell it to install in the <code>/usr</code> directory :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* install the software but not in <code>/usr</code>, in <code>$startdir/pkg/usr</code> so that pacman has control of the files.<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
What we want to do is build the package not to install it, so instead of installing to the standard place (<code>/usr</code>), we tell <code>make</code> to put all files in our special directory : <code>$startdir/pkg/usr</code>. Thus, makepkg can look and see which files the package installs, and then compress them into the Arch package.<br />
<br />
'''NOTE''': It is sometimes the case where <code>prefix</code> is not used in the <code>Makefile</code>; often <code>DESTDIR</code> is used instead. If the package is built with autoconf/automake, use <code>DESTDIR</code>, this is what is [http://sources.redhat.com/automake/automake.html#Install documented] in the manuals. Check if the generated <code>filelist</code> is a lot shorter than it should be, and if so, try building with <code>make DESTDIR=$startdir/pkg install</code>. If that does not work, you'll have to look further into the install commands that are executed by "<code>make <...> install=</code>".<br />
<br />
==== The ABS tree====<br />
<br />
When you run abs for the first time :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
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 :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
So the ABS tree has exactly the same structure as the package database :<br />
* first level directory represent categories<br />
* second level directories represent the packages<br />
* PKGBUILD files contains every information needed concerning the package<br />
<br />
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.<br />
<br />
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''<br />
<br />
Now that you know what the ABS tree is, how can we use it ?<br />
<br />
==== First use of ABS : customizing a package====<br />
<br />
This situation can arise more often than you may think : official packages are compiled choosing a certain number of <code>--enable</code> or <code>--disable</code> options, and these are not necessarily the ones you would have chosen.<br />
<br />
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 :<br />
* find where is the ''foo'' package located. you can do this by :<br />
<br />
search for ''foo'' at [http://archlinux.org/packages.php]<br />
use the find command :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
use the slocate command :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In any case, you'll find that foo is part of <code>extra</code> and <code>multimedia</code> (for example)<br />
<br />
* copy the ''foo'' <code>PKGBUILD</code> file to <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* modify the <code>PKGBUILD</code> file : we'll add support for '''arts''' :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
becomes :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* launch <code>makepkg</code> :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* install the new package using one of the following commands (<code>-A</code> for install, <code>-U</code> to upgrade an already installed package):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Compiler Flags and Customizing makepkg====<br />
<br />
The configuration file for <code>makepkg</code> is <code>/etc/makepkg.conf</code>. Here you can set environment variables for <code>gcc</code> and <code>make</code>, as well as some for <code>makepkg</code> itself. The following is an example of <code>/etc/makepkg.conf</code>.<br />
<br />
<pre><br />
# The FTP/HTTP download utility that makepkg will use to acquire sources<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Information passed to gcc about what type of computer this is.<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags passed to gcc when a package is being compiled<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags passed to make when a package is being compiled<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Enable colorized output messages<br />
export USE_COLOR="y"<br />
<br />
# The remaining variables only affect the behavior of makepkg<br />
# Enable fakeroot for building packages as a non-root user.<br />
# See 'man fakeroot' for more information on fakeroot<br />
export USE_FAKEROOT="y"<br />
<br />
# The directory where all packages will be placed (default is ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Base of the ABS tree (default is /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Set this if you want your name to show up in the packages you build<br />
export PACKAGER="John Doe <nowhere@microsoft.com>"<br />
</pre><br />
<br />
A word of caution: Users should be sure of any changes they may make to the variables <code>CFLAGS</code>, <code>CXXFLAGS</code>, and <code>MAKEFLAGS</code> 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 <code>CARCH</code>, <code>CHOST</code>, and <code>USE_FAKEROOT</code>.<br />
<br />
References for gcc and make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]<br />
<br />
==== Other uses of ABS====<br />
<br />
Well here are two more wiki pages, whose goal is to go deeper in ABS :<br />
* [[The Arch package making HOW-TO - with guidelines]]<br />
* [[Custom local repository with ABS and gensync]]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1451Arch Build System2006-08-08T16:20:13Z<p>Wtfoo: </p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. im Ordner 'foo' gespeichert hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meist ''foo''.pkg.tar.gz genannt ist.<br />
<br />
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:<br />
<br />
* Die zu installierenden Dateien<br />
<br />
*.PKGINFO : enthält alle Metadaten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.<br />
<br />
*.FILELIST : enthält alle Dateien des Archives. Nötig um ein Paket zu deinstallieren oder um ggf. Abhängigkeitskonflikte festzustellen<br />
<br />
*.INSTALL : enthält Befehle, die nach dem Installieren/Upgraden/Deinstallieren ausgeführt werden. (Nur vorhanden, wenn es in PKGBUILD definiert wurde)<br />
<br />
==== Was ist PKGBUILD und was enthält es? ====<br />
<br />
Wie schon gesagt, enthält PKGBUILD die Metadaten über ein Paket. Es ist eine einfache Textdatei, die z.B. so aussehen könnte:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Erklärung für jede Zeile:<br />
<br />
* '''# text''' : Kommentare<br />
* '''# $Id: PKGBUILD,v ...''' : Das CVS-Tag für dieses Paket (Vom Archlinux-CVS System erstellt).<br />
* '''# Maintainer''' : Der Verantwortliche für dieses Paket in den offiziellen Repo's.<br />
* '''# Contributor''' : Der Verfasser der ersten PKGBUILD für dieses Paket.<br />
* '''pkgname''' : Der Paketname<br />
* '''pkgver''' : Die Paketversion<br />
* '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion.<br />
* '''pkgdesc''' : Eine Kurzbeschreibung des Paketes. Du siehst sie, in der [http://archlinux.org/packages.php Paket Datenbank]<br />
* '''arch''' : Die Architekturen, auf denen das Paket kompiliert und getestet wurde.<br />
* '''url''' : Die Homepage des Programmes<br />
* '''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<br />
* '''provides''' : Wird genutzt, wenn das Paket ein anderes Paket enthält. z.B. enthält 'kernel-scsi' 'kernel'<br />
* '''depends''' : Liste der Abhängigkeiten um das Programm auszuführen.<br />
* '''makedepends''' : Liste der Abhängigkeiten um das Programm zu kompilieren.<br />
* '''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>. <br />
* '''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><br />
* '''backup''' : which files to backup (as file.pacsave) when the package is removed<br />
* '''install''' : specifies a special install script that is to be included in the package (it has to be in the same directory as PKGBUILD)<br />
* '''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 <i>pkgname</i> and <i>pkgver</i> in order to avoid changing the source each time the version changes.<br />
* '''md5sums''' : md5sums of the source to check their integrity<br />
<br />
So now, let's explain the function :<br />
<br />
* build : all the actions needed to build the package (it will be explained with more attention later in this document)<br />
<br />
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.<br />
<br />
There are also install files. This PKGBUILD specifies 'foo.install' as the package's install file. Here is an example install file:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Here are the function explainations :<br />
<br />
* post_install : this script is run right after files are installed, it takes one argument : <br />
** the package version<br />
* post_upgrade : this script is run after all files have been upgraded, <em>it takes two arguments</em> :<br />
** the new package version<br />
** the old package version<br />
* pre_remove : this script is run right before files are removed (stop a daemon for example) and takes one argument : <br />
** the package version<br />
<br />
The three lines at the bottom are needed in every install file so that they run properly.<br />
<br />
==== The build function====<br />
<br />
If you're not familiar with building packages, you should know that most packages (but not all) can be built this way :<br />
* uncompress the source file : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* enter the directory<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* configure the package : generally, there is a little script called <code>configure</code> 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 :<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
You should first try the help to better understand how it works :<br />
<br />
<pre>./configure --help</pre><br />
<br />
* compile the sources :<br />
<br />
<pre>make</pre><br />
<br />
* install<br />
<br />
<pre>make install</pre><br />
<br />
However, you should always read the <code>INSTALL</code> file to know how the package should be built and install ! '''Not all packages use the <code>configure; make; make install</code> system!<br />
<br />
So let's take a look at a "standard" build function :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
What we do is :<br />
* enter the directory where sources were uncompressed :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
But if you try to build your package, be carefull that this is the right directory : sometimes the uncompressed directory might be named differently :<br />
<br />
<pre>tar -xzf foo-0.99.tar.gz</pre><br />
<br />
and a <code>ls</code> might return :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo/</pre><br />
<br />
and not :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo-0.99/</pre><br />
<br />
* configure the package, and tell it to install in the <code>/usr</code> directory :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* install the software but not in <code>/usr</code>, in <code>$startdir/pkg/usr</code> so that pacman has control of the files.<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
What we want to do is build the package not to install it, so instead of installing to the standard place (<code>/usr</code>), we tell <code>make</code> to put all files in our special directory : <code>$startdir/pkg/usr</code>. Thus, makepkg can look and see which files the package installs, and then compress them into the Arch package.<br />
<br />
'''NOTE''': It is sometimes the case where <code>prefix</code> is not used in the <code>Makefile</code>; often <code>DESTDIR</code> is used instead. If the package is built with autoconf/automake, use <code>DESTDIR</code>, this is what is [http://sources.redhat.com/automake/automake.html#Install documented] in the manuals. Check if the generated <code>filelist</code> is a lot shorter than it should be, and if so, try building with <code>make DESTDIR=$startdir/pkg install</code>. If that does not work, you'll have to look further into the install commands that are executed by "<code>make <...> install=</code>".<br />
<br />
==== The ABS tree====<br />
<br />
When you run abs for the first time :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
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 :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
So the ABS tree has exactly the same structure as the package database :<br />
* first level directory represent categories<br />
* second level directories represent the packages<br />
* PKGBUILD files contains every information needed concerning the package<br />
<br />
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.<br />
<br />
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''<br />
<br />
Now that you know what the ABS tree is, how can we use it ?<br />
<br />
==== First use of ABS : customizing a package====<br />
<br />
This situation can arise more often than you may think : official packages are compiled choosing a certain number of <code>--enable</code> or <code>--disable</code> options, and these are not necessarily the ones you would have chosen.<br />
<br />
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 :<br />
* find where is the ''foo'' package located. you can do this by :<br />
<br />
search for ''foo'' at [http://archlinux.org/packages.php]<br />
use the find command :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
use the slocate command :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In any case, you'll find that foo is part of <code>extra</code> and <code>multimedia</code> (for example)<br />
<br />
* copy the ''foo'' <code>PKGBUILD</code> file to <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* modify the <code>PKGBUILD</code> file : we'll add support for '''arts''' :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
becomes :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* launch <code>makepkg</code> :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* install the new package using one of the following commands (<code>-A</code> for install, <code>-U</code> to upgrade an already installed package):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Compiler Flags and Customizing makepkg====<br />
<br />
The configuration file for <code>makepkg</code> is <code>/etc/makepkg.conf</code>. Here you can set environment variables for <code>gcc</code> and <code>make</code>, as well as some for <code>makepkg</code> itself. The following is an example of <code>/etc/makepkg.conf</code>.<br />
<br />
<pre><br />
# The FTP/HTTP download utility that makepkg will use to acquire sources<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Information passed to gcc about what type of computer this is.<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags passed to gcc when a package is being compiled<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags passed to make when a package is being compiled<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Enable colorized output messages<br />
export USE_COLOR="y"<br />
<br />
# The remaining variables only affect the behavior of makepkg<br />
# Enable fakeroot for building packages as a non-root user.<br />
# See 'man fakeroot' for more information on fakeroot<br />
export USE_FAKEROOT="y"<br />
<br />
# The directory where all packages will be placed (default is ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Base of the ABS tree (default is /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Set this if you want your name to show up in the packages you build<br />
export PACKAGER="John Doe <nowhere@microsoft.com>"<br />
</pre><br />
<br />
A word of caution: Users should be sure of any changes they may make to the variables <code>CFLAGS</code>, <code>CXXFLAGS</code>, and <code>MAKEFLAGS</code> 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 <code>CARCH</code>, <code>CHOST</code>, and <code>USE_FAKEROOT</code>.<br />
<br />
References for gcc and make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]<br />
<br />
==== Other uses of ABS====<br />
<br />
Well here are two more wiki pages, whose goal is to go deeper in ABS :<br />
* [[The Arch package making HOW-TO - with guidelines]]<br />
* [[Custom local repository with ABS and gensync]]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1450Arch Build System2006-08-08T16:12:31Z<p>Wtfoo: </p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. im Ordner 'foo' gespeichert hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meist ''foo''.pkg.tar.gz genannt ist.<br />
<br />
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:<br />
<br />
* Die zu installierenden Dateien<br />
<br />
*.PKGINFO : enthält alle Metadaten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.<br />
<br />
*.FILELIST : enthält alle Dateien des Archives. Nötig um ein Paket zu deinstallieren oder um ggf. Abhängigkeitskonflikte festzustellen<br />
<br />
*.INSTALL : enthält Befehle, die nach dem Installieren/Upgraden/Deinstallieren ausgeführt werden. (Nur vorhanden, wenn es in PKGBUILD definiert wurde)<br />
<br />
==== Was ist PKGBUILD und was enthält es? ====<br />
<br />
Wie schon gesagt, enthält PKGBUILD die Metadaten über ein Paket. Es ist eine einfache Textdatei, die z.B. so aussehen könnte:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
Erklärung für jede Zeile:<br />
<br />
* '''# text''' : Kommentare<br />
* '''# $Id: PKGBUILD,v ...''' : Das CVS-Tag für dieses Paket (Vom Archlinux-CVS System erstellt).<br />
* '''# Maintainer''' : Der Verantwortliche für dieses Paket in den offiziellen Repo's.<br />
* '''# Contributor''' : Der Verfasser der ersten PKGBUILD für dieses Paket.<br />
* '''pkgname''' : Der Paketname<br />
* '''pkgver''' : Die Paketversion<br />
* '''pkgrel''' : Die Releasenummer des Arch Paketes. Wird geändert, wenn das PKGBUILD verändert wurde, sie unterscheided sich also von der Paketversion.<br />
* '''pkgdesc''' : a brief description of the package. This is what you see when you browse the [http://archlinux.org/packages.php package database]<br />
* '''arch''' : shows on what architectures it is known to build and work - see [[Arch64_FAQ]] for porting details<br />
* '''url''' : the homepage of the software (which appears when you click on a package on the package database)<br />
* '''groups''' : this is used to group packages: when you try to install kde for example, it installs all packages which belongs to the kde group<br />
* '''provides''' : this is used if the package provides another package, for example, kernel-scsi provides kernel<br />
* '''depends''' : this lists the run-time dependencies of the package (what it needs to work)<br />
* '''makedepends''' : dependencies needed to build the package but which are not needed once the package is built<br />
* '''conflicts''' : these packages cannot be installed at the same time. Here, <i>foo</i> conflicts with <i>yafoo (yet another foo)</i>. They cannot be installed at the same time.<br />
* '''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><br />
* '''backup''' : which files to backup (as file.pacsave) when the package is removed<br />
* '''install''' : specifies a special install script that is to be included in the package (it has to be in the same directory as PKGBUILD)<br />
* '''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 <i>pkgname</i> and <i>pkgver</i> in order to avoid changing the source each time the version changes.<br />
* '''md5sums''' : md5sums of the source to check their integrity<br />
<br />
So now, let's explain the function :<br />
<br />
* build : all the actions needed to build the package (it will be explained with more attention later in this document)<br />
<br />
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.<br />
<br />
There are also install files. This PKGBUILD specifies 'foo.install' as the package's install file. Here is an example install file:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Here are the function explainations :<br />
<br />
* post_install : this script is run right after files are installed, it takes one argument : <br />
** the package version<br />
* post_upgrade : this script is run after all files have been upgraded, <em>it takes two arguments</em> :<br />
** the new package version<br />
** the old package version<br />
* pre_remove : this script is run right before files are removed (stop a daemon for example) and takes one argument : <br />
** the package version<br />
<br />
The three lines at the bottom are needed in every install file so that they run properly.<br />
<br />
==== The build function====<br />
<br />
If you're not familiar with building packages, you should know that most packages (but not all) can be built this way :<br />
* uncompress the source file : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* enter the directory<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* configure the package : generally, there is a little script called <code>configure</code> 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 :<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
You should first try the help to better understand how it works :<br />
<br />
<pre>./configure --help</pre><br />
<br />
* compile the sources :<br />
<br />
<pre>make</pre><br />
<br />
* install<br />
<br />
<pre>make install</pre><br />
<br />
However, you should always read the <code>INSTALL</code> file to know how the package should be built and install ! '''Not all packages use the <code>configure; make; make install</code> system!<br />
<br />
So let's take a look at a "standard" build function :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
What we do is :<br />
* enter the directory where sources were uncompressed :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
But if you try to build your package, be carefull that this is the right directory : sometimes the uncompressed directory might be named differently :<br />
<br />
<pre>tar -xzf foo-0.99.tar.gz</pre><br />
<br />
and a <code>ls</code> might return :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo/</pre><br />
<br />
and not :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo-0.99/</pre><br />
<br />
* configure the package, and tell it to install in the <code>/usr</code> directory :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* install the software but not in <code>/usr</code>, in <code>$startdir/pkg/usr</code> so that pacman has control of the files.<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
What we want to do is build the package not to install it, so instead of installing to the standard place (<code>/usr</code>), we tell <code>make</code> to put all files in our special directory : <code>$startdir/pkg/usr</code>. Thus, makepkg can look and see which files the package installs, and then compress them into the Arch package.<br />
<br />
'''NOTE''': It is sometimes the case where <code>prefix</code> is not used in the <code>Makefile</code>; often <code>DESTDIR</code> is used instead. If the package is built with autoconf/automake, use <code>DESTDIR</code>, this is what is [http://sources.redhat.com/automake/automake.html#Install documented] in the manuals. Check if the generated <code>filelist</code> is a lot shorter than it should be, and if so, try building with <code>make DESTDIR=$startdir/pkg install</code>. If that does not work, you'll have to look further into the install commands that are executed by "<code>make <...> install=</code>".<br />
<br />
==== The ABS tree====<br />
<br />
When you run abs for the first time :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
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 :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
So the ABS tree has exactly the same structure as the package database :<br />
* first level directory represent categories<br />
* second level directories represent the packages<br />
* PKGBUILD files contains every information needed concerning the package<br />
<br />
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.<br />
<br />
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''<br />
<br />
Now that you know what the ABS tree is, how can we use it ?<br />
<br />
==== First use of ABS : customizing a package====<br />
<br />
This situation can arise more often than you may think : official packages are compiled choosing a certain number of <code>--enable</code> or <code>--disable</code> options, and these are not necessarily the ones you would have chosen.<br />
<br />
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 :<br />
* find where is the ''foo'' package located. you can do this by :<br />
<br />
search for ''foo'' at [http://archlinux.org/packages.php]<br />
use the find command :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
use the slocate command :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In any case, you'll find that foo is part of <code>extra</code> and <code>multimedia</code> (for example)<br />
<br />
* copy the ''foo'' <code>PKGBUILD</code> file to <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* modify the <code>PKGBUILD</code> file : we'll add support for '''arts''' :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
becomes :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* launch <code>makepkg</code> :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* install the new package using one of the following commands (<code>-A</code> for install, <code>-U</code> to upgrade an already installed package):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Compiler Flags and Customizing makepkg====<br />
<br />
The configuration file for <code>makepkg</code> is <code>/etc/makepkg.conf</code>. Here you can set environment variables for <code>gcc</code> and <code>make</code>, as well as some for <code>makepkg</code> itself. The following is an example of <code>/etc/makepkg.conf</code>.<br />
<br />
<pre><br />
# The FTP/HTTP download utility that makepkg will use to acquire sources<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Information passed to gcc about what type of computer this is.<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags passed to gcc when a package is being compiled<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags passed to make when a package is being compiled<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Enable colorized output messages<br />
export USE_COLOR="y"<br />
<br />
# The remaining variables only affect the behavior of makepkg<br />
# Enable fakeroot for building packages as a non-root user.<br />
# See 'man fakeroot' for more information on fakeroot<br />
export USE_FAKEROOT="y"<br />
<br />
# The directory where all packages will be placed (default is ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Base of the ABS tree (default is /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Set this if you want your name to show up in the packages you build<br />
export PACKAGER="John Doe <nowhere@microsoft.com>"<br />
</pre><br />
<br />
A word of caution: Users should be sure of any changes they may make to the variables <code>CFLAGS</code>, <code>CXXFLAGS</code>, and <code>MAKEFLAGS</code> 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 <code>CARCH</code>, <code>CHOST</code>, and <code>USE_FAKEROOT</code>.<br />
<br />
References for gcc and make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]<br />
<br />
==== Other uses of ABS====<br />
<br />
Well here are two more wiki pages, whose goal is to go deeper in ABS :<br />
* [[The Arch package making HOW-TO - with guidelines]]<br />
* [[Custom local repository with ABS and gensync]]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1449Arch Build System2006-08-08T15:54:33Z<p>Wtfoo: </p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. im Ordner 'foo' gespeichert hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meist ''foo''.pkg.tar.gz genannt ist.<br />
<br />
Es ist nicht mehr, als ein gz komprimiertes tar-Archiv, das folgendes enthält:<br />
<br />
* Die zu installierenden Dateien<br />
<br />
*.PKGINFO : enthält alle Daten, die pacman für den Umgang mit Paketen, Abhängigkeiten etc. benötigt.<br />
<br />
*.FILELIST : lists all the files of the archive. It's used in order to uninstall the software or to check for file conflicts.<br />
<br />
*.INSTALL : a file used to execute commands after the install/upgrade/remove stage. (This file is only present if specified in the PKGBUILD)<br />
<br />
==== What is a PKGBUILD and what does it contain?====<br />
<br />
As explained before, the PKGBUILD file contains metadata about a package. It is a simple plain text file. Here is an example:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
So let's explain each field :<br />
<br />
* '''# text''' : comments<br />
* '''# $Id: PKGBUILD,v ...''' : the cvs-tag for this pkg (from the archlinux-cvs system created)<br />
* '''# Maintainer''' : the maintainer responsible for this pkg in the official Repositories<br />
* '''# Contributor''' : the person who wrote the first PKGBUILD for this package<br />
* '''pkgname''' : the name of the package<br />
* '''pkgver''' : the version of the package<br />
* '''pkgrel''' : the release number of the Arch package. It is different from the version of the package and is changed when the PKGBUILD is modified. This can happen for many reasons, for example if you enable compile-time support for something.<br />
* '''pkgdesc''' : a brief description of the package. This is what you see when you browse the [http://archlinux.org/packages.php package database]<br />
* '''arch''' : shows on what architectures it is known to build and work - see [[Arch64_FAQ]] for porting details<br />
* '''url''' : the homepage of the software (which appears when you click on a package on the package database)<br />
* '''groups''' : this is used to group packages: when you try to install kde for example, it installs all packages which belongs to the kde group<br />
* '''provides''' : this is used if the package provides another package, for example, kernel-scsi provides kernel<br />
* '''depends''' : this lists the run-time dependencies of the package (what it needs to work)<br />
* '''makedepends''' : dependencies needed to build the package but which are not needed once the package is built<br />
* '''conflicts''' : these packages cannot be installed at the same time. Here, <i>foo</i> conflicts with <i>yafoo (yet another foo)</i>. They cannot be installed at the same time.<br />
* '''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><br />
* '''backup''' : which files to backup (as file.pacsave) when the package is removed<br />
* '''install''' : specifies a special install script that is to be included in the package (it has to be in the same directory as PKGBUILD)<br />
* '''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 <i>pkgname</i> and <i>pkgver</i> in order to avoid changing the source each time the version changes.<br />
* '''md5sums''' : md5sums of the source to check their integrity<br />
<br />
So now, let's explain the function :<br />
<br />
* build : all the actions needed to build the package (it will be explained with more attention later in this document)<br />
<br />
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.<br />
<br />
There are also install files. This PKGBUILD specifies 'foo.install' as the package's install file. Here is an example install file:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Here are the function explainations :<br />
<br />
* post_install : this script is run right after files are installed, it takes one argument : <br />
** the package version<br />
* post_upgrade : this script is run after all files have been upgraded, <em>it takes two arguments</em> :<br />
** the new package version<br />
** the old package version<br />
* pre_remove : this script is run right before files are removed (stop a daemon for example) and takes one argument : <br />
** the package version<br />
<br />
The three lines at the bottom are needed in every install file so that they run properly.<br />
<br />
==== The build function====<br />
<br />
If you're not familiar with building packages, you should know that most packages (but not all) can be built this way :<br />
* uncompress the source file : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* enter the directory<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* configure the package : generally, there is a little script called <code>configure</code> 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 :<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
You should first try the help to better understand how it works :<br />
<br />
<pre>./configure --help</pre><br />
<br />
* compile the sources :<br />
<br />
<pre>make</pre><br />
<br />
* install<br />
<br />
<pre>make install</pre><br />
<br />
However, you should always read the <code>INSTALL</code> file to know how the package should be built and install ! '''Not all packages use the <code>configure; make; make install</code> system!<br />
<br />
So let's take a look at a "standard" build function :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
What we do is :<br />
* enter the directory where sources were uncompressed :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
But if you try to build your package, be carefull that this is the right directory : sometimes the uncompressed directory might be named differently :<br />
<br />
<pre>tar -xzf foo-0.99.tar.gz</pre><br />
<br />
and a <code>ls</code> might return :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo/</pre><br />
<br />
and not :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo-0.99/</pre><br />
<br />
* configure the package, and tell it to install in the <code>/usr</code> directory :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* install the software but not in <code>/usr</code>, in <code>$startdir/pkg/usr</code> so that pacman has control of the files.<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
What we want to do is build the package not to install it, so instead of installing to the standard place (<code>/usr</code>), we tell <code>make</code> to put all files in our special directory : <code>$startdir/pkg/usr</code>. Thus, makepkg can look and see which files the package installs, and then compress them into the Arch package.<br />
<br />
'''NOTE''': It is sometimes the case where <code>prefix</code> is not used in the <code>Makefile</code>; often <code>DESTDIR</code> is used instead. If the package is built with autoconf/automake, use <code>DESTDIR</code>, this is what is [http://sources.redhat.com/automake/automake.html#Install documented] in the manuals. Check if the generated <code>filelist</code> is a lot shorter than it should be, and if so, try building with <code>make DESTDIR=$startdir/pkg install</code>. If that does not work, you'll have to look further into the install commands that are executed by "<code>make <...> install=</code>".<br />
<br />
==== The ABS tree====<br />
<br />
When you run abs for the first time :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
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 :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
So the ABS tree has exactly the same structure as the package database :<br />
* first level directory represent categories<br />
* second level directories represent the packages<br />
* PKGBUILD files contains every information needed concerning the package<br />
<br />
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.<br />
<br />
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''<br />
<br />
Now that you know what the ABS tree is, how can we use it ?<br />
<br />
==== First use of ABS : customizing a package====<br />
<br />
This situation can arise more often than you may think : official packages are compiled choosing a certain number of <code>--enable</code> or <code>--disable</code> options, and these are not necessarily the ones you would have chosen.<br />
<br />
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 :<br />
* find where is the ''foo'' package located. you can do this by :<br />
<br />
search for ''foo'' at [http://archlinux.org/packages.php]<br />
use the find command :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
use the slocate command :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In any case, you'll find that foo is part of <code>extra</code> and <code>multimedia</code> (for example)<br />
<br />
* copy the ''foo'' <code>PKGBUILD</code> file to <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* modify the <code>PKGBUILD</code> file : we'll add support for '''arts''' :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
becomes :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* launch <code>makepkg</code> :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* install the new package using one of the following commands (<code>-A</code> for install, <code>-U</code> to upgrade an already installed package):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Compiler Flags and Customizing makepkg====<br />
<br />
The configuration file for <code>makepkg</code> is <code>/etc/makepkg.conf</code>. Here you can set environment variables for <code>gcc</code> and <code>make</code>, as well as some for <code>makepkg</code> itself. The following is an example of <code>/etc/makepkg.conf</code>.<br />
<br />
<pre><br />
# The FTP/HTTP download utility that makepkg will use to acquire sources<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Information passed to gcc about what type of computer this is.<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags passed to gcc when a package is being compiled<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags passed to make when a package is being compiled<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Enable colorized output messages<br />
export USE_COLOR="y"<br />
<br />
# The remaining variables only affect the behavior of makepkg<br />
# Enable fakeroot for building packages as a non-root user.<br />
# See 'man fakeroot' for more information on fakeroot<br />
export USE_FAKEROOT="y"<br />
<br />
# The directory where all packages will be placed (default is ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Base of the ABS tree (default is /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Set this if you want your name to show up in the packages you build<br />
export PACKAGER="John Doe <nowhere@microsoft.com>"<br />
</pre><br />
<br />
A word of caution: Users should be sure of any changes they may make to the variables <code>CFLAGS</code>, <code>CXXFLAGS</code>, and <code>MAKEFLAGS</code> 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 <code>CARCH</code>, <code>CHOST</code>, and <code>USE_FAKEROOT</code>.<br />
<br />
References for gcc and make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]<br />
<br />
==== Other uses of ABS====<br />
<br />
Well here are two more wiki pages, whose goal is to go deeper in ABS :<br />
* [[The Arch package making HOW-TO - with guidelines]]<br />
* [[Custom local repository with ABS and gensync]]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1448Arch Build System2006-08-08T15:51:50Z<p>Wtfoo: </p>
<hr />
<div>[[Kategorie:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. in den Ordner 'foo' gedownloaded hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meistens ''foo''.pkg.tar.gz genannt ist.<br />
<br />
In fact, it is no more than a gzipped tar archive which contains:<br />
<br />
* The files to install<br />
<br />
*.PKGINFO : contains all the metadata needed by pacman to deal with packages, dependencies, etc.<br />
<br />
*.FILELIST : lists all the files of the archive. It's used in order to uninstall the software or to check for file conflicts.<br />
<br />
*.INSTALL : a file used to execute commands after the install/upgrade/remove stage. (This file is only present if specified in the PKGBUILD)<br />
<br />
==== What is a PKGBUILD and what does it contain?====<br />
<br />
As explained before, the PKGBUILD file contains metadata about a package. It is a simple plain text file. Here is an example:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
So let's explain each field :<br />
<br />
* '''# text''' : comments<br />
* '''# $Id: PKGBUILD,v ...''' : the cvs-tag for this pkg (from the archlinux-cvs system created)<br />
* '''# Maintainer''' : the maintainer responsible for this pkg in the official Repositories<br />
* '''# Contributor''' : the person who wrote the first PKGBUILD for this package<br />
* '''pkgname''' : the name of the package<br />
* '''pkgver''' : the version of the package<br />
* '''pkgrel''' : the release number of the Arch package. It is different from the version of the package and is changed when the PKGBUILD is modified. This can happen for many reasons, for example if you enable compile-time support for something.<br />
* '''pkgdesc''' : a brief description of the package. This is what you see when you browse the [http://archlinux.org/packages.php package database]<br />
* '''arch''' : shows on what architectures it is known to build and work - see [[Arch64_FAQ]] for porting details<br />
* '''url''' : the homepage of the software (which appears when you click on a package on the package database)<br />
* '''groups''' : this is used to group packages: when you try to install kde for example, it installs all packages which belongs to the kde group<br />
* '''provides''' : this is used if the package provides another package, for example, kernel-scsi provides kernel<br />
* '''depends''' : this lists the run-time dependencies of the package (what it needs to work)<br />
* '''makedepends''' : dependencies needed to build the package but which are not needed once the package is built<br />
* '''conflicts''' : these packages cannot be installed at the same time. Here, <i>foo</i> conflicts with <i>yafoo (yet another foo)</i>. They cannot be installed at the same time.<br />
* '''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><br />
* '''backup''' : which files to backup (as file.pacsave) when the package is removed<br />
* '''install''' : specifies a special install script that is to be included in the package (it has to be in the same directory as PKGBUILD)<br />
* '''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 <i>pkgname</i> and <i>pkgver</i> in order to avoid changing the source each time the version changes.<br />
* '''md5sums''' : md5sums of the source to check their integrity<br />
<br />
So now, let's explain the function :<br />
<br />
* build : all the actions needed to build the package (it will be explained with more attention later in this document)<br />
<br />
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.<br />
<br />
There are also install files. This PKGBUILD specifies 'foo.install' as the package's install file. Here is an example install file:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Here are the function explainations :<br />
<br />
* post_install : this script is run right after files are installed, it takes one argument : <br />
** the package version<br />
* post_upgrade : this script is run after all files have been upgraded, <em>it takes two arguments</em> :<br />
** the new package version<br />
** the old package version<br />
* pre_remove : this script is run right before files are removed (stop a daemon for example) and takes one argument : <br />
** the package version<br />
<br />
The three lines at the bottom are needed in every install file so that they run properly.<br />
<br />
==== The build function====<br />
<br />
If you're not familiar with building packages, you should know that most packages (but not all) can be built this way :<br />
* uncompress the source file : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* enter the directory<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* configure the package : generally, there is a little script called <code>configure</code> 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 :<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
You should first try the help to better understand how it works :<br />
<br />
<pre>./configure --help</pre><br />
<br />
* compile the sources :<br />
<br />
<pre>make</pre><br />
<br />
* install<br />
<br />
<pre>make install</pre><br />
<br />
However, you should always read the <code>INSTALL</code> file to know how the package should be built and install ! '''Not all packages use the <code>configure; make; make install</code> system!<br />
<br />
So let's take a look at a "standard" build function :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
What we do is :<br />
* enter the directory where sources were uncompressed :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
But if you try to build your package, be carefull that this is the right directory : sometimes the uncompressed directory might be named differently :<br />
<br />
<pre>tar -xzf foo-0.99.tar.gz</pre><br />
<br />
and a <code>ls</code> might return :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo/</pre><br />
<br />
and not :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo-0.99/</pre><br />
<br />
* configure the package, and tell it to install in the <code>/usr</code> directory :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* install the software but not in <code>/usr</code>, in <code>$startdir/pkg/usr</code> so that pacman has control of the files.<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
What we want to do is build the package not to install it, so instead of installing to the standard place (<code>/usr</code>), we tell <code>make</code> to put all files in our special directory : <code>$startdir/pkg/usr</code>. Thus, makepkg can look and see which files the package installs, and then compress them into the Arch package.<br />
<br />
'''NOTE''': It is sometimes the case where <code>prefix</code> is not used in the <code>Makefile</code>; often <code>DESTDIR</code> is used instead. If the package is built with autoconf/automake, use <code>DESTDIR</code>, this is what is [http://sources.redhat.com/automake/automake.html#Install documented] in the manuals. Check if the generated <code>filelist</code> is a lot shorter than it should be, and if so, try building with <code>make DESTDIR=$startdir/pkg install</code>. If that does not work, you'll have to look further into the install commands that are executed by "<code>make <...> install=</code>".<br />
<br />
==== The ABS tree====<br />
<br />
When you run abs for the first time :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
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 :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
So the ABS tree has exactly the same structure as the package database :<br />
* first level directory represent categories<br />
* second level directories represent the packages<br />
* PKGBUILD files contains every information needed concerning the package<br />
<br />
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.<br />
<br />
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''<br />
<br />
Now that you know what the ABS tree is, how can we use it ?<br />
<br />
==== First use of ABS : customizing a package====<br />
<br />
This situation can arise more often than you may think : official packages are compiled choosing a certain number of <code>--enable</code> or <code>--disable</code> options, and these are not necessarily the ones you would have chosen.<br />
<br />
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 :<br />
* find where is the ''foo'' package located. you can do this by :<br />
<br />
search for ''foo'' at [http://archlinux.org/packages.php]<br />
use the find command :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
use the slocate command :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In any case, you'll find that foo is part of <code>extra</code> and <code>multimedia</code> (for example)<br />
<br />
* copy the ''foo'' <code>PKGBUILD</code> file to <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* modify the <code>PKGBUILD</code> file : we'll add support for '''arts''' :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
becomes :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* launch <code>makepkg</code> :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* install the new package using one of the following commands (<code>-A</code> for install, <code>-U</code> to upgrade an already installed package):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Compiler Flags and Customizing makepkg====<br />
<br />
The configuration file for <code>makepkg</code> is <code>/etc/makepkg.conf</code>. Here you can set environment variables for <code>gcc</code> and <code>make</code>, as well as some for <code>makepkg</code> itself. The following is an example of <code>/etc/makepkg.conf</code>.<br />
<br />
<pre><br />
# The FTP/HTTP download utility that makepkg will use to acquire sources<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Information passed to gcc about what type of computer this is.<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags passed to gcc when a package is being compiled<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags passed to make when a package is being compiled<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Enable colorized output messages<br />
export USE_COLOR="y"<br />
<br />
# The remaining variables only affect the behavior of makepkg<br />
# Enable fakeroot for building packages as a non-root user.<br />
# See 'man fakeroot' for more information on fakeroot<br />
export USE_FAKEROOT="y"<br />
<br />
# The directory where all packages will be placed (default is ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Base of the ABS tree (default is /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Set this if you want your name to show up in the packages you build<br />
export PACKAGER="John Doe <nowhere@microsoft.com>"<br />
</pre><br />
<br />
A word of caution: Users should be sure of any changes they may make to the variables <code>CFLAGS</code>, <code>CXXFLAGS</code>, and <code>MAKEFLAGS</code> 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 <code>CARCH</code>, <code>CHOST</code>, and <code>USE_FAKEROOT</code>.<br />
<br />
References for gcc and make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]<br />
<br />
==== Other uses of ABS====<br />
<br />
Well here are two more wiki pages, whose goal is to go deeper in ABS :<br />
* [[The Arch package making HOW-TO - with guidelines]]<br />
* [[Custom local repository with ABS and gensync]]</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Diskussion:Arch_Build_System&diff=1447Diskussion:Arch Build System2006-08-08T15:50:51Z<p>Wtfoo: </p>
<hr />
<div>Übersetzt aus dem englischen Wiki.</div>Wtfoohttps://wiki.archlinux.de/index.php?title=Arch_Build_System&diff=1446Arch Build System2006-08-08T15:47:11Z<p>Wtfoo: </p>
<hr />
<div>[[Category:Paketverwaltung]]<br />
==== Einführung ====<br />
Das Arch Build System (ABS) wird genutzt um:<br />
<br />
* Neue Pakete für Software zu erstellen, für die noch keine Pakete vorhanden sind<br />
* Vorhande Pakete an die eigenen Bedürfnisse anzupassen<br />
* Das komplette System mit eigenen Compiler-flags neuzubauen, "a la gentoo" (Und so Kernel Module mit eigenem Kernel nutzbar machen!)<br />
<br />
ABS ist nicht notwendig um Arch Linux zu nutzen, aber es ist nützlich.<br />
<br />
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.<br />
<br />
==== Vorbereitung ====<br />
<br />
Um ABS zu nutzen, musst du zuerst die Programme "cvsup" und "wget" installieren:<br />
<br />
<pre><br />
pacman -Sy cvsup wget</pre><br />
<br />
Oder, wenn du die Pakete z.B. in den Ordner 'foo' gedownloaded hast:<br />
<pre><br />
cd foo<br />
pacman -A cvsup-*.pkg.tar.gz wget-*.pkg.tar.gz</pre><br />
<br />
==== Was ist ein Paket ?====<br />
<br />
Ein Paket ist eine Datei, die meistens ''foo''.pkg.tar.gz genannt ist.<br />
<br />
In fact, it is no more than a gzipped tar archive which contains:<br />
<br />
* The files to install<br />
<br />
*.PKGINFO : contains all the metadata needed by pacman to deal with packages, dependencies, etc.<br />
<br />
*.FILELIST : lists all the files of the archive. It's used in order to uninstall the software or to check for file conflicts.<br />
<br />
*.INSTALL : a file used to execute commands after the install/upgrade/remove stage. (This file is only present if specified in the PKGBUILD)<br />
<br />
==== What is a PKGBUILD and what does it contain?====<br />
<br />
As explained before, the PKGBUILD file contains metadata about a package. It is a simple plain text file. Here is an example:<br />
<br />
<pre><br />
# $Id: PKGBUILD,v 1.12 2003/11/06 08:26:13 dorphell Exp $<br />
# Maintainer: judd <jvinet@zeroflux.org><br />
# Contributor: Judd Vinet <jvinet@zeroflux.org><br />
pkgname=foo<br />
pkgver=0.99 # note: if the pkgver had been '0.99-10' then use an underscore. like '0.99_10'<br />
pkgrel=1<br />
pkgdesc="short description of foo"<br />
arch=(i686 x86_64)<br />
url="http://www.foo.org"<br />
groups=<br />
provides=<br />
depends=('qt' 'python')<br />
makedepends=('guile')<br />
conflicts=('yafoo')<br />
replaces=('mffoo')<br />
backup=('etc/foo/foo.conf')<br />
install=('foo.install')<br />
source=(http://www.foo.org/download/$pkgname-$pkgver.tar.gz)<br />
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d35175bee593a7cc7d6205584a94d8625')<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
So let's explain each field :<br />
<br />
* '''# text''' : comments<br />
* '''# $Id: PKGBUILD,v ...''' : the cvs-tag for this pkg (from the archlinux-cvs system created)<br />
* '''# Maintainer''' : the maintainer responsible for this pkg in the official Repositories<br />
* '''# Contributor''' : the person who wrote the first PKGBUILD for this package<br />
* '''pkgname''' : the name of the package<br />
* '''pkgver''' : the version of the package<br />
* '''pkgrel''' : the release number of the Arch package. It is different from the version of the package and is changed when the PKGBUILD is modified. This can happen for many reasons, for example if you enable compile-time support for something.<br />
* '''pkgdesc''' : a brief description of the package. This is what you see when you browse the [http://archlinux.org/packages.php package database]<br />
* '''arch''' : shows on what architectures it is known to build and work - see [[Arch64_FAQ]] for porting details<br />
* '''url''' : the homepage of the software (which appears when you click on a package on the package database)<br />
* '''groups''' : this is used to group packages: when you try to install kde for example, it installs all packages which belongs to the kde group<br />
* '''provides''' : this is used if the package provides another package, for example, kernel-scsi provides kernel<br />
* '''depends''' : this lists the run-time dependencies of the package (what it needs to work)<br />
* '''makedepends''' : dependencies needed to build the package but which are not needed once the package is built<br />
* '''conflicts''' : these packages cannot be installed at the same time. Here, <i>foo</i> conflicts with <i>yafoo (yet another foo)</i>. They cannot be installed at the same time.<br />
* '''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><br />
* '''backup''' : which files to backup (as file.pacsave) when the package is removed<br />
* '''install''' : specifies a special install script that is to be included in the package (it has to be in the same directory as PKGBUILD)<br />
* '''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 <i>pkgname</i> and <i>pkgver</i> in order to avoid changing the source each time the version changes.<br />
* '''md5sums''' : md5sums of the source to check their integrity<br />
<br />
So now, let's explain the function :<br />
<br />
* build : all the actions needed to build the package (it will be explained with more attention later in this document)<br />
<br />
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.<br />
<br />
There are also install files. This PKGBUILD specifies 'foo.install' as the package's install file. Here is an example install file:<br />
<br />
<pre><br />
post_install() {<br />
/bin/true<br />
}<br />
<br />
post_upgrade() {<br />
/bin/true<br />
}<br />
<br />
pre_remove() {<br />
/bin/true<br />
}<br />
<br />
op=$1<br />
shift<br />
<br />
$op "$@"<br />
</pre><br />
<br />
Here are the function explainations :<br />
<br />
* post_install : this script is run right after files are installed, it takes one argument : <br />
** the package version<br />
* post_upgrade : this script is run after all files have been upgraded, <em>it takes two arguments</em> :<br />
** the new package version<br />
** the old package version<br />
* pre_remove : this script is run right before files are removed (stop a daemon for example) and takes one argument : <br />
** the package version<br />
<br />
The three lines at the bottom are needed in every install file so that they run properly.<br />
<br />
==== The build function====<br />
<br />
If you're not familiar with building packages, you should know that most packages (but not all) can be built this way :<br />
* uncompress the source file : <br />
<br />
<pre><br />
tar -xzf foo-0.99.tar.gz<br />
tar -xjf foo-0.99.tar.bz2</pre><br />
<br />
* enter the directory<br />
<br />
<pre>cd foo-0.99</pre><br />
<br />
* configure the package : generally, there is a little script called <code>configure</code> 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 :<br />
<br />
<pre>./configure [[option]]</pre><br />
<br />
You should first try the help to better understand how it works :<br />
<br />
<pre>./configure --help</pre><br />
<br />
* compile the sources :<br />
<br />
<pre>make</pre><br />
<br />
* install<br />
<br />
<pre>make install</pre><br />
<br />
However, you should always read the <code>INSTALL</code> file to know how the package should be built and install ! '''Not all packages use the <code>configure; make; make install</code> system!<br />
<br />
So let's take a look at a "standard" build function :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}<br />
</pre><br />
<br />
What we do is :<br />
* enter the directory where sources were uncompressed :<br />
<br />
<pre>cd $startdir/src/$pkgname-$pkgver</pre><br />
<br />
But if you try to build your package, be carefull that this is the right directory : sometimes the uncompressed directory might be named differently :<br />
<br />
<pre>tar -xzf foo-0.99.tar.gz</pre><br />
<br />
and a <code>ls</code> might return :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo/</pre><br />
<br />
and not :<br />
<br />
<pre><br />
.<br />
..<br />
foo-0.99.tar.gz<br />
foo-0.99/</pre><br />
<br />
* configure the package, and tell it to install in the <code>/usr</code> directory :<br />
<br />
<pre><br />
./configure --prefix=/usr</pre><br />
<br />
* compile<br />
<br />
<pre><br />
make || return 1</pre><br />
<br />
* install the software but not in <code>/usr</code>, in <code>$startdir/pkg/usr</code> so that pacman has control of the files.<br />
<br />
<pre><br />
make prefix=$startdir/pkg/usr install</pre><br />
<br />
What we want to do is build the package not to install it, so instead of installing to the standard place (<code>/usr</code>), we tell <code>make</code> to put all files in our special directory : <code>$startdir/pkg/usr</code>. Thus, makepkg can look and see which files the package installs, and then compress them into the Arch package.<br />
<br />
'''NOTE''': It is sometimes the case where <code>prefix</code> is not used in the <code>Makefile</code>; often <code>DESTDIR</code> is used instead. If the package is built with autoconf/automake, use <code>DESTDIR</code>, this is what is [http://sources.redhat.com/automake/automake.html#Install documented] in the manuals. Check if the generated <code>filelist</code> is a lot shorter than it should be, and if so, try building with <code>make DESTDIR=$startdir/pkg install</code>. If that does not work, you'll have to look further into the install commands that are executed by "<code>make <...> install=</code>".<br />
<br />
==== The ABS tree====<br />
<br />
When you run abs for the first time :<br />
<br />
<pre><br />
root @ localhost # abs</pre><br />
<br />
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 :<br />
<br />
<pre><br />
|-<br />
| -- base/<br />
|-<br />
| ||-- autoconf/<br />
|-<br />
| ||-- automake/<br />
|-<br />
| ||-- ...<br />
|-<br />
| -- devel/<br />
|-<br />
| -- ...<br />
|-<br />
| -- extra/<br />
|-<br />
| || -- deamons/<br />
|-<br />
| || || -- acpid/<br />
|-<br />
| || || || -- PKGBUILD<br />
... ... ... ...<br />
</pre><br />
<br />
So the ABS tree has exactly the same structure as the package database :<br />
* first level directory represent categories<br />
* second level directories represent the packages<br />
* PKGBUILD files contains every information needed concerning the package<br />
<br />
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.<br />
<br />
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''<br />
<br />
Now that you know what the ABS tree is, how can we use it ?<br />
<br />
==== First use of ABS : customizing a package====<br />
<br />
This situation can arise more often than you may think : official packages are compiled choosing a certain number of <code>--enable</code> or <code>--disable</code> options, and these are not necessarily the ones you would have chosen.<br />
<br />
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 :<br />
* find where is the ''foo'' package located. you can do this by :<br />
<br />
search for ''foo'' at [http://archlinux.org/packages.php]<br />
use the find command :<br />
<br />
<pre><br />
find /var/abs -name "foo"</pre><br />
<br />
use the slocate command :<br />
<br />
<pre><br />
slocate foo | grep ^/var/abs</pre><br />
<br />
In any case, you'll find that foo is part of <code>extra</code> and <code>multimedia</code> (for example)<br />
<br />
* copy the ''foo'' <code>PKGBUILD</code> file to <code>/var/abs/local/foo</code><br />
<br />
<pre><br />
mkdir /var/abs/local/foo<br />
cp /var/abs/extra/multimedia/foo/* /var/abs/local/foo<br />
cd /var/abs/local/foo</pre><br />
<br />
* modify the <code>PKGBUILD</code> file : we'll add support for '''arts''' :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
becomes :<br />
<br />
<pre><br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
./configure --enable-arts --prefix=/usr<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install<br />
}</pre><br />
<br />
* launch <code>makepkg</code> :<br />
<br />
<pre><br />
makepkg</pre><br />
<br />
* install the new package using one of the following commands (<code>-A</code> for install, <code>-U</code> to upgrade an already installed package):<br />
<br />
<pre><br />
pacman -A foo-*.pkg.tar.gz<br />
pacman -U foo-*.pkg.tar.gz</pre><br />
<br />
==== Compiler Flags and Customizing makepkg====<br />
<br />
The configuration file for <code>makepkg</code> is <code>/etc/makepkg.conf</code>. Here you can set environment variables for <code>gcc</code> and <code>make</code>, as well as some for <code>makepkg</code> itself. The following is an example of <code>/etc/makepkg.conf</code>.<br />
<br />
<pre><br />
# The FTP/HTTP download utility that makepkg will use to acquire sources<br />
export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"<br />
<br />
# Information passed to gcc about what type of computer this is.<br />
export CARCH="i686"<br />
export CHOST="i686-pc-linux-gnu"<br />
<br />
# Flags passed to gcc when a package is being compiled<br />
export CFLAGS "-march athlon-tbird -O2 -pipe"<br />
export CXXFLAGS "-march athlon-tbird -02 -pipe"<br />
<br />
# Flags passed to make when a package is being compiled<br />
export MAKEFLAGS="-j 2"<br />
<br />
# Enable colorized output messages<br />
export USE_COLOR="y"<br />
<br />
# The remaining variables only affect the behavior of makepkg<br />
# Enable fakeroot for building packages as a non-root user.<br />
# See 'man fakeroot' for more information on fakeroot<br />
export USE_FAKEROOT="y"<br />
<br />
# The directory where all packages will be placed (default is ./)<br />
export PKGDEST=/home/packages<br />
<br />
# Base of the ABS tree (default is /var/abs)<br />
export ABSROOT=/var/abs<br />
<br />
# Set this if you want your name to show up in the packages you build<br />
export PACKAGER="John Doe <nowhere@microsoft.com>"<br />
</pre><br />
<br />
A word of caution: Users should be sure of any changes they may make to the variables <code>CFLAGS</code>, <code>CXXFLAGS</code>, and <code>MAKEFLAGS</code> 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 <code>CARCH</code>, <code>CHOST</code>, and <code>USE_FAKEROOT</code>.<br />
<br />
References for gcc and make flags<br />
* [http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Option-Summary.html#Option-Summary]<br />
* [http://www.gnu.org/software/make/manual/html''chapter/make''9.html#SEC102]<br />
<br />
==== Other uses of ABS====<br />
<br />
Well here are two more wiki pages, whose goal is to go deeper in ABS :<br />
* [[The Arch package making HOW-TO - with guidelines]]<br />
* [[Custom local repository with ABS and gensync]]</div>Wtfoo