''Ports'' is a system used by *BSD to automate the process of building software from source code. The system uses a ''port'' to download, unpack, patch, compile, and install the given software. A ''port'' is merely a small directory on the user's computer, named after the corresponding software to be installed, that contains a few files with the instructions for building and installing the software from source. This makes installing software as simple as typing {{ic|make}} or {{ic|make install clean}} within the port's directory.

''Ports'' is a system used by *BSD to automate the process of building software from source code. The system uses a ''port'' to download, unpack, patch, compile, and install the given software. A ''port'' is merely a small directory on the user's computer, named after the corresponding software to be installed, that contains a few files with the instructions for building and installing the software from source. This makes installing software as simple as typing {{ic|make}} or {{ic|make install clean}} within the port's directory.

−

=== '''ABS''' is a similar concept ===

+

=== ABS is a similar concept ===

ABS is made up of a directory tree (the ABS tree) residing under {{ic|/var/abs}}. 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 is made up of a directory tree (the ABS tree) residing under {{ic|/var/abs}}. 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.

Line 62:

Line 63:

* 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]])

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.

−

== How to use ABS? ==

+

== How to use ABS ==

Building packages using abs consists of these steps:

Building packages using abs consists of these steps:

Line 81:

Line 82:

=== Install tools ===

=== Install tools ===

−

To use the ABS, you first need to install {{Pkg|abs}} from the [[Official Repositories|official repositories]]:

+

To use the ABS, you first need to [[pacman|install]] {{Pkg|abs}} from the [[Official Repositories|official repositories]].

−

−

# pacman -S abs

This will grab the abs-sync scripts, various build scripts, and [[rsync]] (as a dependency, if you do not 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.

−

−

# pacman -S base-devel

=== /etc/abs.conf ===

=== /etc/abs.conf ===

Line 148:

Line 145:

==== Set the PACKAGER variable in /etc/makepkg.conf ====

==== Set the PACKAGER variable in /etc/makepkg.conf ====

−

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:

+

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 {{Pkg|expac}} available from the community repo:

===== Showing All Packages (including those from AUR) =====

===== Showing All Packages (including those from AUR) =====

Line 210:

Line 207:

==== fakeroot ====

==== fakeroot ====

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

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

−

−

== Traditional method of compiling software, without ABS ==

−

−

If you are not familiar with manually compiling software from source, you should know that most packages (but not all) can be built from source in this '''traditional way''':

* Configure the package. Generally, there is a script called {{ic|configure}} 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 ''options''

−

−

You should first try the help to better understand how it works:

−

$ ./configure --help

−

−

If a {{ic|--prefix}} option is not passed to the script, ''most'' scripts will use {{ic|/usr/local}} as the install path, but others will use {{ic|/usr}}. For the sake of consistency, it is generally advised to pass the {{ic|1=--prefix=/usr/local}} option. It is good practice, as per [[Filesystem_Hierarchy_Standard|FHS]], to install personal programs in {{ic|/usr/local}}, and to have the ones being managed by the distro in {{ic|/usr}}. This ensures personal program versions can coexist with those being managed by the distro's package manager &mdash; 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 {{ic|INSTALL}} file to know how the package should be built and installed! '''Not all packages use the {{ic|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.}}

This article provides an overview of the Arch Build System along with a walkthrough for beginners. It is not a complete reference guide! For a quick and simple introduction to the ABS, see the ABS FAQ. If you need more information, please reference the man pages.

Note: ABS syncs once a day so it may lag behind what is already available in the repositories.

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 a collection of tools for compiling source into installable .pkg.tar.xz packages.

What is a ports-like system?

Ports is a system used by *BSD to automate the process of building software from source code. The system uses a port to download, unpack, patch, compile, and install the given software. A port is merely a small directory on the user's computer, named after the corresponding software to be installed, that contains a few files with the instructions for building and installing the software from source. This makes installing software as simple as typing make or make install clean within the port's directory.

ABS is a similar concept

ABS is made up of a directory tree (the ABS tree) residing under /var/abs. 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 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 tools as a complete toolkit:

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. The tree is created after installing the abs package with pacman and subsequently running the abs script.

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

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)

How to use ABS

Run abs as root to create the ABS tree by synchronizing it with the Arch Linux server.

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 or .pkg.tar.xz.

Installing is as easy as doing pacman -U <.pkg.tar.xz file>. Package removal is also handled by pacman.

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:

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

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