Arch build system

提供: ArchWiki
2017年5月31日 (水) 13:25時点におけるKusanaginoturugi (トーク | 投稿記録)による版 (→‎ABS の使用方法: absの取得方法はsubversionに変更になったので、とりあえず原文を転記。)
ナビゲーションに移動 検索に移動

関連記事

この記事では Arch Build System の概要と、初心者のためのウォークスルーを提供しています。完全なリファレンスガイドではありません!ABS の簡単な手引きは、ABS FAQ を見て下さい。より詳しい情報が必要な場合は、man ページを参照してください。

ノート: ABS の同期は日に一度行われます。そのためリポジトリで利用可能になっているものとラグが生じることがあります。

Arch Build System について

ABS とは Arch Build System の略で、FreeBSD などで採用されている ports に似ています。ABS はソースコードから .pkg.tar.xz 形式のバイナリパッケージを作成することができます。作られたパッケージは pacman によって、通常の(配布されている)バイナリパッケージと同様に管理することができます。

ports システムとは

'Ports' は BSD 系 UNIX によって採用されている、ソースコードからのソフトウェアのビルドを自動化するシステムです。port を使ってソフトウェアのソースコードのダウンロード・展開、パッチの適用、コンパイル、インストールを行います。'port' はただの小さなディレクトリで、それぞれの 'port' に対応する個々のソフト名が付けられており、中にはソフトウェアのビルド・インストールのための情報が書かれたファイルが入っています。ソフトウェアをインストールしたい時は、port のフォルダまで移動し make もしくは make install clean と入力するだけでパッケージのダウンロードからコンパイル、インストールまでを自動的に行います。

ABS の特徴

ABS も Ports に似たシステムで、/var/abs ディレクトリ下に、カテゴリ - パッケージ名の順番で、ツリー状のフォルダ群 (ABS ツリー) を保存しています。これには Arch Linux の公式ソフト すべてのパッケージが含まれます (Ports と同様に、ソースコードやバイナリパッケージを含んでいないのでサイズはそんなに大きくありません)。パッケージ名 (例えば、'ABS') のフォルダを開いたとします。すると、中にはソフトウェアパッケージやソースはなく、代わりに PKGBUILD というファイルが含まれています。PKGBUILD は簡潔な Bash スクリプトで、ソースコードのダウンロード元や、コンパイル、パッケージ作成に必要なコマンドが記述してあります。ABS の makepkg を実行することで、ソフトウェアはコンパイル・パッケージングされビルド用ディレクトリにパッケージが作成されます。後は pacman を使って、ソフトウェアを簡単に管理することが可能です。

ABS の概要

'ABS' という言葉は総称 (umbrella term) として使われることがあります。ABS は複数のものから構成されているからです; そのため、技術的には正確ではありませんが、'ABS' はツールキットとして以下のツールを意味します:

ABS ツリー
ABS のディレクトリ構造; あなたの(ローカル)マシンの /var/abs/ 下の SVN 階層のことです。/etc/abs.conf で設定したリポジトリにある全ての公式 Arch Linux ソフトウェア毎にサブディレクトリが存在します。ただしパッケージ自体は含まれていません。このツリーは pacmanabs パッケージをインストールして abs スクリプトを実行した後に作られます。
ノート: 実際のパッケージは svngit リポジトリにあり、abs スクリプトは rsync を使ってダウンロードしています。
PKGBUILD
ソースコードの URL とコンパイル・パッケージングの手順が入った Bash スクリプト。
makepkg
PKGBUILD を読み込む ABS のシェルコマンドツール。自動的にソースをダウンロード・コンパイルし .pkg.tar* (形式は makepkg.confPKGEXT で設定) を作成します。makepkg を使って AUR やサードパーティのソースからカスタムパッケージを作成することも可能です (パッケージの作成を見て下さい)。
pacman
pacman は abs とは完全に切り離されています。ただし、ビルドしたパッケージをインストール・削除したり依存関係を解決するのには pacman が必要になります。pacman は makepkg によって実行されることもあります。
AUR
Arch User Repository は勿論 ABS とは別物ですが、AUR の(サポートがない) PKGBUILD をビルドするときには makepkg を使ってパッケージをコンパイル・作成します。ローカルマシン上の ABS ツリーと対照的に、AUR にはウェブインターフェースがあります。AUR にはユーザーによって投稿された沢山の PKGBUILD が含まれており、その PKGBUILD を使うことで公式の Arch リポジトリにないソフトウェアをインストールできます。公式の Arch ツリーにないパッケージをビルドする必要がある場合は、AUR を使うことになります。
警告: 公式の PKGBUILD ではパッケージはクリーンな chroot でビルドされることを前提としています。汚いビルド環境でソフトウェアをビルドしても上手くいかなかったり、動作時に予期せぬ挙動が起こったりすることがあります。ビルドシステムは依存関係を動的に検出して、ビルド環境に存在するパッケージによって結果が変わるためです。

ABS を使う理由

Arch Build System の用途は以下の通りです:

  • 何らかの理由で、パッケージをコンパイル・リコンパイルする
  • パッケージがもう入手できなくなったので、ソフトウェアのソースから新しいパッケージを作成・インストールする (パッケージの作成を見て下さい)
  • ニーズにあわせて既存のパッケージをカスタマイズする (オプションを有効化・無効化、パッチをあてる)
  • FreeBSD 流に (à la FreeBSD)、自分で決めたコンパイルフラグを使ってシステム全体をリビルドする (例: pacbuilder)
  • カスタムカーネルをクリーンにビルド・インストールする (カーネル#コンパイルを見て下さい)
  • カスタムカーネルと一緒に動作するカーネルモジュールを手に入れる
  • PKGBUILD 内のバージョン番号を変えることで Arch パッケージの新しい・古い・ベータ版の・開発版のバージョンを簡単にコンパイル・インストールする

ABS は Arch Linux を使うにあたって必須のものではありませんが、ソースコンパイルなどの作業の自動化に役立ちます。

ABS の使用方法

Prerequisites

Install the subversion package.

Non-recursive checkout

警告: Do not download the whole repo; only follow the instructions below. The entire SVN repo is huge. Not only will it take an obscene amount of disk space, but it will also tax the archlinux.org server for you to download it. If you abuse this service, your address may be blocked. Never use the public SVN for any sort of scripting.

To checkout the core, extra, and testing repositories:

$ svn checkout --depth=empty svn://svn.archlinux.org/packages

To checkout the community and multilib repositories:

$ svn checkout --depth=empty svn://svn.archlinux.org/community

In both cases, it simply creates an empty directory, but it does know that it is an svn checkout.

Checkout a package

In the directory containing the svn repository you checked out (i.e., packages or community), do:

$ svn update package-name

This will pull the package you requested into your checkout. From now on, any time you svn update at the top level, this will be updated as well.

If you specify a package that does not exist, svn will not warn you. It will just print something like "At revision 115847", without creating any files. If that happens, check your spelling of the package name and that the package has not been moved to another repository (i.e. from community to the main repository).

ヒント: To checkout an older version of a package, see #Checkout an older version of a package.

You should periodically update all of your checked out packages if you wish to perform rebuilds on more recent revisions of the repositories. To do so, do:

$ svn update

Configure makepkg

See makepkg#Configuration on how to configure makepkg for building packages from the PKGBUILD's you have checked out.

Build package

Copy the directory containing the PKGBUILD you wish to modify to a new location. Then make the desired modifications. From there, use makepkg as described in makepkg#Usage to create and install the new package.

fakeroot

This article or section is being considered for deletion.
Reason: I'm not sure the point of this section (Discuss)

Essentially, the same steps are being executed in the traditional method (generally including the ./configure, make, make install steps) but the software is installed into a fake root environment. (A fake root is simply a subdirectory within the build directory that functions and behaves as the system's root directory. In conjunction with the fakeroot program, makepkg creates a fake root directory, and installs the compiled binaries and associated files into it, with root as owner.) The fake root, or subdirectory tree containing the compiled software, is then compressed into an archive with the extension .pkg.tar.xz, or a package. When invoked, pacman then extracts the package (installs it) into the system's real root directory (/).

他のツール

  • pbget - ウェブインターフェイスから直接パッケージの PKGBUILD を取得します。AUR にも対応。
  • asp - Arch Linux パッケージを作成するのに使われるビルドソースファイルを管理するツール。git インターフェイスを使用することで最新のソースを提供します。