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

From ArchWiki
Jump to: navigation, search
(rm temporary i18n template)
m (temporary redirect)
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:About Arch (日本語)]]
#redirect[[ja:Arch Build System]]
[[Category:Package development (日本語)]]
[[Category:Package management (日本語)]]
{{Out of date}}
[[cs:Arch Build System]]
[[da:Arch Build System]]
[[de:Arch Build System]]
[[el:Arch Build System]]
[[en:Arch Build System]]
[[es:Arch Build System]]
[[it:Arch Build System]]
[[ko:Arch Build System]]
[[pl:Arch Build System]]
[[ru:Arch Build System]]
[[zh-CN:Arch Build System]]
[[zh-TW:Arch Build System]]
== このページは完全には翻訳されていません  ==
== ABSについて ==
ABSとはArch Build Systemの略で、FreeBSDなどで採用されている'ports'に似ています。
=== 'Ports'とは ===
ソフトウェアをインストールしたい時は、多くの場合、ソフト名のフォルダまで移動し'make' 'make install'と入力することによって
=== "ABS"の特徴  ===
ABSもPortsに似たシステムで、/var/abs ディレクトリ傘下に、カテゴリ - パッケージ名の順番で、ツリー状のフォルダ群を保存しています。
これにはArch Linux公式ソフトすべてのパッケージが含まれます。(Portsと同様、ソースコードやバイナリパッケージを含んでいないのでサイズはそんなに大きくありません)
=== Quick Walkthrough ===
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.
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)
''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.''
=== ABS Overview ===
'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? ==
The Arch Build System (ABS for short) is used to
* 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, "a la FreeBSD" (p.e. with [[pacbuilder]])
* Cleanly build and install your own custom kernel. (See [[Custom Kernel Compilation with ABS]] as well as [[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.
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.
== Get Started: Install Packages ==
To use abs, you first need to install '''abs''' from the core repository; this can be done simply by:
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).
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:
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 ===
As root, edit /etc/abs.conf to include your desired repositories:
<pre>vim /etc/abs.conf</pre>
<pre>nano /etc/abs.conf</pre>
Remove the ! in front of the appropriate repos, e.g.:
REPOS=(core extra community !testing)
=== Create the ABS tree ===
As root, do:
# 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:
| -- core/
|    || -- base/
|    ||    || -- acl/
|    ||    ||    || -- PKGBUILD
|    ||    || -- attr/
|    ||    ||    || -- PKGBUILD
|    ||    || -- ...
|    || -- devel/
|    ||    || -- abs/
|    ||    ||    || -- PKGBUILD
|    ||    || -- autoconf/
|    ||    ||    || -- PKGBUILD
|    ||    || -- ...
|    || -- ...
| -- extra/
|    || -- daemons/
|    ||    || -- acpid/
|    ||    ||    || -- PKGBUILD
|    ||    ||    || -- ...
|    ||    || -- apache/
|    ||    ||    || -- ...
|    ||    || -- ...
|    || -- ...
| -- community/
|    || -- ...
So the ABS tree has exactly the same structure as the package database:
* first-level directory represents categories
* second-level directories represents the ABS themselves, whose names actually correspond to the packages you want to build
* PKGBUILD files contain all information needed concerning the package
* Further, an ABS directory can contain patches and/or other files needed for building the package.
''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.
==== Create a Build Directory ====
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.
Create your build directory. e.g.:
mkdir -p $HOME/abs
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''.
Now that you know what the ABS tree is, how can we use it ?
=== The build function, traditional method ===
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''':
* Download source tarball from remote server, using web browser, ftp, wget or alternate method.
* decompress the source file:
  tar -xzf foo-0.99.tar.gz
  tar -xjf foo-0.99.tar.bz2</pre>
* enter the directory
  <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:
  <pre>./configure [[option]]</pre>
You should first try the help to better understand how it works:
  <pre>./configure --help</pre>
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''.
./configure --prefix=/usr/local
* compile the sources:
* install
make install
* Uninstalling would be accomplished by entering the source directory and running:
make uninstall
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!
{{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.}}
=== The build function, the ABS way ===
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.
*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.
*3. Do makepkg as normal user (to install with automatic dependency handling):
makepkg -s
Install as root:
# pacman -U slim 1.3.0-2-i686.pkg.tar.gz
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)
* 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.
=== More ABS and related info ===
* [[Makepkg]]
* [[Creating Packages]]
* [[Safe Cflags]]
* [[Kernel Compilation with ABS]]
* [[ArchLinux User-community Repository (AUR)]]
* [[Custom local repository with ABS and gensync]]

Latest revision as of 00:47, 1 March 2015