Arch Build System (한국어)

From ArchWiki
Revision as of 13:04, 10 January 2010 by Linukizx (Talk | contribs) (ABS 개요)

Jump to: navigation, search

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

이 문서는 초보자를 위한 빠른 설명과 함께 아치 빌드 시스템의 개요를 제공합니다. 이 문서의 내용은 완벽한 안내서가 아닙니다! 더 많은 정보가 필요하면, 맨 페이지를 참조 해주세요.

아치 빌드 시스템이란?

아치 빌드 시스템은 BSD의 포트와 유사한 소스코드로 부터 패키지를 만드는 시스템입니다. ABS (Template:Filename 패키지를 만들기 위한 전문적인 도구)를 통해 소스를 컴파일 후 팩맨을 통해 바이너리 패키지를 관리(설치/삭제/업그레이드등)을 도와줍니다.

포트와 유사한(ports-like) 시스템이란?

'포트'시스템은 BSD*에서 소스 패키지를 다운로드 압축 해제, 패치, 컴파일하여 설치하는 사용됩니다. '포트'는 사용자의 컴퓨터에 디렉토리로 존재합니다. 이 작은 디렉토리는 해당 소프트웨어의 이름이 같으며, 일반적으로 디렉토리 안에는 소스와 응용 프로그램을 설치하기 위한 지침을 몇 가지 파일이 포함되어 있습니다. 이 시스템은 보다 쉽게 소스를 컴파일하고 원하는 소프트웨어 설치를 도와줍니다.

ABS 는 같은 개념입니다.

ABS 는 Template:Filename 아래에 ABS 라는 디렉토리 구조를 만듭니다. 이 구조에는 많은 하부 디렉토리와 각각의 패키들에 의해 명명되고 분류되어 있습니다. 이 구조는 SVN 시스템에 의해 복구되는 모든 공식 아치 소프트웨어를 표현 합니다.(내용을 담고 있지는 않습니다.) 'ABS'에서 각각의 패키지 명명화된 하부 디렉토리를 참조 할것이며, '포트'에서 참조하는것 보다 많은 방법을 사용 할것입니다. 이들 ABS (또는 하부 디렉토리들)은 소프트웨어 패키지 또는 소스를 포함하지 않지만 PKGBUILD 화일(그리고 때로는 다른 화일들)을 포함합니다. PKGBUILD는 간결한 BASH 빌더 스크립터 입니다. -- 다운로드 할 수 있는 tar 묶음된 소스의 가장 적절한 URL로 구성된 컴파일 하기와 패키징 하기 정보를 담고 있는 텍스트 화일입니다. (ABS에서 가장 중요한 요소는 PKGBUILD입니다.) ABS makepkg에 의해서 야기된 소프트웨어는 인스톨되기전에 빌더 디렉토리에서 먼저 컴파일되고 패키지화 됩니다. 이제 여러분은 아치 리눅스 패키지 매니저인 pacman을 사용하여 새로운 패키지를 설치, 업데이트, 삭제 할 수 있습니다.

ABS 개요

'ABS' 는 ABS를 포함해서 그 외 의존하는 여러가지 구성 요소를 총칭하는 용어로 사용할 수 있습니다. 따라서, 'ABS'는 다음과 같은 구조와 도구를 지칭 할 때도 사용 됩니다 :

ABS 트리
ABS 디렉토리 구조; 여러분의 (로컬) 머신에 SVN 계층구조와 같이 Template:파일명 . 그것은 여러 하위 디렉토리의 지정된 저장소에 사용 가능한 모든 공식 아치 리눅스 소프트웨어가 포함되어 있습니다. Template:파일명, 하지만 패키지 자체는 저장 되어 있지 않습니다.
ABS 
공식아치 리눅스의 PKGBUILDs 내용을 읽어서, 빌드. PKGBUILDs 예제도 포함되어있습니다.
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. ABS 디렉토리 아래에 존재하는 텍스트 파일로 만들어진 스크립트, 혹은 사용자가 정의한 스크립트, 필요한 파일이나 url, 빌드방법을 적어둔 지침
makepkg
ABS 쉘 명령어 도구로 PKGBUILDs 읽고 소스를 자동으로 다운로드, 컴파일 및 Template:Filename 파일 생성
pacman
pacman은 직접적인 연관은 없지만 makepkg나 수동으로 필요한 패키지를 설치, 제거, 의존성 해결을 위해서 필요 합니다.
AUR
아치 사용자 저장소를 ABS에서 AUR ([비공식]) 직접적으로 지원하지는 않지만 makepkg 도구를 통해서 PKGBUILDs 파일을 컴파일 및 패키지로 만들수 있습니다. AUR에는 16,000 이상의 아치 패키지로 만들수 있는 PKGBUILDs가 포함되어있습니다. 만약 공식적인 아치 트리 밖으로 패키지를 빌드해야 한다면 AUR 을 이용하시면 됩니다.

ABS를 왜 사용하나요?

아래와 같은 경우 아치 빌드 시스템을 사용합니다 :

  • 어떤 이유로 인해서 패키지를 재컴파일 해야하는 경우
  • 패키지가 없는 새로운 소프트웨어를 소스로부터 패키지를 생성 /설치시(Building Packages 참고)
  • 사용자 정의 패키지 (기존 패키지의 옵션을 활성화하거나 비활성화, 패치)
  • 컴파일러 플래그를 지정하여 여러분의 전체 시스템을 재빌드 "a la FreeBSD"(pacbuilder)참고)
  • 자신만의 사용자 정의 커널 설치 (Custom Kernel Compilation with ABSKernel Compilation 참고)
  • 사용자 정의 커널과 커널 모듈 작업
  • 새버전을 쉽게 컴파일하고, 베타 또는 아치 패키지의 개발 버전을 수정하여 원하는 버전 번호를 PKGBUILD에 적용 설치

ABS를 사용하기 위해서 아치리눅스를 사용할 필요는 없지만 소스를 컴파일하여 특정 작업을 자동화하는데 좀 더 편리하게 이용 가능합니다.

Walkthrough

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.

Quick overview

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.

You may also use makepkg to make your own custom packages from the AUR or third-party sources. (See the Building Packages wiki article.)

Details

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
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.

Template:Filename

As root, edit Template:Filename to include your desired repositories:

# vim /etc/abs.conf

or:

# 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:

# abs

Your ABS tree is now created under Template:Filename. Note the appropriate branches of the ABS tree now exist and correspond to the ones you specified in Template:Filename.

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

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
Note: The first download of the abs tree is the biggest, then only minor updates are needed. 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. For example, as of November 24, 2009, the abs tree that includes core, extra and community repositories is a ~16MB download (~56MB on disk).

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

or

$ 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:
# 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!

Note: The above traditional method of compiling source tarballs can, of course, still be used on Arch Linux. However, 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.

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.