Arch Build System (Italiano)
Template:I18n links start 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 links end
- 1 Cosa è ABS?
- 2 Why would I want to use ABS?
- 3 Get Started: Install Packages
Cosa è ABS?
ABS è l'acronimo di "Arch Build System", Sistema di costruzione (dei pacchetti) di arch. E' un sistema per fare pacchetti del codice sorgente. Mentre pacman è il tool di Arch specializzato nella gestione dei pacchetti binari (inclusi i pacchetti fatti con ABS), ABS è il tool specializzato nella compilazione dei sorgenti in un pacchetto .pkg.tar.gz installabile
Cos'è un sistema ports-like?
"Ports" è il sistema usato da FreeBSD che permette di scaricare, scompattare, patchare, compilare e installare i pacchetti con i codici sorgenti. "Un 'port' è solo una piccola cartella nel computer dell'utente, chiamata come il corrispondente software che ci verrà installato, che contiene un po' di file con le istruzioni per scaricare ed installare il pacchetto dai sorgenti", solitamente entrando nella cartella, o port, e dando 'make' e 'make install'. Il sistema si occuperà di scaricare, compilare ed installare il software desiderato.
ABS è un concetto simile.
"ABS" è costituito da un'albero di dircetory (the "ABS Tree"), che sta in /var/abs, che contiene molte sottodirectory, ognuna dentro una categoria, e ognuna chiamata con il rispettivo pacchetto installabile contenuto al suo interno. Si può considerare ogni sottodirectory chiamata come un pacchetto un "ABS", più o meno allo stesso modo con cui ci si potrebbe riferire ad un "Port". Questi "ABS", o sottodirectory, "non contengono il pacchetto del software, nè tantomeno il codice sorgente", bensì contengono un file "PKGBUILD" (e a volte altri file). Un PKGBUILD è un semplice script, un file di testo contenente le istruzioni per la compilazione e la pacchettizzazione, ma anche l'url dell'apposito pacchetto di sorgenti da scaricare. "I componenti più importanti di ABS sono proprio i PKGBUILD"
Running 'abs' as root creates the ABS tree by synchronizing with the cvs system. If you wanted to build nano from source, for instance, you would copy /var/abs/core/base/nano to a build directory, navigate to the build directory and do makepkg. It's as simple as that. Makepkg will attempt to read and execute the instructions contained within the PKGBUILD. The appropriate source tarball will automatically be downloaded, unpacked, compiled according to CFLAGS specified in /etc/makepkg.conf, and finally squeezed into a package with the extension .pkg.tar.gz, as per the instructions in the PKGBUILD. Installing is as easy as doing pacman -U nano.pkg.tar.gz. Package removal is also handled by pacman.
The PKGBUILD and other files may, of course, be customized to suit your needs, and you may choose to use the ABS makepkg function to make your own custom packages from outside sources. (See the prototype PKGBUILD and install files under /var/abs/core/)
With the ABS Tree in place, an Arch user has all available Arch software at their fingertips, to compile from source and automatically package as a .pkg.tar.gz.
'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 under /var/abs/. It contains many subdirectories, named for all available Arch cvs software, 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 files residing under the ABS directories, with instructions for building packages and the URL of the sources.
- makepkg: ABS shell command tool which reads the PKGBUILDs, 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 used via the ABS makepkg tool, to compile and package up software. The AUR contains user-contributed PKGBUILDs for software which may be unavailable as an official Arch package.
Why would I want to use ABS?
The Arch Build System (ABS for short) is used to
- Make new packages from source, of software for which no packages are yet available (See The Arch package making HOW-TO - with guidelines)
- Customize existing packages to fit your needs (enabling or disabling options)
- Rebuild your entire system using your compiler flags, "a la FreeBSD"
- Cleanly build and install your own custom kernel. (See Kernel Compilation)
- Get kernel modules working with your custom kernel.
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, you should try to 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 -Sy abs
This will grab any necessary dependencies.
edit /etc/abs/abs.conf to include your desired repositories:
Remove the ! in front of the appropriate repos, e.g.:
SUPFILES=(core extra unstable community !testing)
Create the ABS tree
As root, do:
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/abs.conf.
The abs command should also be used to periodically sync and update your ABS Tree.
/etc/makepkg.conf specifies global environment variables and compiler flags which you may wish to edit if you are using an SMP system. 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 utilize one core/CPU- see Safe Cflags.).
The ABS tree
When you run abs for the first time, it synchronizes the ABS tree with the Arch server using the cvs system. So what exactly is the ABS tree? It is 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. 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/yourusername/abs/local/
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
- enter the directory
- configure the package: generally, there is a little script called
configurein 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:
You should first try the help to better understand how it works:
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.
- compile the sources:
- Uninstalling would be accomplished by entering the source directory and running:
However, you should always read the
INSTALL file to know how the package should be built and installed! Not all packages use the
configure; make; make install system!
The above traditional method of compiling source tarballs can, of course, still be used on Arch Linux, but ABS offers a streamlined, simple, and elegant alternative, as you shall see.
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 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 /var/abs/extra/x11/slim/* /home/yourusername/abs/local/slim
- 2. Navigate to the build directory
- 3. Do makepkg as normal user:
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)
- 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 ABS PKGBUILD Explained for a complete overview of a sample PKGBUILD.