Difference between revisions of "Abuild and Helpers"

From Alpine Linux
Jump to: navigation, search
(No difference)

Revision as of 03:43, 8 December 2011

The abuild script and its friends are installed automatically along with the alpine-sdk package. The git repository contains always the lastest version of the scripts, example-files, and makefiles.

Fetch latest abuild

While inside your build environment you need to have the set of scripts/makefiles/etc.

Note: You only need to do these 2 steps once! Next time you can skip this part.

apk add alpine-sdk cd ~ git clone git://dev.alpinelinux.org/abuild

When the above is done you might be interested in fetching the latest updates.

cd ~ git pull

Package build helpers


For abuild a public/private rsa key pair is needed. abuild-keygen does the generation of those keys for you.

abuild-keygen -a -i

abuild-keygen options

  • -a Set PACKAGER_PRIVKEY=<generated key> in abuild.conf
  • -i Install public key into /etc/apk/keys using sudo
  • -h Show this help
  • -n Non-interactive. Use defaults
  • -q Quiet mode

Creating keys manually

In older versions of Alpine, we had to manually create keys for signing packages and indexes. This explains how. Nowadays you can just use abuild-keygen.

Since the public key needs to be unique for each developer, the email address should be used as name for the public key.

Create the private key:

openssl genrsa -out emailaddress.priv 2048

Tip: Append -aes256 if you want it encrypted, but then you'll need to enter the password for every package you sign

Create the public key:

openssl rsa -in emailaddress.priv -pubout -out /etc/apk/keys/emailaddress

The public key should be distributed and installed into /etc/apk/keys on the alpine box that will install the packages. The private key, when created by abuild, is installed into ~/.abuild/$something.rsa. This basically means that the main developer's public keys should be in /etc/apk/keys on all Alpine boxes.


abuild-sign is for signing indexes.

abuild-sign [-hq] [-k PRIVKEY] [-p PUBKEY] INDEXFILE...

abuild-sign options

  • -h Show this help
  • -k The private key to use for signing
  • -p The name of public key. apk add will look for /etc/apk/keys/PUBKEY


apkbuild-tar [--hash[=<algorithm>]] [--cut]

apkbuild-tar options

  • --hash[=sha1|md5] Read tar archive from stdin, precalculate hash for regular entries and output tar archive on stdout
  • --cut Remove the end of file tar record


The tool abump is a utility to bump pkgver in APKBUILD files if the package gets an update to a newer upstream release.

abump [-hR]

abump options

  • -h Show this help
  • -R Run abuild with -R for recursive building
  • -k Keep existing packages


If you want to bump or reset the pkgrel value of your APKBUILD or test your APKBUILD files, apkgrel can assist you.

apkgrel -a|-h|-s NUM|-t|-z [-f] FILE...

apkgrel options

  • -a Add 1 to current pkgrel
  • -f Force, even if given files are not in proper format
  • -h Show this help
  • -s Set pkgrel to NUM
  • -t Only verify that files are in proper format
  • -z Set pkgrel to 0


To build a package, abuild is used. Besides the package building functionality, options for other package maintainance tasks are also provided.

If you just want to build a package from an APKBUILD file, only those two command are needed.

abuild checksum && abuild -r

To use the command above, you have to be in the abuild group.

Below all options and commands for abuild are listed.

abuild [options] [-P REPODEST] [-s SRCDEST] [-D DESCRIPTION] [cmd] ...

abuild options

  • -A Print CARCH and exit
  • -c Enable colored output
  • -d Disable dependency checking
  • -D Set APKINDEX description (default: $repo $(git describe))
  • -f Force specified cmd (skip checks: apk up to date, arch, libc)
  • -F Force run as root
  • -h Show this help
  • -i Install PKG after successful build
  • -k Keep built packages, even if APKBUILD or sources are newer
  • -K Keep buildtime temp dirs and files (srcdir/pkgdir/deps)
  • -m Disable colors (monochrome)
  • -P Set REPODEST as the repository location for created packages
  • -q Quiet
  • -r Install missing dependencies from system repository (using sudo)
  • -s Set source package destination directory
  • -u Recursively build and upgrade all dependencies (using sudo)
  • -v Verbose: show every command as it is run (very noisy)

abuild commands

  • build Compile and install package into $pkgdir
  • check Run any defined tests concerning the package
  • checksum Generate checksum to be included in APKBUILD
  • clean Remove temp build and install dirs
  • cleancache Remove downloaded files from $SRCDEST
  • cleanoldpkg Remove binary packages except current version
  • cleanpkg Remove already built binary and source package
  • deps Install packages listed in makedepends and depends
  • fetch Fetch sources to $SRCDEST and verify checksums
  • index Regenerate indexes in $REPODEST
  • listpkg List target packages
  • package Create package in $PKGDEST
  • prepare Apply patches
  • rootbld Build package in clean chroot
  • rootpkg Run 'package', the split functions and create apks as fakeroot
  • sanitycheck Basic sanity check of APKBUILD
  • snapshot Create a $giturl or $svnurl snapshot and upload to $disturl
  • sourcecheck Check if remote source package exists upstream
  • srcpkg Make a source package
  • undeps Uninstall packages listed in makedepends and depends
  • unpack Unpack sources to $srcdir
  • up2date Compare target and sources dates
  • verify Verify checksums

See also

APKBUILD generation


To create the actual APKBUILD file newapkbuild can serve you a template to start with. It will create a directory with the given package name, place an example/template APKBUILD file to the given directory, and fill some variables if those are provided.

newapkbuild packagename

newapkbuild options

  • -n Set package name to NAME
  • -d Set package description (pkgdesc) to DESC
  • -l Set package license to LICENSE
  • -u Set package URL
  • -a Create autotools package (use ./configure ...)
  • -C Create CMake package (Assume cmake/ is there)
  • -m Create meson package (Assume meson.build is there)
  • -p Create perl package (Assume Makefile.PL is there)
  • -y Create python package (Assume setup.py is there)
  • -s Use sourceforge source URL
  • -c Copy a sample init.d, conf.d, and install script to new directory
  • -f Force even if directory already exist
  • -h Show this help


The Comprehensive Perl Archive Network (CPAN) provides a large collection of perl software and documentation. apkbuild-cpan helps with the creation of APKBUILD for perl modules from CPAN.

apkbuild-cpan [create <Module::Name> | check | recreate | update | upgrade]


The Python Package Index (PyPi) is a repository of software and libraries for the Python programming language. apkbuild-pypi helps with the creation of APKBUILD for python package hosted at PyPI.

apkbuild-pypi [create <package> | check | recreate | update | upgrade

Misc tools


More details can be found at the buildlab page.


buildrepo creates a local package repository for you.

buildrepo [-a APORTSDIR] [-d REPODIR] [-hp] [-l LOGPREFIX ] [-r DEPREPO] REPOSITORY...

buildrepo options

  • -a Set the aports base dir to APORTSDIR instead of $HOME/aports
  • -d Set destination repository base dir to REPODIR instead of $HOME/packages
  • -h Show this help and exit
  • -l Send build to logfile, prefixed by LOGPREFIX
  • -p Purge obsolete packages from REPODIR after build
  • -r Dependencies are found in DEPREPO