Difference between revisions of "Arch Build System (日本語)"

From ArchWiki
Jump to: navigation, search
(rm temporary i18n template)
m
Line 2: Line 2:
 
[[Category:Package development (日本語)]]
 
[[Category:Package development (日本語)]]
 
[[Category:Package management (日本語)]]
 
[[Category:Package management (日本語)]]
[[Category:日本語]]
 
{{Out of date}}
 
{{Translateme}}
 
 
[[cs:Arch Build System]]
 
[[cs:Arch Build System]]
 
[[da:Arch Build System]]
 
[[da:Arch Build System]]
Line 20: Line 17:
 
[[zh-CN:Arch Build System]]
 
[[zh-CN:Arch Build System]]
 
[[zh-TW:Arch Build System]]
 
[[zh-TW:Arch Build System]]
== このページは完全には翻訳されていません  ==
+
{{Article summary start|概要}}
 +
{{Article summary text|Arch Build System はソースコードからソフトウェアをビルド・パッケージするための ports ライクなシステムです。この記事では ABS の概要とその使い方を説明しています。}}
 +
{{Article summary heading|概括}}
 +
{{Article summary text|{{Package management overview (日本語)}}}}
 +
{{Article summary heading|関連項目}}
 +
{{Article summary wiki|ABS FAQ}}
 +
{{Article summary wiki|Arch Packaging Standards}}
 +
{{Article summary wiki|Creating Packages (日本語)}}
 +
{{Article summary wiki|Kernel Compilation with ABS}}
 +
{{Article summary end}}
  
== ABSについて ==
+
この記事では Arch Build System の概要と、初心者のためのウォークスルーを提供しています。完全なリファレンスガイドではありません!ABS の簡単な手引きは、[[ABS FAQ]] を見て下さい。より詳しい情報が必要な場合は、man ページを参照してください。
 +
{{Note|ABS の同期は日に一度行われます。そのためリポジトリで利用可能になっているものとラグが生じることがあります。}}
 +
== Arch Build System について ==
  
ABSとはArch Build Systemの略で、FreeBSDなどで採用されている'ports'に似ています。
+
ABS とは '''Arch Build System''' の略で、FreeBSD などで採用されている ''ports'' に似ています。ABS はソースコードから {{ic|.pkg.tar.xz}} 形式のバイナリパッケージを作成することができます。作られたパッケージは [[pacman (日本語)|pacman]] によって、通常の(配布されている)バイナリパッケージと同様に管理することができます。
ABSはソースコードから.pkg.tar.gz形式のバイナリパッケージを作成することができます。
+
このパッケージはpacmanによって、通常の(配布されている)バイナリパッケージと同様に管理することができます。
+
  
=== 'Ports'とは ===
+
=== ports システムとは ===
  
'Ports'はBSD系UNIXによって採用されているシステムです。
+
'Ports' は BSD 系 UNIX によって採用されている、ソースコードからのソフトウェアのビルドを自動化するシステムです。''port'' を使ってソフトウェアのソースコードのダウンロード・展開、パッチの適用、コンパイル、インストールを行います。'port' はただの小さなディレクトリで、それぞれの 'port' に対応する個々のソフト名が付けられており、中にはソフトウェアのビルド・インストールのための情報が書かれたファイルが入っています。ソフトウェアをインストールしたい時は、port のフォルダまで移動し {{ic|make}} もしくは {{ic|make install clean}} と入力するだけでパッケージのダウンロードからコンパイル、インストールまでを自動的に行います。
ソフトウェアのソースコードのダウンロード・展開、パッチの適用、コンパイル、インストールができます。
+
'Ports'は複数の'port'から構成され、一つ一つの'port'は対応する個々のソフト名の付けられたフォルダで、中には動作用の情報が入っています。
+
ソフトウェアをインストールしたい時は、多くの場合、ソフト名のフォルダまで移動し'make' 'make install'と入力することによって
+
パッケージのダウンロードからコンパイル、インストールまでを自動的に行います。
+
  
=== "ABS"の特徴 ===
+
=== ABS の特徴 ===
  
ABSもPortsに似たシステムで、/var/abs ディレクトリ傘下に、カテゴリ - パッケージ名の順番で、ツリー状のフォルダ群を保存しています。
+
ABS も Ports に似たシステムで、{{ic|/var/abs}} ディレクトリ下に、カテゴリ - パッケージ名の順番で、ツリー状のフォルダ群 (ABS ツリー) を保存しています。これには ''Arch Linux の公式ソフト'' すべてのパッケージが含まれます (Ports と同様に、ソースコードやバイナリパッケージを含んでいないのでサイズはそんなに大きくありません)。パッケージ名 (例えば、'ABS') のフォルダを開いたとします。すると、中にはソフトウェアパッケージやソースはなく、代わりに [[PKGBUILD (日本語)|PKGBUILD]] というファイルが含まれています。PKGBUILD は簡潔な Bash スクリプトで、ソースコードのダウンロード元や、コンパイル、パッケージ作成に必要なコマンドが記述してあります。ABS の [[makepkg]] を実行することで、ソフトウェアはコンパイル・''パッケージング''されビルド用ディレクトリにパッケージが作成されます。後は [[pacman (日本語)|pacman]] を使って、ソフトウェアを簡単に管理することが可能です。
これにはArch Linux公式ソフトすべてのパッケージが含まれます。(Portsと同様、ソースコードやバイナリパッケージを含んでいないのでサイズはそんなに大きくありません)
+
パッケージ名(例えば、ABS)のフォルダを開いたとします。すると、中にはPKGBUILDというファイルが含まれています。
+
これは簡潔なBASHスクリプトで、ソースコードのダウンロード元や、コンパイル、パッケージ作成が可能なコマンドが記述してあります。
+
PKGBUILDによって、ABSの"makepkg"コマンドが動作し、ビルド用ディレクトリにパッケージが作成されます。
+
あとは[[Pacman]]を使って、ソフトウェアを簡単に管理できます。
+
  
 +
=== ABS の概要 ===
  
=== Quick Walkthrough ===
+
'ABS' という言葉は総称 (umbrella term) として使われることがあります。ABS は複数のものから構成されているからです; そのため、技術的には正確ではありませんが、'ABS' はツールキットとして以下のツールを意味します:
  
Install abs with pacman -S abs. Running 'abs' as root creates the ABS tree by synchronizing with the Arch Linux server. If you wanted to build a package from source you would copy the build files (usually residing under /var/abs/<repo>/<pkgname>) to a build directory, navigate to that directory, edit the PKGBUILD (if desired/necessary) and do '''makepkg'''. According to instructions in the PKGBUILD, makepkg will download the appropriate source tarball, unpack it, patch if desired, compile according to CFLAGS specified in makepkg.conf, and finally compress the built files into a package with the extension .pkg.tar.gz. PKGBUILDs may be customized to suit your unique configuration needs, or for applying patches. Installing is as easy as doing pacman -U <.pkg.tar.gz file>. Package removal is also handled by pacman.
+
; ABS ツリー: The ABS directory structure; an SVN hierarchy under {{ic|/var/abs/}} on your (local) machine. It contains many subdirectories, named for all available official Arch Linux software from repositories specified in {{ic|/etc/abs.conf}}, but not the packages themselves. The tree is created after installing the {{Pkg|abs}} package with [[pacman]] and subsequently running the {{ic|abs}} script.
  
You may also use <code>makepkg</code> to make your own custom packages from the [[AUR]] or third party sources. (See the [[Creating Packages]] wiki article)
+
; [[PKGBUILD (日本語)|PKGBUILD]]: A [[Bash]] script that contains the URL of the source code along with the compilation and packaging instructions.
  
-----
+
; [[makepkg]]: ABS shell command tool which reads the PKGBUILDs, automatically downloads and compiles the sources and creates a {{ic|.pkg.tar*}} according to the {{ic|PKGEXT}} array in {{ic|makepkg.conf}}. You may also use makepkg to make your own custom packages from the [[AUR]] or third-party sources. (See the [[Creating Packages]] wiki article.)
  
''With the '''ABS Tree''' in place, an Arch user has all available Arch software at their fingertips, to compile from source, automatically package as a .pkg.tar.gz, and finally, install with pacman.''
+
; [[pacman (日本語)|pacman]]: pacman is completely separate, but is necessarily invoked either by makepkg or manually, to install and remove the built packages and for fetching dependencies.
  
=== ABS Overview ===
+
; [[Arch User Repository (日本語)|AUR]]: The Arch User Repository is separate from ABS but AUR (unsupported) PKGBUILDs are built using makepkg to compile and package up software. In contrast to the ABS tree on your local machine, the AUR exists as a website interface. It contains many thousands of user-contributed PKGBUILDs for software which is unavailable as an official Arch package. If you need to build a package outside the official Arch tree, chances are it is in the AUR.
 
+
'ABS' may be used as an umbrella term, since it includes and relies on several other components. Therefore, though not technically accurate, 'ABS' can refer to the following structure and tools as a complete toolkit:
+
 
+
* '''The ABS tree:''' The ABS directory structure; an SVN hierarchy under /var/abs/ on your (local) machine. It contains many subdirectories, named for all available official Arch Linux software from repositories specified in /etc/abs.conf, but not the packages themselves.
+
 
+
* '''ABS:''' A set of tools to retrieve and build '''official''' Arch Linux PKGBUILDs. Example PKGBUILDs are also included.
+
 
+
* '''PKGBUILDs:''' Text build script files residing under the ABS directories, or that are custom made, with instructions for building packages  and the URL of the sources.
+
 
+
* '''[[makepkg]]:''' ABS shell command tool which reads the PKGBUILDs, automatically downloads and compiles the sources and creates a .pkg.tar.gz.
+
 
+
* '''[[Pacman]]:''' Pacman is completely separate, but is necessarily invoked either by makepkg or manually, to install and remove the built packages, and for fetching dependencies.
+
 
+
* '''[[AUR]]:''' The Arch User-Community Repository is separate from ABS but [[AUR]] [unsupported] PKGBUILDs can be built using the ABS '''makepkg''' tool, to compile and package up software. The AUR contains almost 16,000 user-contributed PKGBUILDs for software which is unavailable as an official Arch package. If you need to build a package outside the official Arch tree, chances are it is in the [[AUR]].
+
  
 
== Why would I want to use ABS? ==
 
== Why would I want to use ABS? ==
  
The Arch Build System (ABS for short) is used to
+
The Arch Build System is used to:
* Recompile a package, for any reason.
+
* Compile or recompile a package, for any reason
* Make and install new packages from source, of software for which no packages are yet available (See [[Creating Packages]])  
+
* Make and install new packages from source of software for which no packages are yet available (see [[Creating Packages]])  
 
* Customize existing packages to fit your needs (enabling or disabling options, patching)
 
* Customize existing packages to fit your needs (enabling or disabling options, patching)
* Rebuild your entire system using your compiler flags, "a la FreeBSD" (p.e. with [[pacbuilder]])
+
* Rebuild your entire system using your compiler flags, "à la FreeBSD" (e.g. with [[pacbuilder]])
* Cleanly build and install your own custom kernel. (See [[Custom Kernel Compilation with ABS]] as well as [[Kernel Compilation]])
+
* Cleanly build and install your own custom kernel (see [[Kernel Compilation]])
* Get kernel modules working with your custom kernel.
+
* Get kernel modules working with your custom kernel
 
* Easily compile and install a newer, older, beta, or development version of an Arch package by editing the version number in the PKGBUILD
 
* Easily compile and install a newer, older, beta, or development version of an Arch package by editing the version number in the PKGBUILD
 +
 
ABS is not necessary to use Arch Linux, but it is useful for automating certain tasks of source compilation.
 
ABS is not necessary to use Arch Linux, but it is useful for automating certain tasks of source compilation.
  
This how-to tries to give you an overview of ABS and Arch packages; it's not a complete reference guide! If you want more, read the man pages.
+
== How to use ABS ==
  
== Get Started: Install Packages ==
+
Building packages using abs consists of these steps:
 +
#Install the {{Pkg|abs}} package with [[pacman]].
 +
#Run {{ic|abs}} as root to create the ABS tree by synchronizing it with the Arch Linux server.
 +
#Copy the build files (usually residing under {{ic|/var/abs/<repo>/<pkgname>}}) to a build directory.
 +
#Navigate to that directory, edit the PKGBUILD (if desired/necessary) and do '''makepkg'''.
 +
#According to instructions in the PKGBUILD, makepkg will download the appropriate source tarball, unpack it, patch if desired, compile according to {{ic|CFLAGS}} specified in {{ic|makepkg.conf}}, and finally compress the built files into a package with the extension {{ic|.pkg.tar.gz}} or {{ic|.pkg.tar.xz}}.
 +
#Installing is as easy as doing {{ic|pacman -U <.pkg.tar.xz file>}}. Package removal is also handled by pacman.
  
To use abs, you first need to install '''abs''' from the core repository; this can be done simply by:
+
=== Install tools ===
  
<pre>
+
To use the ABS, you first need to [[pacman|install]] {{Pkg|abs}} from the [[Official Repositories|official repositories]].
pacman -S abs</pre>
+
  
This will grab the abs-sync scripts, various build scipts, and rsync (as a dependency, if you don't already have it).
+
This will grab the abs-sync scripts, various build scripts, and [[rsync]] (as a dependency, if you do not already have it).
  
Before you can actually build anything, however, you will also need to grab basic compiling tools. These are handily collected in the package group '''base-devel'''.  This group can be installed with:
+
Before you can actually build anything, however, you will also need basic compiling tools. These are handily collected in the [[Pacman#Installing_package_groups|package group]] {{grp|base-devel}}.  This group can be installed with pacman.
 
+
<pre>
+
pacman -S base-devel</pre>
+
 
+
{{Warning | Remember this before complaining about missing (make)dependencies. The "base" group is assumed already installed in all Arch setups . The group "base-devel" is assumed already installed when building with makepkg .}}
+
  
 
=== /etc/abs.conf ===
 
=== /etc/abs.conf ===
  
As root, edit /etc/abs.conf to include your desired repositories:
+
As root, edit {{ic|/etc/abs.conf}} to include your desired repositories.
<pre>vim /etc/abs.conf</pre>
+
 
+
or:
+
  
<pre>nano /etc/abs.conf</pre>
+
Remove the {{ic|!}} in front of the appropriate repositories. For example:
Remove the ! in front of the appropriate repos, e.g.:
+
 
  REPOS=(core extra community !testing)
 
  REPOS=(core extra community !testing)
  
=== Create the ABS tree ===
+
=== ABS tree ===
  
As root, do:
+
The ABS tree is an SVN directory hierarchy located under {{ic|/var/abs}} and looks like this:
# abs
+
Your ABS tree is now created under /var/abs. Note the appropriate branches of the ABS tree now exist and correspond to the ones you specified in /etc/abs.conf.
+
 
+
''The abs command should also be used to periodically sync and update your ABS Tree.''
+
 
+
=== /etc/makepkg.conf ===
+
 
+
/etc/makepkg.conf specifies global environment variables and compiler flags which you may wish to edit if you are using an SMP system, or to specify other desired optimizations. The default settings are for i686 and x86_64 optimizations which will work fine for those architectures on single-cpu systems. (The defaults will work on SMP machines, but will only use one core/CPU when compiling- see [[Safe Cflags]].).
+
 
+
=== The ABS tree ===
+
  
When you run abs for the first time, it synchronizes the ABS tree with the Arch Linux server. So what exactly is the ABS tree? It is an SVN directory hierarchy located under /var/abs and looks like this:
+
{{bc|<nowiki>
<pre>
+
 
| -- core/
 
| -- core/
|    || -- base/
+
|    || -- acl/
|    ||    || -- acl/
+
|    ||    || -- PKGBUILD
|    ||    ||    || -- PKGBUILD
+
|    || -- attr/
|    ||    || -- attr/
+
|    ||    || -- PKGBUILD
|    ||    ||    || -- PKGBUILD
+
|    || -- abs/
|    ||    || -- ...
+
|    ||    || -- PKGBUILD
|    || -- devel/
+
|    || -- autoconf/
|    ||    || -- abs/
+
|    ||    || -- PKGBUILD
|    ||    ||    || -- PKGBUILD
+
|    ||    || -- autoconf/
+
|    ||    ||    || -- PKGBUILD
+
|    ||    || -- ...
+
 
|    || -- ...
 
|    || -- ...
 
| -- extra/
 
| -- extra/
|    || -- daemons/
+
|    || -- acpid/
|    ||    || -- acpid/
+
|    ||    || -- PKGBUILD
|    ||    ||    || -- PKGBUILD
+
|    || -- apache/
|    ||    ||    || -- ...
+
|    ||    || -- PKGBUILD
|    ||    || -- apache/
+
|    ||    ||    || -- ...
+
|    ||    || -- ...
+
 
|    || -- ...
 
|    || -- ...
 
| -- community/
 
| -- community/
 
|    || -- ...
 
|    || -- ...
</pre>
+
</nowiki>}}
So the ABS tree has exactly the same structure as the package database:
+
  
* first-level directory represents categories
+
The ABS tree has exactly the same structure as the package database:
  
* second-level directories represents the ABS themselves, whose names actually correspond to the packages you want to build
+
* First-level: Reposistory name
 +
* Second-level: Package name directories
 +
* Third level: PKGBUILD (contains information needed to build a package) and other related files (patches, other files needed for building the package)
  
* PKGBUILD files contain all information needed concerning the package
+
The source code for the package is not present in the ABS directory. Instead, the '''PKGBUILD''' file contains a URL that will download the source code when the package is built. So the size of abs tree is quite small.
  
* Further, an ABS directory can contain patches and/or other files needed for building the package.
+
==== Download ABS tree ====
''It is important to understand that the actual source code for the package is not present in the ABS directory.'' Instead, the '''PKGBUILD''' file contains a URL from which ABS will automatically download from.
+
As root, run:
 +
# abs
  
==== Create a Build Directory ====
+
Your ABS tree is now created under {{ic|/var/abs}}. Note the appropriate branches of the ABS tree now exist and correspond to the ones you specified in {{ic|/etc/abs.conf}}.
  
You must create a build directory, where the actual compiling will take place. This is where you'll do everything; you should never modify the ABS Tree by building within it, as data will be lost (overwritten) on each abs update. It is good practice to use your home directory, though some Arch users prefer to create a 'local' directory under /var/abs/, owned by normal user. Copy the ABS from the tree (var/abs/branch/category/pkgname) to the build directory, /path/to/build/dir.
+
The abs command should be run periodically to keep in sync with the official repositories. Individual ABS package files can also be downloaded with:
  
Create your build directory. e.g.:
+
  # abs <repository>/<package>
  mkdir -p $HOME/abs
+
This way you do not have to check out the entire abs tree just to build one package.
  
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 is compressed during the transfer''.
+
=== /etc/makepkg.conf ===
  
Now that you know what the ABS tree is, how can we use it ?
+
{{ic|/etc/makepkg.conf}} specifies global environment variables and compiler flags which you may wish to edit if you are using an SMP system, or to specify other desired optimizations. The default settings are for i686 and x86_64 optimizations which will work fine for those architectures on single-CPU systems. (The defaults will work on SMP machines, but will only use one core/CPU when compiling -- see [[makepkg.conf]].)
  
=== The build function, traditional method ===
+
==== Set the PACKAGER variable in /etc/makepkg.conf ====
  
If you're not familiar with compiling from source, you should know that most packages (but not all) can be built from source in this '''traditional way''':
+
Setting the PACKAGER variable in {{ic|/etc/makepkg.conf}} is an optional but ''highly recommended'' step.  It allows a "flag" to quickly identify which packages have been built and/or installed by YOU, not the official maintainer!  This is easily accomplished using '''expac''' available from the community repo:
  
* Download source tarball from remote server, using web browser, ftp, wget or alternate method.
+
===== Showing All Packages (including those from AUR) =====
 +
$ grep myname /etc/makepkg.conf
 +
PACKAGER="myname <myemail@myserver.com>"
  
* decompress the source file:
+
$ expac "%n %p" | grep "myname" | column -t
  <pre>
+
archey3 myname
  tar -xzf foo-0.99.tar.gz
+
binutils myname
  tar -xjf foo-0.99.tar.bz2</pre>
+
gcc myname
 +
gcc-libs myname
 +
glibc myname
 +
tar myname
  
* enter the directory
+
===== Showing Only Packages Contained in Repos =====
  <pre>cd foo-0.99</pre>
+
  
* configure the package: generally, there is a little script called <code>configure</code> in the source directory that is used to configure the package (add or remove support for things, choose the install destination, etc.) and check that your computer has all the software needed by the package. It can be run by:
+
This example only shows packages contained in the repos defined in {{ic|/etc/pacman.conf}}:
  <pre>./configure [[option]]</pre>
+
  
You should first try the help to better understand how it works:
+
$ . /etc/makepkg.conf; grep -xvFf <(pacman -Qqm) <(expac "%n\t%p" | grep "$PACKAGER$" | cut -f1)
  <pre>./configure --help</pre>
+
binutils
 +
gcc
 +
gcc-libs
 +
glibc
 +
tar
  
If a --prefix option is not passed to the script, ''most'' scripts will use /usr/local as the install path, but others will use /usr. For the sake of consistency, it is generally advised to pass the --prefix=/usr/local option. It is good practice to install personal programs in /usr/local, and to have the ones being managed by the distro, in /usr. This ensures personal program versions can coexist with those being managed by the distro's package manager- in Arch's case, ''pacman''.
+
=== Create a build directory ===
./configure --prefix=/usr/local
+
  
* compile the sources:
+
It is recommended to create a build directory where the actual compiling will take place; you should never modify the ABS tree by building within it, as data will be lost (overwritten) on each ABS update. It is good practice to use your home directory, though some Arch users prefer to create a 'local' directory under {{ic|/var/abs/}}, owned by a normal user.
 +
 
 +
Create your build directory. e.g.:
  
  make
+
  $ mkdir -p $HOME/abs
  
* install
+
Copy the ABS from the tree ({{ic|/var/abs/<repository>/<pkgname>}}) to the build directory.
  
make install
+
=== Build package ===
  
* Uninstalling would be accomplished by entering the source directory and running:
+
In our example, we will build the ''slim'' display manager package.
  
  make uninstall
+
Copy the slim ABS from the ABS tree to a build directory:
 +
  $ cp -r /var/abs/extra/slim/ ~/abs
  
However, you should always read the <code>INSTALL</code> file to know how the package should be built and installed! '''Not all packages use the <code>configure; make; make install</code> system!
+
Navigate to the build directory:
 +
$ cd ~/abs/slim
  
{{Note | The above traditional method of compiling source tarballs can, of course, still be used on Arch Linux, but if you are not careful, files may become scattered throughout the filesystem, that pacman, (or any other package manager), will be unaware of. You should only use this method if you are experienced at manual compilation and system software tracking, as it can lead to future problems on Arch, or any distribution, if using a package manager.}}
+
Modify the PKGBUILD to add or remove support for components, to patch or to change package versions, etc. (optional):
 +
$ nano PKGBUILD
  
=== The build function, the ABS way ===
+
Run makepkg as normal user (with {{ic|-s}} switch to install with automatic dependency handling):
 +
$ makepkg -s
  
ABS is an elegant tool which allows for powerful assistance and customization for the build process, and creates a ''pacman-trackable'' package file for installation. The ABS method involves copying an ABS from the Tree to a build directory, and doing makepkg. In our example, we will build the ''slim'' display manager package.
+
{{Note|Before complaining about missing (make) dependencies, remember that the {{Grp|base}} group is assumed to be installed on all Arch Linux systems. The group "base-devel" is assumed to be installed when building with '''makepkg'''. See [[#Install tools]].}}
  
*1. Copy the slim ABS from the ABS Tree to a build directory.
 
cp -r /var/abs/extra/slim/ /home/yourusername/abs
 
*2. Navigate to the build directory
 
cd /home/yourusername/abs/slim
 
*2a. (Optional)
 
Modify the PKGBUILD to add or remove support for components, to patch or to change package versions, etc.
 
nano PKGBUILD
 
*3. Do makepkg as normal user (to install with automatic dependency handling):
 
makepkg -s
 
 
Install as root:
 
Install as root:
  # pacman -U slim 1.3.0-2-i686.pkg.tar.gz
+
  # pacman -U slim-1.3.0-2-i686.pkg.tar.xz
  
That's it. You have just built slim from source and cleanly installed it to your system with pacman. Package removal is also handled by pacman- (pacman -R slim)
+
That's it. You have just built slim from source and cleanly installed it to your system with pacman. Package removal is also handled by pacman with {{ic|pacman -R slim}}.
* What is happening:
+
Essentially, the same steps are being executed, 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.gz, or a ''package''. When invoked, pacman then extracts the package (installs it) into the system's real root directory, (/). Simple.
+
* ''The ABS method adds a level of convenience and automation, while still maintaining complete transparency and control of the build and installation functions by including them in the PKGBUILD.''
+
  
See [[Creating Packages]] for a complete overview of a sample PKGBUILD.
+
The ABS method adds a level of convenience and automation, while still maintaining complete transparency and control of the build and installation functions by including them in the PKGBUILD.
  
=== More ABS and related info ===
+
==== fakeroot ====
* [[Makepkg]]
+
Essentially, the same steps are being executed in the traditional method (generally including the {{ic|./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 {{ic|.pkg.tar.xz}}, or a ''package''. When invoked, pacman then extracts the package (installs it) into the system's real root directory ({{ic|/}}).
* [[Creating Packages]]
+
* [[Safe Cflags]]
+
* [[Kernel Compilation with ABS]]
+
* [[ArchLinux User-community Repository (AUR)]]
+
* [[Custom local repository with ABS and gensync]]
+

Revision as of 13:21, 17 May 2013

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end

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

Note: 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 ツリー
The ABS directory structure; an SVN hierarchy under /var/abs/ on your (local) machine. It contains many subdirectories, named for all available official Arch Linux software from repositories specified in /etc/abs.conf, but not the packages themselves. The tree is created after installing the abs package with pacman and subsequently running the abs script.
PKGBUILD
A Bash script that contains the URL of the source code along with the compilation and packaging instructions.
makepkg
ABS shell command tool which reads the PKGBUILDs, automatically downloads and compiles the sources and creates a .pkg.tar* according to the PKGEXT array in makepkg.conf. You may also use makepkg to make your own custom packages from the AUR or third-party sources. (See the Creating Packages wiki article.)
pacman
pacman is completely separate, but is necessarily invoked either by makepkg or manually, to install and remove the built packages and for fetching dependencies.
AUR
The Arch User Repository is separate from ABS but AUR (unsupported) PKGBUILDs are built using makepkg to compile and package up software. In contrast to the ABS tree on your local machine, the AUR exists as a website interface. It contains many thousands of user-contributed PKGBUILDs for software which is unavailable as an official Arch package. If you need to build a package outside the official Arch tree, chances are it is in the AUR.

Why would I want to use ABS?

The Arch Build System is used to:

  • Compile or recompile a package, for any reason
  • Make and install new packages from source of software for which no packages are yet available (see Creating Packages)
  • Customize existing packages to fit your needs (enabling or disabling options, patching)
  • Rebuild your entire system using your compiler flags, "à la FreeBSD" (e.g. with pacbuilder)
  • Cleanly build and install your own custom kernel (see Kernel Compilation)
  • Get kernel modules working with your custom kernel
  • Easily compile and install a newer, older, beta, or development version of an Arch package by editing the version number in the PKGBUILD

ABS is not necessary to use Arch Linux, but it is useful for automating certain tasks of source compilation.

How to use ABS

Building packages using abs consists of these steps:

  1. Install the abs package with pacman.
  2. Run abs as root to create the ABS tree by synchronizing it with the Arch Linux server.
  3. Copy the build files (usually residing under /var/abs/<repo>/<pkgname>) to a build directory.
  4. Navigate to that directory, edit the PKGBUILD (if desired/necessary) and do makepkg.
  5. According to instructions in the PKGBUILD, makepkg will download the appropriate source tarball, unpack it, patch if desired, compile according to CFLAGS specified in makepkg.conf, and finally compress the built files into a package with the extension .pkg.tar.gz or .pkg.tar.xz.
  6. Installing is as easy as doing pacman -U <.pkg.tar.xz file>. Package removal is also handled by pacman.

Install tools

To use the ABS, you first need to install abs from the official repositories.

This will grab the abs-sync scripts, various build scripts, and rsync (as a dependency, if you do not already have it).

Before you can actually build anything, however, you will also need basic compiling tools. These are handily collected in the package group base-devel. This group can be installed with pacman.

/etc/abs.conf

As root, edit /etc/abs.conf to include your desired repositories.

Remove the ! in front of the appropriate repositories. For example:

REPOS=(core extra community !testing)

ABS tree

The ABS tree is an SVN directory hierarchy located under /var/abs and looks like this:

| -- core/
|     || -- acl/
|     ||     || -- PKGBUILD
|     || -- attr/
|     ||     || -- PKGBUILD
|     || -- abs/
|     ||     || -- PKGBUILD
|     || -- autoconf/
|     ||     || -- PKGBUILD
|     || -- ...
| -- extra/
|     || -- acpid/
|     ||     || -- PKGBUILD
|     || -- apache/
|     ||     || -- PKGBUILD
|     || -- ...
| -- community/
|     || -- ...

The ABS tree has exactly the same structure as the package database:

  • First-level: Reposistory name
  • Second-level: Package name directories
  • Third level: PKGBUILD (contains information needed to build a package) and other related files (patches, other files needed for building the package)

The source code for the package is not present in the ABS directory. Instead, the PKGBUILD file contains a URL that will download the source code when the package is built. So the size of abs tree is quite small.

Download ABS tree

As root, run:

# abs

Your ABS tree is now created under /var/abs. Note the appropriate branches of the ABS tree now exist and correspond to the ones you specified in /etc/abs.conf.

The abs command should be run periodically to keep in sync with the official repositories. Individual ABS package files can also be downloaded with:

# abs <repository>/<package>

This way you do not have to check out the entire abs tree just to build one package.

/etc/makepkg.conf

/etc/makepkg.conf specifies global environment variables and compiler flags which you may wish to edit if you are using an SMP system, or to specify other desired optimizations. The default settings are for i686 and x86_64 optimizations which will work fine for those architectures on single-CPU systems. (The defaults will work on SMP machines, but will only use one core/CPU when compiling -- see makepkg.conf.)

Set the PACKAGER variable in /etc/makepkg.conf

Setting the PACKAGER variable in /etc/makepkg.conf is an optional but highly recommended step. It allows a "flag" to quickly identify which packages have been built and/or installed by YOU, not the official maintainer! This is easily accomplished using expac available from the community repo:

Showing All Packages (including those from AUR)
$ grep myname /etc/makepkg.conf
PACKAGER="myname <myemail@myserver.com>"
$ expac "%n %p" | grep "myname" | column -t
archey3 myname
binutils myname
gcc myname
gcc-libs myname
glibc myname
tar myname
Showing Only Packages Contained in Repos

This example only shows packages contained in the repos defined in /etc/pacman.conf:

$ . /etc/makepkg.conf; grep -xvFf <(pacman -Qqm) <(expac "%n\t%p" | grep "$PACKAGER$" | cut -f1)
binutils
gcc
gcc-libs
glibc
tar

Create a build directory

It is recommended to create a build directory where the actual compiling will take place; you should never modify the ABS tree by building within it, as data will be lost (overwritten) on each ABS update. It is good practice to use your home directory, though some Arch users prefer to create a 'local' directory under /var/abs/, owned by a normal user.

Create your build directory. e.g.:

$ mkdir -p $HOME/abs

Copy the ABS from the tree (/var/abs/<repository>/<pkgname>) to the build directory.

Build package

In our example, we will build the slim display manager package.

Copy the slim ABS from the ABS tree to a build directory:

$ cp -r /var/abs/extra/slim/ ~/abs

Navigate to the build directory:

$ cd ~/abs/slim

Modify the PKGBUILD to add or remove support for components, to patch or to change package versions, etc. (optional):

$ nano PKGBUILD

Run makepkg as normal user (with -s switch to install with automatic dependency handling):

$ makepkg -s
Note: Before complaining about missing (make) dependencies, remember that the base group is assumed to be installed on all Arch Linux systems. The group "base-devel" is assumed to be installed when building with makepkg. See #Install tools.

Install as root:

# pacman -U slim-1.3.0-2-i686.pkg.tar.xz

That's it. You have just built slim from source and cleanly installed it to your system with pacman. Package removal is also handled by pacman with pacman -R slim.

The ABS method adds a level of convenience and automation, while still maintaining complete transparency and control of the build and installation functions by including them in the PKGBUILD.

fakeroot

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 (/).