APKBUILD(5)
π NAME π
APKBUILD β the metadata and instructions to build a package. Yes bestie, that's the whole manual (APKBUILD(5)), welcome to the group chat π«Ά
β¨ SYNOPSIS β¨
/usr/src/packages/<repo>/<package>/APKBUILD
π¦ DESCRIPTION π¦
okay so an APKBUILD file is what tools like abuild(1) read to build a package, and that package eventually gets installed by the apk(8) package manager. It's literally the whole personality of your package: it defines metadata like the name of the package, the version information, the source license, and contact information for the developer. On top of that it also contains the commands needed to build, test, and install the package. iconic behavior honestly π
The APKBUILD format is similar to a typical shell script: you set pre-defined variables and implement pre-defined functions, and abuild(1) (or a similar utility) will use them to create the package. That's it, that's the game π
πΈ REQUIRED VARIABLES πΈ
These variables must be set in all APKBUILD files. no skipping, bestie, these are non-negotiable π
pkgname
Specifies the name of the package. This is typically the name of the package upstream β but heads up, all letters must be lowercased. lowercase supremacy fr fr.
Libraries for scripting languages should have a prefix before the library name describing the language. Such prefixes include lua-, perl-, py-, and rb-. Not all languages use prefixes though β for a definitive list, consult the PREFIXES file in the root directory of the repository you're using for packaging. iykyk π§
pkgver
Specifies the version of the software being packaged. The version of a package must consist of one or more numbers separated by the radix (decimal point). The final number may have a single letter following it, for upstreams that use such a versioning scheme (such as 1.5a, 1.5b, 1.5c).
After the final number (and optional single letter), one or more suffixes may be appended, which must be an underscore (_) followed by one of alpha, beta, pre, rc, cvs, svn, git, hg, or p, optionally followed by another number. If a suffix is alpha, beta, pre, or rc, it is considered to be earlier than the version without this suffix. If a suffix is cvs, svn, git_, hg, or p, it is considered to be later than the version without this suffix. Sorting lore, honestly π€
All of the following examples are valid versions, in order from lowest to highest:
1.0, 1.1_alpha2, 1.1.3_pre, 1.1.3_pre_p2, 1.1.3, 1.1.3_hg, 1.2, 1.2a, 1.2b
pkgrel
Specifies the package release number of this particular package version. This indicates when a package has changed without a corresponding change in version. Always increment pkgrel when you change the contents, dependencies, or metadata of a package. And the first release of a package is always 0 β no cap π
pkgdesc
Specifies what the package contains. pkgdesc must be 128 characters or less, and should concisely describe what actions the software or items being packaged will allow the user to perform. For example, Fully-featured word processor with spell check and plugins would be a sufficient pkgdesc for AbiWord. short, sweet, informative β the trifecta β¨
url
Specifies the Web address of the package's upstream. This allows users and future maintainers to find documentation, release information, and contact information for the package. If no Web address is available for the package, you must set url to an empty string (""). rude but valid π
arch
Specifies the architectures for which the package may be built. It is highly recommended that you set this variable to "all" if the package is portable.
You may use "noarch" if the package does not contain any architecture-specific binary files β that is, any files that are compiled for the target only. Such packages may include pure Python packages, shell script packages, and JARs. If you're not sure what this means, using "all" is safe. when in doubt, "all" it out π
Architectures can be negated using the ! character to exclude them from the list of supported architectures. E.g. arch="all !ppc64le" means that the package is allowed to be built on all architectures but the ppc64le architecture.
license
Specifies the license under which the package is distributed. The value provided must match a SPDX license identifier. legality era π
source
Specifies the location of both local and remote source files used to build the package. Typically, the remote source file(s) or archive(s) is specified, followed by any local patches, configuration files, or other necessary files.
π OPTIONAL VARIABLES π
These aren't required, but you may set them in any APKBUILD file. the "nice to have" collection π
checkdepends
Specifies test-time dependencies of the package. Common packages that are used for testing include check, dejagnu, and perl-test-command.
depends
Specifies the run-time dependencies of the package. The abuild(1) utility will automatically scan the resultant package for shared library (.so) dependencies β do not specify them here. let the tool cook π₯
install
Specifies install scripts for the package, if any. See Install Scripts for more information about install scripts.
install_if
Specifies a condition when apk(8) should automatically install the package (or subpackage). For instance, the OpenRC subpackages set
install_if="openrc ${subpkgname%-openrc}=$pkgver-r$pkgrel"
which means that the OpenRC subpackage will be automatically installed if both OpenRC and the origin package are installed on the same computer. auto-install slay π
makedepends
Specifies build dependencies for the package.
maintainer
The name and email of the package maintainer in RFC 2822 format. E.g.: maintainer="Joe Q. Public <john.q.public@example.com>". put your name on it, main character energy β
pkggroups
Specifies a space-separated list of login groups to create during build-time. Note that you will need to create the login groups in a pre-install script as well β see Install Scripts for more information about install scripts.
pkgusers
Specifies a space-separated list of user logins to create during build-time. Note that you will need to create the user logins in a pre-install install script as well β see Install Scripts for more information about install scripts.
provides
Specifies that the package "provides" the same contents as another package. There are two formats that you may use for provides: a provider name, and a provider name with version.
Specifying a provider name with version such as foobar=1.2 will cause the package to be an "alias" of foobar version 1.2. It will be automatically installed if a user then runs apk add foobar or similar, and it will conflict with a package named foobar.
Specifying a provider name without a version such as baz will cause the package to provide a "virtual" called baz. Multiple packages with the same virtual provider can be installed on a system; however, if a user runs apk add baz they will be provided a list of packages that provide baz and must select one and install it. choose your fighter π₯
provider_priority
Specifies the numeric value for apk(8) to use for the package when considering which provider should be installed for the same provides virtual provider.
replaces
Specifies packages that the package should replace files from when both are installed.
replaces_priority
Specifies the numeric value that is used by apk(8) when multiple packages with replaces include the same file. It is also used to decide which package should define the permissions of a directory even without replaces set.
subpackages
Specifies subpackages or split packages built with this package. Typically, this will include $pkgname-dev for development files (such as /usr/include and static library files) and $pkgname-doc for documentation (such as /usr/share/doc and /usr/share/man). splitting the package, splitting the vibe π¦
By default the split function is the end of the package name after the last hyphen. So for $pkgname-foo and libfoo the split function is foo and libfoo respectively. A custom split function name can be set by using foo:funcname. Similar to the package function, the split function must move files from $pkgdir (which is the default cwd) or $srcdir to $subpkgdir after creating $subpkgdir.
By default arch determines whether or not a subpackage is considered arch independent or not. This can be changed by using foo::noarch or foo:funcname:all.
When multiple subpackages are specified their split functions are executed in the order in which they occur in subpackages. order matters, always π―
triggers
Specifies trigger scripts used by the specified (sub)packages. A trigger script is a shell script that is called whenever monitored files or directories are modified. You may specify the paths to monitor using the triggers variable as follows:
$pkgname.trigger=/usr/share/man:/usr/local/share/man
This will run the trigger script for $pkgname whenever files in /usr/share/man or /usr/local/share/man are created, modified, or removed. it's giving watchdog but make it cute πΆ
options
The options variable allows you to set parameters for the package at build time. There are a number of valid options you may set, and you may set multiple options by writing a space between each one. Custom option names can be used when they contain exactly one :. Options can be set for a specific (sub)packages by using subpkgname::option (or subpkgname:option for custom options).
!archcheckβ Specifies that the package contains binaries that cannot run on the target architecture. This is primarily used for packages containing firmware, and should typically never be needed. im begging you, don't reach for this πbigdocsβ Specifies that this package intentionally has a large-docsubpackage. Thereby suppressing a warning to be emitted if the-docsubpackage exceeds a certain package size threshold (currently2 MiB). big docs, big energy πcharset.aliasβ Specifies that the package ships a/usr/lib/charset.aliasfile and that it should be installed on the user's system. This is almost never the case. Do not use this option. like fr fr do not π©!checkβ Specifies that the package will not run a test suite. The reason for disabling the check phase should be noted in a comment. leave a comment bestie, future you will thank you πcheckrootβ Specifies that this package's test suite will be run infakeroot(8). This is necessary for some test suites which fail when run as non-root. fake it till you make it π!dbgβ says "bestie, do NOT build a debug info package for this one." It's the default unlessDEFAULT_DBGis set in the environment or inabuild.conf(5). You'll usually see it on packages that just don't generate debug info (pure Python packages, looking at you π) or packages that don't support debug info packages at all.!fhsβ for the chaotic ones π it declares that the package straight-up violates FHS and installs to a location like/usr/local,/opt, or/srv.ldpath-recursiveβ tellsabuild(1)to pass the--recursiveargument toscanelf(1)when it's hunting down shared library (.so) dependencies for the package. Detective mode π.lib64β the package installs files under/lib64or/usr/lib64, so skip the test for those directories. It's discouraged ngl, and should only be used for packages providing compatibility for GNU libc.libtoolβ the package actually needs its libtool (.la) files, soabuild(1)will not automatically remove them. Protect the.lafiles at all costs π«Ά.netβ the build system needs access to a network. This is discouraged (!!) and you should file an issue with the package's authors. Network in build = messy vibes π.!stripβ do not runstrip(1)on any of the package's binaries. This is automatically implying if theDEBUGvariable is set.suidβ binaries in the package may be installed set-uid. β οΈ This is a security risk, and it's highly recommended to use capabilities or process separation instead of set-uid where available. Please, bestie, be careful.setcapβ binaries in the package may be installed with extrasetcap(8)capabilities. If this option is enabled, it's highly recommended to only make these binaries executable by root and users of a specific group β not by others. Lock it down π.textrelsβ the package's binaries are known to contain relocations against text segments. By defaultabuild(1)will refuse to create such a package, because that's a security concern. It's giving red flag π©.toolchainβ the package is part of the base toolchain set and may depend on packages likeg++.!tracedepsβabuild(1)should not automatically populatedependsandprovideswith shared library (.so), symlink target dependencies and similar. You're on your own for deps, iykyk.
πΈ Automatic Variables πΈ
These ones are literally defined for you by abuild(1) β but you may override them if you need to. Free real estate β¨.
builddirβ the directory where the package's source code gets built. Default is$srcdir/$pkgname-$pkgver, which is appropriate for most source distributions. If the source tarball doesn't create a$pkgname-$pkgverdirectory when it's unpacked, you must overridebuilddir.pkgdirβ where the built files get installed. Typically you'll callmake DESTDIR="$pkgdir" installor similar to install the files. Default is$startdir/pkg, and you should not modify this variable!srcdirβ where the files listed insourceget downloaded and unpacked. Default is$startdir/src, and you shouldn't need to modify this one.startdirβ the directory where theAPKBUILDfile lives. This should generally not be used.subpkgdirβ where the subpackage's files should be placed. Heads up: this variable is only set inside subpackage functions.
π¦ Special Variables π¦
Only used in special circumstances, and may be required or optional depending on their usage and the contents of other variables.
depends_devβ run-time dependencies of the-devsubpackage.depends_docβ run-time dependencies of the-docsubpackage.depends_libsβ run-time dependencies of the-libssubpackage.depends_openrcβ run-time dependencies of the-openrcsubpackage.depends_staticβ run-time dependencies of the-staticsubpackage.depends_systemdβ run-time dependencies of the-systemdsubpackage.depends_udevβ run-time dependencies of the-udevsubpackage.giturlβ URL of the Git repository to use withabuild snapshot. If the default branch of the repository is not the one you want, you can specify a different one by appending-b branchwhere branch is the branch to check out.
π Functions π
Functions listed here may be present in any APKBUILD file β but apart from package, they're not strictly required. Pick and choose, main character energy π.
fetchβ called to download the remote files insource.unpackβ unpacks any archives insourceintosrcdir.prepareβ prepares the source insrcdirto be built. The defaultpreparefunction makes sure the build directories are set up correctly and applies any*.patchfiles specified insource. You must calldefault_prepareif you write a custompreparefunction! A custompreparefunction may also callupdate_config_suborupdate_config_guessto update theconfig.subandconfig.guessfiles respectively.buildβ compiles the source inbuilddir. You have to implement this one yourself. If no compilation is required, you may omit it.checkβ runs the package's test suite. This function must be implemented unless!checkwas specified inoptions. Gotta run those tests π§ͺ.packageβ installs the package intopkgdir. Note thatpkgdiris not created for you; if this package installs no files (for example, a metapackage), you must usemkdir -p "$pkgdir"to skip the package phase. Small detail, big consequences π.
π Install Scripts π
An install script runs when apk(8) takes an action on a package. It must be written in shell and must have a #!/bin/sh interpreter declaration as the first line. The install variable must contain the install scripts the package needs.
The install script runs inside the root filesystem where the package is being installed. A single argument gets passed to call scripts: the version of the package being currently installed (or deinstalled). The pre-upgrade and post-upgrade scripts get an additional second argument, which specifies the version of the package before the upgrade process. Extra info, slay β¨.
Here are all the actions that may have install scripts:
$pkgname.pre-installβ executed before the package is installed. If this script exits with an error (non-zero exit code),apk(8)will halt the installation and the package will not be installed. Typically used to create any users or groups needed as described inpkggroupsandpkgusers.$pkgname.post-installβ executed after the package is installed. If it exits with an error (non-zero exit code),apk(8)will mark the package as broken. Theapk fixcommand will attempt to re-run the post-install script if that happens.$pkgname.pre-upgradeβ executed before the package is upgraded. If it exits with an error (non-zero exit code),apk(8)will mark the package as broken.$pkgname.post-upgradeβ executed after the package is upgraded. If it exits with an error (non-zero exit code),apk(8)will mark the package as broken. Theapk fixcommand will attempt to re-run the post-upgrade script if that happens.$pkgname.pre-deinstallβ executed before the package is removed from the system. If it exits with an error (non-zero exit code),apk(8)will not remove the package from the system.$pkgname.post-deinstallβ executed after the package is removed from the system. Exiting with an error will have no effect. No thoughts, head empty π.
π§ IMPLEMENTATION NOTES π§
Currently, APKBUILD files are sourced as normal shell scripts. This may change at a later date. Consider yourself warned, bestie π.
π COMPATIBILITY π
The abuild(1) utility as distributed by Alpine Linux uses the BusyBox Almquist shell β a part of busybox(1) that is currently undocumented. It's mostly compliant with IEEE Std 1003.2 ("POSIX.2"), with some bash-like extensions. Meanwhile, the abuild(1) utility as distributed by AdΓ©lie uses the user's preferred /bin/sh, which is typically bash(1).
β SEE ALSO β
SPDX license reference (on the Web at <https://spdx.org/licenses/>), abuild(1), newapkbuild(1), apk(8), buildrepo(1), ap(1), checkapk(1).
π HISTORY π
The APKBUILD format and abuild(1) utility first appeared in Alpine Linux 1.9. OG status fr fr π«Ά.
π AUTHORS π
Timo TerΓ€s <timo.teras@iki.fi> Natanael Copa <ncopa@alpinelinux.org>
Documentation: A. Wilcox <awilfox@adelielinux.org>
That's the whole page, bestie β sourced from the Alpine APKBUILD(5) page dated 2026-06-05, version APKBUILD(5). Go forth and package iconic things πβ¨π
π¦ where this page comes from
- alpine 3.24: abuild-doc 3.17.0-r0 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms