Arch Build System (한국어)
Template:Article summary start Template:Article summary text Template:Article summary heading Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end
이 문서는 초보자를 위한 빠른 설명과 함께 아치 빌드 시스템의 개요를 제공합니다. 이 문서의 내용은 완벽한 안내서가 아닙니다! 더 많은 정보가 필요하면, 맨 페이지를 참조 해주세요.
- 1 What is the Arch Build System?
- 2 Why would I want to use ABS?
- 3 Walkthrough
What is the Arch Build System?
The Arch Build System (ABS for short) is a 'ports-like' system for building and packaging software from source code. While pacman is the specialized Arch tool for binary package management (including packages built with the ABS) ABS is the specialized Arch tool for compiling source into an installable Template:Filename package.
What is a ports-like system?
'Ports' is a system used by *BSD, which allows source packages to be downloaded, unpacked, patched, compiled and installed. A 'port' is merely a small directory on the user's computer, named after the corresponding software to be installed, which contains a few files with instructions for downloading and installing an application from source (typically by navigating to the directory, or port, and doing 'make' and 'make install'). The system will then download, compile and install the desired software.
ABS is a similar concept
ABS is made up of a directory tree (the ABS tree) residing under Template:Filename. This tree contains many subdirectories, each within a category and each named by their respective package. This tree represents (but does not contain) all official Arch software, retrievable through the SVN system. You may refer to each package-named subdirectory as an 'ABS', much the way one would refer to a 'port'. These ABS (or subdirectories) do not contain the software package nor the source but rather a PKGBUILD file (and sometimes other files). A PKGBUILD is a simple BASH build script -- a text file containing the compilation and packaging instructions as well as the URL of the appropriate source tarball to be downloaded. (The most important component of ABS are PKGBUILDs.) By issuing the ABS makepkg command, the software is first compiled and then packaged within the build directory before being installed. Now you may use pacman, the Arch Linux package manager, to install, upgrade, and remove your new package.
'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 Template:Filename on your (local) machine. It contains many subdirectories, named for all available official Arch Linux software from repositories specified in Template:Filename, but not the packages themselves.
- A set of tools to retrieve and build official Arch Linux PKGBUILDs. Example PKGBUILDs are also included.
- 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.
- ABS shell command tool which reads the PKGBUILDs, automatically downloads and compiles the sources and creates a Template:Filename.
- pacman is completely separate, but is necessarily invoked either by makepkg or manually to install and remove the built packages and for fetching dependencies.
- The Arch User 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 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 Building Packages)
- Customize existing packages to fit your needs (enabling or disabling options, patching)
- Rebuild your entire system using your compiler flags, "a 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)
- 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.
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 Template:Filename, and finally, install with pacman.
Install the ABS package with Template:Codeline. Running Template:Codeline 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 Template:Filename) 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 Template:Filename, and finally compress the built files into a package with the extension Template:Filename. PKGBUILDs may be customized to suit your unique configuration needs, or for applying patches. Installing is as easy as doing Template:Codeline. 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:
# pacman -S abs
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
As root, edit Template:Filename to include your desired repositories:
# vim /etc/abs.conf
# nano /etc/abs.conf
Remove the ! in front of the appropriate repos, e.g.:
REPOS=(core extra community !testing)
Download the ABS tree
As root, run:
If you are an active developer, the abs command should also be run periodically to be in sync with the official repositories. If you are a casual developer, individual ABS package files can be downloaded by:
# abs repository/package
Template:Filename 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 ABS tree
When you run Template:Codeline for the first time, it synchronizes the ABS tree on the Arch Linux server to your computer. The ABS tree is an SVN directory hierarchy located under Template:Filename and looks like this:
| -- core/ | || -- base/ | || || -- acl/ | || || || -- PKGBUILD | || || -- attr/ | || || || -- PKGBUILD | || || -- ... | || -- devel/ | || || -- abs/ | || || || -- PKGBUILD | || || -- autoconf/ | || || || -- PKGBUILD | || || -- ... | || -- ... | -- extra/ | || -- daemons/ | || || -- acpid/ | || || || -- PKGBUILD | || || || -- ... | || || -- apache/ | || || || -- ... | || || -- ... | || -- ... | -- community/ | || -- ...
The ABS tree has exactly the same structure as the package database:
- First-level: Category directories
- 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.
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 Template:Filename, owned by a normal user. Copy the ABS from the tree (Template:Filename) to the build directory, Template:Filename.
Create your build directory. e.g.:
$ mkdir -p $HOME/abs
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
- Enter the directory:
$ cd foo-0.99
- Configure the package. Generally, there is a script called Template:Filename 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:
$ ./configure [option]
You should first try the help to better understand how it works:
$ ./configure --help
If a Template:Codeline option is not passed to the script, most scripts will use Template:Filename as the install path, but others will use Template:Filename. For the sake of consistency, it is generally advised to pass the Template:Codeline option. It is good practice to install personal programs in Template:Filename, and to have the ones being managed by the distro in Template:Filename. 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:
# make install
- Removal would be accomplished by entering the source directory and running:
# make uninstall
However, you should always read the Template:Filename file to know how the package should be built and installed! Not all packages use the
configure; make; make install system!
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.
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 Template:Codeline switch 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 -- (Template:Codeline).
Essentially, the same steps are being executed as described 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 Template:Filename, or a package. When invoked, pacman then extracts the package (installs it) into the system's real root directory (Template:Filename). 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.