Search⌘ K

Build APKBUILDs with abuild

Discover what you can do with APKBUILDs, and try building your first package using abuild.

Preface

The abuild package also installs an additional tool for us: newapkbuild. This command can be used for creating a template to base our first package on.

Run newapkbuild

First, let’s see how to run newapkbuild. Its help page lists all available commands:

Shell
$ newapkbuild -h
newapkbuild 3.9.0-r0 - generate a new APKBUILD
Usage: newapkbuild [-n PKGNAME] [-d PKGDESC] [-l LICENSE] [-u URL]
[-a | -C | -m | -p | -y | -r] [-s] [-c] [-f] [-h]
PKGNAME[-PKGVER] | SRCURL
Options:
-n Set package name to PKGNAME (only use with SRCURL)
-d Set package description to PKGDESC
-l Set package license to LICENSE, use identifiers from:
<https://spdx.org/licenses/>
-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)
-r Create rust package (Assume Cargo.toml is there)
-s Use sourceforge source URL
-c Copy a sample init.d, conf.d, and install script
-f Force even if directory already exists
-h Show this help

We’ll go through these options at a later stage, so don’t worry if these aren’t immediately clear. Since we only want to create a simple dummy package, only a handful of options are relevant for us. The following command will do to create our first package:

Shell
newapkbuild -d "This is our first package" "our-first-package-0.0.1"

Afterward, we can inspect the output newapkbuild generated:

Shell
# Contributor:
# Maintainer:
pkgname=our-first-package
pkgver=0.0.1
pkgrel=0
pkgdesc="This is our first package"
url=""
arch="all"
license=""
depends=""
makedepends=""
checkdepends=""
install=""
subpackages="$pkgname-dev $pkgname-doc"
source=""
builddir="$srcdir/"
build() {
# Replace with proper build command(s)
:
}
check() {
# Replace with proper check command(s)
:
}
package() {
# Replace with proper package command(s)
:
}

As we can see, newapkbuild has set pkgdesc to the description we passed to it via -d and set pkgname to the last positional argument we passed to it. Let’s go over the function of the individual keys, line by line.

  • Contributor is an optional comment that is used in aports, Alpine’s package tree. Everyone that has contributed to this particular APKBUILD is listed here in the format Name <email@example.org>. There may be multiple contributors to one APKBUILD, in which case there are multiple
...