<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ollieparanoid</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ollieparanoid"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Ollieparanoid"/>
	<updated>2026-04-26T06:38:34Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=29207</id>
		<title>APKBUILD Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=29207"/>
		<updated>2025-03-09T15:03:11Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: makedepends: add makedepends_build, makedepends_host&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;APKBUILDs are the scripts that are created in order to build Alpine packages using the [[Abuild and Helpers|abuild]] tool.&lt;br /&gt;
&lt;br /&gt;
See [[aports]] for details on Alpine&#039;s official ports repository.&lt;br /&gt;
&lt;br /&gt;
This page is intended to serve as a reference for creating APKBUILDs; if this is your first time creating a package for Alpine Linux, please see [[Creating an Alpine package]].&lt;br /&gt;
&lt;br /&gt;
= Legend =&lt;br /&gt;
The following notes will assist you in understanding this document.&lt;br /&gt;
&lt;br /&gt;
In description text:&lt;br /&gt;
* If a variable is not prefixed with a &#039;&#039;$&#039;&#039;, it will be represented by italics (i.e., &#039;&#039;srcdir&#039;&#039; ).&lt;br /&gt;
* Functions will also be represented by italics, but will also end with a pair of parentheses (i.e., &#039;&#039;build()&#039;&#039; ).&lt;br /&gt;
* Shell commands will be represented &amp;lt;code&amp;gt;like this&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Variables =&lt;br /&gt;
{{Note|Variables that contain a path (e.g. &#039;&#039;$srcdir&#039;&#039; and &#039;&#039;$pkgdir&#039;&#039;) should always be quoted using double quotes (i.e., &#039;&#039;&amp;quot;$srcdir&amp;quot;&#039;&#039;).  This is done to prevent things from breaking, should the user have the APKBUILD in a directory path that contains spaces.}}&lt;br /&gt;
{{Note|All arbitrary variable and function names should be prefixed with an underscore character ( _ ) to avoid name clashes with the internals of abuild (for example, &#039;&#039;_luaversions&#039;&#039;).}}&lt;br /&gt;
&lt;br /&gt;
These variables are all well documented in &amp;lt;code&amp;gt;man 5 APKBUILD&amp;lt;/code&amp;gt; ([https://gitlab.alpinelinux.org/alpine/abuild/-/blob/master/APKBUILD.5.scd man page source]).&lt;br /&gt;
&lt;br /&gt;
== User-defined variables ==&lt;br /&gt;
The following variables should be defined by the user:&lt;br /&gt;
==== maintainer ====&lt;br /&gt;
: Name and email address of the maintainer of the package.&lt;br /&gt;
: A well-formatted example is &amp;lt;code&amp;gt;maintainer=&amp;quot;John Snow &amp;lt;john_snow@thewall.net&amp;gt;&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== arch ====&lt;br /&gt;
: Package architecture(s) to build for.  Can be one or several seperated by whitespace of: &#039;&#039;&#039;[[x86]], [[x86_64]], [[armv7]], [[armhf]], [[aarch64]], [[ppc64le]], [[s390x]], [[riscv64]], all&#039;&#039;&#039;, or &#039;&#039;&#039;noarch&#039;&#039;&#039;, where &#039;&#039;&#039;all&#039;&#039;&#039; means all architectures, and &#039;&#039;&#039;noarch&#039;&#039;&#039; means it&#039;s architecture-independent (e.g., a pure-python package). Architectures can be negated using the ! character to exclude them from the list of supported architectures. E.g. &#039;&#039;&#039;arch=&amp;quot;all !ppc64le&amp;quot;&#039;&#039;&#039; means that the package is allowed to be built on all architectures but the ppc64le architecture.&lt;br /&gt;
: {{Tip|To determine if your APKBUILD can use &#039;&#039;&#039;noarch&#039;&#039;&#039;: First specify &#039;&#039;&#039;all&#039;&#039;&#039; and then build the package by executing &amp;lt;code&amp;gt;abuild -r&amp;lt;/code&amp;gt;.  Watch the output towards the end for warnings saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used.  If the main package and all subpackages, if you have any subpackages, give a warning saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used, then you can use &#039;&#039;&#039;noarch&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
==== depends ====&lt;br /&gt;
: Run-time dependency package(s) that are not shared-object dependencies.  Shared objects dependencies are auto-detected and should not be specified here. To specify a conflicting package, add the package name prefixed with a &#039;!&#039;.&lt;br /&gt;
&lt;br /&gt;
==== depends_dev ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
: {{Note|From ncopa on IRC: To find out if you need to add a package to depends_dev have a look at *requires* in usr/lib/pkgconfig/*.pc. With libtool it gets more complicated, but we should delete the .la files. Also check if there are any  /usr/bin/*-configure #!/bin/bash #!/usr/bin/perl or Python. Sometimes scripts or similar are generated at build time (i.e autoconf automake) then you normally don&#039;t need add those to depends_dev. You can also just add all -dev makedepends to depends_dev but it will slow the build process a little bit (more build dependencies).}}&lt;br /&gt;
&lt;br /&gt;
==== depends_doc ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== depends_openrc ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-openrc&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== depends_libs ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-libs&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== depends_static ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-static&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== checkdepends ====&lt;br /&gt;
: Dependencies that are only required during the check phase, they are only installed if the check option is enabled&lt;br /&gt;
&lt;br /&gt;
==== giturl ====&lt;br /&gt;
:Git repository from which &amp;lt;code&amp;gt;abuild checkout&amp;lt;/code&amp;gt; checks out. You can checkout a specific branch in git by adding &amp;lt;code&amp;gt;-b $branch&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== install ====&lt;br /&gt;
: There are 6 different types of install scripts.  Install scripts are named &#039;&#039;&#039;$pkgname.action&#039;&#039;&#039;, where &#039;&#039;&#039;action&#039;&#039;&#039; can be:  &#039;&#039;&#039;pre-install, post-install, pre-upgrade, post-upgrade, pre-deinstall&#039;&#039;&#039;, or &#039;&#039;&#039;post-deinstall&#039;&#039;&#039;.  For example, if &#039;&#039;pkgname&#039;&#039; is set to &#039;&#039;&#039;mypackage&#039;&#039;&#039; and &#039;&#039;install&#039;&#039; is set to &#039;&#039;&#039;$pkgname.post-install&#039;&#039;&#039;, then a script named &#039;&#039;&#039;mypackage.post-install&#039;&#039;&#039; must exist along-side the APKBUILD.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;{{Note|Always use &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt; for the command-line interpreter on the [https://en.wikipedia.org/wiki/Shebang_%28Unix%29 shebang line] of your install scripts.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the different types of install scripts in detail:&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-install =====&lt;br /&gt;
: This script is executed &#039;&#039;before installing&#039;&#039; the package.  Typical use is when the package needs a group and a user to be created. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
addgroup -S clamav 2&amp;gt;/dev/null&lt;br /&gt;
adduser -S -D -H -s /sbin/nologin -G clamav -g clamav clamav 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|If the script exits with a failure (e.g., if the user already exists), the package will not be installed and &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will exit with failure, hence the &amp;lt;code&amp;gt;exit 0&amp;lt;/code&amp;gt; at the end.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-install =====&lt;br /&gt;
: This script is executed &#039;&#039;after installing&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;before upgrading/downgrading/reinstalling&#039;&#039; the package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;after upgrading/downgrading/reinstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;before uninstalling&#039;&#039; the package.&lt;br /&gt;
: {{Note|If the script exits with failure, &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will not uninstall the package.}}&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;after uninstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
==== install_if ====&lt;br /&gt;
:install_if can be used when a package needs to be installed when some packages are already installed or are in the dependency tree. It works in reverse to the &#039;&#039;recommends&#039;&#039; feature, that other package managers provide.&lt;br /&gt;
&lt;br /&gt;
: Typically this is used in a subpackage that should provide files which make sense with another package. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
subpackages=&amp;quot;$pkgname-bash-completion:bashcomp:noarch&amp;quot;&lt;br /&gt;
...&lt;br /&gt;
bashcomp() {&lt;br /&gt;
	pkgdesc=&amp;quot;Bash completions for $pkgname&amp;quot;&lt;br /&gt;
	install_if=&amp;quot;$pkgname=$pkgver-r$pkgrel bash-completion&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	install -Dm644 &amp;quot;$builddir&amp;quot;/doc/bash_completion/aria2c \&lt;br /&gt;
		&amp;quot;$subpkgdir&amp;quot;/usr/share/bash-completion/completions/_aria2c&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
From the aria2c APKBUILD. Note that the custom bashcomp() function is only necessary, because the files are not in /usr/share/bash-completion.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:In general, install_if should only be used with &#039;&#039;&#039;at least one versioned constraint&#039;&#039;&#039;. Otherwise, a package that was implicitly installed by install_if and then removed from the binary repositories, will not get purged with &amp;lt;code&amp;gt;apk upgrade&amp;lt;/code&amp;gt;. [https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues/10720#note_121298]&lt;br /&gt;
&lt;br /&gt;
==== license ====&lt;br /&gt;
: License(s) for the package, for example &amp;lt;code&amp;gt;GPL-3.0-or-later&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;BSD-2-Clause&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;MIT&amp;lt;/code&amp;gt; [[Creating_an_Alpine_package#license|(details)]].&lt;br /&gt;
&lt;br /&gt;
==== makedepends ====&lt;br /&gt;
: Build-time dependency package(s). For cross compiling support, split it into &amp;lt;code&amp;gt;makedepends_build&amp;lt;/code&amp;gt; (native system) and &amp;lt;code&amp;gt;makedepends_host&amp;lt;/code&amp;gt; (foreign system).&lt;br /&gt;
&lt;br /&gt;
==== md5sums/sha256sums/sha512sums ====&lt;br /&gt;
: Checksums for the files/URLs listed in &#039;&#039;source&#039;&#039;.  The checksums are normally generated and updated by executing &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; and should be the last item in the APKBUILD.&lt;br /&gt;
&lt;br /&gt;
New packages should use only sha512sums.&lt;br /&gt;
&lt;br /&gt;
==== options ====&lt;br /&gt;
: Build-time options for the package.&lt;br /&gt;
&lt;br /&gt;
: {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!archcheck&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to verify that the architecture of the binary files is the same architecture as abuild should build for. One example where it makes sense to set this are packages with firmware files, that get executed on another CPU (such as WiFi firmware).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to run the &amp;lt;code&amp;gt;check()&amp;lt;/code&amp;gt; function. Please always add a short comment after the &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt; about why it&#039;s disabled. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142545300] Creating a very simple check function, that calls &amp;lt;code&amp;gt;program --version&amp;lt;/code&amp;gt; is worse than disabling tests completely because it gives the false impression that the package is thoroughly tested with the testsuite from upstream. [https://github.com/alpinelinux/aports/pull/7326#discussion_r278797457]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;checkroot&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies that the package&#039;s test suite will be run in &#039;&#039;fakeroot&#039;&#039;. This is necessary for some test suites which fail when run as non-root.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;net&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allows network access when run in &#039;&#039;rootbld&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!strip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Avoid stripping symbols from binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;suid&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allow [https://en.wikipedia.org/wiki/Setuid setuid] binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!tracedeps&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not automatically find dependencies (e.g. by using &amp;lt;code&amp;gt;ldd&amp;lt;/code&amp;gt; to find dynamic libraries, which the resulting binary links against).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;chmod-clean&amp;lt;/code&amp;gt;&lt;br /&gt;
| Make all files writable in the src/ directory. Useful for packages that make files read-only in the process of building packages (go modules).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;toolchain&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t warn when g++ is in makedepends&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!dbg&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t create debugging subpackage&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ldpath-recursive&amp;lt;/code&amp;gt;&lt;br /&gt;
| Scan directories recursively when creating .so providers&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!spdx&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not check if the license= field has a SPDX compliant license&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;textrels&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t error out when text relocations are found&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;charset.alias&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t error out if /usr/lib/charset.alias is found&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;libtool&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t delete libtool .la files&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!fhs&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t enforce checks on path that follow the FHS&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== pkgdesc ====&lt;br /&gt;
: A brief, one-line description of what the package does.&lt;br /&gt;
&lt;br /&gt;
: Here&#039;s an example from the OpenSSH client package:&lt;br /&gt;
: &amp;lt;pre&amp;gt;pkgdesc=&amp;quot;Port of OpenBSD&#039;s free SSH release - client&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== pkggroups ====&lt;br /&gt;
: System group(s) to be created during build-time.  System group(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system group(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgname ====&lt;br /&gt;
: The name of the package.  All letters should be lowercase.&lt;br /&gt;
: {{Note|When creating an APKBUILD of a module or library for another package, we use some common package prefixes, such as: &#039;&#039;lua-&#039;&#039;, &#039;&#039;perl-&#039;&#039;, &#039;&#039;php-&#039;&#039;, and &#039;&#039;py3-&#039;&#039;.  Search aports for other common prefixes.}}&lt;br /&gt;
&lt;br /&gt;
==== pkgrel ====&lt;br /&gt;
: Alpine package release number.  Starts at 0 (zero).  Always increment &#039;&#039;pkgrel&#039;&#039; when making updates to an aport; reset &#039;&#039;pkgrel&#039;&#039; to 0 (zero) when incrementing &#039;&#039;pkgver&#039;&#039;.&lt;br /&gt;
==== pkgusers ====&lt;br /&gt;
: System user(s) to be created during build-time.  System user(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system user(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgver ====&lt;br /&gt;
: The version of the software being packaged. Format for valid versions: &amp;lt;code&amp;gt;{digit}{.digit}...{letter}{_suf{#}}...{-r#}&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n17]&lt;br /&gt;
: A Suffix &amp;lt;code&amp;gt;suf&amp;lt;/code&amp;gt; in the above format can be one of the following to indicate that the release is &#039;&#039;less recent&#039;&#039; than the version without the suffix: &amp;lt;code&amp;gt;alpha&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pre&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rc&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n75]&lt;br /&gt;
: These are for indicating &#039;&#039;more recent&#039;&#039; releases: &amp;lt;code&amp;gt;cvs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;svn&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;hg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n76]&lt;br /&gt;
: All other suffices are invalid. To package a specific git commit, the date of the commit gets appended to the latest release, e.g. &amp;lt;code&amp;gt;1.0.0_git20180204&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== provides ====&lt;br /&gt;
: List of package names (and optionally version info) this package provides.&lt;br /&gt;
&lt;br /&gt;
: If package with a version is provided (provides=&#039;foo=1.2&#039;) apk will consider it as an alternate name and it will automatically consider the package for installation by the alternate name, and conflict with other packages having the same name, or provides.&lt;br /&gt;
&lt;br /&gt;
: If version is not provided (provides=&#039;foo&#039;), apk will consider it as virtual package name. Several package with same non-versioned provides can be installed simultaneously. However, none of them will be installed by default when requested by the virtual name - instead, error message is given and user is asked to choose which package providing the virtual name should be installed.&lt;br /&gt;
==== provider_priority ====&lt;br /&gt;
: A numeric value which is used by apk-tools to break ties when choosing a virtual package to satisfy a dependency. Higher values have higher priority. The primary use case is to specify the primary package that satisfies a virtual (provider).&lt;br /&gt;
==== replaces ====&lt;br /&gt;
: Allow this package to be installed at the same time as the listed packages, even if they have conflicting files. The files from this package will override (&amp;quot;take over&amp;quot;) the conflicting files.&lt;br /&gt;
&lt;br /&gt;
: This can be used to override config files with &amp;quot;policy packages&amp;quot; [https://gitlab.alpinelinux.org/alpine/apk-tools/-/commit/89d003f8c2e5a92655ee778f7bfa5c0e85ddbed4].&lt;br /&gt;
&lt;br /&gt;
: Another use case is renaming packages (or moving files from one package to another): &amp;quot;replaces&amp;quot; will avoid the file conflict error that apk reports if it happens to install the new package before uninstalling the old package [https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues/10724#note_132872].&lt;br /&gt;
&lt;br /&gt;
: A common misconception is that &amp;quot;replaces&amp;quot; is used to replace packages (like in [https://wiki.archlinux.org/index.php/PKGBUILD#replaces PKGBUILD]). This is not the case, it is only for solving file conflicts. To let apk consider installing one package instead of another one, refer to [[#provides|provides]] (with the version).&lt;br /&gt;
&lt;br /&gt;
==== replaces_priority ====&lt;br /&gt;
: The priority of the replaces. If multiple packages replace files of each other, then the package with the highest &#039;&#039;replaces_priority&#039;&#039; will win.&lt;br /&gt;
&lt;br /&gt;
==== source ====&lt;br /&gt;
: The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[APKBUILD Reference#install|install variable]]), patches, and all other necessary files.&lt;br /&gt;
&lt;br /&gt;
: Here are few things to note:&lt;br /&gt;
&lt;br /&gt;
:* When you are finished adding local and/or remote files to &#039;&#039;source&#039;&#039;, you can execute the following command to add their checksums to the APKBUILD file:&lt;br /&gt;
:: {{Cmd|abuild checksum}}&lt;br /&gt;
:: {{Note|When later updating the content of &#039;&#039;source&#039;&#039;, or updating a file that is listed in &#039;&#039;source&#039;&#039;, you must also update their checksums again with the same command.}}&lt;br /&gt;
&lt;br /&gt;
:* When the remote file is hosted at SourceForge, it&#039;s best to specify the special mirrors link used by SourceForge:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://downloads.sourceforge.net/software/software-$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: (or similar depending on the package).&lt;br /&gt;
&lt;br /&gt;
:* You can set target filename (eg &#039;save as...&#039;) by prefixing the URI with &#039;&#039;filename::&#039;&#039;. This is useful when the remote filename is not specified in the URI (ie, does not end in &#039;/software-1.0.tar.gz&#039;), such as:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: or when the filename is braindead, like githubs&#039; download tags:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: The above two examples needs a target filename prefix:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::http://oss.example.org/?get=software&amp;amp;ver=$pkgver&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: and:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following protocols for remote file retrieval:&lt;br /&gt;
:** http&lt;br /&gt;
:** https&lt;br /&gt;
:** ftp&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following archive types/archive file extensions:&lt;br /&gt;
:** .tar (only in Alpine &amp;gt;= 2.5)&lt;br /&gt;
:** .tar.gz / .tgz&lt;br /&gt;
:** .tar.bz2&lt;br /&gt;
:** .tar.lz (only in Alpine &amp;gt;=3.7)&lt;br /&gt;
:** .tar.lzma&lt;br /&gt;
:** .tar.xz&lt;br /&gt;
:** .zip&lt;br /&gt;
&lt;br /&gt;
:* &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; should only include variables that change often like &amp;lt;code&amp;gt;pkgver&amp;lt;/code&amp;gt; or a commit ID. CI will warn you if you include &amp;lt;code&amp;gt;pkgname&amp;lt;/code&amp;gt; in source. Other variables like for example &amp;lt;code&amp;gt;_pkgname&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;_pyname&amp;lt;/code&amp;gt; do not belong in &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; either.&lt;br /&gt;
&lt;br /&gt;
==== subpackages ====&lt;br /&gt;
: Subpackages built from this APKBUILD.  abuild will parse this variable and try to find a subpackage split function.  The split function must &#039;&#039;move&#039;&#039; files that do not belong in the main package, from &#039;&#039;$pkgdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.  Files and directories can also be &#039;&#039;copied&#039;&#039; from &#039;&#039;$startdir&#039;&#039; and &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: The split function can be specified in 1 of 3 different methods:&lt;br /&gt;
:# subpkgname:&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# $pkgname-&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# &#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
: {{Note|Split function names &#039;&#039;&#039;cannot&#039;&#039;&#039; use hyphens; use the first method above if the subpackage name contains a hyphen (-) character, like this: &#039;&#039;subpkg-name:subpkg_name&#039;&#039;, where &amp;lt;code&amp;gt;subpkg-name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;&#039;&#039; and &amp;lt;code&amp;gt;subpkg_name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;s split function&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
: {{Tip|For more information, see the [[APKBUILD_examples:Subpackages|Subpackages example]].}}&lt;br /&gt;
&lt;br /&gt;
==== triggers ====&lt;br /&gt;
: Apk-tools can &amp;quot;monitor&amp;quot; directories and execute a trigger if any package installed/uninstalled any file in the monitored dir. The triggers are always executed after the apk action (install, uninstall, upgrade).&lt;br /&gt;
&lt;br /&gt;
: The triggers are specified in the format: &#039;&#039;scriptname&#039;&#039;=&#039;&#039;pathlist&#039;&#039; where &#039;&#039;scriptname&#039;&#039; is the (sub)package name + .trigger suffix and pathlist is : separated list of the dirs to monitor.&lt;br /&gt;
&lt;br /&gt;
: The &#039;&#039;&#039;triggers&#039;&#039;&#039; variable must include the triggers for subpackages too if they have any.&lt;br /&gt;
&lt;br /&gt;
: It is possible to use wildcards (*) in the dir list.&lt;br /&gt;
&lt;br /&gt;
==== url ====&lt;br /&gt;
: The homepage for the package.  This is to help users find upstream documentation and other information regarding the package.&lt;br /&gt;
&lt;br /&gt;
==== langdir ====&lt;br /&gt;
: Path to where the language files are located for the &#039;&#039;&#039;-lang&#039;&#039;&#039; subpackage, defaults to &#039;&#039;&#039;/usr/share/locale&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== pcprefix ====&lt;br /&gt;
: Prefix all provides derived from parsing pkg-config Requires: with the value in this variable, example: &#039;&#039;&#039;&#039;pcprefix=&amp;quot;foo:&amp;quot;&#039;&#039;&#039; will produce &#039;&#039;&#039;pc:foo:bar&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== sonameprefix ====&lt;br /&gt;
: Prefix all provides derived from parsing shared objects with the value in this variable, example: &#039;&#039;&#039;sonameprefix=&amp;quot;foo&amp;quot;&#039;&#039;&#039; will produce &#039;&#039;&#039;so:foo:bar.so.X&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
{{Note|All functions that are not &#039;&#039;prepare()&#039;&#039;, &#039;&#039;build()&#039;&#039;, &#039;&#039;check()&#039;&#039; and &#039;&#039;package()&#039;&#039; should consider the current working directory as undefined, and should therefore use the [[APKBUILD Reference#abuild-defined_variables|abuild-defined directory variables]] to their advantage.}}&lt;br /&gt;
&lt;br /&gt;
 sanitycheck() -&amp;gt; clean()-&amp;gt; fetch() -&amp;gt; verify() -&amp;gt; unpack() -&amp;gt; prepare() -&amp;gt; mkusers() -&amp;gt; build() -&amp;gt; check() -&amp;gt; package() -&amp;gt; subpackages() -&amp;gt; language packs -&amp;gt; apk -&amp;gt; cleanup()&lt;br /&gt;
&lt;br /&gt;
== abuild-defined functions ==&lt;br /&gt;
The following functions are provided by abuild and can be overridden, but it is strongly discouraged on code review for some functions:&lt;br /&gt;
&lt;br /&gt;
==== fetch() ====&lt;br /&gt;
: Downloads remote sources listed in &#039;&#039;source&#039;&#039; to &#039;&#039;SRCDEST&#039;&#039; (&#039;&#039;SRCDEST&#039;&#039; is configured in &#039;&#039;/etc/abuild.conf&#039;&#039;) and creates symlinks in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== unpack() ====&lt;br /&gt;
: unpack() will call default_unpack().&lt;br /&gt;
&lt;br /&gt;
: [https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L403 default_unpack()] unpacks .tar, .tgz, .tar.gz, .tar.lz (only available in Alpine &amp;gt;=3.7), .tar.bz2, .tar.lzma, .tar.xz, and .zip archives from a symlink in &#039;&#039;$srcdir&#039;&#039; associated with &#039;&#039;$SRCDEST&#039;&#039; (or distfiles folder) resulting in an unpacked folder in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== dev() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; package is used to collect developer files and folders for use in other packages in the compilation process nothing more.  Without specifying a custom &#039;&#039;dev()&#039;&#039; function, abuild will call its internal &#039;&#039;dev()&#039;&#039; function, which in turn calls default_dev().&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L1605 default_dev()]&#039;&#039; will move any &#039;&#039;include&#039;&#039; folder and folders containing &#039;&#039;*.[acho]&#039;&#039; (static archive, c source, c header file, object file), &#039;&#039;*.prl&#039;&#039; file extension patterns in &#039;&#039;&amp;quot;$pkgdir&amp;quot;/{lib,usr}&#039;&#039; to &#039;&#039;&amp;quot;$subpkgdir&amp;quot;/{lib,usr}&#039;&#039; recursively; and &#039;&#039;*.so&#039;&#039; files from &#039;&#039;&amp;quot;$pkgdir&amp;quot;/{lib,usr/lib}&#039;&#039; to &#039;&#039;&amp;quot;$subpkgdir&amp;quot;/{lib,usr/lib}&#039;&#039;.  It will also scan and move &#039;&#039;usr/{include,lib/{pkgconfig,cmake,qt*/mkspecs},share/{aclocal,gettext,vala/vapi,gir-[0-9]*,qt*/mkspecs},bin/*-config}}&#039;&#039; developer only folders in &#039;&#039;$pkgdir&#039;&#039; and transfer them to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: In general, default_dev() will support packages that share pkg-config, C programming language API, shared and static libraries, Autotools, gettext, Vala programming language bindings, Python GObject introspection, a provided custom pkg-config like command (*-config), Qt, and CMake.  If you have packages that have C++, other languages, other build system, etc; you need to manually move those developer files only if they are to be used in other packages.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: For default_dev() to be called as in no dev(), you need to explicitly add subpackages=&amp;quot;$pkgname-dev&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== doc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; package whose job is only to collect documentation folders from $pkgdir nothing more.  Without specifying a custom &#039;&#039;doc()&#039;&#039; function, abuild will call its internal &#039;&#039;doc()&#039;&#039; function, which in turn calls default_doc().&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L1519 default_doc()]&#039;&#039; will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/{doc,man,info,html,sgml,licenses,gtk-doc,ri,help}&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: Overriding this function is strongly discouraged.  Packaging docs should be done in the package() function while letting abuild automatically collect the doc folders.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: For default_doc() to be called as in no doc(), you need to explicitly add subpackages=&amp;quot;$pkgname-doc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== openrc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-openrc&#039;&#039;&#039; package whose job is to collect OpenRC service files that are in /etc/init.d and /etc/conf.d.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L1661 default_openrc()]&#039;&#039; will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/etc/{conf,init}.d&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: Overriding this function is strongly discouraged. Packaging OpenRC service definitions should be in the package() function while letting abuild automatically collect the openrc folders.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: for default_openrc() to be called as in no openrc(), you need to explicitly add subpackages=&amp;quot;$pkgname-openrc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== static() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-static&#039;&#039;&#039; package whose job is to collect static libraries that are stored in /lib and /usr/lib.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.4.0_rc4/abuild.in#L1748 default_static()]&#039;&#039; will move all static libraries (files ending with .a) from &#039;&#039;&amp;quot;$pkgdir&amp;quot;/lib&#039;&#039; and &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/lib&#039;&#039; to their equivalents in &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: Overriding this function is strongly discouraged. Packaging static libraries should be done in the package() function while letting abuild automatically collect the static libraries.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: for default_static() to be called as in no static(), you need to explicitly add subpackages=&amp;quot;$pkgname-static&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== snapshot() ====&lt;br /&gt;
: &#039;&#039;&#039;Optional&#039;&#039;&#039;.  For live APKBUILDs or those with a _cvs, _svn, _git, _hg in their version number, you should create a snapshot function only if there is no download link to an archive file (.zip, .tar.gz, ...) to the commit/hash/tag.  The purpose of the snapshot function is to create an archive of the source code so that the package source code is deterministic, and it doesn&#039;t waste time to fetch the source code but bypasses the download step after snapshotting.  Those that download the source code from a git repository will follow head or the latest change to the source code.  It is better to archive the source code as a zip / tar.gz / tar.bz2 up to the commit or the tag which you are trying to build a package.  If it is not deterministic or not every part of the code frozen in time for every dependency and the main project, then the patches will fail or the package may fail to compile when you revisit the package months or years to backport a patch.&lt;br /&gt;
&lt;br /&gt;
: The default [https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L2310 snapshot()] function has variables associated with it:&lt;br /&gt;
:* $disturl - the base-url of the place to autoupload the snapshot&lt;br /&gt;
:* $svnurl - Subversion repository &lt;br /&gt;
:* $giturl - Git repository&lt;br /&gt;
&lt;br /&gt;
: The default snapshot() can only support one repository.  It is better to override it if there are multiple repositories involved in your package.  CVS, Mercurial (hg), and alternative version control systems must override the default snapshot().&lt;br /&gt;
&lt;br /&gt;
: See [[APKBUILD_examples:Git_checkout]] to how to use it with git.  It takes 2-3 general steps.  Clone the repository; check it out at a specific revision/commit or tag; then you use an archiver to dump it in the &#039;&#039;$SRCDEST&#039;&#039; variable which points to the distfiles folder and the base path to the full path to the archive that you want to create.  You do this for every internal dependency that the package pulls.&lt;br /&gt;
&lt;br /&gt;
: After you have created your snapshot function, you use &amp;lt;code&amp;gt;abuild snapshot&amp;lt;/code&amp;gt; to run it.  &lt;br /&gt;
&lt;br /&gt;
: The archives produced by the snapshot will be saved in &#039;&#039;/var/cache/distfiles&#039;&#039; or whatever you set for &#039;&#039;$SRCDEST&#039;&#039;.  You may need to create symlinks to the archive if the archive is not saved to the Alpine server.&lt;br /&gt;
&lt;br /&gt;
: After you snapshot it, you need to produce the checksums with &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; to use it in the APKBUILD creation process.&lt;br /&gt;
&lt;br /&gt;
: This feature is available since Alpine &amp;gt;=2.6.&lt;br /&gt;
&lt;br /&gt;
==== default_prepare() ====&lt;br /&gt;
&lt;br /&gt;
:  Before build preparation it handles set of patches inside &amp;lt;code&amp;gt;$srcdir&amp;lt;/code&amp;gt; and prints failed ones.&lt;br /&gt;
&lt;br /&gt;
== User-defined functions ==&lt;br /&gt;
The following functions should be defined by the user: &lt;br /&gt;
&lt;br /&gt;
==== prepare() ====&lt;br /&gt;
: {{note|Please adjust old APKBUILDs, which still have a &#039;&#039;prepare()&#039;&#039; function that does the same as the &#039;&#039;default_prepare()&#039;&#039; when you edit them anyway.}}&lt;br /&gt;
: &#039;&#039;&#039;&#039;&#039;Optional&#039;&#039;.&#039;&#039;&#039;  Used for build preparation: patches, etc, should be applied here. When you don&#039;t specify a custom &#039;&#039;prepare()&#039;&#039;, the built-in &#039;&#039;default_prepare()&#039;&#039; from abuild will be used. It applies patches already (always prepare them in the &amp;lt;code&amp;gt;-p1&amp;lt;/code&amp;gt; format), so &#039;&#039;&#039;usually it makes sense to not create a custom &#039;&#039;prepare()&#039;&#039; function at all!&#039;&#039;&#039; If you do create one, call &#039;&#039;default_prepare()&#039;&#039; inside it:&lt;br /&gt;
&lt;br /&gt;
: Before default_prepare gets called, you can define &#039;&#039;patch_args&#039;&#039; to supply the argument to the patch command in global scope then throw away prepare() so it is unnecessary to use the old template code floating around to patch.  patch_args and autopatching is only available in Alpine &amp;gt;=3.4.  See [[Creating_an_Alpine_package#Patches]] to fix the patch that uses a different patch level (-pX).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
prepare() {&lt;br /&gt;
    default_prepare&lt;br /&gt;
    # your custom code here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== build() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the compilation stage.  This function will be called as the current user (unless the &#039;&#039;package()&#039;&#039; function is missing - for compatibility reasons).  If no compilation is needed, this function can contain a single line: &amp;lt;code&amp;gt;return 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: To enable or disable CFLAGS, CXXFLAGS, CMake with option, or configure option per arch, use the CARCH variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local cmakeoptions=&lt;br /&gt;
case &amp;quot;$CARCH&amp;quot; in&lt;br /&gt;
        aarch64*|arm*|ppc64le|x86|s390x) cmakeoptions=&amp;quot;$cmakeoptions -DWITH_OPENMP=OFF&amp;quot; ;;&lt;br /&gt;
        x86_64)                          cmakeoptions=&amp;quot;$cmakeoptions -DWITH_OPENMP=ON&amp;quot; ;;&lt;br /&gt;
        *)                               msg &amp;quot;Unable to determine architecture from (CARCH=$CARCH)&amp;quot; ; return 1 ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
: The block can be used in other parts of the APKBUILD even in global.&lt;br /&gt;
&lt;br /&gt;
==== check() ====&lt;br /&gt;
: &#039;&#039;&#039;Required if functionality exists.&#039;&#039;&#039; This function is called right after the build stage.  It should check that the packaged thing is actually working, typically by running (integration) tests, if provided by upstream.  If there’s no (easy) way how to test the package, you can declare that it does not want to use &#039;&#039;check()&#039;&#039; by adding &amp;quot;!check&amp;quot; into the &#039;&#039;options&#039;&#039; variable (&amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
: default_check() does nothing.  You need to manually explicitly call the unit tests or test suite yourself.  When you run the test, the program should return with an exit code of 0, indicating the tests were a success.  Unit tests or test suites will do feature tests, per function correctness check, fuzz testing, benchmarks.&lt;br /&gt;
&lt;br /&gt;
: A package may also require additional testing frameworks packages that are external dependencies.  You should add those to the &#039;&#039;checkdepends=&#039;&#039; in Alpine &amp;gt;=3.6 or &#039;&#039;makedepends=&#039;&#039; for older for backporters.  If the testing framework is not available, you need to create a package for it.  If it requires a specific version of a testing framework, consider making it an internal dependency or a new package with a package name containing the major and minor version number like the python packages.&lt;br /&gt;
&lt;br /&gt;
: Generally speaking, you should define the check functions for libraries, large programs like web browsers, or compilers and interpreters, cryptographic/security/anonymity stuff, mission critical stuff, PCI compliance/money/accounting software, server software with a lot of stakeholders or consumers.  Soon for the new policy change will have virtually &#039;&#039;&#039;all packages with testing capabilities be required to have a working and defined check() function&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: There are times when the unit tests do not work, just because the test itself is broken, new unimplemented feature, external factors not taken into consideration, unbundling path differences, breakage caused by ccache, missing test dependency or version mismatch dependency as in python2 vs python3, test scripts only work for particular language implementation like only supporting python2 but not python3 having used the 2to3 conversion script.  If a unit test is known not to work, you may need to patch it to omit that test or fix it; but, certain tests should not be disabled if it is important.  You may need to alter the references to uncompiled internal dependencies to work with the external dependencies instead.  For ccache, you can either disable it or remove it from the PATH environmental variable before running tests.&lt;br /&gt;
&lt;br /&gt;
{{Note|Tests for graphical applications and toolkits might work on a X11 user setup but will fail on the server unless run with xvfb-run.}}&lt;br /&gt;
&lt;br /&gt;
: If you don&#039;t add the &#039;&#039;check()&#039;&#039; and the &#039;&#039;options=&#039;&#039;, this is what you will see:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; WARNING: py-webtest*: APKBUILD does not run any tests!&lt;br /&gt;
    Alpine policy will soon require that packages have any relevant testsuites run during the build process.&lt;br /&gt;
    To fix, either define a check() function, or declare !check in $options to indicate the package does not have a testsuite.&lt;br /&gt;
&lt;br /&gt;
: If you do not do a check or disable it, you must state there is no testsuite in comment form (#) next to options=&amp;quot;!check&amp;quot; for the code reviewers.&lt;br /&gt;
&lt;br /&gt;
: To run test suite with autotools do:&lt;br /&gt;
&lt;br /&gt;
  make check&lt;br /&gt;
&lt;br /&gt;
: To run the test suite with python setuptools:&lt;br /&gt;
&lt;br /&gt;
  python2 setup.py test&lt;br /&gt;
  python3 setup.py test&lt;br /&gt;
&lt;br /&gt;
: For python it should be &#039;&#039;&#039;test&#039;&#039;&#039; not check.  Check for python setuptools will check the packaging metadata fields[https://docs.python.org/3/distutils/examples.html#checking-a-package] only but not run the unit tests.  There should be verbose output also.  The dependencies for the tests are found in test_require in the setup.py.&lt;br /&gt;
&lt;br /&gt;
: If it says &amp;lt;code&amp;gt;Ran 0 tests in 0.000s&amp;lt;/code&amp;gt; that is not acceptable.  check() will say it was good but it is not actually correct.  It needs to run the test suite with an alternative method like &amp;lt;code&amp;gt;tox -e py27,py36&amp;lt;/code&amp;gt; if you see a tox.ini file.&lt;br /&gt;
&lt;br /&gt;
: You want to do it for each implementation to ensure that the API calls are correct per implementation but ncopa said it was just fine with python3.&lt;br /&gt;
&lt;br /&gt;
: If there is a circular dependency for the checkdepends=, you need to disable the check and put the reason next to &amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt; that there is a circular dependency.  You should disable it for the package that package that is least important or least security risk.  The other solution is to make the conflicting dependency an internal dependency but making sure that it doesn&#039;t pull it at check time.  This way they can both preform tests properly.&lt;br /&gt;
&lt;br /&gt;
==== package() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the packaging stage.  Here, the built application and support files should be installed into &#039;&#039;&#039;$pkgdir&#039;&#039;&#039;.  If this is a metapackage, this function can contain a single line: &amp;lt;code&amp;gt;mkdir -p &amp;quot;$pkgdir&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Building in fakeroot will reduce performance for parallel builds dramatically.  It is for this reason that we split the build and package process into two separate functions.}}&lt;br /&gt;
&lt;br /&gt;
= Special Operators =&lt;br /&gt;
&lt;br /&gt;
== $pkgname~$pkgver ==&lt;br /&gt;
&lt;br /&gt;
Specifies a required &amp;lt;code&amp;gt;$pkgver&amp;lt;/code&amp;gt; for [[apk]] to satisfy the &amp;lt;code&amp;gt;$pkgname&amp;lt;/code&amp;gt; requirement. &amp;lt;code&amp;gt;~&amp;lt;/code&amp;gt; ignores revisions of the package version. For example &amp;lt;code&amp;gt;superd~0.6&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;$depends&amp;lt;/code&amp;gt; will ensure superd with package version 0.6 is installed as a run-time dependency for the package.&lt;br /&gt;
&lt;br /&gt;
== $pkgname&amp;gt;=$pkgver ==&lt;br /&gt;
&lt;br /&gt;
Specifies the installed package version must be greater than or equal to &amp;lt;code&amp;gt;$pkgver&amp;lt;/code&amp;gt; for [[apk]] to satisfy the &amp;lt;code&amp;gt;$pkgname&amp;lt;/code&amp;gt; requirement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
The [[APKBUILD examples]] page will assist you in understanding how to create an APKBUILD.&lt;br /&gt;
&lt;br /&gt;
= Version =&lt;br /&gt;
&lt;br /&gt;
This document assumes abuild for Alpine Edge.  For older releases of abuild, some of these features may not be available if you are using an older release.  A link to the implementation is linked for researchers and backporters.&lt;br /&gt;
&lt;br /&gt;
For more information see [[APKBUILD_versions]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=18382</id>
		<title>APKBUILD Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=18382"/>
		<updated>2020-12-30T16:49:48Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: /* replaces_priority */ &amp;quot;replace each other&amp;quot; -&amp;gt; &amp;quot;replace files of each other&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;APKBUILDs are the scripts that are created in order to build Alpine packages using the [[abuild]] tool.&lt;br /&gt;
&lt;br /&gt;
See [[aports]] for details on Alpine&#039;s official ports repository.&lt;br /&gt;
&lt;br /&gt;
This page is intended to serve as a reference for creating APKBUILDs; if this is your first time creating a package for Alpine Linux, please see [[Creating an Alpine package]].&lt;br /&gt;
&lt;br /&gt;
= Legend =&lt;br /&gt;
The following notes will assist you in understanding this document.&lt;br /&gt;
&lt;br /&gt;
In description text:&lt;br /&gt;
* If a variable is not prefixed with a &#039;&#039;$&#039;&#039;, it will be represented by italics (i.e., &#039;&#039;srcdir&#039;&#039; ).&lt;br /&gt;
* Functions will also be represented by italics, but will also end with a pair of parentheses (i.e., &#039;&#039;build()&#039;&#039; ).&lt;br /&gt;
* Shell commands will be represented &amp;lt;code&amp;gt;like this&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Variables =&lt;br /&gt;
{{Note|Variables that contain a path (e.g. &#039;&#039;$srcdir&#039;&#039; and &#039;&#039;$pkgdir&#039;&#039;) should always be quoted using double quotes (i.e., &#039;&#039;&amp;quot;$srcdir&amp;quot;&#039;&#039;).  This is done to prevent things from breaking, should the user have the APKBUILD in a directory path that contains spaces.}}&lt;br /&gt;
{{Note|All arbitrary variable and function names should be prefixed with an underscore character ( _ ) to avoid name clashes with the internals of abuild (for example, &#039;&#039;_luaversions&#039;&#039;).}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined variables ==&lt;br /&gt;
The following variables are defined by abuild:&lt;br /&gt;
&lt;br /&gt;
==== startdir ====&lt;br /&gt;
: The directory where the APKBUILD script is.&lt;br /&gt;
==== srcdir ====&lt;br /&gt;
: The directory where sources, from the &#039;&#039;source&#039;&#039; variable, are downloaded to and unpacked to.&lt;br /&gt;
==== pkgdir ====&lt;br /&gt;
: This directory should receive the files for the main package.  For example, a normal [http://en.wikipedia.org/wiki/GNU_build_system autotools] package would have &amp;lt;code&amp;gt;make DESTDIR=&amp;quot;$pkgdir&amp;quot; install&amp;lt;/code&amp;gt; in the &#039;&#039;package()&#039;&#039; function.&lt;br /&gt;
==== subpkgdir ====&lt;br /&gt;
: This directory should receive the files for a subpackage. This variable should only be used from subpackage functions.&lt;br /&gt;
==== builddir ====&lt;br /&gt;
: This variable should point to the directory inside the &#039;&#039;srcdir&#039;&#039; where the main package source is unpacked.  This is typically &#039;&#039;$srcdir/$pkgname-$pkgver&#039;&#039;.  It’s used by the default &#039;&#039;prepare()&#039;&#039; function as a working directory when applying patches.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User-defined variables ==&lt;br /&gt;
The following variables should be defined by the user:&lt;br /&gt;
==== arch ====&lt;br /&gt;
: Package architecture(s) to build for.  Can be one of: &#039;&#039;&#039;[[x86]], [[x86_64]], [[arm7]], [[armhf]], [[aarch64]], [[ppc64le]], [[s390x]], [[mips64]], all&#039;&#039;&#039;, or &#039;&#039;&#039;noarch&#039;&#039;&#039;, where &#039;&#039;&#039;all&#039;&#039;&#039; means all architectures, and &#039;&#039;&#039;noarch&#039;&#039;&#039; means it&#039;s architecture-independent (e.g., a pure-python package).&lt;br /&gt;
: {{Tip|To determine if your APKBUILD can use &#039;&#039;&#039;noarch&#039;&#039;&#039;: First specify &#039;&#039;&#039;all&#039;&#039;&#039; and then build the package by executing &amp;lt;code&amp;gt;abuild -r&amp;lt;/code&amp;gt;.  Watch the output towards the end for warnings saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used.  If the main package and all subpackages, if you have any subpackages, give a warning saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used, then you can use &#039;&#039;&#039;noarch&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
==== depends ====&lt;br /&gt;
: Run-time dependency package(s) that are not shared-object dependencies.  Shared objects dependencies are auto-detected and should not be specified here.&lt;br /&gt;
==== depends_dev ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
: {{Note|From ncopa on IRC: To find out if you need to add a package to depends_dev have a look at *requires* in usr/lib/pkgconfig/*.pc. With libtool it gets more complicated, but we should delete the .la files. Also check if there are any  /usr/bin/*-configure #!/bin/bash #!/usr/bin/perl or Python. Sometimes scripts or similar are generated at build time (i.e autoconf automake) then you normally don&#039;t need add those to depends_dev. You can also just add all -dev makedepends to depends_dev but it will slow the build process a little bit (more build dependencies).}}&lt;br /&gt;
&lt;br /&gt;
==== depends_doc ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== depends_openrc ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-openrc&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== depends_libs ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-libs&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== depends_static ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-static&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== checkdepends ====&lt;br /&gt;
: Dependencies that are only required during the check phase, they are only installed if the check option is enabled&lt;br /&gt;
&lt;br /&gt;
==== giturl ====&lt;br /&gt;
:Git repository from which &amp;lt;code&amp;gt;abuild checkout&amp;lt;/code&amp;gt; checks out. You can checkout a specific branch in git by adding &amp;lt;code&amp;gt;-b $branch&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== install ====&lt;br /&gt;
: There are 6 different types of install scripts.  Install scripts are named &#039;&#039;&#039;$pkgname.action&#039;&#039;&#039;, where &#039;&#039;&#039;action&#039;&#039;&#039; can be:  &#039;&#039;&#039;pre-install, post-install, pre-upgrade, post-upgrade, pre-deinstall&#039;&#039;&#039;, or &#039;&#039;&#039;post-deinstall&#039;&#039;&#039;.  For example, if &#039;&#039;pkgname&#039;&#039; is set to &#039;&#039;&#039;mypackage&#039;&#039;&#039; and &#039;&#039;install&#039;&#039; is set to &#039;&#039;&#039;$pkgname.post-install&#039;&#039;&#039;, then a script named &#039;&#039;&#039;mypackage.post-install&#039;&#039;&#039; must exist along-side the APKBUILD.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;{{Note|Always use &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt; for the command-line interpreter on the [http://en.wikipedia.org/wiki/Shebang_%28Unix%29 shebang line] of your install scripts.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the different types of install scripts in detail:&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-install =====&lt;br /&gt;
: This script is executed &#039;&#039;before installing&#039;&#039; the package.  Typical use is when the package needs a group and a user to be created. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
addgroup -S clamav 2&amp;gt;/dev/null&lt;br /&gt;
adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|If the script exits with a failure (e.g., if the user already exists), the package will not be installed and &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will exit with failure, hence the &amp;lt;code&amp;gt;exit 0&amp;lt;/code&amp;gt; at the end.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-install =====&lt;br /&gt;
: This script is executed &#039;&#039;after installing&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;before upgrading/downgrading/reinstalling&#039;&#039; the package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;after upgrading/downgrading/reinstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;before uninstalling&#039;&#039; the package.&lt;br /&gt;
: {{Note|If the script exits with failure, &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will not uninstall the package.}}&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;after uninstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
==== install_if ====&lt;br /&gt;
:install_if can be used when a package needs to be installed when some packages are already installed or are in the dependency tree. It works in reverse to the &#039;&#039;recommends&#039;&#039; feature, that other package managers provide.&lt;br /&gt;
&lt;br /&gt;
: Typically this is used in a subpackage that should provide files which make sense with another package. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
subpackages=&amp;quot;$pkgname-bash-completion:bashcomp:noarch&amp;quot;&lt;br /&gt;
...&lt;br /&gt;
bashcomp() {&lt;br /&gt;
	pkgdesc=&amp;quot;Bash completions for $pkgname&amp;quot;&lt;br /&gt;
	install_if=&amp;quot;$pkgname=$pkgver-r$pkgrel bash-completion&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	install -Dm644 &amp;quot;$builddir&amp;quot;/doc/bash_completion/aria2c \&lt;br /&gt;
		&amp;quot;$subpkgdir&amp;quot;/usr/share/bash-completion/completions/_aria2c&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
From the aria2c APKBUILD. Note that the custom bashcomp() function is only necessary, because the files are not in /usr/share/bash-completion.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:In general, install_if should only be used with &#039;&#039;&#039;at least one versioned constraint&#039;&#039;&#039;. Otherwise, a package that was implicitly installed by install_if and then removed from the binary repositories, will not get purged with &amp;lt;code&amp;gt;apk upgrade&amp;lt;/code&amp;gt;. [https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues/10720#note_121298]&lt;br /&gt;
&lt;br /&gt;
==== license ====&lt;br /&gt;
: License(s) for the package, for example &amp;lt;code&amp;gt;GPL-3.0-or-later&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;BSD-2-Clause&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;MIT&amp;lt;/code&amp;gt; [[Creating_an_Alpine_package#license|(details)]].&lt;br /&gt;
&lt;br /&gt;
==== makedepends ====&lt;br /&gt;
: Build-time dependency package(s).&lt;br /&gt;
==== md5sums/sha256sums/sha512sums ====&lt;br /&gt;
: Checksums for the files/URLs listed in &#039;&#039;source&#039;&#039;.  The checksums are normally generated and updated by executing &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; and should be the last item in the APKBUILD.&lt;br /&gt;
&lt;br /&gt;
New packages should use only sha512sums.&lt;br /&gt;
&lt;br /&gt;
==== options ====&lt;br /&gt;
: Build-time options for the package.&lt;br /&gt;
&lt;br /&gt;
: {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!archcheck&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to verify that the architecture of the binary files is the same architecture as abuild should build for. One example where it makes sense to set this are packages with firmware files, that get executed on another CPU (such as WiFi firmware).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to run the &amp;lt;code&amp;gt;check()&amp;lt;/code&amp;gt; function. Please always add a short comment after the &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt; about why it&#039;s disabled. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142545300] Creating a very simple check function, that calls &amp;lt;code&amp;gt;program --version&amp;lt;/code&amp;gt; is worse than disabling tests completely because it gives the false impression that the package is thoroughly tested with the testsuite from upstream. [https://github.com/alpinelinux/aports/pull/7326#discussion_r278797457]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;checkroot&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies that the package&#039;s test suite will be run in &#039;&#039;fakeroot&#039;&#039;. This is necessary for some test suites which fail when run as non-root.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;net&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allows network access when run in &#039;&#039;rootbld&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!strip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Avoid stripping symbols from binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;suid&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allow [https://en.wikipedia.org/wiki/Setuid setuid] binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!tracedeps&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not automatically find dependencies (e.g. by using &amp;lt;code&amp;gt;ldd&amp;lt;/code&amp;gt; to find dynamic libraries, which the resulting binary links against).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;chmod-clean&amp;lt;/code&amp;gt;&lt;br /&gt;
| Make all files writable in the src/ directory. Useful for packages that make files read-only in the process of building packages (go modules).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;toolchain&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t warn when g++ is in makedepends&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!dbg&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t create debugging subpackage&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ldpath-recursive&amp;lt;/code&amp;gt;&lt;br /&gt;
| Scan directories recursively when creating .so providers&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!spdx&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not check if the license= field has a SPDX compliant license&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;textrels&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t error out when text relocations are found&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;charset.alias&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t error out if /usr/lib/charset.alias is found&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;libtool&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t delete libtool .la files&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!fhs&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t enforce checks on path that follow the FHS&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== pkgdesc ====&lt;br /&gt;
: A brief, one-line description of what the package does.&lt;br /&gt;
&lt;br /&gt;
: Here&#039;s an example from the OpenSSH client package:&lt;br /&gt;
: &amp;lt;pre&amp;gt;pkgdesc=&amp;quot;Port of OpenBSD&#039;s free SSH release - client&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== pkggroups ====&lt;br /&gt;
: System group(s) to be created during build-time.  System group(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system group(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgname ====&lt;br /&gt;
: The name of the package.  All letters should be lowercase.&lt;br /&gt;
: {{Note|When creating an APKBUILD of a module or library for another package, we use some common package prefixes, such as: &#039;&#039;lua-&#039;&#039;, &#039;&#039;perl-&#039;&#039;, &#039;&#039;php-&#039;&#039;, and &#039;&#039;py-&#039;&#039;.  Search aports for other common prefixes.}}&lt;br /&gt;
&lt;br /&gt;
==== pkgrel ====&lt;br /&gt;
: Alpine package release number.  Starts at 0 (zero).  Always increment &#039;&#039;pkgrel&#039;&#039; when making updates to an aport; reset &#039;&#039;pkgrel&#039;&#039; to 0 (zero) when incrementing &#039;&#039;pkgver&#039;&#039;.&lt;br /&gt;
==== pkgusers ====&lt;br /&gt;
: System user(s) to be created during build-time.  System user(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system user(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgver ====&lt;br /&gt;
: The version of the software being packaged. Format for valid versions: &amp;lt;code&amp;gt;{digit}{.digit}...{letter}{_suf{#}}...{-r#}&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n17]&lt;br /&gt;
: A Suffix &amp;lt;code&amp;gt;suf&amp;lt;/code&amp;gt; in the above format can be one of the following to indicate that the release is &#039;&#039;less recent&#039;&#039; than the version without the suffix: &amp;lt;code&amp;gt;alpha&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pre&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rc&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n75]&lt;br /&gt;
: These are for indicating &#039;&#039;more recent&#039;&#039; releases: &amp;lt;code&amp;gt;cvs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;svn&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;hg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n76]&lt;br /&gt;
: All other suffices are invalid. To package a specific git commit, the date of the commit gets appended to the latest release, e.g. &amp;lt;code&amp;gt;1.0.0_git20180204&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== provides ====&lt;br /&gt;
: List of package names (and optionally version info) this package provides.&lt;br /&gt;
&lt;br /&gt;
: If package with a version is provided (provides=&#039;foo=1.2&#039;) apk will consider it as an alternate name and it will automatically consider the package for installation by the alternate name, and conflict with other packages having the same name, or provides.&lt;br /&gt;
&lt;br /&gt;
: If version is not provided (provides=&#039;foo&#039;), apk will consider it as virtual package name. Several package with same non-versioned provides can be installed simultaneously. However, none of them will be installed by default when requested by the virtual name - instead, error message is given and user is asked to choose which package providing the virtual name should be installed.&lt;br /&gt;
==== provider_priority ====&lt;br /&gt;
: A numeric value which is used by apk-tools to break ties when choosing a virtual package to satisfy a dependency. Higher values have higher priority. The primary use case is to specify the primary package that satisfies a virtual (provider).&lt;br /&gt;
==== replaces ====&lt;br /&gt;
: Allow this package to be installed at the same time as the listed packages, even if they have conflicting files. The files from this package will override (&amp;quot;take over&amp;quot;) the conflicting files.&lt;br /&gt;
&lt;br /&gt;
: This can be used to override config files with &amp;quot;policy packages&amp;quot; [https://gitlab.alpinelinux.org/alpine/apk-tools/-/commit/89d003f8c2e5a92655ee778f7bfa5c0e85ddbed4].&lt;br /&gt;
&lt;br /&gt;
: Another use case is renaming packages (or moving files from one package to another): &amp;quot;replaces&amp;quot; will avoid the file conflict error that apk reports if it happens to install the new package before uninstalling the old package [https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues/10724#note_132872].&lt;br /&gt;
&lt;br /&gt;
: A common misconception is, that &amp;quot;replaces&amp;quot; is used to replace packages (like in [https://wiki.archlinux.org/index.php/PKGBUILD#replaces PKGBUILD]). This is not the case, it is only for solving file conflicts. To let apk consider installing one package instead of another one, refer to [[#provides|provides]] (with the version).&lt;br /&gt;
&lt;br /&gt;
==== replaces_priority ====&lt;br /&gt;
: The priority of the replaces. If multiple packages replace files of each other, then the package with the highest &#039;&#039;replaces_priority&#039;&#039; will win.&lt;br /&gt;
&lt;br /&gt;
==== source ====&lt;br /&gt;
: The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[APKBUILD Reference#install|install variable]]), patches, and all other necessary files.&lt;br /&gt;
&lt;br /&gt;
: Here are few things to note:&lt;br /&gt;
&lt;br /&gt;
:* When you are finished adding local and/or remote files to &#039;&#039;source&#039;&#039;, you can execute the following command to add their checksums to the APKBUILD file:&lt;br /&gt;
:: {{Cmd|abuild checksum}}&lt;br /&gt;
:: {{Note|When later updating the content of &#039;&#039;source&#039;&#039;, or updating a file that is listed in &#039;&#039;source&#039;&#039;, you must also update their checksums again with the same command.}}&lt;br /&gt;
&lt;br /&gt;
:* When the remote file is hosted at SourceForge, it&#039;s best to specify the special mirrors link used by SourceForge:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://downloads.sourceforge.net/software/software-$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: (or similar depending on the package).&lt;br /&gt;
&lt;br /&gt;
:* You can set target filename (eg &#039;save as...&#039;) by prefixing the URI with &#039;&#039;filename::&#039;&#039;. This is useful when the remote filename is not specified in the URI (ie, does not end in &#039;/software-1.0.tar.gz&#039;), such as:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: or when the filename is braindead, like githubs&#039; download tags:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: The above two examples needs a target filename prefix:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::http://oss.example.org/?get=software&amp;amp;ver=$pkgver&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: and:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following protocols for remote file retrieval:&lt;br /&gt;
:** http&lt;br /&gt;
:** https&lt;br /&gt;
:** ftp&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following archive types/archive file extensions:&lt;br /&gt;
:** .tar (only in Alpine &amp;gt;= 2.5)&lt;br /&gt;
:** .tar.gz / .tgz&lt;br /&gt;
:** .tar.bz2&lt;br /&gt;
:** .tar.lz (only in Alpine &amp;gt;=3.7)&lt;br /&gt;
:** .tar.lzma&lt;br /&gt;
:** .tar.xz&lt;br /&gt;
:** .zip&lt;br /&gt;
&lt;br /&gt;
:* &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; should only include variables that change often like &amp;lt;code&amp;gt;pkgver&amp;lt;/code&amp;gt; or a commit ID. CI will warn you if you include &amp;lt;code&amp;gt;pkgname&amp;lt;/code&amp;gt; in source. Other variables like for example &amp;lt;code&amp;gt;_pkgname&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;_pyname&amp;lt;/code&amp;gt; do not belong in &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; either.&lt;br /&gt;
&lt;br /&gt;
==== subpackages ====&lt;br /&gt;
: Subpackages built from this APKBUILD.  abuild will parse this variable and try to find a subpackage split function.  The split function must &#039;&#039;move&#039;&#039; files that do not belong in the main package, from &#039;&#039;$pkgdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.  Files and directories can also be &#039;&#039;copied&#039;&#039; from &#039;&#039;$startdir&#039;&#039; and &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: The split function can be specified in 1 of 3 different methods:&lt;br /&gt;
:# subpkgname:&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# $pkgname-&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# &#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
: {{Note|Split function names &#039;&#039;&#039;cannot&#039;&#039;&#039; use hyphens; use the first method above if the subpackage name contains a hyphen (-) character, like this: &#039;&#039;subpkg-name:subpkg_name&#039;&#039;, where &amp;lt;code&amp;gt;subpkg-name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;&#039;&#039; and &amp;lt;code&amp;gt;subpkg_name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;s split function&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
: {{Tip|For more information, see the [[APKBUILD_examples:Subpackages|Subpackages example]].}}&lt;br /&gt;
&lt;br /&gt;
==== triggers ====&lt;br /&gt;
: Apk-tools can &amp;quot;monitor&amp;quot; directories and execute a trigger if any package installed/uninstalled any file in the monitored dir. The triggers are always executed after the apk action (install, uninstall, upgrade).&lt;br /&gt;
&lt;br /&gt;
: The triggers are specified in the format: &#039;&#039;scriptname&#039;&#039;=&#039;&#039;pathlist&#039;&#039; where &#039;&#039;scriptname&#039;&#039; is the (sub)package name + .trigger suffix and pathlist is : separated list of the dirs to monitor.&lt;br /&gt;
&lt;br /&gt;
: The &#039;&#039;&#039;triggers&#039;&#039;&#039; variable must include the triggers for subpackages too if they have any.&lt;br /&gt;
&lt;br /&gt;
: It is possible to use wildcards (*) in the dir list.&lt;br /&gt;
&lt;br /&gt;
==== url ====&lt;br /&gt;
: The homepage for the package.  This is to help users find upstream documentation and other information regarding the package.&lt;br /&gt;
&lt;br /&gt;
==== langdir ====&lt;br /&gt;
: Path to where the language files are located for the &#039;&#039;&#039;-lang&#039;&#039;&#039; subpackage, defaults to &#039;&#039;&#039;/usr/share/locale&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== pcprefix ====&lt;br /&gt;
: Prefix all provides derived from parsing pkg-config Requires: with the value in this variable, example: &#039;&#039;&#039;&#039;pcprefix=&amp;quot;foo:&amp;quot;&#039;&#039;&#039; will produce &#039;&#039;&#039;pc:foo:bar&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== sonameprefix ====&lt;br /&gt;
: Prefix all provides derived from parsing shared objects with the value in this variable, example: &#039;&#039;&#039;sonameprefix=&amp;quot;foo&amp;quot;&#039;&#039;&#039; will produce &#039;&#039;&#039;so:foo:bar.so.X&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
{{Note|All functions that are not &#039;&#039;prepare()&#039;&#039;, &#039;&#039;build()&#039;&#039;, &#039;&#039;check()&#039;&#039; and &#039;&#039;package()&#039;&#039; should consider the current working directory as undefined, and should therefore use the [[APKBUILD Reference#abuild-defined_variables|abuild-defined directory variables]] to their advantage.}}&lt;br /&gt;
&lt;br /&gt;
 sanitycheck() -&amp;gt; clean()-&amp;gt; fetch() -&amp;gt; verify() -&amp;gt; unpack() -&amp;gt; prepare() -&amp;gt; mkusers() -&amp;gt; build() -&amp;gt; check() -&amp;gt; package() -&amp;gt; subpackages() -&amp;gt; language packs -&amp;gt; apk -&amp;gt; cleanup()&lt;br /&gt;
&lt;br /&gt;
== abuild-defined functions ==&lt;br /&gt;
The following functions are provided by abuild and can be overridden, but it is strongly discouraged on code review for some functions:&lt;br /&gt;
&lt;br /&gt;
==== fetch() ====&lt;br /&gt;
: Downloads remote sources listed in &#039;&#039;source&#039;&#039; to &#039;&#039;SRCDEST&#039;&#039; (&#039;&#039;SRCDEST&#039;&#039; is configured in &#039;&#039;/etc/abuild.conf&#039;&#039;) and creates symlinks in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== unpack() ====&lt;br /&gt;
: unpack() will call default_unpack().&lt;br /&gt;
&lt;br /&gt;
: [https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L403 default_unpack()] unpacks .tar, .tgz, .tar.gz, .tar.lz (only available in Alpine &amp;gt;=3.7), .tar.bz2, .tar.lzma, .tar.xz, and .zip archives from a symlink in &#039;&#039;$srcdir&#039;&#039; associated with &#039;&#039;$SRCDEST&#039;&#039; (or distfiles folder) resulting in an unpacked folder in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== dev() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; package is used to collect developer files and folders for use in other packages in the compilation process nothing more.  Without specifying a custom &#039;&#039;dev()&#039;&#039; function, abuild will call its internal &#039;&#039;dev()&#039;&#039; function, which in turn calls default_dev().&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L1605 default_dev()]&#039;&#039; will move any &#039;&#039;include&#039;&#039; folder and folders containing &#039;&#039;*.[acho]&#039;&#039; (static archive, c source, c header file, object file), &#039;&#039;*.prl&#039;&#039; file extension patterns in &#039;&#039;&amp;quot;$pkgdir&amp;quot;/{lib,usr}&#039;&#039; to &#039;&#039;&amp;quot;$subpkgdir&amp;quot;/{lib,usr}&#039;&#039; recursively; and &#039;&#039;*.so&#039;&#039; files from &#039;&#039;&amp;quot;$pkgdir&amp;quot;/{lib,usr/lib}&#039;&#039; to &#039;&#039;&amp;quot;$subpkgdir&amp;quot;/{lib,usr/lib}&#039;&#039;.  It will also scan and move &#039;&#039;usr/{include,lib/{pkgconfig,cmake,qt*/mkspecs},share/{aclocal,gettext,vala/vapi,gir-[0-9]*,qt*/mkspecs},bin/*-config}}&#039;&#039; developer only folders in &#039;&#039;$pkgdir&#039;&#039; and transfer them to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: In general, default_dev() will support packages that share pkg-config, C programming language API, shared and static libraries, Autotools, gettext, Vala programming language bindings, Python GObject introspection, a provided custom pkg-config like command (*-config), Qt, and CMake.  If you have packages that have C++, other languages, other build system, etc; you need to manually move those developer files only if they are to be used in other packages.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: For default_dev() to be called as in no dev(), you need to explicitly add subpackages=&amp;quot;$pkgname-dev&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== doc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; package whose job is only to collect documentation folders from $pkgdir nothing more.  Without specifying a custom &#039;&#039;doc()&#039;&#039; function, abuild will call its internal &#039;&#039;doc()&#039;&#039; function, which in turn calls default_doc().&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L1519 default_doc()]&#039;&#039; will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/{doc,man,info,html,sgml,licenses,gtk-doc,ri,help}&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: Overriding this function is strongly discouraged.  Packaging docs should be done in the package() function while letting abuild automatically collect the doc folders.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: For default_doc() to be called as in no doc(), you need to explicitly add subpackages=&amp;quot;$pkgname-doc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== openrc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-opernc&#039;&#039;&#039; package whose job is to collect OpenRC service files that are in /etc/init.d and /etc/conf.d.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L1661 default_openrc()]&#039;&#039; will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/etc/{conf,init}.d&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: Overriding this function is strongly discouraged. Packaging OpenRC service definitions should be in the package() function while letting abuild automatically collect the openrc folders.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: for default_openrc() to be called as in no openrc(), you need to explicitly add subpackages=&amp;quot;$pkgname-openrc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== static() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-static&#039;&#039;&#039; package whose job is to collect static libraries that are stored in /lib and /usr/lib.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.4.0_rc4/abuild.in#L1748 default_static()]&#039;&#039; will move all static libraries (files ending with .a) from &#039;&#039;&amp;quot;$pkgdir&amp;quot;/lib&#039;&#039; and &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/lib&#039;&#039; to their equivalents in &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: Overriding this function is strongly discouraged. Packaging static libraries should be done in the package() function while letting abuild automatically collect the static libraries.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: for default_static() to be called as in no static(), you need to explicitly add subpackages=&amp;quot;$pkgname-static&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== snapshot() ====&lt;br /&gt;
: &#039;&#039;&#039;Optional&#039;&#039;&#039;.  For live APKBUILDs or those with a _cvs, _svn, _git, _hg in their version number, you should create a snapshot function only if there is no download link to an archive file (.zip, .tar.gz, ...) to the commit/hash/tag.  The purpose of the snapshot function is to create an archive of the source code so that the package source code is deterministic, and it doesn&#039;t waste time to fetch the source code but bypasses the download step after snapshotting.  Those that download the source code from a git repository will follow head or the latest change to the source code.  It is better to archive the source code as a zip / tar.gz / tar.bz2 up to the commit or the tag which you are trying to build a package.  If it is not deterministic or not every part of the code frozen in time for every dependency and the main project, then the patches will fail or the package may fail to compile when you revisit the package months or years to backport a patch.&lt;br /&gt;
&lt;br /&gt;
: The default [https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L2310 snapshot()] function has variables associated with it:&lt;br /&gt;
:* $disturl - the base-url of the place to autoupload the snapshot&lt;br /&gt;
:* $svnurl - Subversion repository &lt;br /&gt;
:* $giturl - Git repository&lt;br /&gt;
&lt;br /&gt;
: The default snapshot() can only support one repository.  It is better to override it if there are multiple repositories involved in your package.  CVS, Mercurial (hg), and alternative version control systems must override the default snapshot().&lt;br /&gt;
&lt;br /&gt;
: See [[APKBUILD_examples:Git_checkout]] to how to use it with git.  It takes 2-3 general steps.  Clone the repository; check it out at a specific revision/commit or tag; then you use an archiver to dump it in the &#039;&#039;$SRCDEST&#039;&#039; variable which points to the distfiles folder and the base path to the full path to the archive that you want to create.  You do this for every internal dependency that the package pulls.&lt;br /&gt;
&lt;br /&gt;
: After you have created your snapshot function, you use &amp;lt;code&amp;gt;abuild snapshot&amp;lt;/code&amp;gt; to run it.  &lt;br /&gt;
&lt;br /&gt;
: The archives produced by the snapshot will be saved in &#039;&#039;/var/cache/distfiles&#039;&#039; or whatever you set for &#039;&#039;$SRCDEST&#039;&#039;.  You may need to create symlinks to the archive if the archive is not saved to the Alpine server.&lt;br /&gt;
&lt;br /&gt;
: After you snapshot it, you need to produce the checksums with &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; to use it in the APKBUILD creation process.&lt;br /&gt;
&lt;br /&gt;
: This feature is available since Alpine &amp;gt;=2.6.&lt;br /&gt;
&lt;br /&gt;
==== default_prepare() ====&lt;br /&gt;
&lt;br /&gt;
:  Before build preparation it handles set of patches inside &amp;lt;code&amp;gt;$srcdir&amp;lt;/code&amp;gt; and prints failed ones.&lt;br /&gt;
&lt;br /&gt;
== User-defined functions ==&lt;br /&gt;
The following functions should be defined by the user: &lt;br /&gt;
&lt;br /&gt;
==== prepare() ====&lt;br /&gt;
: {{note|Please adjust old APKBUILDs, which still have a &#039;&#039;prepare()&#039;&#039; function that does the same as the &#039;&#039;default_prepare()&#039;&#039; when you edit them anyway.}}&lt;br /&gt;
: &#039;&#039;&#039;&#039;&#039;Optional&#039;&#039;.&#039;&#039;&#039;  Used for build preparation: patches, etc, should be applied here. When you don&#039;t specify a custom &#039;&#039;prepare()&#039;&#039;, the built-in &#039;&#039;default_prepare()&#039;&#039; from abuild will be used. It applies patches already (always prepare them in the &amp;lt;code&amp;gt;-p1&amp;lt;/code&amp;gt; format), so &#039;&#039;&#039;usually it makes sense to not create a custom &#039;&#039;prepare()&#039;&#039; function at all!&#039;&#039;&#039; If you do create one, call &#039;&#039;default_prepare()&#039;&#039; inside it:&lt;br /&gt;
&lt;br /&gt;
: Before default_prepare gets called, you can define &#039;&#039;patch_args&#039;&#039; to supply the argument to the patch command in global scope then throw away prepare() so it is unnecessary to use the old template code floating around to patch.  patch_args and autopatching is only available in Alpine &amp;gt;=3.4.  See [[Creating_an_Alpine_package#Patches]] to fix the patch that uses a different patch level (-pX).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
prepare() {&lt;br /&gt;
    default_prepare&lt;br /&gt;
    # your custom code here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== build() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the compilation stage.  This function will be called as the current user (unless the &#039;&#039;package()&#039;&#039; function is missing - for compatibility reasons).  If no compilation is needed, this function can contain a single line: &amp;lt;code&amp;gt;return 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: To enable or disable CFLAGS, CXXFLAGS, CMake with option, or configure option per arch, use the CARCH variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local cmakeoptions=&lt;br /&gt;
case &amp;quot;$CARCH&amp;quot; in&lt;br /&gt;
        aarch64*|arm*|ppc64le|x86|s390x) cmakeoptions=&amp;quot;$cmakeoptions -DWITH_OPENMP=OFF&amp;quot; ;;&lt;br /&gt;
        x86_64)                          cmakeoptions=&amp;quot;$cmakeoptions -DWITH_OPENMP=ON&amp;quot; ;;&lt;br /&gt;
        *)                               msg &amp;quot;Unable to determine architecture from (CARCH=$CARCH)&amp;quot; ; return 1 ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
: The block can be used in other parts of the APKBUILD even in global.&lt;br /&gt;
&lt;br /&gt;
==== check() ====&lt;br /&gt;
: &#039;&#039;&#039;Required if functionality exists.&#039;&#039;&#039; This function is called right after the build stage.  It should check that the packaged thing is actually working, typically by running (integration) tests, if provided by upstream.  If there’s no (easy) way how to test the package, you can declare that it does not want to use &#039;&#039;check()&#039;&#039; by adding &amp;quot;!check&amp;quot; into the &#039;&#039;options&#039;&#039; variable (&amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
: default_check() does nothing.  You need to manually explicitly call the unit tests or test suite yourself.  When you run the test, the program should return with an exit code of 0, indicating the tests were a success.  Unit tests or test suites will do feature tests, per function correctness check, fuzz testing, benchmarks.&lt;br /&gt;
&lt;br /&gt;
: A package may also require additional testing frameworks packages that are external dependencies.  You should add those to the &#039;&#039;checkdepends=&#039;&#039; in Alpine &amp;gt;=3.6 or &#039;&#039;makedepends=&#039;&#039; for older for backporters.  If the testing framework is not available, you need to create a package for it.  If it requires a specific version of a testing framework, consider making it an internal dependency or a new package with a package name containing the major and minor version number like the python packages.&lt;br /&gt;
&lt;br /&gt;
: Generally speaking, you should define the check functions for libraries, large programs like web browsers, or compilers and interpreters, cryptographic/security/anonymity stuff, mission critical stuff, PCI compliance/money/accounting software, server software with a lot of stakeholders or consumers.  Soon for the new policy change will have virtually &#039;&#039;&#039;all packages with testing capabilities be required to have a working and defined check() function&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: There are times when the unit tests do not work, just because the test itself is broken, new unimplemented feature, external factors not taken into consideration, unbundling path differences, breakage caused by ccache, missing test dependency or version mismatch dependency as in python2 vs python3, test scripts only work for particular language implementation like only supporting python2 but not python3 having used the 2to3 conversion script.  If a unit test is known not to work, you may need to patch it to omit that test or fix it; but, certain tests should not be disabled if it is important.  You may need to alter the references to uncompiled internal dependencies to work with the external dependencies instead.  For ccache, you can either disable it or remove it from the PATH environmental variable before running tests.&lt;br /&gt;
&lt;br /&gt;
{{Note|Tests for graphical applications and toolkits might work on a X11 user setup but will fail on the server unless run with xvfb-run.}}&lt;br /&gt;
&lt;br /&gt;
: If you don&#039;t add the &#039;&#039;check()&#039;&#039; and the &#039;&#039;options=&#039;&#039;, this is what you will see:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; WARNING: py-webtest*: APKBUILD does not run any tests!&lt;br /&gt;
    Alpine policy will soon require that packages have any relevant testsuites run during the build process.&lt;br /&gt;
    To fix, either define a check() function, or declare !check in $options to indicate the package does not have a testsuite.&lt;br /&gt;
&lt;br /&gt;
: If you do not do a check or disable it, you must state there is no testsuite in comment form (#) next to options=&amp;quot;!check&amp;quot; for the code reviewers.&lt;br /&gt;
&lt;br /&gt;
: To run test suite with autotools do:&lt;br /&gt;
&lt;br /&gt;
  make check&lt;br /&gt;
&lt;br /&gt;
: To run the test suite with python setuptools:&lt;br /&gt;
&lt;br /&gt;
  python2 setup.py test&lt;br /&gt;
  python3 setup.py test&lt;br /&gt;
&lt;br /&gt;
: For python it should be &#039;&#039;&#039;test&#039;&#039;&#039; not check.  Check for python setuptools will check the packaging metadata fields[https://docs.python.org/3/distutils/examples.html#checking-a-package] only but not run the unit tests.  There should be verbose output also.  The dependencies for the tests are found in test_require in the setup.py.&lt;br /&gt;
&lt;br /&gt;
: If it says &amp;lt;code&amp;gt;Ran 0 tests in 0.000s&amp;lt;/code&amp;gt; that is not acceptable.  check() will say it was good but it is not actually correct.  It needs to run the test suite with an alternative method like &amp;lt;code&amp;gt;tox -e py27,py36&amp;lt;/code&amp;gt; if you see a tox.ini file.&lt;br /&gt;
&lt;br /&gt;
: You want to do it for each implementation to ensure that the API calls are correct per implementation but ncopa said it was just fine with python3.&lt;br /&gt;
&lt;br /&gt;
: If there is a circular dependency for the checkdepends=, you need to disable the check and put the reason next to &amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt; that there is a circular dependency.  You should disable it for the package that package that is least important or least security risk.  The other solution is to make the conflicting dependency an internal dependency but making sure that it doesn&#039;t pull it at check time.  This way they can both preform tests properly.&lt;br /&gt;
&lt;br /&gt;
==== package() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the packaging stage.  Here, the built application and support files should be installed into &#039;&#039;&#039;$pkgdir&#039;&#039;&#039;.  If this is a metapackage, this function can contain a single line: &amp;lt;code&amp;gt;mkdir -p &amp;quot;$pkgdir&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Building in fakeroot will reduce performance for parallel builds dramatically.  It is for this reason that we split the build and package process into two separate functions.}}&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
The [[APKBUILD examples]] page will assist you in understanding how to create an APKBUILD.&lt;br /&gt;
&lt;br /&gt;
= Version =&lt;br /&gt;
&lt;br /&gt;
This document assumes abuild for Alpine Edge.  For older releases of abuild, some of these features may not be available if you are using an older release.  A link to the implementation is linked for researchers and backporters.&lt;br /&gt;
&lt;br /&gt;
For more information see [[APKBUILD_versions]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=18380</id>
		<title>APKBUILD Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=18380"/>
		<updated>2020-12-30T16:48:50Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: /* replaces */ reword to make clear that it&amp;#039;s about avoiding file conflicts and not about replacing packages like in Arch Linux PKGBUILD&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;APKBUILDs are the scripts that are created in order to build Alpine packages using the [[abuild]] tool.&lt;br /&gt;
&lt;br /&gt;
See [[aports]] for details on Alpine&#039;s official ports repository.&lt;br /&gt;
&lt;br /&gt;
This page is intended to serve as a reference for creating APKBUILDs; if this is your first time creating a package for Alpine Linux, please see [[Creating an Alpine package]].&lt;br /&gt;
&lt;br /&gt;
= Legend =&lt;br /&gt;
The following notes will assist you in understanding this document.&lt;br /&gt;
&lt;br /&gt;
In description text:&lt;br /&gt;
* If a variable is not prefixed with a &#039;&#039;$&#039;&#039;, it will be represented by italics (i.e., &#039;&#039;srcdir&#039;&#039; ).&lt;br /&gt;
* Functions will also be represented by italics, but will also end with a pair of parentheses (i.e., &#039;&#039;build()&#039;&#039; ).&lt;br /&gt;
* Shell commands will be represented &amp;lt;code&amp;gt;like this&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Variables =&lt;br /&gt;
{{Note|Variables that contain a path (e.g. &#039;&#039;$srcdir&#039;&#039; and &#039;&#039;$pkgdir&#039;&#039;) should always be quoted using double quotes (i.e., &#039;&#039;&amp;quot;$srcdir&amp;quot;&#039;&#039;).  This is done to prevent things from breaking, should the user have the APKBUILD in a directory path that contains spaces.}}&lt;br /&gt;
{{Note|All arbitrary variable and function names should be prefixed with an underscore character ( _ ) to avoid name clashes with the internals of abuild (for example, &#039;&#039;_luaversions&#039;&#039;).}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined variables ==&lt;br /&gt;
The following variables are defined by abuild:&lt;br /&gt;
&lt;br /&gt;
==== startdir ====&lt;br /&gt;
: The directory where the APKBUILD script is.&lt;br /&gt;
==== srcdir ====&lt;br /&gt;
: The directory where sources, from the &#039;&#039;source&#039;&#039; variable, are downloaded to and unpacked to.&lt;br /&gt;
==== pkgdir ====&lt;br /&gt;
: This directory should receive the files for the main package.  For example, a normal [http://en.wikipedia.org/wiki/GNU_build_system autotools] package would have &amp;lt;code&amp;gt;make DESTDIR=&amp;quot;$pkgdir&amp;quot; install&amp;lt;/code&amp;gt; in the &#039;&#039;package()&#039;&#039; function.&lt;br /&gt;
==== subpkgdir ====&lt;br /&gt;
: This directory should receive the files for a subpackage. This variable should only be used from subpackage functions.&lt;br /&gt;
==== builddir ====&lt;br /&gt;
: This variable should point to the directory inside the &#039;&#039;srcdir&#039;&#039; where the main package source is unpacked.  This is typically &#039;&#039;$srcdir/$pkgname-$pkgver&#039;&#039;.  It’s used by the default &#039;&#039;prepare()&#039;&#039; function as a working directory when applying patches.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User-defined variables ==&lt;br /&gt;
The following variables should be defined by the user:&lt;br /&gt;
==== arch ====&lt;br /&gt;
: Package architecture(s) to build for.  Can be one of: &#039;&#039;&#039;[[x86]], [[x86_64]], [[arm7]], [[armhf]], [[aarch64]], [[ppc64le]], [[s390x]], [[mips64]], all&#039;&#039;&#039;, or &#039;&#039;&#039;noarch&#039;&#039;&#039;, where &#039;&#039;&#039;all&#039;&#039;&#039; means all architectures, and &#039;&#039;&#039;noarch&#039;&#039;&#039; means it&#039;s architecture-independent (e.g., a pure-python package).&lt;br /&gt;
: {{Tip|To determine if your APKBUILD can use &#039;&#039;&#039;noarch&#039;&#039;&#039;: First specify &#039;&#039;&#039;all&#039;&#039;&#039; and then build the package by executing &amp;lt;code&amp;gt;abuild -r&amp;lt;/code&amp;gt;.  Watch the output towards the end for warnings saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used.  If the main package and all subpackages, if you have any subpackages, give a warning saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used, then you can use &#039;&#039;&#039;noarch&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
==== depends ====&lt;br /&gt;
: Run-time dependency package(s) that are not shared-object dependencies.  Shared objects dependencies are auto-detected and should not be specified here.&lt;br /&gt;
==== depends_dev ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
: {{Note|From ncopa on IRC: To find out if you need to add a package to depends_dev have a look at *requires* in usr/lib/pkgconfig/*.pc. With libtool it gets more complicated, but we should delete the .la files. Also check if there are any  /usr/bin/*-configure #!/bin/bash #!/usr/bin/perl or Python. Sometimes scripts or similar are generated at build time (i.e autoconf automake) then you normally don&#039;t need add those to depends_dev. You can also just add all -dev makedepends to depends_dev but it will slow the build process a little bit (more build dependencies).}}&lt;br /&gt;
&lt;br /&gt;
==== depends_doc ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== depends_openrc ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-openrc&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== depends_libs ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-libs&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== depends_static ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-static&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== checkdepends ====&lt;br /&gt;
: Dependencies that are only required during the check phase, they are only installed if the check option is enabled&lt;br /&gt;
&lt;br /&gt;
==== giturl ====&lt;br /&gt;
:Git repository from which &amp;lt;code&amp;gt;abuild checkout&amp;lt;/code&amp;gt; checks out. You can checkout a specific branch in git by adding &amp;lt;code&amp;gt;-b $branch&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== install ====&lt;br /&gt;
: There are 6 different types of install scripts.  Install scripts are named &#039;&#039;&#039;$pkgname.action&#039;&#039;&#039;, where &#039;&#039;&#039;action&#039;&#039;&#039; can be:  &#039;&#039;&#039;pre-install, post-install, pre-upgrade, post-upgrade, pre-deinstall&#039;&#039;&#039;, or &#039;&#039;&#039;post-deinstall&#039;&#039;&#039;.  For example, if &#039;&#039;pkgname&#039;&#039; is set to &#039;&#039;&#039;mypackage&#039;&#039;&#039; and &#039;&#039;install&#039;&#039; is set to &#039;&#039;&#039;$pkgname.post-install&#039;&#039;&#039;, then a script named &#039;&#039;&#039;mypackage.post-install&#039;&#039;&#039; must exist along-side the APKBUILD.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;{{Note|Always use &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt; for the command-line interpreter on the [http://en.wikipedia.org/wiki/Shebang_%28Unix%29 shebang line] of your install scripts.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the different types of install scripts in detail:&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-install =====&lt;br /&gt;
: This script is executed &#039;&#039;before installing&#039;&#039; the package.  Typical use is when the package needs a group and a user to be created. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
addgroup -S clamav 2&amp;gt;/dev/null&lt;br /&gt;
adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|If the script exits with a failure (e.g., if the user already exists), the package will not be installed and &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will exit with failure, hence the &amp;lt;code&amp;gt;exit 0&amp;lt;/code&amp;gt; at the end.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-install =====&lt;br /&gt;
: This script is executed &#039;&#039;after installing&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;before upgrading/downgrading/reinstalling&#039;&#039; the package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;after upgrading/downgrading/reinstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;before uninstalling&#039;&#039; the package.&lt;br /&gt;
: {{Note|If the script exits with failure, &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will not uninstall the package.}}&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;after uninstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
==== install_if ====&lt;br /&gt;
:install_if can be used when a package needs to be installed when some packages are already installed or are in the dependency tree. It works in reverse to the &#039;&#039;recommends&#039;&#039; feature, that other package managers provide.&lt;br /&gt;
&lt;br /&gt;
: Typically this is used in a subpackage that should provide files which make sense with another package. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
subpackages=&amp;quot;$pkgname-bash-completion:bashcomp:noarch&amp;quot;&lt;br /&gt;
...&lt;br /&gt;
bashcomp() {&lt;br /&gt;
	pkgdesc=&amp;quot;Bash completions for $pkgname&amp;quot;&lt;br /&gt;
	install_if=&amp;quot;$pkgname=$pkgver-r$pkgrel bash-completion&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	install -Dm644 &amp;quot;$builddir&amp;quot;/doc/bash_completion/aria2c \&lt;br /&gt;
		&amp;quot;$subpkgdir&amp;quot;/usr/share/bash-completion/completions/_aria2c&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
From the aria2c APKBUILD. Note that the custom bashcomp() function is only necessary, because the files are not in /usr/share/bash-completion.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:In general, install_if should only be used with &#039;&#039;&#039;at least one versioned constraint&#039;&#039;&#039;. Otherwise, a package that was implicitly installed by install_if and then removed from the binary repositories, will not get purged with &amp;lt;code&amp;gt;apk upgrade&amp;lt;/code&amp;gt;. [https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues/10720#note_121298]&lt;br /&gt;
&lt;br /&gt;
==== license ====&lt;br /&gt;
: License(s) for the package, for example &amp;lt;code&amp;gt;GPL-3.0-or-later&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;BSD-2-Clause&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;MIT&amp;lt;/code&amp;gt; [[Creating_an_Alpine_package#license|(details)]].&lt;br /&gt;
&lt;br /&gt;
==== makedepends ====&lt;br /&gt;
: Build-time dependency package(s).&lt;br /&gt;
==== md5sums/sha256sums/sha512sums ====&lt;br /&gt;
: Checksums for the files/URLs listed in &#039;&#039;source&#039;&#039;.  The checksums are normally generated and updated by executing &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; and should be the last item in the APKBUILD.&lt;br /&gt;
&lt;br /&gt;
New packages should use only sha512sums.&lt;br /&gt;
&lt;br /&gt;
==== options ====&lt;br /&gt;
: Build-time options for the package.&lt;br /&gt;
&lt;br /&gt;
: {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!archcheck&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to verify that the architecture of the binary files is the same architecture as abuild should build for. One example where it makes sense to set this are packages with firmware files, that get executed on another CPU (such as WiFi firmware).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to run the &amp;lt;code&amp;gt;check()&amp;lt;/code&amp;gt; function. Please always add a short comment after the &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt; about why it&#039;s disabled. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142545300] Creating a very simple check function, that calls &amp;lt;code&amp;gt;program --version&amp;lt;/code&amp;gt; is worse than disabling tests completely because it gives the false impression that the package is thoroughly tested with the testsuite from upstream. [https://github.com/alpinelinux/aports/pull/7326#discussion_r278797457]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;checkroot&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies that the package&#039;s test suite will be run in &#039;&#039;fakeroot&#039;&#039;. This is necessary for some test suites which fail when run as non-root.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;net&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allows network access when run in &#039;&#039;rootbld&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!strip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Avoid stripping symbols from binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;suid&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allow [https://en.wikipedia.org/wiki/Setuid setuid] binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!tracedeps&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not automatically find dependencies (e.g. by using &amp;lt;code&amp;gt;ldd&amp;lt;/code&amp;gt; to find dynamic libraries, which the resulting binary links against).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;chmod-clean&amp;lt;/code&amp;gt;&lt;br /&gt;
| Make all files writable in the src/ directory. Useful for packages that make files read-only in the process of building packages (go modules).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;toolchain&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t warn when g++ is in makedepends&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!dbg&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t create debugging subpackage&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ldpath-recursive&amp;lt;/code&amp;gt;&lt;br /&gt;
| Scan directories recursively when creating .so providers&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!spdx&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not check if the license= field has a SPDX compliant license&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;textrels&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t error out when text relocations are found&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;charset.alias&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t error out if /usr/lib/charset.alias is found&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;libtool&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t delete libtool .la files&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!fhs&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t enforce checks on path that follow the FHS&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== pkgdesc ====&lt;br /&gt;
: A brief, one-line description of what the package does.&lt;br /&gt;
&lt;br /&gt;
: Here&#039;s an example from the OpenSSH client package:&lt;br /&gt;
: &amp;lt;pre&amp;gt;pkgdesc=&amp;quot;Port of OpenBSD&#039;s free SSH release - client&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== pkggroups ====&lt;br /&gt;
: System group(s) to be created during build-time.  System group(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system group(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgname ====&lt;br /&gt;
: The name of the package.  All letters should be lowercase.&lt;br /&gt;
: {{Note|When creating an APKBUILD of a module or library for another package, we use some common package prefixes, such as: &#039;&#039;lua-&#039;&#039;, &#039;&#039;perl-&#039;&#039;, &#039;&#039;php-&#039;&#039;, and &#039;&#039;py-&#039;&#039;.  Search aports for other common prefixes.}}&lt;br /&gt;
&lt;br /&gt;
==== pkgrel ====&lt;br /&gt;
: Alpine package release number.  Starts at 0 (zero).  Always increment &#039;&#039;pkgrel&#039;&#039; when making updates to an aport; reset &#039;&#039;pkgrel&#039;&#039; to 0 (zero) when incrementing &#039;&#039;pkgver&#039;&#039;.&lt;br /&gt;
==== pkgusers ====&lt;br /&gt;
: System user(s) to be created during build-time.  System user(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system user(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgver ====&lt;br /&gt;
: The version of the software being packaged. Format for valid versions: &amp;lt;code&amp;gt;{digit}{.digit}...{letter}{_suf{#}}...{-r#}&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n17]&lt;br /&gt;
: A Suffix &amp;lt;code&amp;gt;suf&amp;lt;/code&amp;gt; in the above format can be one of the following to indicate that the release is &#039;&#039;less recent&#039;&#039; than the version without the suffix: &amp;lt;code&amp;gt;alpha&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pre&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rc&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n75]&lt;br /&gt;
: These are for indicating &#039;&#039;more recent&#039;&#039; releases: &amp;lt;code&amp;gt;cvs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;svn&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;hg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n76]&lt;br /&gt;
: All other suffices are invalid. To package a specific git commit, the date of the commit gets appended to the latest release, e.g. &amp;lt;code&amp;gt;1.0.0_git20180204&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== provides ====&lt;br /&gt;
: List of package names (and optionally version info) this package provides.&lt;br /&gt;
&lt;br /&gt;
: If package with a version is provided (provides=&#039;foo=1.2&#039;) apk will consider it as an alternate name and it will automatically consider the package for installation by the alternate name, and conflict with other packages having the same name, or provides.&lt;br /&gt;
&lt;br /&gt;
: If version is not provided (provides=&#039;foo&#039;), apk will consider it as virtual package name. Several package with same non-versioned provides can be installed simultaneously. However, none of them will be installed by default when requested by the virtual name - instead, error message is given and user is asked to choose which package providing the virtual name should be installed.&lt;br /&gt;
==== provider_priority ====&lt;br /&gt;
: A numeric value which is used by apk-tools to break ties when choosing a virtual package to satisfy a dependency. Higher values have higher priority. The primary use case is to specify the primary package that satisfies a virtual (provider).&lt;br /&gt;
==== replaces ====&lt;br /&gt;
: Allow this package to be installed at the same time as the listed packages, even if they have conflicting files. The files from this package will override (&amp;quot;take over&amp;quot;) the conflicting files.&lt;br /&gt;
&lt;br /&gt;
: This can be used to override config files with &amp;quot;policy packages&amp;quot; [https://gitlab.alpinelinux.org/alpine/apk-tools/-/commit/89d003f8c2e5a92655ee778f7bfa5c0e85ddbed4].&lt;br /&gt;
&lt;br /&gt;
: Another use case is renaming packages (or moving files from one package to another): &amp;quot;replaces&amp;quot; will avoid the file conflict error that apk reports if it happens to install the new package before uninstalling the old package [https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues/10724#note_132872].&lt;br /&gt;
&lt;br /&gt;
: A common misconception is, that &amp;quot;replaces&amp;quot; is used to replace packages (like in [https://wiki.archlinux.org/index.php/PKGBUILD#replaces PKGBUILD]). This is not the case, it is only for solving file conflicts. To let apk consider installing one package instead of another one, refer to [[#provides|provides]] (with the version).&lt;br /&gt;
&lt;br /&gt;
==== replaces_priority ====&lt;br /&gt;
: The priority of the replaces. If multiple packages replace each other, then will the package with highest &#039;&#039;replaces_priority&#039;&#039; win.&lt;br /&gt;
==== source ====&lt;br /&gt;
: The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[APKBUILD Reference#install|install variable]]), patches, and all other necessary files.&lt;br /&gt;
&lt;br /&gt;
: Here are few things to note:&lt;br /&gt;
&lt;br /&gt;
:* When you are finished adding local and/or remote files to &#039;&#039;source&#039;&#039;, you can execute the following command to add their checksums to the APKBUILD file:&lt;br /&gt;
:: {{Cmd|abuild checksum}}&lt;br /&gt;
:: {{Note|When later updating the content of &#039;&#039;source&#039;&#039;, or updating a file that is listed in &#039;&#039;source&#039;&#039;, you must also update their checksums again with the same command.}}&lt;br /&gt;
&lt;br /&gt;
:* When the remote file is hosted at SourceForge, it&#039;s best to specify the special mirrors link used by SourceForge:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://downloads.sourceforge.net/software/software-$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: (or similar depending on the package).&lt;br /&gt;
&lt;br /&gt;
:* You can set target filename (eg &#039;save as...&#039;) by prefixing the URI with &#039;&#039;filename::&#039;&#039;. This is useful when the remote filename is not specified in the URI (ie, does not end in &#039;/software-1.0.tar.gz&#039;), such as:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: or when the filename is braindead, like githubs&#039; download tags:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: The above two examples needs a target filename prefix:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::http://oss.example.org/?get=software&amp;amp;ver=$pkgver&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: and:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following protocols for remote file retrieval:&lt;br /&gt;
:** http&lt;br /&gt;
:** https&lt;br /&gt;
:** ftp&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following archive types/archive file extensions:&lt;br /&gt;
:** .tar (only in Alpine &amp;gt;= 2.5)&lt;br /&gt;
:** .tar.gz / .tgz&lt;br /&gt;
:** .tar.bz2&lt;br /&gt;
:** .tar.lz (only in Alpine &amp;gt;=3.7)&lt;br /&gt;
:** .tar.lzma&lt;br /&gt;
:** .tar.xz&lt;br /&gt;
:** .zip&lt;br /&gt;
&lt;br /&gt;
:* &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; should only include variables that change often like &amp;lt;code&amp;gt;pkgver&amp;lt;/code&amp;gt; or a commit ID. CI will warn you if you include &amp;lt;code&amp;gt;pkgname&amp;lt;/code&amp;gt; in source. Other variables like for example &amp;lt;code&amp;gt;_pkgname&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;_pyname&amp;lt;/code&amp;gt; do not belong in &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; either.&lt;br /&gt;
&lt;br /&gt;
==== subpackages ====&lt;br /&gt;
: Subpackages built from this APKBUILD.  abuild will parse this variable and try to find a subpackage split function.  The split function must &#039;&#039;move&#039;&#039; files that do not belong in the main package, from &#039;&#039;$pkgdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.  Files and directories can also be &#039;&#039;copied&#039;&#039; from &#039;&#039;$startdir&#039;&#039; and &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: The split function can be specified in 1 of 3 different methods:&lt;br /&gt;
:# subpkgname:&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# $pkgname-&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# &#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
: {{Note|Split function names &#039;&#039;&#039;cannot&#039;&#039;&#039; use hyphens; use the first method above if the subpackage name contains a hyphen (-) character, like this: &#039;&#039;subpkg-name:subpkg_name&#039;&#039;, where &amp;lt;code&amp;gt;subpkg-name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;&#039;&#039; and &amp;lt;code&amp;gt;subpkg_name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;s split function&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
: {{Tip|For more information, see the [[APKBUILD_examples:Subpackages|Subpackages example]].}}&lt;br /&gt;
&lt;br /&gt;
==== triggers ====&lt;br /&gt;
: Apk-tools can &amp;quot;monitor&amp;quot; directories and execute a trigger if any package installed/uninstalled any file in the monitored dir. The triggers are always executed after the apk action (install, uninstall, upgrade).&lt;br /&gt;
&lt;br /&gt;
: The triggers are specified in the format: &#039;&#039;scriptname&#039;&#039;=&#039;&#039;pathlist&#039;&#039; where &#039;&#039;scriptname&#039;&#039; is the (sub)package name + .trigger suffix and pathlist is : separated list of the dirs to monitor.&lt;br /&gt;
&lt;br /&gt;
: The &#039;&#039;&#039;triggers&#039;&#039;&#039; variable must include the triggers for subpackages too if they have any.&lt;br /&gt;
&lt;br /&gt;
: It is possible to use wildcards (*) in the dir list.&lt;br /&gt;
&lt;br /&gt;
==== url ====&lt;br /&gt;
: The homepage for the package.  This is to help users find upstream documentation and other information regarding the package.&lt;br /&gt;
&lt;br /&gt;
==== langdir ====&lt;br /&gt;
: Path to where the language files are located for the &#039;&#039;&#039;-lang&#039;&#039;&#039; subpackage, defaults to &#039;&#039;&#039;/usr/share/locale&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== pcprefix ====&lt;br /&gt;
: Prefix all provides derived from parsing pkg-config Requires: with the value in this variable, example: &#039;&#039;&#039;&#039;pcprefix=&amp;quot;foo:&amp;quot;&#039;&#039;&#039; will produce &#039;&#039;&#039;pc:foo:bar&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== sonameprefix ====&lt;br /&gt;
: Prefix all provides derived from parsing shared objects with the value in this variable, example: &#039;&#039;&#039;sonameprefix=&amp;quot;foo&amp;quot;&#039;&#039;&#039; will produce &#039;&#039;&#039;so:foo:bar.so.X&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
{{Note|All functions that are not &#039;&#039;prepare()&#039;&#039;, &#039;&#039;build()&#039;&#039;, &#039;&#039;check()&#039;&#039; and &#039;&#039;package()&#039;&#039; should consider the current working directory as undefined, and should therefore use the [[APKBUILD Reference#abuild-defined_variables|abuild-defined directory variables]] to their advantage.}}&lt;br /&gt;
&lt;br /&gt;
 sanitycheck() -&amp;gt; clean()-&amp;gt; fetch() -&amp;gt; verify() -&amp;gt; unpack() -&amp;gt; prepare() -&amp;gt; mkusers() -&amp;gt; build() -&amp;gt; check() -&amp;gt; package() -&amp;gt; subpackages() -&amp;gt; language packs -&amp;gt; apk -&amp;gt; cleanup()&lt;br /&gt;
&lt;br /&gt;
== abuild-defined functions ==&lt;br /&gt;
The following functions are provided by abuild and can be overridden, but it is strongly discouraged on code review for some functions:&lt;br /&gt;
&lt;br /&gt;
==== fetch() ====&lt;br /&gt;
: Downloads remote sources listed in &#039;&#039;source&#039;&#039; to &#039;&#039;SRCDEST&#039;&#039; (&#039;&#039;SRCDEST&#039;&#039; is configured in &#039;&#039;/etc/abuild.conf&#039;&#039;) and creates symlinks in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== unpack() ====&lt;br /&gt;
: unpack() will call default_unpack().&lt;br /&gt;
&lt;br /&gt;
: [https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L403 default_unpack()] unpacks .tar, .tgz, .tar.gz, .tar.lz (only available in Alpine &amp;gt;=3.7), .tar.bz2, .tar.lzma, .tar.xz, and .zip archives from a symlink in &#039;&#039;$srcdir&#039;&#039; associated with &#039;&#039;$SRCDEST&#039;&#039; (or distfiles folder) resulting in an unpacked folder in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== dev() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; package is used to collect developer files and folders for use in other packages in the compilation process nothing more.  Without specifying a custom &#039;&#039;dev()&#039;&#039; function, abuild will call its internal &#039;&#039;dev()&#039;&#039; function, which in turn calls default_dev().&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L1605 default_dev()]&#039;&#039; will move any &#039;&#039;include&#039;&#039; folder and folders containing &#039;&#039;*.[acho]&#039;&#039; (static archive, c source, c header file, object file), &#039;&#039;*.prl&#039;&#039; file extension patterns in &#039;&#039;&amp;quot;$pkgdir&amp;quot;/{lib,usr}&#039;&#039; to &#039;&#039;&amp;quot;$subpkgdir&amp;quot;/{lib,usr}&#039;&#039; recursively; and &#039;&#039;*.so&#039;&#039; files from &#039;&#039;&amp;quot;$pkgdir&amp;quot;/{lib,usr/lib}&#039;&#039; to &#039;&#039;&amp;quot;$subpkgdir&amp;quot;/{lib,usr/lib}&#039;&#039;.  It will also scan and move &#039;&#039;usr/{include,lib/{pkgconfig,cmake,qt*/mkspecs},share/{aclocal,gettext,vala/vapi,gir-[0-9]*,qt*/mkspecs},bin/*-config}}&#039;&#039; developer only folders in &#039;&#039;$pkgdir&#039;&#039; and transfer them to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: In general, default_dev() will support packages that share pkg-config, C programming language API, shared and static libraries, Autotools, gettext, Vala programming language bindings, Python GObject introspection, a provided custom pkg-config like command (*-config), Qt, and CMake.  If you have packages that have C++, other languages, other build system, etc; you need to manually move those developer files only if they are to be used in other packages.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: For default_dev() to be called as in no dev(), you need to explicitly add subpackages=&amp;quot;$pkgname-dev&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== doc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; package whose job is only to collect documentation folders from $pkgdir nothing more.  Without specifying a custom &#039;&#039;doc()&#039;&#039; function, abuild will call its internal &#039;&#039;doc()&#039;&#039; function, which in turn calls default_doc().&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L1519 default_doc()]&#039;&#039; will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/{doc,man,info,html,sgml,licenses,gtk-doc,ri,help}&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: Overriding this function is strongly discouraged.  Packaging docs should be done in the package() function while letting abuild automatically collect the doc folders.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: For default_doc() to be called as in no doc(), you need to explicitly add subpackages=&amp;quot;$pkgname-doc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== openrc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-opernc&#039;&#039;&#039; package whose job is to collect OpenRC service files that are in /etc/init.d and /etc/conf.d.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L1661 default_openrc()]&#039;&#039; will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/etc/{conf,init}.d&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: Overriding this function is strongly discouraged. Packaging OpenRC service definitions should be in the package() function while letting abuild automatically collect the openrc folders.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: for default_openrc() to be called as in no openrc(), you need to explicitly add subpackages=&amp;quot;$pkgname-openrc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== static() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-static&#039;&#039;&#039; package whose job is to collect static libraries that are stored in /lib and /usr/lib.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.4.0_rc4/abuild.in#L1748 default_static()]&#039;&#039; will move all static libraries (files ending with .a) from &#039;&#039;&amp;quot;$pkgdir&amp;quot;/lib&#039;&#039; and &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/lib&#039;&#039; to their equivalents in &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: Overriding this function is strongly discouraged. Packaging static libraries should be done in the package() function while letting abuild automatically collect the static libraries.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: for default_static() to be called as in no static(), you need to explicitly add subpackages=&amp;quot;$pkgname-static&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== snapshot() ====&lt;br /&gt;
: &#039;&#039;&#039;Optional&#039;&#039;&#039;.  For live APKBUILDs or those with a _cvs, _svn, _git, _hg in their version number, you should create a snapshot function only if there is no download link to an archive file (.zip, .tar.gz, ...) to the commit/hash/tag.  The purpose of the snapshot function is to create an archive of the source code so that the package source code is deterministic, and it doesn&#039;t waste time to fetch the source code but bypasses the download step after snapshotting.  Those that download the source code from a git repository will follow head or the latest change to the source code.  It is better to archive the source code as a zip / tar.gz / tar.bz2 up to the commit or the tag which you are trying to build a package.  If it is not deterministic or not every part of the code frozen in time for every dependency and the main project, then the patches will fail or the package may fail to compile when you revisit the package months or years to backport a patch.&lt;br /&gt;
&lt;br /&gt;
: The default [https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L2310 snapshot()] function has variables associated with it:&lt;br /&gt;
:* $disturl - the base-url of the place to autoupload the snapshot&lt;br /&gt;
:* $svnurl - Subversion repository &lt;br /&gt;
:* $giturl - Git repository&lt;br /&gt;
&lt;br /&gt;
: The default snapshot() can only support one repository.  It is better to override it if there are multiple repositories involved in your package.  CVS, Mercurial (hg), and alternative version control systems must override the default snapshot().&lt;br /&gt;
&lt;br /&gt;
: See [[APKBUILD_examples:Git_checkout]] to how to use it with git.  It takes 2-3 general steps.  Clone the repository; check it out at a specific revision/commit or tag; then you use an archiver to dump it in the &#039;&#039;$SRCDEST&#039;&#039; variable which points to the distfiles folder and the base path to the full path to the archive that you want to create.  You do this for every internal dependency that the package pulls.&lt;br /&gt;
&lt;br /&gt;
: After you have created your snapshot function, you use &amp;lt;code&amp;gt;abuild snapshot&amp;lt;/code&amp;gt; to run it.  &lt;br /&gt;
&lt;br /&gt;
: The archives produced by the snapshot will be saved in &#039;&#039;/var/cache/distfiles&#039;&#039; or whatever you set for &#039;&#039;$SRCDEST&#039;&#039;.  You may need to create symlinks to the archive if the archive is not saved to the Alpine server.&lt;br /&gt;
&lt;br /&gt;
: After you snapshot it, you need to produce the checksums with &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; to use it in the APKBUILD creation process.&lt;br /&gt;
&lt;br /&gt;
: This feature is available since Alpine &amp;gt;=2.6.&lt;br /&gt;
&lt;br /&gt;
==== default_prepare() ====&lt;br /&gt;
&lt;br /&gt;
:  Before build preparation it handles set of patches inside &amp;lt;code&amp;gt;$srcdir&amp;lt;/code&amp;gt; and prints failed ones.&lt;br /&gt;
&lt;br /&gt;
== User-defined functions ==&lt;br /&gt;
The following functions should be defined by the user: &lt;br /&gt;
&lt;br /&gt;
==== prepare() ====&lt;br /&gt;
: {{note|Please adjust old APKBUILDs, which still have a &#039;&#039;prepare()&#039;&#039; function that does the same as the &#039;&#039;default_prepare()&#039;&#039; when you edit them anyway.}}&lt;br /&gt;
: &#039;&#039;&#039;&#039;&#039;Optional&#039;&#039;.&#039;&#039;&#039;  Used for build preparation: patches, etc, should be applied here. When you don&#039;t specify a custom &#039;&#039;prepare()&#039;&#039;, the built-in &#039;&#039;default_prepare()&#039;&#039; from abuild will be used. It applies patches already (always prepare them in the &amp;lt;code&amp;gt;-p1&amp;lt;/code&amp;gt; format), so &#039;&#039;&#039;usually it makes sense to not create a custom &#039;&#039;prepare()&#039;&#039; function at all!&#039;&#039;&#039; If you do create one, call &#039;&#039;default_prepare()&#039;&#039; inside it:&lt;br /&gt;
&lt;br /&gt;
: Before default_prepare gets called, you can define &#039;&#039;patch_args&#039;&#039; to supply the argument to the patch command in global scope then throw away prepare() so it is unnecessary to use the old template code floating around to patch.  patch_args and autopatching is only available in Alpine &amp;gt;=3.4.  See [[Creating_an_Alpine_package#Patches]] to fix the patch that uses a different patch level (-pX).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
prepare() {&lt;br /&gt;
    default_prepare&lt;br /&gt;
    # your custom code here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== build() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the compilation stage.  This function will be called as the current user (unless the &#039;&#039;package()&#039;&#039; function is missing - for compatibility reasons).  If no compilation is needed, this function can contain a single line: &amp;lt;code&amp;gt;return 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: To enable or disable CFLAGS, CXXFLAGS, CMake with option, or configure option per arch, use the CARCH variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local cmakeoptions=&lt;br /&gt;
case &amp;quot;$CARCH&amp;quot; in&lt;br /&gt;
        aarch64*|arm*|ppc64le|x86|s390x) cmakeoptions=&amp;quot;$cmakeoptions -DWITH_OPENMP=OFF&amp;quot; ;;&lt;br /&gt;
        x86_64)                          cmakeoptions=&amp;quot;$cmakeoptions -DWITH_OPENMP=ON&amp;quot; ;;&lt;br /&gt;
        *)                               msg &amp;quot;Unable to determine architecture from (CARCH=$CARCH)&amp;quot; ; return 1 ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
: The block can be used in other parts of the APKBUILD even in global.&lt;br /&gt;
&lt;br /&gt;
==== check() ====&lt;br /&gt;
: &#039;&#039;&#039;Required if functionality exists.&#039;&#039;&#039; This function is called right after the build stage.  It should check that the packaged thing is actually working, typically by running (integration) tests, if provided by upstream.  If there’s no (easy) way how to test the package, you can declare that it does not want to use &#039;&#039;check()&#039;&#039; by adding &amp;quot;!check&amp;quot; into the &#039;&#039;options&#039;&#039; variable (&amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
: default_check() does nothing.  You need to manually explicitly call the unit tests or test suite yourself.  When you run the test, the program should return with an exit code of 0, indicating the tests were a success.  Unit tests or test suites will do feature tests, per function correctness check, fuzz testing, benchmarks.&lt;br /&gt;
&lt;br /&gt;
: A package may also require additional testing frameworks packages that are external dependencies.  You should add those to the &#039;&#039;checkdepends=&#039;&#039; in Alpine &amp;gt;=3.6 or &#039;&#039;makedepends=&#039;&#039; for older for backporters.  If the testing framework is not available, you need to create a package for it.  If it requires a specific version of a testing framework, consider making it an internal dependency or a new package with a package name containing the major and minor version number like the python packages.&lt;br /&gt;
&lt;br /&gt;
: Generally speaking, you should define the check functions for libraries, large programs like web browsers, or compilers and interpreters, cryptographic/security/anonymity stuff, mission critical stuff, PCI compliance/money/accounting software, server software with a lot of stakeholders or consumers.  Soon for the new policy change will have virtually &#039;&#039;&#039;all packages with testing capabilities be required to have a working and defined check() function&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: There are times when the unit tests do not work, just because the test itself is broken, new unimplemented feature, external factors not taken into consideration, unbundling path differences, breakage caused by ccache, missing test dependency or version mismatch dependency as in python2 vs python3, test scripts only work for particular language implementation like only supporting python2 but not python3 having used the 2to3 conversion script.  If a unit test is known not to work, you may need to patch it to omit that test or fix it; but, certain tests should not be disabled if it is important.  You may need to alter the references to uncompiled internal dependencies to work with the external dependencies instead.  For ccache, you can either disable it or remove it from the PATH environmental variable before running tests.&lt;br /&gt;
&lt;br /&gt;
{{Note|Tests for graphical applications and toolkits might work on a X11 user setup but will fail on the server unless run with xvfb-run.}}&lt;br /&gt;
&lt;br /&gt;
: If you don&#039;t add the &#039;&#039;check()&#039;&#039; and the &#039;&#039;options=&#039;&#039;, this is what you will see:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; WARNING: py-webtest*: APKBUILD does not run any tests!&lt;br /&gt;
    Alpine policy will soon require that packages have any relevant testsuites run during the build process.&lt;br /&gt;
    To fix, either define a check() function, or declare !check in $options to indicate the package does not have a testsuite.&lt;br /&gt;
&lt;br /&gt;
: If you do not do a check or disable it, you must state there is no testsuite in comment form (#) next to options=&amp;quot;!check&amp;quot; for the code reviewers.&lt;br /&gt;
&lt;br /&gt;
: To run test suite with autotools do:&lt;br /&gt;
&lt;br /&gt;
  make check&lt;br /&gt;
&lt;br /&gt;
: To run the test suite with python setuptools:&lt;br /&gt;
&lt;br /&gt;
  python2 setup.py test&lt;br /&gt;
  python3 setup.py test&lt;br /&gt;
&lt;br /&gt;
: For python it should be &#039;&#039;&#039;test&#039;&#039;&#039; not check.  Check for python setuptools will check the packaging metadata fields[https://docs.python.org/3/distutils/examples.html#checking-a-package] only but not run the unit tests.  There should be verbose output also.  The dependencies for the tests are found in test_require in the setup.py.&lt;br /&gt;
&lt;br /&gt;
: If it says &amp;lt;code&amp;gt;Ran 0 tests in 0.000s&amp;lt;/code&amp;gt; that is not acceptable.  check() will say it was good but it is not actually correct.  It needs to run the test suite with an alternative method like &amp;lt;code&amp;gt;tox -e py27,py36&amp;lt;/code&amp;gt; if you see a tox.ini file.&lt;br /&gt;
&lt;br /&gt;
: You want to do it for each implementation to ensure that the API calls are correct per implementation but ncopa said it was just fine with python3.&lt;br /&gt;
&lt;br /&gt;
: If there is a circular dependency for the checkdepends=, you need to disable the check and put the reason next to &amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt; that there is a circular dependency.  You should disable it for the package that package that is least important or least security risk.  The other solution is to make the conflicting dependency an internal dependency but making sure that it doesn&#039;t pull it at check time.  This way they can both preform tests properly.&lt;br /&gt;
&lt;br /&gt;
==== package() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the packaging stage.  Here, the built application and support files should be installed into &#039;&#039;&#039;$pkgdir&#039;&#039;&#039;.  If this is a metapackage, this function can contain a single line: &amp;lt;code&amp;gt;mkdir -p &amp;quot;$pkgdir&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Building in fakeroot will reduce performance for parallel builds dramatically.  It is for this reason that we split the build and package process into two separate functions.}}&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
The [[APKBUILD examples]] page will assist you in understanding how to create an APKBUILD.&lt;br /&gt;
&lt;br /&gt;
= Version =&lt;br /&gt;
&lt;br /&gt;
This document assumes abuild for Alpine Edge.  For older releases of abuild, some of these features may not be available if you are using an older release.  A link to the implementation is linked for researchers and backporters.&lt;br /&gt;
&lt;br /&gt;
For more information see [[APKBUILD_versions]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=18183</id>
		<title>APKBUILD Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=18183"/>
		<updated>2020-11-12T13:13:32Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: /* replaces */ replacing and replaced pkg can be installed at same time, use case &amp;quot;policy packages&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;APKBUILDs are the scripts that are created in order to build Alpine packages using the [[abuild]] tool.&lt;br /&gt;
&lt;br /&gt;
See [[aports]] for details on Alpine&#039;s official ports repository.&lt;br /&gt;
&lt;br /&gt;
This page is intended to serve as a reference for creating APKBUILDs; if this is your first time creating a package for Alpine Linux, please see [[Creating an Alpine package]].&lt;br /&gt;
&lt;br /&gt;
= Legend =&lt;br /&gt;
The following notes will assist you in understanding this document.&lt;br /&gt;
&lt;br /&gt;
In description text:&lt;br /&gt;
* If a variable is not prefixed with a &#039;&#039;$&#039;&#039;, it will be represented by italics (i.e., &#039;&#039;srcdir&#039;&#039; ).&lt;br /&gt;
* Functions will also be represented by italics, but will also end with a pair of parentheses (i.e., &#039;&#039;build()&#039;&#039; ).&lt;br /&gt;
* Shell commands will be represented &amp;lt;code&amp;gt;like this&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Variables =&lt;br /&gt;
{{Note|Variables that contain a path (e.g. &#039;&#039;$srcdir&#039;&#039; and &#039;&#039;$pkgdir&#039;&#039;) should always be quoted using double quotes (i.e., &#039;&#039;&amp;quot;$srcdir&amp;quot;&#039;&#039;).  This is done to prevent things from breaking, should the user have the APKBUILD in a directory path that contains spaces.}}&lt;br /&gt;
{{Note|All arbitrary variable and function names should be prefixed with an underscore character ( _ ) to avoid name clashes with the internals of abuild (for example, &#039;&#039;_luaversions&#039;&#039;).}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined variables ==&lt;br /&gt;
The following variables are defined by abuild:&lt;br /&gt;
&lt;br /&gt;
==== startdir ====&lt;br /&gt;
: The directory where the APKBUILD script is.&lt;br /&gt;
==== srcdir ====&lt;br /&gt;
: The directory where sources, from the &#039;&#039;source&#039;&#039; variable, are downloaded to and unpacked to.&lt;br /&gt;
==== pkgdir ====&lt;br /&gt;
: This directory should receive the files for the main package.  For example, a normal [http://en.wikipedia.org/wiki/GNU_build_system autotools] package would have &amp;lt;code&amp;gt;make DESTDIR=&amp;quot;$pkgdir&amp;quot; install&amp;lt;/code&amp;gt; in the &#039;&#039;package()&#039;&#039; function.&lt;br /&gt;
==== subpkgdir ====&lt;br /&gt;
: This directory should receive the files for a subpackage. This variable should only be used from subpackage functions.&lt;br /&gt;
==== builddir ====&lt;br /&gt;
: This variable should point to the directory inside the &#039;&#039;srcdir&#039;&#039; where the main package source is unpacked.  This is typically &#039;&#039;$srcdir/$pkgname-$pkgver&#039;&#039;.  It’s used by the default &#039;&#039;prepare()&#039;&#039; function as a working directory when applying patches.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User-defined variables ==&lt;br /&gt;
The following variables should be defined by the user:&lt;br /&gt;
==== arch ====&lt;br /&gt;
: Package architecture(s) to build for.  Can be one of: &#039;&#039;&#039;[[x86]], [[x86_64]], [[armhf]], [[aarch64]], [[ppc64le]], [[s390x]], all&#039;&#039;&#039;, or &#039;&#039;&#039;noarch&#039;&#039;&#039;, where &#039;&#039;&#039;all&#039;&#039;&#039; means all architectures, and &#039;&#039;&#039;noarch&#039;&#039;&#039; means it&#039;s architecture-independent (e.g., a pure-python package).&lt;br /&gt;
: {{Tip|To determine if your APKBUILD can use &#039;&#039;&#039;noarch&#039;&#039;&#039;: First specify &#039;&#039;&#039;all&#039;&#039;&#039; and then build the package by executing &amp;lt;code&amp;gt;abuild -r&amp;lt;/code&amp;gt;.  Watch the output towards the end for warnings saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used.  If the main package and all subpackages, if you have any subpackages, give a warning saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used, then you can use &#039;&#039;&#039;noarch&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
==== depends ====&lt;br /&gt;
: Run-time dependency package(s) that are not shared-object dependencies.  Shared objects dependencies are auto-detected and should not be specified here.&lt;br /&gt;
==== depends_dev ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
: {{Note|From ncopa on IRC: To find out if you need to add a package to depends_dev have a look at *requires* in usr/lib/pkgconfig/*.pc. With libtool it gets more complicated, but we should delete the .la files. Also check if there are any  /usr/bin/*-configure #!/bin/bash #!/usr/bin/perl or Python. Sometimes scripts or similar are generated at build time (i.e autoconf automake) then you normally don&#039;t need add those to depends_dev. You can also just add all -dev makedepends to depends_dev but it will slow the build process a little bit (more build dependencies).}}&lt;br /&gt;
&lt;br /&gt;
==== depends_doc ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== depends_openrc ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-openrc&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== depends_libs ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-libs&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== depends_static ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-static&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== checkdepends ====&lt;br /&gt;
: Dependencies that are only required during the check phase, they are only installed if the check option is enabled&lt;br /&gt;
&lt;br /&gt;
==== giturl ====&lt;br /&gt;
:Git repository from which &amp;lt;code&amp;gt;abuild checkout&amp;lt;/code&amp;gt; checks out. You can checkout a specific branch in git by adding &amp;lt;code&amp;gt;-b $branch&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== install ====&lt;br /&gt;
: There are 6 different types of install scripts.  Install scripts are named &#039;&#039;&#039;$pkgname.action&#039;&#039;&#039;, where &#039;&#039;&#039;action&#039;&#039;&#039; can be:  &#039;&#039;&#039;pre-install, post-install, pre-upgrade, post-upgrade, pre-deinstall&#039;&#039;&#039;, or &#039;&#039;&#039;post-deinstall&#039;&#039;&#039;.  For example, if &#039;&#039;pkgname&#039;&#039; is set to &#039;&#039;&#039;mypackage&#039;&#039;&#039; and &#039;&#039;install&#039;&#039; is set to &#039;&#039;&#039;$pkgname.post-install&#039;&#039;&#039;, then a script named &#039;&#039;&#039;mypackage.post-install&#039;&#039;&#039; must exist along-side the APKBUILD.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;{{Note|Always use &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt; for the command-line interpreter on the [http://en.wikipedia.org/wiki/Shebang_%28Unix%29 shebang line] of your install scripts.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the different types of install scripts in detail:&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-install =====&lt;br /&gt;
: This script is executed &#039;&#039;before installing&#039;&#039; the package.  Typical use is when the package needs a group and a user to be created. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
addgroup -S clamav 2&amp;gt;/dev/null&lt;br /&gt;
adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|If the script exits with a failure (e.g., if the user already exists), the package will not be installed and &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will exit with failure, hence the &amp;lt;code&amp;gt;exit 0&amp;lt;/code&amp;gt; at the end.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-install =====&lt;br /&gt;
: This script is executed &#039;&#039;after installing&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;before upgrading/downgrading/reinstalling&#039;&#039; the package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;after upgrading/downgrading/reinstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;before uninstalling&#039;&#039; the package.&lt;br /&gt;
: {{Note|If the script exits with failure, &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will not uninstall the package.}}&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;after uninstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
==== install_if ====&lt;br /&gt;
:install_if can be used when a package needs to be installed when some packages are already installed or are in the dependency tree. It works in reverse to the &#039;&#039;recommends&#039;&#039; feature, that other package managers provide.&lt;br /&gt;
&lt;br /&gt;
: Typically this is used in a subpackage that should provide files which make sense with another package. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
subpackages=&amp;quot;$pkgname-bash-completion:bashcomp:noarch&amp;quot;&lt;br /&gt;
...&lt;br /&gt;
bashcomp() {&lt;br /&gt;
	pkgdesc=&amp;quot;Bash completions for $pkgname&amp;quot;&lt;br /&gt;
	install_if=&amp;quot;$pkgname=$pkgver-r$pkgrel bash-completion&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	install -Dm644 &amp;quot;$builddir&amp;quot;/doc/bash_completion/aria2c \&lt;br /&gt;
		&amp;quot;$subpkgdir&amp;quot;/usr/share/bash-completion/completions/_aria2c&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
From the aria2c APKBUILD. Note that the custom bashcomp() function is only necessary, because the files are not in /usr/share/bash-completion.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:In general, install_if should only be used with &#039;&#039;&#039;at least one versioned constraint&#039;&#039;&#039;. Otherwise, a package that was implicitly installed by install_if and then removed from the binary repositories, will not get purged with &amp;lt;code&amp;gt;apk upgrade&amp;lt;/code&amp;gt;. [https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues/10720#note_121298]&lt;br /&gt;
&lt;br /&gt;
==== license ====&lt;br /&gt;
: License(s) for the package, for example &amp;lt;code&amp;gt;GPL-3.0-or-later&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;BSD-2-Clause&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;MIT&amp;lt;/code&amp;gt; [[Creating_an_Alpine_package#license|(details)]].&lt;br /&gt;
&lt;br /&gt;
==== makedepends ====&lt;br /&gt;
: Build-time dependency package(s).&lt;br /&gt;
==== md5sums/sha256sums/sha512sums ====&lt;br /&gt;
: Checksums for the files/URLs listed in &#039;&#039;source&#039;&#039;.  The checksums are normally generated and updated by executing &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; and should be the last item in the APKBUILD.&lt;br /&gt;
&lt;br /&gt;
New packages should use only sha512sums.&lt;br /&gt;
&lt;br /&gt;
==== options ====&lt;br /&gt;
: Build-time options for the package.&lt;br /&gt;
&lt;br /&gt;
: {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!archcheck&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to verify that the architecture of the binary files is the same architecture as abuild should build for. One example where it makes sense to set this are packages with firmware files, that get executed on another CPU (such as WiFi firmware).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to run the &amp;lt;code&amp;gt;check()&amp;lt;/code&amp;gt; function. Please always add a short comment after the &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt; about why it&#039;s disabled. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142545300] Creating a very simple check function, that calls &amp;lt;code&amp;gt;program --version&amp;lt;/code&amp;gt; is worse than disabling tests completely because it gives the false impression that the package is thoroughly tested with the testsuite from upstream. [https://github.com/alpinelinux/aports/pull/7326#discussion_r278797457]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;checkroot&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies that the package&#039;s test suite will be run in &#039;&#039;fakeroot&#039;&#039;. This is necessary for some test suites which fail when run as non-root.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;net&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allows network access when run in &#039;&#039;rootbld&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!strip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Avoid stripping symbols from binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;suid&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allow [https://en.wikipedia.org/wiki/Setuid setuid] binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!tracedeps&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not automatically find dependencies (e.g. by using &amp;lt;code&amp;gt;ldd&amp;lt;/code&amp;gt; to find dynamic libraries, which the resulting binary links against).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;chmod-clean&amp;lt;/code&amp;gt;&lt;br /&gt;
| Make all files writable in the src/ directory. Useful for packages that make files read-only in the process of building packages (go modules).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;toolchain&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t warn when g++ is in makedepends&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!dbg&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t create debugging subpackage&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ldpath-recursive&amp;lt;/code&amp;gt;&lt;br /&gt;
| Scan directories recursively when creating .so providers&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!spdx&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not check if the license= field has a SPDX compliant license&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;textrels&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t error out when text relocations are found&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;charset.alias&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t error out if /usr/lib/charset.alias is found&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;libtool&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t delete libtool .la files&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!fhs&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t enforce checks on path that follow the FHS&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== pkgdesc ====&lt;br /&gt;
: A brief, one-line description of what the package does.&lt;br /&gt;
&lt;br /&gt;
: Here&#039;s an example from the OpenSSH client package:&lt;br /&gt;
: &amp;lt;pre&amp;gt;pkgdesc=&amp;quot;Port of OpenBSD&#039;s free SSH release - client&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== pkggroups ====&lt;br /&gt;
: System group(s) to be created during build-time.  System group(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system group(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgname ====&lt;br /&gt;
: The name of the package.  All letters should be lowercase.&lt;br /&gt;
: {{Note|When creating an APKBUILD of a module or library for another package, we use some common package prefixes, such as: &#039;&#039;lua-&#039;&#039;, &#039;&#039;perl-&#039;&#039;, &#039;&#039;php-&#039;&#039;, and &#039;&#039;py-&#039;&#039;.  Search aports for other common prefixes.}}&lt;br /&gt;
&lt;br /&gt;
==== pkgrel ====&lt;br /&gt;
: Alpine package release number.  Starts at 0 (zero).  Always increment &#039;&#039;pkgrel&#039;&#039; when making updates to an aport; reset &#039;&#039;pkgrel&#039;&#039; to 0 (zero) when incrementing &#039;&#039;pkgver&#039;&#039;.&lt;br /&gt;
==== pkgusers ====&lt;br /&gt;
: System user(s) to be created during build-time.  System user(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system user(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgver ====&lt;br /&gt;
: The version of the software being packaged. Format for valid versions: &amp;lt;code&amp;gt;{digit}{.digit}...{letter}{_suf{#}}...{-r#}&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n17]&lt;br /&gt;
: A Suffix &amp;lt;code&amp;gt;suf&amp;lt;/code&amp;gt; in the above format can be one of the following to indicate that the release is &#039;&#039;less recent&#039;&#039; than the version without the suffix: &amp;lt;code&amp;gt;alpha&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pre&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rc&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n75]&lt;br /&gt;
: These are for indicating &#039;&#039;more recent&#039;&#039; releases: &amp;lt;code&amp;gt;cvs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;svn&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;hg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n76]&lt;br /&gt;
: All other suffices are invalid. To package a specific git commit, the date of the commit gets appended to the latest release, e.g. &amp;lt;code&amp;gt;1.0.0_git20180204&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== provides ====&lt;br /&gt;
: List of package names (and optionally version info) this package provides.&lt;br /&gt;
&lt;br /&gt;
: If package with a version is provided (provides=&#039;foo=1.2&#039;) apk will consider it as an alternate name and it will automatically consider the package for installation by the alternate name, and conflict with other packages having the same name, or provides.&lt;br /&gt;
&lt;br /&gt;
: If version is not provided (provides=&#039;foo&#039;), apk will consider it as virtual package name. Several package with same non-versioned provides can be installed simultaneously. However, none of them will be installed by default when requested by the virtual name - instead, error message is given and user is asked to choose which package providing the virtual name should be installed.&lt;br /&gt;
==== provider_priority ====&lt;br /&gt;
: A numeric value which is used by apk-tools to break ties when choosing a virtual package to satisfy a dependency. Higher values have higher priority. The primary use case is to specify the primary package that satisfies a virtual (provider).&lt;br /&gt;
==== replaces ====&lt;br /&gt;
: Package(s) that this package replaces.  This package will &amp;quot;take over&amp;quot; files owned by packages listed in the &#039;&#039;replaces&#039;&#039; variable.  This is useful when files move from one package to another, or when a package gets renamed.&lt;br /&gt;
&lt;br /&gt;
: The replaced package and the replacing package can be installed at the same time. A use case for this is replacing config files in &amp;quot;policy packages&amp;quot; [https://gitlab.alpinelinux.org/alpine/apk-tools/-/commit/89d003f8c2e5a92655ee778f7bfa5c0e85ddbed4].&lt;br /&gt;
&lt;br /&gt;
==== replaces_priority ====&lt;br /&gt;
: The priority of the replaces. If multiple packages replace each other, then will the package with highest &#039;&#039;replaces_priority&#039;&#039; win.&lt;br /&gt;
==== source ====&lt;br /&gt;
: The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[APKBUILD Reference#install|install variable]]), patches, and all other necessary files.&lt;br /&gt;
&lt;br /&gt;
: Here are few things to note:&lt;br /&gt;
&lt;br /&gt;
:* When you are finished adding local and/or remote files to &#039;&#039;source&#039;&#039;, you can execute the following command to add their checksums to the APKBUILD file:&lt;br /&gt;
:: {{Cmd|abuild checksum}}&lt;br /&gt;
:: {{Note|When later updating the content of &#039;&#039;source&#039;&#039;, or updating a file that is listed in &#039;&#039;source&#039;&#039;, you must also update their checksums again with the same command.}}&lt;br /&gt;
&lt;br /&gt;
:* When the remote file is hosted at SourceForge, it&#039;s best to specify the special mirrors link used by SourceForge:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://downloads.sourceforge.net/software/software-$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: (or similar depending on the package).&lt;br /&gt;
&lt;br /&gt;
:* You can set target filename (eg &#039;save as...&#039;) by prefixing the URI with &#039;&#039;filename::&#039;&#039;. This is useful when the remote filename is not specified in the URI (ie, does not end in &#039;/software-1.0.tar.gz&#039;), such as:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: or when the filename is braindead, like githubs&#039; download tags:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: The above two examples needs a target filename prefix:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::http://oss.example.org/?get=software&amp;amp;ver=$pkgver&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: and:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following protocols for remote file retrieval:&lt;br /&gt;
:** http&lt;br /&gt;
:** https&lt;br /&gt;
:** ftp&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following archive types/archive file extensions:&lt;br /&gt;
:** .tar (only in Alpine &amp;gt;= 2.5)&lt;br /&gt;
:** .tar.gz / .tgz&lt;br /&gt;
:** .tar.bz2&lt;br /&gt;
:** .tar.lz (only in Alpine &amp;gt;=3.7)&lt;br /&gt;
:** .tar.lzma&lt;br /&gt;
:** .tar.xz&lt;br /&gt;
:** .zip&lt;br /&gt;
&lt;br /&gt;
:* &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; should only include variables that change often like &amp;lt;code&amp;gt;pkgver&amp;lt;/code&amp;gt; or a commit ID. CI will warn you if you include &amp;lt;code&amp;gt;pkgname&amp;lt;/code&amp;gt; in source. Other variables like for example &amp;lt;code&amp;gt;_pkgname&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;_pyname&amp;lt;/code&amp;gt; do not belong in &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; either.&lt;br /&gt;
&lt;br /&gt;
==== subpackages ====&lt;br /&gt;
: Subpackages built from this APKBUILD.  abuild will parse this variable and try to find a subpackage split function.  The split function must &#039;&#039;move&#039;&#039; files that do not belong in the main package, from &#039;&#039;$pkgdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.  Files and directories can also be &#039;&#039;copied&#039;&#039; from &#039;&#039;$startdir&#039;&#039; and &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: The split function can be specified in 1 of 3 different methods:&lt;br /&gt;
:# subpkgname:&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# $pkgname-&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# &#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
: {{Note|Split function names &#039;&#039;&#039;cannot&#039;&#039;&#039; use hyphens; use the first method above if the subpackage name contains a hyphen (-) character, like this: &#039;&#039;subpkg-name:subpkg_name&#039;&#039;, where &amp;lt;code&amp;gt;subpkg-name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;&#039;&#039; and &amp;lt;code&amp;gt;subpkg_name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;s split function&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
: {{Tip|For more information, see the [[APKBUILD_examples:Subpackages|Subpackages example]].}}&lt;br /&gt;
&lt;br /&gt;
==== triggers ====&lt;br /&gt;
: Apk-tools can &amp;quot;monitor&amp;quot; directories and execute a trigger if any package installed/uninstalled any file in the monitored dir. The triggers are always executed after the apk action (install, uninstall, upgrade).&lt;br /&gt;
&lt;br /&gt;
: The triggers are specified in the format: &#039;&#039;scriptname&#039;&#039;=&#039;&#039;pathlist&#039;&#039; where &#039;&#039;scriptname&#039;&#039; is the (sub)package name + .trigger suffix and pathlist is : separated list of the dirs to monitor.&lt;br /&gt;
&lt;br /&gt;
: The &#039;&#039;&#039;triggers&#039;&#039;&#039; variable must include the triggers for subpackages too if they have any.&lt;br /&gt;
&lt;br /&gt;
: It is possible to use wildcards (*) in the dir list.&lt;br /&gt;
&lt;br /&gt;
==== url ====&lt;br /&gt;
: The homepage for the package.  This is to help users find upstream documentation and other information regarding the package.&lt;br /&gt;
&lt;br /&gt;
==== langdir ====&lt;br /&gt;
: Path to where the language files are located for the &#039;&#039;&#039;-lang&#039;&#039;&#039; subpackage, defaults to &#039;&#039;&#039;/usr/share/locale&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== pcprefix ====&lt;br /&gt;
: Prefix all provides derived from parsing pkg-config Requires: with the value in this variable, example: &#039;&#039;&#039;&#039;pcprefix=&amp;quot;foo:&amp;quot;&#039;&#039;&#039; will produce &#039;&#039;&#039;pc:foo:bar&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== sonameprefix ====&lt;br /&gt;
: Prefix all provides derived from parsing shared objects with the value in this variable, example: &#039;&#039;&#039;sonameprefix=&amp;quot;foo&amp;quot;&#039;&#039;&#039; will produce &#039;&#039;&#039;so:foo:bar.so.X&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
{{Note|All functions that are not &#039;&#039;prepare()&#039;&#039;, &#039;&#039;build()&#039;&#039;, &#039;&#039;check()&#039;&#039; and &#039;&#039;package()&#039;&#039; should consider the current working directory as undefined, and should therefore use the [[APKBUILD Reference#abuild-defined_variables|abuild-defined directory variables]] to their advantage.}}&lt;br /&gt;
&lt;br /&gt;
 sanitycheck() -&amp;gt; clean()-&amp;gt; fetch() -&amp;gt; verify() -&amp;gt; unpack() -&amp;gt; prepare() -&amp;gt; mkusers() -&amp;gt; build() -&amp;gt; check() -&amp;gt; package() -&amp;gt; subpackages() -&amp;gt; language packs -&amp;gt; apk -&amp;gt; cleanup()&lt;br /&gt;
&lt;br /&gt;
== abuild-defined functions ==&lt;br /&gt;
The following functions are provided by abuild and can be overridden, but it is strongly discouraged on code review for some functions:&lt;br /&gt;
&lt;br /&gt;
==== fetch() ====&lt;br /&gt;
: Downloads remote sources listed in &#039;&#039;source&#039;&#039; to &#039;&#039;SRCDEST&#039;&#039; (&#039;&#039;SRCDEST&#039;&#039; is configured in &#039;&#039;/etc/abuild.conf&#039;&#039;) and creates symlinks in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== unpack() ====&lt;br /&gt;
: unpack() will call default_unpack().&lt;br /&gt;
&lt;br /&gt;
: [https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L403 default_unpack()] unpacks .tar, .tgz, .tar.gz, .tar.lz (only available in Alpine &amp;gt;=3.7), .tar.bz2, .tar.lzma, .tar.xz, and .zip archives from a symlink in &#039;&#039;$srcdir&#039;&#039; associated with &#039;&#039;$SRCDEST&#039;&#039; (or distfiles folder) resulting in an unpacked folder in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== dev() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; package is used to collect developer files and folders for use in other packages in the compilation process nothing more.  Without specifying a custom &#039;&#039;dev()&#039;&#039; function, abuild will call its internal &#039;&#039;dev()&#039;&#039; function, which in turn calls default_dev().&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L1605 default_dev()]&#039;&#039; will move any &#039;&#039;include&#039;&#039; folder and folders containing &#039;&#039;*.[acho]&#039;&#039; (static archive, c source, c header file, object file), &#039;&#039;*.prl&#039;&#039; file extension patterns in &#039;&#039;&amp;quot;$pkgdir&amp;quot;/{lib,usr}&#039;&#039; to &#039;&#039;&amp;quot;$subpkgdir&amp;quot;/{lib,usr}&#039;&#039; recursively; and &#039;&#039;*.so&#039;&#039; files from &#039;&#039;&amp;quot;$pkgdir&amp;quot;/{lib,usr/lib}&#039;&#039; to &#039;&#039;&amp;quot;$subpkgdir&amp;quot;/{lib,usr/lib}&#039;&#039;.  It will also scan and move &#039;&#039;usr/{include,lib/{pkgconfig,cmake,qt*/mkspecs},share/{aclocal,gettext,vala/vapi,gir-[0-9]*,qt*/mkspecs},bin/*-config}}&#039;&#039; developer only folders in &#039;&#039;$pkgdir&#039;&#039; and transfer them to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: In general, default_dev() will support packages that share pkg-config, C programming language API, shared and static libraries, Autotools, gettext, Vala programming language bindings, Python GObject introspection, a provided custom pkg-config like command (*-config), Qt, and CMake.  If you have packages that have C++, other languages, other build system, etc; you need to manually move those developer files only if they are to be used in other packages.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: For default_dev() to be called as in no dev(), you need to explicitly add subpackages=&amp;quot;$pkgname-dev&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== doc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; package whose job is only to collect documentation folders from $pkgdir nothing more.  Without specifying a custom &#039;&#039;doc()&#039;&#039; function, abuild will call its internal &#039;&#039;doc()&#039;&#039; function, which in turn calls default_doc().&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L1519 default_doc()]&#039;&#039; will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/{doc,man,info,html,sgml,licenses,gtk-doc,ri,help}&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: Overriding this function is strongly discouraged.  Packaging docs should be done in the package() function while letting abuild automatically collect the doc folders.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: For default_doc() to be called as in no doc(), you need to explicitly add subpackages=&amp;quot;$pkgname-doc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== openrc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-opernc&#039;&#039;&#039; package whose job is to collect OpenRC service files that are in /etc/init.d and /etc/conf.d.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L1661 default_openrc()]&#039;&#039; will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/etc/{conf,init}.d&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: Overriding this function is strongly discouraged. Packaging OpenRC service definitions should be in the package() function while letting abuild automatically collect the openrc folders.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: for default_openrc() to be called as in no openrc(), you need to explicitly add subpackages=&amp;quot;$pkgname-openrc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== static() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-static&#039;&#039;&#039; package whose job is to collect static libraries that are stored in /lib and /usr/lib.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.4.0_rc4/abuild.in#L1748 default_static()]&#039;&#039; will move all static libraries (files ending with .a) from &#039;&#039;&amp;quot;$pkgdir&amp;quot;/lib&#039;&#039; and &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/lib&#039;&#039; to their equivalents in &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: Overriding this function is strongly discouraged. Packaging static libraries should be done in the package() function while letting abuild automatically collect the static libraries.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: for default_static() to be called as in no static(), you need to explicitly add subpackages=&amp;quot;$pkgname-static&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== snapshot() ====&lt;br /&gt;
: &#039;&#039;&#039;Optional&#039;&#039;&#039;.  For live APKBUILDs or those with a _cvs, _svn, _git, _hg in their version number, you should create a snapshot function only if there is no download link to an archive file (.zip, .tar.gz, ...) to the commit/hash/tag.  The purpose of the snapshot function is to create an archive of the source code so that the package source code is deterministic, and it doesn&#039;t waste time to fetch the source code but bypasses the download step after snapshotting.  Those that download the source code from a git repository will follow head or the latest change to the source code.  It is better to archive the source code as a zip / tar.gz / tar.bz2 up to the commit or the tag which you are trying to build a package.  If it is not deterministic or not every part of the code frozen in time for every dependency and the main project, then the patches will fail or the package may fail to compile when you revisit the package months or years to backport a patch.&lt;br /&gt;
&lt;br /&gt;
: The default [https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L2310 snapshot()] function has variables associated with it:&lt;br /&gt;
:* $disturl - the base-url of the place to autoupload the snapshot&lt;br /&gt;
:* $svnurl - Subversion repository &lt;br /&gt;
:* $giturl - Git repository&lt;br /&gt;
&lt;br /&gt;
: The default snapshot() can only support one repository.  It is better to override it if there are multiple repositories involved in your package.  CVS, Mercurial (hg), and alternative version control systems must override the default snapshot().&lt;br /&gt;
&lt;br /&gt;
: See [[APKBUILD_examples:Git_checkout]] to how to use it with git.  It takes 2-3 general steps.  Clone the repository; check it out at a specific revision/commit or tag; then you use an archiver to dump it in the &#039;&#039;$SRCDEST&#039;&#039; variable which points to the distfiles folder and the base path to the full path to the archive that you want to create.  You do this for every internal dependency that the package pulls.&lt;br /&gt;
&lt;br /&gt;
: After you have created your snapshot function, you use &amp;lt;code&amp;gt;abuild snapshot&amp;lt;/code&amp;gt; to run it.  &lt;br /&gt;
&lt;br /&gt;
: The archives produced by the snapshot will be saved in &#039;&#039;/var/cache/distfiles&#039;&#039; or whatever you set for &#039;&#039;$SRCDEST&#039;&#039;.  You may need to create symlinks to the archive if the archive is not saved to the Alpine server.&lt;br /&gt;
&lt;br /&gt;
: After you snapshot it, you need to produce the checksums with &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; to use it in the APKBUILD creation process.&lt;br /&gt;
&lt;br /&gt;
: This feature is available since Alpine &amp;gt;=2.6.&lt;br /&gt;
&lt;br /&gt;
==== default_prepare() ====&lt;br /&gt;
&lt;br /&gt;
:  Before build preparation it handles set of patches inside &amp;lt;code&amp;gt;$srcdir&amp;lt;/code&amp;gt; and prints failed ones.&lt;br /&gt;
&lt;br /&gt;
== User-defined functions ==&lt;br /&gt;
The following functions should be defined by the user: &lt;br /&gt;
&lt;br /&gt;
==== prepare() ====&lt;br /&gt;
: {{note|Please adjust old APKBUILDs, which still have a &#039;&#039;prepare()&#039;&#039; function that does the same as the &#039;&#039;default_prepare()&#039;&#039; when you edit them anyway.}}&lt;br /&gt;
: &#039;&#039;&#039;&#039;&#039;Optional&#039;&#039;.&#039;&#039;&#039;  Used for build preparation: patches, etc, should be applied here. When you don&#039;t specify a custom &#039;&#039;prepare()&#039;&#039;, the built-in &#039;&#039;default_prepare()&#039;&#039; from abuild will be used. It applies patches already (always prepare them in the &amp;lt;code&amp;gt;-p1&amp;lt;/code&amp;gt; format), so &#039;&#039;&#039;usually it makes sense to not create a custom &#039;&#039;prepare()&#039;&#039; function at all!&#039;&#039;&#039; If you do create one, call &#039;&#039;default_prepare()&#039;&#039; inside it:&lt;br /&gt;
&lt;br /&gt;
: Before default_prepare gets called, you can define &#039;&#039;patch_args&#039;&#039; to supply the argument to the patch command in global scope then throw away prepare() so it is unnecessary to use the old template code floating around to patch.  patch_args and autopatching is only available in Alpine &amp;gt;=3.4.  See [[Creating_an_Alpine_package#Patches]] to fix the patch that uses a different patch level (-pX).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
prepare() {&lt;br /&gt;
    default_prepare&lt;br /&gt;
    # your custom code here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== build() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the compilation stage.  This function will be called as the current user (unless the &#039;&#039;package()&#039;&#039; function is missing - for compatibility reasons).  If no compilation is needed, this function can contain a single line: &amp;lt;code&amp;gt;return 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: To enable or disable CFLAGS, CXXFLAGS, CMake with option, or configure option per arch, use the CARCH variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local cmakeoptions=&lt;br /&gt;
case &amp;quot;$CARCH&amp;quot; in&lt;br /&gt;
        aarch64*|arm*|ppc64le|x86|s390x) cmakeoptions=&amp;quot;$cmakeoptions -DWITH_OPENMP=OFF&amp;quot; ;;&lt;br /&gt;
        x86_64)                          cmakeoptions=&amp;quot;$cmakeoptions -DWITH_OPENMP=ON&amp;quot; ;;&lt;br /&gt;
        *)                               msg &amp;quot;Unable to determine architecture from (CARCH=$CARCH)&amp;quot; ; return 1 ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
: The block can be used in other parts of the APKBUILD even in global.&lt;br /&gt;
&lt;br /&gt;
==== check() ====&lt;br /&gt;
: &#039;&#039;&#039;Required if functionality exists.&#039;&#039;&#039; This function is called right after the build stage.  It should check that the packaged thing is actually working, typically by running (integration) tests, if provided by upstream.  If there’s no (easy) way how to test the package, you can declare that it does not want to use &#039;&#039;check()&#039;&#039; by adding &amp;quot;!check&amp;quot; into the &#039;&#039;options&#039;&#039; variable (&amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
: default_check() does nothing.  You need to manually explicitly call the unit tests or test suite yourself.  When you run the test, the program should return with an exit code of 0, indicating the tests were a success.  Unit tests or test suites will do feature tests, per function correctness check, fuzz testing, benchmarks.&lt;br /&gt;
&lt;br /&gt;
: A package may also require additional testing frameworks packages that are external dependencies.  You should add those to the &#039;&#039;checkdepends=&#039;&#039; in Alpine &amp;gt;=3.6 or &#039;&#039;makedepends=&#039;&#039; for older for backporters.  If the testing framework is not available, you need to create a package for it.  If it requires a specific version of a testing framework, consider making it an internal dependency or a new package with a package name containing the major and minor version number like the python packages.&lt;br /&gt;
&lt;br /&gt;
: Generally speaking, you should define the check functions for libraries, large programs like web browsers, or compilers and interpreters, cryptographic/security/anonymity stuff, mission critical stuff, PCI compliance/money/accounting software, server software with a lot of stakeholders or consumers.  Soon for the new policy change will have virtually &#039;&#039;&#039;all packages with testing capabilities be required to have a working and defined check() function&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: There are times when the unit tests do not work, just because the test itself is broken, new unimplemented feature, external factors not taken into consideration, unbundling path differences, breakage caused by ccache, missing test dependency or version mismatch dependency as in python2 vs python3, test scripts only work for particular language implementation like only supporting python2 but not python3 having used the 2to3 conversion script.  If a unit test is known not to work, you may need to patch it to omit that test or fix it; but, certain tests should not be disabled if it is important.  You may need to alter the references to uncompiled internal dependencies to work with the external dependencies instead.  For ccache, you can either disable it or remove it from the PATH environmental variable before running tests.&lt;br /&gt;
&lt;br /&gt;
{{Note|Tests for graphical applications and toolkits might work on a X11 user setup but will fail on the server unless run with xvfb-run.}}&lt;br /&gt;
&lt;br /&gt;
: If you don&#039;t add the &#039;&#039;check()&#039;&#039; and the &#039;&#039;options=&#039;&#039;, this is what you will see:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; WARNING: py-webtest*: APKBUILD does not run any tests!&lt;br /&gt;
    Alpine policy will soon require that packages have any relevant testsuites run during the build process.&lt;br /&gt;
    To fix, either define a check() function, or declare !check in $options to indicate the package does not have a testsuite.&lt;br /&gt;
&lt;br /&gt;
: If you do not do a check or disable it, you must state there is no testsuite in comment form (#) next to options=&amp;quot;!check&amp;quot; for the code reviewers.&lt;br /&gt;
&lt;br /&gt;
: To run test suite with autotools do:&lt;br /&gt;
&lt;br /&gt;
  make check&lt;br /&gt;
&lt;br /&gt;
: To run the test suite with python setuptools:&lt;br /&gt;
&lt;br /&gt;
  python2 setup.py test&lt;br /&gt;
  python3 setup.py test&lt;br /&gt;
&lt;br /&gt;
: For python it should be &#039;&#039;&#039;test&#039;&#039;&#039; not check.  Check for python setuptools will check the packaging metadata fields[https://docs.python.org/3/distutils/examples.html#checking-a-package] only but not run the unit tests.  There should be verbose output also.  The dependencies for the tests are found in test_require in the setup.py.&lt;br /&gt;
&lt;br /&gt;
: If it says &amp;lt;code&amp;gt;Ran 0 tests in 0.000s&amp;lt;/code&amp;gt; that is not acceptable.  check() will say it was good but it is not actually correct.  It needs to run the test suite with an alternative method like &amp;lt;code&amp;gt;tox -e py27,py36&amp;lt;/code&amp;gt; if you see a tox.ini file.&lt;br /&gt;
&lt;br /&gt;
: You want to do it for each implementation to ensure that the API calls are correct per implementation but ncopa said it was just fine with python3.&lt;br /&gt;
&lt;br /&gt;
: If there is a circular dependency for the checkdepends=, you need to disable the check and put the reason next to &amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt; that there is a circular dependency.  You should disable it for the package that package that is least important or least security risk.  The other solution is to make the conflicting dependency an internal dependency but making sure that it doesn&#039;t pull it at check time.  This way they can both preform tests properly.&lt;br /&gt;
&lt;br /&gt;
==== package() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the packaging stage.  Here, the built application and support files should be installed into &#039;&#039;&#039;$pkgdir&#039;&#039;&#039;.  If this is a metapackage, this function can contain a single line: &amp;lt;code&amp;gt;mkdir -p &amp;quot;$pkgdir&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Building in fakeroot will reduce performance for parallel builds dramatically.  It is for this reason that we split the build and package process into two separate functions.}}&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
The [[APKBUILD examples]] page will assist you in understanding how to create an APKBUILD.&lt;br /&gt;
&lt;br /&gt;
= Version =&lt;br /&gt;
&lt;br /&gt;
This document assumes abuild for Alpine Edge.  For older releases of abuild, some of these features may not be available if you are using an older release.  A link to the implementation is linked for researchers and backporters.&lt;br /&gt;
&lt;br /&gt;
For more information see [[APKBUILD_versions]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=18141</id>
		<title>APKBUILD Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=18141"/>
		<updated>2020-11-02T18:00:58Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: /* install_if */ provide real world example, note that install_if should be used with at least one versioned constraint&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;APKBUILDs are the scripts that are created in order to build Alpine packages using the [[abuild]] tool.&lt;br /&gt;
&lt;br /&gt;
See [[aports]] for details on Alpine&#039;s official ports repository.&lt;br /&gt;
&lt;br /&gt;
This page is intended to serve as a reference for creating APKBUILDs; if this is your first time creating a package for Alpine Linux, please see [[Creating an Alpine package]].&lt;br /&gt;
&lt;br /&gt;
= Legend =&lt;br /&gt;
The following notes will assist you in understanding this document.&lt;br /&gt;
&lt;br /&gt;
In description text:&lt;br /&gt;
* If a variable is not prefixed with a &#039;&#039;$&#039;&#039;, it will be represented by italics (i.e., &#039;&#039;srcdir&#039;&#039; ).&lt;br /&gt;
* Functions will also be represented by italics, but will also end with a pair of parentheses (i.e., &#039;&#039;build()&#039;&#039; ).&lt;br /&gt;
* Shell commands will be represented &amp;lt;code&amp;gt;like this&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Variables =&lt;br /&gt;
{{Note|Variables that contain a path (e.g. &#039;&#039;$srcdir&#039;&#039; and &#039;&#039;$pkgdir&#039;&#039;) should always be quoted using double quotes (i.e., &#039;&#039;&amp;quot;$srcdir&amp;quot;&#039;&#039;).  This is done to prevent things from breaking, should the user have the APKBUILD in a directory path that contains spaces.}}&lt;br /&gt;
{{Note|All arbitrary variable and function names should be prefixed with an underscore character ( _ ) to avoid name clashes with the internals of abuild (for example, &#039;&#039;_luaversions&#039;&#039;).}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined variables ==&lt;br /&gt;
The following variables are defined by abuild:&lt;br /&gt;
&lt;br /&gt;
==== startdir ====&lt;br /&gt;
: The directory where the APKBUILD script is.&lt;br /&gt;
==== srcdir ====&lt;br /&gt;
: The directory where sources, from the &#039;&#039;source&#039;&#039; variable, are downloaded to and unpacked to.&lt;br /&gt;
==== pkgdir ====&lt;br /&gt;
: This directory should receive the files for the main package.  For example, a normal [http://en.wikipedia.org/wiki/GNU_build_system autotools] package would have &amp;lt;code&amp;gt;make DESTDIR=&amp;quot;$pkgdir&amp;quot; install&amp;lt;/code&amp;gt; in the &#039;&#039;package()&#039;&#039; function.&lt;br /&gt;
==== subpkgdir ====&lt;br /&gt;
: This directory should receive the files for a subpackage. This variable should only be used from subpackage functions.&lt;br /&gt;
==== builddir ====&lt;br /&gt;
: This variable should point to the directory inside the &#039;&#039;srcdir&#039;&#039; where the main package source is unpacked.  This is typically &#039;&#039;$srcdir/$pkgname-$pkgver&#039;&#039;.  It’s used by the default &#039;&#039;prepare()&#039;&#039; function as a working directory when applying patches.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User-defined variables ==&lt;br /&gt;
The following variables should be defined by the user:&lt;br /&gt;
==== arch ====&lt;br /&gt;
: Package architecture(s) to build for.  Can be one of: &#039;&#039;&#039;[[x86]], [[x86_64]], [[armhf]], [[aarch64]], [[ppc64le]], [[s390x]], all&#039;&#039;&#039;, or &#039;&#039;&#039;noarch&#039;&#039;&#039;, where &#039;&#039;&#039;all&#039;&#039;&#039; means all architectures, and &#039;&#039;&#039;noarch&#039;&#039;&#039; means it&#039;s architecture-independent (e.g., a pure-python package).&lt;br /&gt;
: {{Tip|To determine if your APKBUILD can use &#039;&#039;&#039;noarch&#039;&#039;&#039;: First specify &#039;&#039;&#039;all&#039;&#039;&#039; and then build the package by executing &amp;lt;code&amp;gt;abuild -r&amp;lt;/code&amp;gt;.  Watch the output towards the end for warnings saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used.  If the main package and all subpackages, if you have any subpackages, give a warning saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used, then you can use &#039;&#039;&#039;noarch&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
==== depends ====&lt;br /&gt;
: Run-time dependency package(s) that are not shared-object dependencies.  Shared objects dependencies are auto-detected and should not be specified here.&lt;br /&gt;
==== depends_dev ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
: {{Note|From ncopa on IRC: To find out if you need to add a package to depends_dev have a look at *requires* in usr/lib/pkgconfig/*.pc. With libtool it gets more complicated, but we should delete the .la files. Also check if there are any  /usr/bin/*-configure #!/bin/bash #!/usr/bin/perl or Python. Sometimes scripts or similar are generated at build time (i.e autoconf automake) then you normally don&#039;t need add those to depends_dev. You can also just add all -dev makedepends to depends_dev but it will slow the build process a little bit (more build dependencies).}}&lt;br /&gt;
&lt;br /&gt;
==== depends_doc ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== depends_openrc ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-openrc&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== depends_libs ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-libs&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== depends_static ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-static&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
==== checkdepends ====&lt;br /&gt;
: Dependencies that are only required during the check phase, they are only installed if the check option is enabled&lt;br /&gt;
&lt;br /&gt;
==== giturl ====&lt;br /&gt;
:Git repository from which &amp;lt;code&amp;gt;abuild checkout&amp;lt;/code&amp;gt; checks out. You can checkout a specific branch in git by adding &amp;lt;code&amp;gt;-b $branch&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== install ====&lt;br /&gt;
: There are 6 different types of install scripts.  Install scripts are named &#039;&#039;&#039;$pkgname.action&#039;&#039;&#039;, where &#039;&#039;&#039;action&#039;&#039;&#039; can be:  &#039;&#039;&#039;pre-install, post-install, pre-upgrade, post-upgrade, pre-deinstall&#039;&#039;&#039;, or &#039;&#039;&#039;post-deinstall&#039;&#039;&#039;.  For example, if &#039;&#039;pkgname&#039;&#039; is set to &#039;&#039;&#039;mypackage&#039;&#039;&#039; and &#039;&#039;install&#039;&#039; is set to &#039;&#039;&#039;$pkgname.post-install&#039;&#039;&#039;, then a script named &#039;&#039;&#039;mypackage.post-install&#039;&#039;&#039; must exist along-side the APKBUILD.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;{{Note|Always use &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt; for the command-line interpreter on the [http://en.wikipedia.org/wiki/Shebang_%28Unix%29 shebang line] of your install scripts.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the different types of install scripts in detail:&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-install =====&lt;br /&gt;
: This script is executed &#039;&#039;before installing&#039;&#039; the package.  Typical use is when the package needs a group and a user to be created. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
addgroup -S clamav 2&amp;gt;/dev/null&lt;br /&gt;
adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|If the script exits with a failure (e.g., if the user already exists), the package will not be installed and &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will exit with failure, hence the &amp;lt;code&amp;gt;exit 0&amp;lt;/code&amp;gt; at the end.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-install =====&lt;br /&gt;
: This script is executed &#039;&#039;after installing&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;before upgrading/downgrading/reinstalling&#039;&#039; the package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;after upgrading/downgrading/reinstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;before uninstalling&#039;&#039; the package.&lt;br /&gt;
: {{Note|If the script exits with failure, &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will not uninstall the package.}}&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;after uninstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
==== install_if ====&lt;br /&gt;
:install_if can be used when a package needs to be installed when some packages are already installed or are in the dependency tree. It works in reverse to the &#039;&#039;recommends&#039;&#039; feature, that other package managers provide.&lt;br /&gt;
&lt;br /&gt;
: Typically this is used in a subpackage that should provide files which make sense with another package. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
subpackages=&amp;quot;$pkgname-bash-completion:bashcomp:noarch&amp;quot;&lt;br /&gt;
...&lt;br /&gt;
bashcomp() {&lt;br /&gt;
	pkgdesc=&amp;quot;Bash completions for $pkgname&amp;quot;&lt;br /&gt;
	install_if=&amp;quot;$pkgname=$pkgver-r$pkgrel bash-completion&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	install -Dm644 &amp;quot;$builddir&amp;quot;/doc/bash_completion/aria2c \&lt;br /&gt;
		&amp;quot;$subpkgdir&amp;quot;/usr/share/bash-completion/completions/_aria2c&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
From the aria2c APKBUILD. Note that the custom bashcomp() function is only necessary, because the files are not in /usr/share/bash-completion.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:In general, install_if should only be used with &#039;&#039;&#039;at least one versioned constraint&#039;&#039;&#039;. Otherwise, a package that was implicitly installed by install_if and then removed from the binary repositories, will not get purged with &amp;lt;code&amp;gt;apk upgrade&amp;lt;/code&amp;gt;. [https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues/10720#note_121298]&lt;br /&gt;
&lt;br /&gt;
==== license ====&lt;br /&gt;
: License(s) for the package, for example &amp;lt;code&amp;gt;GPL-3.0-or-later&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;BSD-2-Clause&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;MIT&amp;lt;/code&amp;gt; [[Creating_an_Alpine_package#license|(details)]].&lt;br /&gt;
&lt;br /&gt;
==== makedepends ====&lt;br /&gt;
: Build-time dependency package(s).&lt;br /&gt;
==== md5sums/sha256sums/sha512sums ====&lt;br /&gt;
: Checksums for the files/URLs listed in &#039;&#039;source&#039;&#039;.  The checksums are normally generated and updated by executing &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; and should be the last item in the APKBUILD.&lt;br /&gt;
&lt;br /&gt;
New packages should use only sha512sums.&lt;br /&gt;
&lt;br /&gt;
==== options ====&lt;br /&gt;
: Build-time options for the package.&lt;br /&gt;
&lt;br /&gt;
: {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!archcheck&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to verify that the architecture of the binary files is the same architecture as abuild should build for. One example where it makes sense to set this are packages with firmware files, that get executed on another CPU (such as WiFi firmware).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to run the &amp;lt;code&amp;gt;check()&amp;lt;/code&amp;gt; function. Please always add a short comment after the &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt; about why it&#039;s disabled. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142545300] Creating a very simple check function, that calls &amp;lt;code&amp;gt;program --version&amp;lt;/code&amp;gt; is worse than disabling tests completely because it gives the false impression that the package is thoroughly tested with the testsuite from upstream. [https://github.com/alpinelinux/aports/pull/7326#discussion_r278797457]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;checkroot&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specifies that the package&#039;s test suite will be run in &#039;&#039;fakeroot&#039;&#039;. This is necessary for some test suites which fail when run as non-root.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;net&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allows network access when run in &#039;&#039;rootbld&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!strip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Avoid stripping symbols from binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;suid&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allow [https://en.wikipedia.org/wiki/Setuid setuid] binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!tracedeps&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not automatically find dependencies (e.g. by using &amp;lt;code&amp;gt;ldd&amp;lt;/code&amp;gt; to find dynamic libraries, which the resulting binary links against).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;chmod-clean&amp;lt;/code&amp;gt;&lt;br /&gt;
| Make all files writable in the src/ directory. Useful for packages that make files read-only in the process of building packages (go modules).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;toolchain&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t warn when g++ is in makedepends&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!dbg&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t create debugging subpackage&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ldpath-recursive&amp;lt;/code&amp;gt;&lt;br /&gt;
| Scan directories recursively when creating .so providers&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!spdx&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not check if the license= field has a SPDX compliant license&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;textrels&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t error out when text relocations are found&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;charset.alias&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t error out if /usr/lib/charset.alias is found&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;libtool&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t delete libtool .la files&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!fhs&amp;lt;/code&amp;gt;&lt;br /&gt;
| Don&#039;t enforce checks on path that follow the FHS&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== pkgdesc ====&lt;br /&gt;
: A brief, one-line description of what the package does.&lt;br /&gt;
&lt;br /&gt;
: Here&#039;s an example from the OpenSSH client package:&lt;br /&gt;
: &amp;lt;pre&amp;gt;pkgdesc=&amp;quot;Port of OpenBSD&#039;s free SSH release - client&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== pkggroups ====&lt;br /&gt;
: System group(s) to be created during build-time.  System group(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system group(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgname ====&lt;br /&gt;
: The name of the package.  All letters should be lowercase.&lt;br /&gt;
: {{Note|When creating an APKBUILD of a module or library for another package, we use some common package prefixes, such as: &#039;&#039;lua-&#039;&#039;, &#039;&#039;perl-&#039;&#039;, &#039;&#039;php-&#039;&#039;, and &#039;&#039;py-&#039;&#039;.  Search aports for other common prefixes.}}&lt;br /&gt;
&lt;br /&gt;
==== pkgrel ====&lt;br /&gt;
: Alpine package release number.  Starts at 0 (zero).  Always increment &#039;&#039;pkgrel&#039;&#039; when making updates to an aport; reset &#039;&#039;pkgrel&#039;&#039; to 0 (zero) when incrementing &#039;&#039;pkgver&#039;&#039;.&lt;br /&gt;
==== pkgusers ====&lt;br /&gt;
: System user(s) to be created during build-time.  System user(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system user(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgver ====&lt;br /&gt;
: The version of the software being packaged. Format for valid versions: &amp;lt;code&amp;gt;{digit}{.digit}...{letter}{_suf{#}}...{-r#}&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n17]&lt;br /&gt;
: A Suffix &amp;lt;code&amp;gt;suf&amp;lt;/code&amp;gt; in the above format can be one of the following to indicate that the release is &#039;&#039;less recent&#039;&#039; than the version without the suffix: &amp;lt;code&amp;gt;alpha&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pre&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rc&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n75]&lt;br /&gt;
: These are for indicating &#039;&#039;more recent&#039;&#039; releases: &amp;lt;code&amp;gt;cvs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;svn&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;hg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n76]&lt;br /&gt;
: All other suffices are invalid. To package a specific git commit, the date of the commit gets appended to the latest release, e.g. &amp;lt;code&amp;gt;1.0.0_git20180204&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== provides ====&lt;br /&gt;
: List of package names (and optionally version info) this package provides.&lt;br /&gt;
&lt;br /&gt;
: If package with a version is provided (provides=&#039;foo=1.2&#039;) apk will consider it as an alternate name and it will automatically consider the package for installation by the alternate name, and conflict with other packages having the same name, or provides.&lt;br /&gt;
&lt;br /&gt;
: If version is not provided (provides=&#039;foo&#039;), apk will consider it as virtual package name. Several package with same non-versioned provides can be installed simultaneously. However, none of them will be installed by default when requested by the virtual name - instead, error message is given and user is asked to choose which package providing the virtual name should be installed.&lt;br /&gt;
==== provider_priority ====&lt;br /&gt;
: A numeric value which is used by apk-tools to break ties when choosing a virtual package to satisfy a dependency. Higher values have higher priority. The primary use case is to specify the primary package that satisfies a virtual (provider).&lt;br /&gt;
==== replaces ====&lt;br /&gt;
: Package(s) that this package replaces.  This package will &amp;quot;take over&amp;quot; files owned by packages listed in the &#039;&#039;replaces&#039;&#039; variable.  This is useful when files move from one package to another, or when a package gets renamed.&lt;br /&gt;
==== replaces_priority ====&lt;br /&gt;
: The priority of the replaces. If multiple packages replace each other, then will the package with highest &#039;&#039;replaces_priority&#039;&#039; win.&lt;br /&gt;
==== source ====&lt;br /&gt;
: The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[APKBUILD Reference#install|install variable]]), patches, and all other necessary files.&lt;br /&gt;
&lt;br /&gt;
: Here are few things to note:&lt;br /&gt;
&lt;br /&gt;
:* When you are finished adding local and/or remote files to &#039;&#039;source&#039;&#039;, you can execute the following command to add their checksums to the APKBUILD file:&lt;br /&gt;
:: {{Cmd|abuild checksum}}&lt;br /&gt;
:: {{Note|When later updating the content of &#039;&#039;source&#039;&#039;, or updating a file that is listed in &#039;&#039;source&#039;&#039;, you must also update their checksums again with the same command.}}&lt;br /&gt;
&lt;br /&gt;
:* When the remote file is hosted at SourceForge, it&#039;s best to specify the special mirrors link used by SourceForge:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://downloads.sourceforge.net/software/software-$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: (or similar depending on the package).&lt;br /&gt;
&lt;br /&gt;
:* You can set target filename (eg &#039;save as...&#039;) by prefixing the URI with &#039;&#039;filename::&#039;&#039;. This is useful when the remote filename is not specified in the URI (ie, does not end in &#039;/software-1.0.tar.gz&#039;), such as:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: or when the filename is braindead, like githubs&#039; download tags:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: The above two examples needs a target filename prefix:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::http://oss.example.org/?get=software&amp;amp;ver=$pkgver&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: and:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following protocols for remote file retrieval:&lt;br /&gt;
:** http&lt;br /&gt;
:** https&lt;br /&gt;
:** ftp&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following archive types/archive file extensions:&lt;br /&gt;
:** .tar (only in Alpine &amp;gt;= 2.5)&lt;br /&gt;
:** .tar.gz / .tgz&lt;br /&gt;
:** .tar.bz2&lt;br /&gt;
:** .tar.lz (only in Alpine &amp;gt;=3.7)&lt;br /&gt;
:** .tar.lzma&lt;br /&gt;
:** .tar.xz&lt;br /&gt;
:** .zip&lt;br /&gt;
&lt;br /&gt;
:* &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; should only include variables that change often like &amp;lt;code&amp;gt;pkgver&amp;lt;/code&amp;gt; or a commit ID. CI will warn you if you include &amp;lt;code&amp;gt;pkgname&amp;lt;/code&amp;gt; in source. Other variables like for example &amp;lt;code&amp;gt;_pkgname&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;_pyname&amp;lt;/code&amp;gt; do not belong in &amp;lt;code&amp;gt;source&amp;lt;/code&amp;gt; either.&lt;br /&gt;
&lt;br /&gt;
==== subpackages ====&lt;br /&gt;
: Subpackages built from this APKBUILD.  abuild will parse this variable and try to find a subpackage split function.  The split function must &#039;&#039;move&#039;&#039; files that do not belong in the main package, from &#039;&#039;$pkgdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.  Files and directories can also be &#039;&#039;copied&#039;&#039; from &#039;&#039;$startdir&#039;&#039; and &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: The split function can be specified in 1 of 3 different methods:&lt;br /&gt;
:# subpkgname:&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# $pkgname-&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# &#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
: {{Note|Split function names &#039;&#039;&#039;cannot&#039;&#039;&#039; use hyphens; use the first method above if the subpackage name contains a hyphen (-) character, like this: &#039;&#039;subpkg-name:subpkg_name&#039;&#039;, where &amp;lt;code&amp;gt;subpkg-name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;&#039;&#039; and &amp;lt;code&amp;gt;subpkg_name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;s split function&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
: {{Tip|For more information, see the [[APKBUILD_examples:Subpackages|Subpackages example]].}}&lt;br /&gt;
&lt;br /&gt;
==== triggers ====&lt;br /&gt;
: Apk-tools can &amp;quot;monitor&amp;quot; directories and execute a trigger if any package installed/uninstalled any file in the monitored dir. The triggers are always executed after the apk action (install, uninstall, upgrade).&lt;br /&gt;
&lt;br /&gt;
: The triggers are specified in the format: &#039;&#039;scriptname&#039;&#039;=&#039;&#039;pathlist&#039;&#039; where &#039;&#039;scriptname&#039;&#039; is the (sub)package name + .trigger suffix and pathlist is : separated list of the dirs to monitor.&lt;br /&gt;
&lt;br /&gt;
: The &#039;&#039;&#039;triggers&#039;&#039;&#039; variable must include the triggers for subpackages too if they have any.&lt;br /&gt;
&lt;br /&gt;
: It is possible to use wildcards (*) in the dir list.&lt;br /&gt;
&lt;br /&gt;
==== url ====&lt;br /&gt;
: The homepage for the package.  This is to help users find upstream documentation and other information regarding the package.&lt;br /&gt;
&lt;br /&gt;
==== langdir ====&lt;br /&gt;
: Path to where the language files are located for the &#039;&#039;&#039;-lang&#039;&#039;&#039; subpackage, defaults to &#039;&#039;&#039;/usr/share/locale&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== pcprefix ====&lt;br /&gt;
: Prefix all provides derived from parsing pkg-config Requires: with the value in this variable, example: &#039;&#039;&#039;&#039;pcprefix=&amp;quot;foo:&amp;quot;&#039;&#039;&#039; will produce &#039;&#039;&#039;pc:foo:bar&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== sonameprefix ====&lt;br /&gt;
: Prefix all provides derived from parsing shared objects with the value in this variable, example: &#039;&#039;&#039;sonameprefix=&amp;quot;foo&amp;quot;&#039;&#039;&#039; will produce &#039;&#039;&#039;so:foo:bar.so.X&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
{{Note|All functions that are not &#039;&#039;prepare()&#039;&#039;, &#039;&#039;build()&#039;&#039;, &#039;&#039;check()&#039;&#039; and &#039;&#039;package()&#039;&#039; should consider the current working directory as undefined, and should therefore use the [[APKBUILD Reference#abuild-defined_variables|abuild-defined directory variables]] to their advantage.}}&lt;br /&gt;
&lt;br /&gt;
 sanitycheck() -&amp;gt; clean()-&amp;gt; fetch() -&amp;gt; verify() -&amp;gt; unpack() -&amp;gt; prepare() -&amp;gt; mkusers() -&amp;gt; build() -&amp;gt; check() -&amp;gt; package() -&amp;gt; subpackages() -&amp;gt; language packs -&amp;gt; apk -&amp;gt; cleanup()&lt;br /&gt;
&lt;br /&gt;
== abuild-defined functions ==&lt;br /&gt;
The following functions are provided by abuild and can be overridden, but it is strongly discouraged on code review for some functions:&lt;br /&gt;
&lt;br /&gt;
==== fetch() ====&lt;br /&gt;
: Downloads remote sources listed in &#039;&#039;source&#039;&#039; to &#039;&#039;SRCDEST&#039;&#039; (&#039;&#039;SRCDEST&#039;&#039; is configured in &#039;&#039;/etc/abuild.conf&#039;&#039;) and creates symlinks in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== unpack() ====&lt;br /&gt;
: unpack() will call default_unpack().&lt;br /&gt;
&lt;br /&gt;
: [https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L403 default_unpack()] unpacks .tar, .tgz, .tar.gz, .tar.lz (only available in Alpine &amp;gt;=3.7), .tar.bz2, .tar.lzma, .tar.xz, and .zip archives from a symlink in &#039;&#039;$srcdir&#039;&#039; associated with &#039;&#039;$SRCDEST&#039;&#039; (or distfiles folder) resulting in an unpacked folder in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== dev() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; package is used to collect developer files and folders for use in other packages in the compilation process nothing more.  Without specifying a custom &#039;&#039;dev()&#039;&#039; function, abuild will call its internal &#039;&#039;dev()&#039;&#039; function, which in turn calls default_dev().&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L1605 default_dev()]&#039;&#039; will move any &#039;&#039;include&#039;&#039; folder and folders containing &#039;&#039;*.[acho]&#039;&#039; (static archive, c source, c header file, object file), &#039;&#039;*.prl&#039;&#039; file extension patterns in &#039;&#039;&amp;quot;$pkgdir&amp;quot;/{lib,usr}&#039;&#039; to &#039;&#039;&amp;quot;$subpkgdir&amp;quot;/{lib,usr}&#039;&#039; recursively; and &#039;&#039;*.so&#039;&#039; files from &#039;&#039;&amp;quot;$pkgdir&amp;quot;/{lib,usr/lib}&#039;&#039; to &#039;&#039;&amp;quot;$subpkgdir&amp;quot;/{lib,usr/lib}&#039;&#039;.  It will also scan and move &#039;&#039;usr/{include,lib/{pkgconfig,cmake,qt*/mkspecs},share/{aclocal,gettext,vala/vapi,gir-[0-9]*,qt*/mkspecs},bin/*-config}}&#039;&#039; developer only folders in &#039;&#039;$pkgdir&#039;&#039; and transfer them to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: In general, default_dev() will support packages that share pkg-config, C programming language API, shared and static libraries, Autotools, gettext, Vala programming language bindings, Python GObject introspection, a provided custom pkg-config like command (*-config), Qt, and CMake.  If you have packages that have C++, other languages, other build system, etc; you need to manually move those developer files only if they are to be used in other packages.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: For default_dev() to be called as in no dev(), you need to explicitly add subpackages=&amp;quot;$pkgname-dev&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== doc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; package whose job is only to collect documentation folders from $pkgdir nothing more.  Without specifying a custom &#039;&#039;doc()&#039;&#039; function, abuild will call its internal &#039;&#039;doc()&#039;&#039; function, which in turn calls default_doc().&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L1519 default_doc()]&#039;&#039; will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/{doc,man,info,html,sgml,licenses,gtk-doc,ri,help}&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: Overriding this function is strongly discouraged.  Packaging docs should be done in the package() function while letting abuild automatically collect the doc folders.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: For default_doc() to be called as in no doc(), you need to explicitly add subpackages=&amp;quot;$pkgname-doc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== openrc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-opernc&#039;&#039;&#039; package whose job is to collect OpenRC service files that are in /etc/init.d and /etc/conf.d.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L1661 default_openrc()]&#039;&#039; will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/etc/{conf,init}.d&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: Overriding this function is strongly discouraged. Packaging OpenRC service definitions should be in the package() function while letting abuild automatically collect the openrc folders.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: for default_openrc() to be called as in no openrc(), you need to explicitly add subpackages=&amp;quot;$pkgname-openrc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== static() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-static&#039;&#039;&#039; package whose job is to collect static libraries that are stored in /lib and /usr/lib.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;[https://github.com/alpinelinux/abuild/blob/v3.4.0_rc4/abuild.in#L1748 default_static()]&#039;&#039; will move all static libraries (files ending with .a) from &#039;&#039;&amp;quot;$pkgdir&amp;quot;/lib&#039;&#039; and &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/lib&#039;&#039; to their equivalents in &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: Overriding this function is strongly discouraged. Packaging static libraries should be done in the package() function while letting abuild automatically collect the static libraries.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Important&#039;&#039;&#039;: for default_static() to be called as in no static(), you need to explicitly add subpackages=&amp;quot;$pkgname-static&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== snapshot() ====&lt;br /&gt;
: &#039;&#039;&#039;Optional&#039;&#039;&#039;.  For live APKBUILDs or those with a _cvs, _svn, _git, _hg in their version number, you should create a snapshot function only if there is no download link to an archive file (.zip, .tar.gz, ...) to the commit/hash/tag.  The purpose of the snapshot function is to create an archive of the source code so that the package source code is deterministic, and it doesn&#039;t waste time to fetch the source code but bypasses the download step after snapshotting.  Those that download the source code from a git repository will follow head or the latest change to the source code.  It is better to archive the source code as a zip / tar.gz / tar.bz2 up to the commit or the tag which you are trying to build a package.  If it is not deterministic or not every part of the code frozen in time for every dependency and the main project, then the patches will fail or the package may fail to compile when you revisit the package months or years to backport a patch.&lt;br /&gt;
&lt;br /&gt;
: The default [https://github.com/alpinelinux/abuild/blob/v3.1.0/abuild.in#L2310 snapshot()] function has variables associated with it:&lt;br /&gt;
:* $disturl - the base-url of the place to autoupload the snapshot&lt;br /&gt;
:* $svnurl - Subversion repository &lt;br /&gt;
:* $giturl - Git repository&lt;br /&gt;
&lt;br /&gt;
: The default snapshot() can only support one repository.  It is better to override it if there are multiple repositories involved in your package.  CVS, Mercurial (hg), and alternative version control systems must override the default snapshot().&lt;br /&gt;
&lt;br /&gt;
: See [[APKBUILD_examples:Git_checkout]] to how to use it with git.  It takes 2-3 general steps.  Clone the repository; check it out at a specific revision/commit or tag; then you use an archiver to dump it in the &#039;&#039;$SRCDEST&#039;&#039; variable which points to the distfiles folder and the base path to the full path to the archive that you want to create.  You do this for every internal dependency that the package pulls.&lt;br /&gt;
&lt;br /&gt;
: After you have created your snapshot function, you use &amp;lt;code&amp;gt;abuild snapshot&amp;lt;/code&amp;gt; to run it.  &lt;br /&gt;
&lt;br /&gt;
: The archives produced by the snapshot will be saved in &#039;&#039;/var/cache/distfiles&#039;&#039; or whatever you set for &#039;&#039;$SRCDEST&#039;&#039;.  You may need to create symlinks to the archive if the archive is not saved to the Alpine server.&lt;br /&gt;
&lt;br /&gt;
: After you snapshot it, you need to produce the checksums with &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; to use it in the APKBUILD creation process.&lt;br /&gt;
&lt;br /&gt;
: This feature is available since Alpine &amp;gt;=2.6.&lt;br /&gt;
&lt;br /&gt;
==== default_prepare() ====&lt;br /&gt;
&lt;br /&gt;
:  Before build preparation it handles set of patches inside &amp;lt;code&amp;gt;$srcdir&amp;lt;/code&amp;gt; and prints failed ones.&lt;br /&gt;
&lt;br /&gt;
== User-defined functions ==&lt;br /&gt;
The following functions should be defined by the user: &lt;br /&gt;
&lt;br /&gt;
==== prepare() ====&lt;br /&gt;
: {{note|Please adjust old APKBUILDs, which still have a &#039;&#039;prepare()&#039;&#039; function that does the same as the &#039;&#039;default_prepare()&#039;&#039; when you edit them anyway.}}&lt;br /&gt;
: &#039;&#039;&#039;&#039;&#039;Optional&#039;&#039;.&#039;&#039;&#039;  Used for build preparation: patches, etc, should be applied here. When you don&#039;t specify a custom &#039;&#039;prepare()&#039;&#039;, the built-in &#039;&#039;default_prepare()&#039;&#039; from abuild will be used. It applies patches already (always prepare them in the &amp;lt;code&amp;gt;-p1&amp;lt;/code&amp;gt; format), so &#039;&#039;&#039;usually it makes sense to not create a custom &#039;&#039;prepare()&#039;&#039; function at all!&#039;&#039;&#039; If you do create one, call &#039;&#039;default_prepare()&#039;&#039; inside it:&lt;br /&gt;
&lt;br /&gt;
: Before default_prepare gets called, you can define &#039;&#039;patch_args&#039;&#039; to supply the argument to the patch command in global scope then throw away prepare() so it is unnecessary to use the old template code floating around to patch.  patch_args and autopatching is only available in Alpine &amp;gt;=3.4.  See [[Creating_an_Alpine_package#Patches]] to fix the patch that uses a different patch level (-pX).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
prepare() {&lt;br /&gt;
    default_prepare&lt;br /&gt;
    # your custom code here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== build() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the compilation stage.  This function will be called as the current user (unless the &#039;&#039;package()&#039;&#039; function is missing - for compatibility reasons).  If no compilation is needed, this function can contain a single line: &amp;lt;code&amp;gt;return 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: To enable or disable CFLAGS, CXXFLAGS, CMake with option, or configure option per arch, use the CARCH variable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local cmakeoptions=&lt;br /&gt;
case &amp;quot;$CARCH&amp;quot; in&lt;br /&gt;
        aarch64*|arm*|ppc64le|x86|s390x) cmakeoptions=&amp;quot;$cmakeoptions -DWITH_OPENMP=OFF&amp;quot; ;;&lt;br /&gt;
        x86_64)                          cmakeoptions=&amp;quot;$cmakeoptions -DWITH_OPENMP=ON&amp;quot; ;;&lt;br /&gt;
        *)                               msg &amp;quot;Unable to determine architecture from (CARCH=$CARCH)&amp;quot; ; return 1 ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
: The block can be used in other parts of the APKBUILD even in global.&lt;br /&gt;
&lt;br /&gt;
==== check() ====&lt;br /&gt;
: &#039;&#039;&#039;Required if functionality exists.&#039;&#039;&#039; This function is called right after the build stage.  It should check that the packaged thing is actually working, typically by running (integration) tests, if provided by upstream.  If there’s no (easy) way how to test the package, you can declare that it does not want to use &#039;&#039;check()&#039;&#039; by adding &amp;quot;!check&amp;quot; into the &#039;&#039;options&#039;&#039; variable (&amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
: default_check() does nothing.  You need to manually explicitly call the unit tests or test suite yourself.  When you run the test, the program should return with an exit code of 0, indicating the tests were a success.  Unit tests or test suites will do feature tests, per function correctness check, fuzz testing, benchmarks.&lt;br /&gt;
&lt;br /&gt;
: A package may also require additional testing frameworks packages that are external dependencies.  You should add those to the &#039;&#039;checkdepends=&#039;&#039; in Alpine &amp;gt;=3.6 or &#039;&#039;makedepends=&#039;&#039; for older for backporters.  If the testing framework is not available, you need to create a package for it.  If it requires a specific version of a testing framework, consider making it an internal dependency or a new package with a package name containing the major and minor version number like the python packages.&lt;br /&gt;
&lt;br /&gt;
: Generally speaking, you should define the check functions for libraries, large programs like web browsers, or compilers and interpreters, cryptographic/security/anonymity stuff, mission critical stuff, PCI compliance/money/accounting software, server software with a lot of stakeholders or consumers.  Soon for the new policy change will have virtually &#039;&#039;&#039;all packages with testing capabilities be required to have a working and defined check() function&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: There are times when the unit tests do not work, just because the test itself is broken, new unimplemented feature, external factors not taken into consideration, unbundling path differences, breakage caused by ccache, missing test dependency or version mismatch dependency as in python2 vs python3, test scripts only work for particular language implementation like only supporting python2 but not python3 having used the 2to3 conversion script.  If a unit test is known not to work, you may need to patch it to omit that test or fix it; but, certain tests should not be disabled if it is important.  You may need to alter the references to uncompiled internal dependencies to work with the external dependencies instead.  For ccache, you can either disable it or remove it from the PATH environmental variable before running tests.&lt;br /&gt;
&lt;br /&gt;
{{Note|Tests for graphical applications and toolkits might work on a X11 user setup but will fail on the server unless run with xvfb-run.}}&lt;br /&gt;
&lt;br /&gt;
: If you don&#039;t add the &#039;&#039;check()&#039;&#039; and the &#039;&#039;options=&#039;&#039;, this is what you will see:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt;&amp;gt;&amp;gt; WARNING: py-webtest*: APKBUILD does not run any tests!&lt;br /&gt;
    Alpine policy will soon require that packages have any relevant testsuites run during the build process.&lt;br /&gt;
    To fix, either define a check() function, or declare !check in $options to indicate the package does not have a testsuite.&lt;br /&gt;
&lt;br /&gt;
: If you do not do a check or disable it, you must state there is no testsuite in comment form (#) next to options=&amp;quot;!check&amp;quot; for the code reviewers.&lt;br /&gt;
&lt;br /&gt;
: To run test suite with autotools do:&lt;br /&gt;
&lt;br /&gt;
  make check&lt;br /&gt;
&lt;br /&gt;
: To run the test suite with python setuptools:&lt;br /&gt;
&lt;br /&gt;
  python2 setup.py test&lt;br /&gt;
  python3 setup.py test&lt;br /&gt;
&lt;br /&gt;
: For python it should be &#039;&#039;&#039;test&#039;&#039;&#039; not check.  Check for python setuptools will check the packaging metadata fields[https://docs.python.org/3/distutils/examples.html#checking-a-package] only but not run the unit tests.  There should be verbose output also.  The dependencies for the tests are found in test_require in the setup.py.&lt;br /&gt;
&lt;br /&gt;
: If it says &amp;lt;code&amp;gt;Ran 0 tests in 0.000s&amp;lt;/code&amp;gt; that is not acceptable.  check() will say it was good but it is not actually correct.  It needs to run the test suite with an alternative method like &amp;lt;code&amp;gt;tox -e py27,py36&amp;lt;/code&amp;gt; if you see a tox.ini file.&lt;br /&gt;
&lt;br /&gt;
: You want to do it for each implementation to ensure that the API calls are correct per implementation but ncopa said it was just fine with python3.&lt;br /&gt;
&lt;br /&gt;
: If there is a circular dependency for the checkdepends=, you need to disable the check and put the reason next to &amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt; that there is a circular dependency.  You should disable it for the package that package that is least important or least security risk.  The other solution is to make the conflicting dependency an internal dependency but making sure that it doesn&#039;t pull it at check time.  This way they can both preform tests properly.&lt;br /&gt;
&lt;br /&gt;
==== package() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the packaging stage.  Here, the built application and support files should be installed into &#039;&#039;&#039;$pkgdir&#039;&#039;&#039;.  If this is a metapackage, this function can contain a single line: &amp;lt;code&amp;gt;mkdir -p &amp;quot;$pkgdir&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Building in fakeroot will reduce performance for parallel builds dramatically.  It is for this reason that we split the build and package process into two separate functions.}}&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
The [[APKBUILD examples]] page will assist you in understanding how to create an APKBUILD.&lt;br /&gt;
&lt;br /&gt;
= Version =&lt;br /&gt;
&lt;br /&gt;
This document assumes abuild for Alpine Edge.  For older releases of abuild, some of these features may not be available if you are using an older release.  A link to the implementation is linked for researchers and backporters.&lt;br /&gt;
&lt;br /&gt;
For more information see [[APKBUILD_versions]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux:Contribute&amp;diff=15487</id>
		<title>Alpine Linux:Contribute</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux:Contribute&amp;diff=15487"/>
		<updated>2018-10-15T07:19:29Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: removing &amp;#039;become an alpine linux developer&amp;#039; link again. I would like to start this page, but I need more information. asked on the ML in this thread: https://lists.alpinelinux.org/alpine-devel/6315.html&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:kuser.png|left|link=]]&lt;br /&gt;
__NOTOC__&lt;br /&gt;
There are many ways that &#039;&#039;you&#039;&#039; can contribute. Whether you are a normal user, a geek, or a hardcore developer, the one and most important thing you can do is to actually &#039;&#039;&#039;use&#039;&#039;&#039; Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
The list below explains some of the ways that you can contribute.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Contribute quality =&lt;br /&gt;
* Submit &#039;&#039;&#039;[http://bugs.alpinelinux.org/ bug reports]&#039;&#039;&#039;. New issues can also be created by emailing alpine (at) bugs (dot) alpinelinux (dot) org.&lt;br /&gt;
* Suggest new &#039;&#039;&#039;[[Project:Ideas|features/ideas]]&#039;&#039;&#039; and &#039;&#039;&#039;[[FAQ#Can_you_build_an_apk_package_for_....3F|packages]]&#039;&#039;&#039;&lt;br /&gt;
* Submit new &#039;&#039;&#039;[[Creating_an_Alpine_package|packages]]&#039;&#039;&#039; that you&#039;ve created, or &#039;&#039;&#039;[[Development using git|patches]]&#039;&#039;&#039; to existing packages. For more information about developing on Alpine Linux, read our [[Developer Documentation]].&lt;br /&gt;
* Submit &#039;&#039;&#039;[[Special:NewFiles|artwork]]&#039;&#039;&#039; (icons, backgrounds, logos)&lt;br /&gt;
* Correct &#039;&#039;&#039;spelling and grammar&#039;&#039;&#039; mistakes in the documentation&lt;br /&gt;
* Help &#039;&#039;&#039;[[Project:Wiki_maintenance|maintain]]&#039;&#039;&#039; the wiki&lt;br /&gt;
&lt;br /&gt;
= Contribute documentation =&lt;br /&gt;
* Help write good &#039;&#039;&#039;[[Tutorials_and_Howtos|documentation]]&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Translate&#039;&#039;&#039; the documentation (and program texts) into another language&lt;br /&gt;
* &#039;&#039;&#039;Proofread&#039;&#039;&#039; existing documentation, follow the examples, and make corrections&lt;br /&gt;
* Create diagrams, &#039;&#039;&#039;screenshots&#039;&#039;&#039;, and graphics for the documentation&lt;br /&gt;
* Develop style, formatting, spelling, and grammar conventions for documenters&lt;br /&gt;
* Expand the &#039;&#039;&#039;[[Glossary]]&#039;&#039;&#039; of technical terms (so non-geeks can understand)&lt;br /&gt;
* Convert documentation into more formats&lt;br /&gt;
&lt;br /&gt;
= Contribute support =&lt;br /&gt;
* &#039;&#039;&#039;Answer questions&#039;&#039;&#039; on the wiki, [[mailing lists]], [[IRC]] channels and [http://stackoverflow.com/questions/tagged/alpine StackOverflow]&lt;br /&gt;
* Contribute to (or start) an online support group&lt;br /&gt;
* Post a tutorial or other to https://asciinema.org&lt;br /&gt;
* Write &#039;&#039;&#039;HOWTOs&#039;&#039;&#039; and post them in the [[Tutorials and Howtos]] or your own blog&lt;br /&gt;
&lt;br /&gt;
= Contribute projects = &lt;br /&gt;
* [[Wishlist]]&lt;br /&gt;
&lt;br /&gt;
= Contribute publicity =&lt;br /&gt;
{{Tip|As Alpine Linux gets more popular, there will be more people wanting to contribute.}}&lt;br /&gt;
* &#039;&#039;&#039;[[Project:Listings|Link to]]&#039;&#039;&#039; the Alpine Linux web site&lt;br /&gt;
* Write &#039;&#039;&#039;reviews&#039;&#039;&#039;&lt;br /&gt;
* Convince people to choose Open Source products when possible&lt;br /&gt;
* Write about new ways of using an Open Source application&lt;br /&gt;
&lt;br /&gt;
= Contribute appreciation =&lt;br /&gt;
* Be &#039;&#039;&#039;polite&#039;&#039;&#039; when reporting bugs or asking for new features; after all, the developers have no obligation to do it&lt;br /&gt;
* &#039;&#039;&#039;Express&#039;&#039;&#039; your appreciation to developers (through [http://wiki.alpinelinux.org/wiki/Mailing_lists e-mail], [http://bugs.alpinelinux.org/ bug reports], and [http://wiki.alpinelinux.org/wiki/IRC IRC])&lt;br /&gt;
* Send the programmers post cards&lt;br /&gt;
* Give the project or [[Alpine_Linux:Developers|a developer a donation/gift]] (some have wish lists for this)&lt;br /&gt;
* Contribute to [https://www.patreon.com/musl musl libc development].&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux:Contribute&amp;diff=15486</id>
		<title>Alpine Linux:Contribute</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux:Contribute&amp;diff=15486"/>
		<updated>2018-10-15T06:58:07Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: /* Contribute quality */ link to &amp;quot;Become an Alpine Linux developer&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:kuser.png|left|link=]]&lt;br /&gt;
__NOTOC__&lt;br /&gt;
There are many ways that &#039;&#039;you&#039;&#039; can contribute. Whether you are a normal user, a geek, or a hardcore developer, the one and most important thing you can do is to actually &#039;&#039;&#039;use&#039;&#039;&#039; Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
The list below explains some of the ways that you can contribute.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Contribute quality =&lt;br /&gt;
* Submit &#039;&#039;&#039;[http://bugs.alpinelinux.org/ bug reports]&#039;&#039;&#039;. New issues can also be created by emailing alpine (at) bugs (dot) alpinelinux (dot) org.&lt;br /&gt;
* Suggest new &#039;&#039;&#039;[[Project:Ideas|features/ideas]]&#039;&#039;&#039; and &#039;&#039;&#039;[[FAQ#Can_you_build_an_apk_package_for_....3F|packages]]&#039;&#039;&#039;&lt;br /&gt;
* Submit new &#039;&#039;&#039;[[Creating_an_Alpine_package|packages]]&#039;&#039;&#039; that you&#039;ve created, or &#039;&#039;&#039;[[Development using git|patches]]&#039;&#039;&#039; to existing packages. For more information about developing on Alpine Linux, read our [[Developer Documentation]].&lt;br /&gt;
* [[Become an Alpine Linux developer]]&lt;br /&gt;
* Submit &#039;&#039;&#039;[[Special:NewFiles|artwork]]&#039;&#039;&#039; (icons, backgrounds, logos)&lt;br /&gt;
* Correct &#039;&#039;&#039;spelling and grammar&#039;&#039;&#039; mistakes in the documentation&lt;br /&gt;
* Help &#039;&#039;&#039;[[Project:Wiki_maintenance|maintain]]&#039;&#039;&#039; the wiki&lt;br /&gt;
&lt;br /&gt;
= Contribute documentation =&lt;br /&gt;
* Help write good &#039;&#039;&#039;[[Tutorials_and_Howtos|documentation]]&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Translate&#039;&#039;&#039; the documentation (and program texts) into another language&lt;br /&gt;
* &#039;&#039;&#039;Proofread&#039;&#039;&#039; existing documentation, follow the examples, and make corrections&lt;br /&gt;
* Create diagrams, &#039;&#039;&#039;screenshots&#039;&#039;&#039;, and graphics for the documentation&lt;br /&gt;
* Develop style, formatting, spelling, and grammar conventions for documenters&lt;br /&gt;
* Expand the &#039;&#039;&#039;[[Glossary]]&#039;&#039;&#039; of technical terms (so non-geeks can understand)&lt;br /&gt;
* Convert documentation into more formats&lt;br /&gt;
&lt;br /&gt;
= Contribute support =&lt;br /&gt;
* &#039;&#039;&#039;Answer questions&#039;&#039;&#039; on the wiki, [[mailing lists]], [[IRC]] channels and [http://stackoverflow.com/questions/tagged/alpine StackOverflow]&lt;br /&gt;
* Contribute to (or start) an online support group&lt;br /&gt;
* Post a tutorial or other to https://asciinema.org&lt;br /&gt;
* Write &#039;&#039;&#039;HOWTOs&#039;&#039;&#039; and post them in the [[Tutorials and Howtos]] or your own blog&lt;br /&gt;
&lt;br /&gt;
= Contribute projects = &lt;br /&gt;
* [[Wishlist]]&lt;br /&gt;
&lt;br /&gt;
= Contribute publicity =&lt;br /&gt;
{{Tip|As Alpine Linux gets more popular, there will be more people wanting to contribute.}}&lt;br /&gt;
* &#039;&#039;&#039;[[Project:Listings|Link to]]&#039;&#039;&#039; the Alpine Linux web site&lt;br /&gt;
* Write &#039;&#039;&#039;reviews&#039;&#039;&#039;&lt;br /&gt;
* Convince people to choose Open Source products when possible&lt;br /&gt;
* Write about new ways of using an Open Source application&lt;br /&gt;
&lt;br /&gt;
= Contribute appreciation =&lt;br /&gt;
* Be &#039;&#039;&#039;polite&#039;&#039;&#039; when reporting bugs or asking for new features; after all, the developers have no obligation to do it&lt;br /&gt;
* &#039;&#039;&#039;Express&#039;&#039;&#039; your appreciation to developers (through [http://wiki.alpinelinux.org/wiki/Mailing_lists e-mail], [http://bugs.alpinelinux.org/ bug reports], and [http://wiki.alpinelinux.org/wiki/IRC IRC])&lt;br /&gt;
* Send the programmers post cards&lt;br /&gt;
* Give the project or [[Alpine_Linux:Developers|a developer a donation/gift]] (some have wish lists for this)&lt;br /&gt;
* Contribute to [https://www.patreon.com/musl musl libc development].&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Package_Maintainers&amp;diff=15213</id>
		<title>Package Maintainers</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Package_Maintainers&amp;diff=15213"/>
		<updated>2018-03-18T08:25:55Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: spelling fixes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft}}&lt;br /&gt;
&lt;br /&gt;
* You can be maintainer without having commit access. Committers can do commits and maintainers can send patches to committers. Any committers can apply patches from maintainers. (This is similar to what FreeBSD does)&lt;br /&gt;
* The maintainer is responsible for the the package and is expected to:&lt;br /&gt;
** fix bugs in package&lt;br /&gt;
** keep it updated. This includes follow upstream announcement list, RSS feed etc and provide updates to Alpine Linux in timely fashion.&lt;br /&gt;
* Committers and others should confirm with the maintainer before making any changes of the package.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]] [[Category:Package Manager]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=14357</id>
		<title>APKBUILD Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=14357"/>
		<updated>2018-02-04T00:15:36Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: /* pkgver */ describe valid versions based on apk source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;APKBUILDs are the scripts that are created in order to build Alpine packages using the [[abuild]] tool.&lt;br /&gt;
&lt;br /&gt;
See [[aports]] for details on Alpine&#039;s official ports repository.&lt;br /&gt;
&lt;br /&gt;
This page is intended to serve as a reference for creating APKBUILDs; if this is your first time creating a package for Alpine Linux, please see [[Creating an Alpine package]].&lt;br /&gt;
&lt;br /&gt;
= Legend =&lt;br /&gt;
The following notes will assist you in understanding this document.&lt;br /&gt;
&lt;br /&gt;
In description text:&lt;br /&gt;
* If a variable is not prefixed with a &#039;&#039;$&#039;&#039;, it will be represented by italics (i.e., &#039;&#039;srcdir&#039;&#039; ).&lt;br /&gt;
* Functions will also be represented by italics, but will also end with a pair of parentheses (i.e., &#039;&#039;build()&#039;&#039; ).&lt;br /&gt;
* Shell commands will be represented &amp;lt;code&amp;gt;like this&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Variables =&lt;br /&gt;
{{Note|Variables that contain a path (e.g. &#039;&#039;$srcdir&#039;&#039; and &#039;&#039;$pkgdir&#039;&#039;) should always be quoted using double quotes (i.e., &#039;&#039;&amp;quot;$srcdir&amp;quot;&#039;&#039;).  This is done to prevent things from breaking, should the user have the APKBUILD in a directory path that contains spaces.}}&lt;br /&gt;
{{Note|All arbitrary variable and function names should be prefixed with an underscore character ( _ ) to avoid name clashes with the internals of abuild (for example, &#039;&#039;_luaversions&#039;&#039;).}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined variables ==&lt;br /&gt;
The following variables are defined by abuild:&lt;br /&gt;
&lt;br /&gt;
==== startdir ====&lt;br /&gt;
: The directory where the APKBUILD script is.&lt;br /&gt;
==== srcdir ====&lt;br /&gt;
: The directory where sources, from the &#039;&#039;source&#039;&#039; variable, are downloaded to and unpacked to.&lt;br /&gt;
==== pkgdir ====&lt;br /&gt;
: This directory should receive the files for the main package.  For example, a normal [http://en.wikipedia.org/wiki/GNU_build_system autotools] package would have &amp;lt;code&amp;gt;make DESTDIR=&amp;quot;$pkgdir&amp;quot; install&amp;lt;/code&amp;gt; in the &#039;&#039;package()&#039;&#039; function.&lt;br /&gt;
==== subpkgdir ====&lt;br /&gt;
: This directory should receive the files for a subpackage. This variable should only be used from subpackage functions.&lt;br /&gt;
==== builddir ====&lt;br /&gt;
: This variable should point to the directory inside the &#039;&#039;srcdir&#039;&#039; where the main package source is unpacked.  This is typically &#039;&#039;$srcdir/$pkgname-$pkgver&#039;&#039;.  It’s used by the default &#039;&#039;prepare()&#039;&#039; function as a working directory when applying patches.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User-defined variables ==&lt;br /&gt;
The following variables should be defined by the user:&lt;br /&gt;
==== arch ====&lt;br /&gt;
: Package architecture(s) to build for.  Can be one of: &#039;&#039;&#039;[[x86]], [[x86_64]], [[armhf]], [[aarch64]], [[ppc64le]], [[s390x]], all&#039;&#039;&#039;, or &#039;&#039;&#039;noarch&#039;&#039;&#039;, where &#039;&#039;&#039;all&#039;&#039;&#039; means all architectures, and &#039;&#039;&#039;noarch&#039;&#039;&#039; means it&#039;s architecture-independent (e.g., a pure-python package).&lt;br /&gt;
: {{Tip|To determine if your APKBUILD can use &#039;&#039;&#039;noarch&#039;&#039;&#039;: First specify &#039;&#039;&#039;all&#039;&#039;&#039; and then build the package by executing &amp;lt;code&amp;gt;abuild -r&amp;lt;/code&amp;gt;.  Watch the output towards the end for warnings saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used.  If the main package and all subpackages, if you have any subpackages, give a warning saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used, then you can use &#039;&#039;&#039;noarch&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
==== depends ====&lt;br /&gt;
: Run-time dependency package(s) that are not shared-object dependencies.  Shared objects dependencies are auto-detected and should not be specified here.&lt;br /&gt;
==== depends_dev ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
: {{Note|From ncopa on IRC: To find out if you need to add a package to depends_dev have a look at *requires* in usr/lib/pkgconfig/*.pc. With libtool it gets more complicated, but we should delete the .la files. Also check if there are any  /usr/bin/*-configure #!/bin/bash #!/usr/bin/perl or Python. Sometimes scripts or similar are generated at build time (i.e autoconf automake) then you normally don&#039;t need add those to depends_dev. You can also just add all -dev makedepends to depends_dev but it will slow the build process a little bit (more build dependencies).}}&lt;br /&gt;
==== giturl ====&lt;br /&gt;
:Git repository from which &amp;lt;code&amp;gt;abuild checkout&amp;lt;/code&amp;gt; checks out. You can checkout a specific branch in git by adding &amp;lt;code&amp;gt;-b $branch&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== install ====&lt;br /&gt;
: There are 6 different types of install scripts.  Install scripts are named &#039;&#039;&#039;$pkgname.action&#039;&#039;&#039;, where &#039;&#039;&#039;action&#039;&#039;&#039; can be:  &#039;&#039;&#039;pre-install, post-install, pre-upgrade, post-upgrade, pre-deinstall&#039;&#039;&#039;, or &#039;&#039;&#039;post-deinstall&#039;&#039;&#039;.  For example, if &#039;&#039;pkgname&#039;&#039; is set to &#039;&#039;&#039;mypackage&#039;&#039;&#039; and &#039;&#039;install&#039;&#039; is set to &#039;&#039;&#039;$pkgname.post-install&#039;&#039;&#039;, then a script named &#039;&#039;&#039;mypackage.post-install&#039;&#039;&#039; must exist along-side the APKBUILD.&lt;br /&gt;
&lt;br /&gt;
: First, a few notes regarding install scripts:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;{{Note|When using install scripts, &#039;&#039;$install&#039;&#039; should be included in &#039;&#039;source&#039;&#039; so that checksums can be generated and used for the install scripts specified in &#039;&#039;install&#039;&#039;.  For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install=&amp;quot;$pkgname.pre-install $pkgname.post-install&amp;quot;&lt;br /&gt;
source=&amp;quot;http://....&lt;br /&gt;
       $install&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;}}&lt;br /&gt;
{{Note|Always use &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt; for the command-line interpreter on the [http://en.wikipedia.org/wiki/Shebang_%28Unix%29 shebang line] of your install scripts.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the different types of install scripts in detail:&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-install =====&lt;br /&gt;
: This script is executed &#039;&#039;before installing&#039;&#039; the package.  Typical use is when the package needs a group and a user to be created. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
addgroup -S clamav 2&amp;gt;/dev/null&lt;br /&gt;
adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|If the script exits with a failure (e.g., if the user already exists), the package will not be installed and &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will exit with failure, hence the &amp;lt;code&amp;gt;exit 0&amp;lt;/code&amp;gt; at the end.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-install =====&lt;br /&gt;
: This script is executed &#039;&#039;after installing&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;before upgrading/downgrading/reinstalling&#039;&#039; the package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;after upgrading/downgrading/reinstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;before uninstalling&#039;&#039; the package.&lt;br /&gt;
: {{Note|If the script exits with failure, &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will not uninstall the package.}}&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;after uninstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
==== install_if ====&lt;br /&gt;
:install_if can be used when a package needs to be installed when some packages are already installed or are in the dependency tree. It works in reverse to the &#039;&#039;recommends&#039;&#039; feature, that other package managers provide.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example:&#039;&#039;&#039; When package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; has &amp;lt;code&amp;gt;install_if=&amp;quot;B C&amp;quot;&amp;lt;/code&amp;gt;, and the user runs &amp;lt;code&amp;gt;apk add B C&amp;lt;/code&amp;gt;, then package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; will get automatically installed.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example 2:&#039;&#039;&#039; A real use-case in Alpine is open-vm-tools. Currently it contains the userspace tools and separate packages for the kernel modules (grsec and vserver). When we install the userspace tools, apk should automatically install the correct kernel modules and will need to figure out for which kernel. This is where install_if jumps in. For any of the kernel modules package we would use:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;pre&amp;gt;install_if=&amp;quot;linux-${_flavor}=${_kernelver} open-vm-tools&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:This will automatically install the package when the specified packages are installed or are in dependency tree.&lt;br /&gt;
&lt;br /&gt;
==== license ====&lt;br /&gt;
: License(s) for the package, for example &amp;lt;code&amp;gt;GPL-3.0-or-later&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;BSD-2-Clause&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;MIT&amp;lt;/code&amp;gt; [[Creating_an_Alpine_package#license|(details)]].&lt;br /&gt;
&lt;br /&gt;
==== makedepends ====&lt;br /&gt;
: Build-time dependency package(s).&lt;br /&gt;
==== md5sums/sha256sums/sha512sums ====&lt;br /&gt;
: Checksums for the files/URLs listed in &#039;&#039;source&#039;&#039;.  The checksums are normally generated and updated by executing &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; and should be the last item in the APKBUILD.&lt;br /&gt;
&lt;br /&gt;
New packages should use only sha512sums.&lt;br /&gt;
&lt;br /&gt;
==== options ====&lt;br /&gt;
: Build-time options for the package.&lt;br /&gt;
&lt;br /&gt;
: {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!archcheck&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to verify that the architecture of the binary files is the same architecture as abuild should build for. One example where it makes sense to set this are packages with firmware files, that get executed on another CPU (such as WiFi firmware).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to run the &amp;lt;code&amp;gt;check()&amp;lt;/code&amp;gt; function. Please always add a short comment after the &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt; about why it&#039;s disabled. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142545300] Creating a very simple check function, that calls &amp;lt;code&amp;gt;program --version&amp;lt;/code&amp;gt; is better than disabling tests completely. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142543002]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!strip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Avoid stripping symbols from binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;suid&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allow [https://en.wikipedia.org/wiki/Setuid setuid] binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!tracedeps&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not automatically find dependencies (e.g. by using &amp;lt;code&amp;gt;ldd&amp;lt;/code&amp;gt; to find dynamic libraries, which the resulting binary links against).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== pkgdesc ====&lt;br /&gt;
: A brief, one-line description of what the package does.&lt;br /&gt;
&lt;br /&gt;
: Here&#039;s an example from the OpenSSH client package:&lt;br /&gt;
: &amp;lt;pre&amp;gt;pkgdesc=&amp;quot;Port of OpenBSD&#039;s free SSH release - client&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== pkggroups ====&lt;br /&gt;
: System group(s) to be created during build-time.  System group(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system group(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgname ====&lt;br /&gt;
: The name of the package.  All letters should be lowercase.&lt;br /&gt;
: {{Note|When creating an APKBUILD of a module or library for another package, we use some common package prefixes, such as: &#039;&#039;lua-&#039;&#039;, &#039;&#039;perl-&#039;&#039;, &#039;&#039;php-&#039;&#039;, and &#039;&#039;py-&#039;&#039;.  Search aports for other common prefixes.}}&lt;br /&gt;
&lt;br /&gt;
==== pkgrel ====&lt;br /&gt;
: Alpine package release number.  Starts at 0 (zero).  Always increment &#039;&#039;pkgrel&#039;&#039; when making updates to an aport; reset &#039;&#039;pkgrel&#039;&#039; to 0 (zero) when incrementing &#039;&#039;pkgver&#039;&#039;.&lt;br /&gt;
==== pkgusers ====&lt;br /&gt;
: System user(s) to be created during build-time.  System user(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system user(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgver ====&lt;br /&gt;
: The version of the software being packaged. Format for valid versions: &amp;lt;code&amp;gt;{digit}{.digit}...{letter}{_suf{#}}...{-r#}&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n17]&lt;br /&gt;
: A Suffix &amp;lt;code&amp;gt;suf&amp;lt;/code&amp;gt; in the above format can be one of the following to indicate that the release is &#039;&#039;less recent&#039;&#039; than the version without the suffix: &amp;lt;code&amp;gt;alpha&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;beta&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pre&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rc&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n75]&lt;br /&gt;
: These are for indicating &#039;&#039;more recent&#039;&#039; releases: &amp;lt;code&amp;gt;cvs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;svn&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;hg&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; [https://git.alpinelinux.org/cgit/apk-tools/tree/src/version.c#n76]&lt;br /&gt;
: All other suffices are invalid. To package a specific git commit, the date of the commit gets appended to the latest release, e.g. &amp;lt;code&amp;gt;1.0.0_git20180204&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== provides ====&lt;br /&gt;
: List of package names (and optionally version info) this package provides.&lt;br /&gt;
&lt;br /&gt;
: If package with a version is provided (provides=&#039;foo=1.2&#039;) apk will consider it as an alternate name and it will automatically consider the package for installation by the alternate name, and conflict with other packages having the same name, or provides.&lt;br /&gt;
&lt;br /&gt;
: If version is not provided (provides=&#039;foo&#039;), apk will consider it as virtual package name. Several package with same non-versioned provides can be installed simultaneously. However, none of them will be installed by default when requested by the virtual name - instead, error message is given and user is asked to choose which package providing the virtual name should be installed.&lt;br /&gt;
==== provider_priority ====&lt;br /&gt;
: A numeric value which is used by apk-tools to break ties when choosing a virtual package to satisfy a dependency. Higher values have higher priority. The primary use case is to specify the primary package that satisfies a virtual (provider).&lt;br /&gt;
==== replaces ====&lt;br /&gt;
: Package(s) that this package replaces.  This package will &amp;quot;take over&amp;quot; files owned by packages listed in the &#039;&#039;replaces&#039;&#039; variable.  This is useful when files move from one package to another, or when a package gets renamed.&lt;br /&gt;
==== replaces_priority ====&lt;br /&gt;
: The priority of the replaces. If multiple packages replace each other, then will the package with highest &#039;&#039;replaces_priority&#039;&#039; win.&lt;br /&gt;
==== source ====&lt;br /&gt;
: The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[APKBUILD Reference#install|install variable]]), patches, and all other necessary files.&lt;br /&gt;
&lt;br /&gt;
: Here are few things to note:&lt;br /&gt;
&lt;br /&gt;
:* When you are finished adding local and/or remote files to &#039;&#039;source&#039;&#039;, you can execute the following command to add their checksums to the APKBUILD file:&lt;br /&gt;
:: {{Cmd|abuild checksum}}&lt;br /&gt;
:: {{Note|When later updating the content of &#039;&#039;source&#039;&#039;, or updating a file that is listed in &#039;&#039;source&#039;&#039;, you must also update their checksums again with the same command.}}&lt;br /&gt;
&lt;br /&gt;
:* When the remote file is hosted at SourceForge, it&#039;s best to specify the special mirrors link used by SourceForge:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: (or similar depending on the package).&lt;br /&gt;
&lt;br /&gt;
:* You can set target filename (eg &#039;save as...&#039;) by prefixing the URI with &#039;&#039;filename::&#039;&#039;. This is useful when the remote filename is not specified in the URI (ie, does not end in &#039;/software-1.0.tar.gz&#039;), such as:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: or when the filename is braindead, like githubs&#039; download tags:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: The above two examples needs a target filename prefix:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::http://oss.example.org/?get=software&amp;amp;ver=$pkgver&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: and:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following protocols for remote file retrieval:&lt;br /&gt;
:** http&lt;br /&gt;
:** https&lt;br /&gt;
:** ftp&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following archive types/archive file extensions:&lt;br /&gt;
:** .tar.gz / .tgz&lt;br /&gt;
:** .tar.bz2&lt;br /&gt;
:** .tar.lzma&lt;br /&gt;
:** .tar.xz&lt;br /&gt;
:** .zip&lt;br /&gt;
&lt;br /&gt;
:: {{Note|Legacy APKBUILD scripts define &#039;&#039;source&#039;&#039; variable as &amp;quot;saveas-[brain-dead-url]/[target-filename]&amp;quot; format instead of the modern [target-filename]::[brain-dead-url].&amp;lt;br /&amp;gt;&#039;&#039;BAD&#039;&#039;:   source&amp;amp;#61;&amp;quot;saveas-http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC/$pkgname-$pkgver.tar.gz&amp;quot;&amp;lt;br /&amp;gt;&#039;&#039;GOOD&#039;&#039;:   source&amp;amp;#61;$pkgname-$pkgver.tar.gz::http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
==== subpackages ====&lt;br /&gt;
: Subpackages built from this APKBUILD.  abuild will parse this variable and try to find a subpackage split function.  The split function must &#039;&#039;move&#039;&#039; files that do not belong in the main package, from &#039;&#039;$pkgdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.  Files and directories can also be &#039;&#039;copied&#039;&#039; from &#039;&#039;$startdir&#039;&#039; and &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: The split function can be specified in 1 of 3 different methods:&lt;br /&gt;
:# subpkgname:&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# $pkgname-&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# &#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
: {{Note|Split function names &#039;&#039;&#039;cannot&#039;&#039;&#039; use hyphens; use the first method above if the subpackage name contains a hyphen (-) character, like this: &#039;&#039;subpkg-name:subpkg_name&#039;&#039;, where &amp;lt;code&amp;gt;subpkg-name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;&#039;&#039; and &amp;lt;code&amp;gt;subpkg_name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;s split function&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
: {{Tip|For more information, see the [[APKBUILD_examples:Subpackages|Subpackages example]].}}&lt;br /&gt;
&lt;br /&gt;
==== triggers ====&lt;br /&gt;
: Apk-tools can &amp;quot;monitor&amp;quot; directories and execute a trigger if any package installed/uninstalled any file in the monitored dir. The triggers are always execute after the apk action (install, uninstall, upgrade).&lt;br /&gt;
&lt;br /&gt;
: The triggers are specified in the format: &#039;&#039;scriptname&#039;&#039;=&#039;&#039;pathlist&#039;&#039; where &#039;&#039;scriptname&#039;&#039; is the (sub)package name + .trigger suffix and pathlist is : separated list of the dirs to monitor.&lt;br /&gt;
&lt;br /&gt;
: The &#039;&#039;&#039;triggers&#039;&#039;&#039; variable must include the triggers for subpackages too if they have any.&lt;br /&gt;
&lt;br /&gt;
: It is possible to use wildcards (*) in the dir list.&lt;br /&gt;
&lt;br /&gt;
==== url ====&lt;br /&gt;
: The homepage for the package.  This is to help users find upstream documentation and other information regarding the package.&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
{{Note|All functions should consider the current working directory as undefined, and should therefore use the [[APKBUILD Reference#abuild-defined_variables|abuild-defined directory variables]] to their advantage.}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined functions ==&lt;br /&gt;
The following functions are provided by abuild and can be overridden:&lt;br /&gt;
&lt;br /&gt;
==== fetch() ====&lt;br /&gt;
: Downloads remote sources listed in &#039;&#039;source&#039;&#039; to &#039;&#039;SRCDEST&#039;&#039; (&#039;&#039;SRCDEST&#039;&#039; is configured in &#039;&#039;/etc/abuild.conf&#039;&#039;) and creates symlinks in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== unpack() ====&lt;br /&gt;
: Unpacks .tgz, .tar.gz, .tar.bz2, .tar.lzma, .tar.xz, and .zip archives in &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== dev() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;dev()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;dev()&#039;&#039; function, which in turn calls &#039;&#039;default_dev()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/include&#039;&#039;, &#039;&#039;*.a&#039;&#039;, &#039;&#039;*.la&#039;&#039; and similar files to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
==== doc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;doc()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;doc()&#039;&#039; function, which in turn calls &#039;&#039;default_doc()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/doc&#039;&#039;, &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/man&#039;&#039; and similar to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== User-defined functions ==&lt;br /&gt;
The following functions should be defined by the user: &lt;br /&gt;
&lt;br /&gt;
==== prepare() ====&lt;br /&gt;
: {{note|Please adjust old APKBUILDs, which still have a &#039;&#039;prepare()&#039;&#039; function that does the same as the &#039;&#039;default_prepare()&#039;&#039; when you edit them anyway.}}&lt;br /&gt;
: &#039;&#039;&#039;&#039;&#039;Optional&#039;&#039;.&#039;&#039;&#039;  Used for build preparation: patches, etc, should be applied here. When you don&#039;t specify a custom &#039;&#039;prepare()&#039;&#039;, the built-in &#039;&#039;default_prepare()&#039;&#039; from abuild will be used. It applies patches already (always prepare them in the &amp;lt;code&amp;gt;-p1&amp;lt;/code&amp;gt; format), so &#039;&#039;&#039;usually it makes sense to not create a custom &#039;&#039;prepare()&#039;&#039; function at all!&#039;&#039;&#039; If you do create one, call &#039;&#039;default_prepare()&#039;&#039; inside it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
prepare() {&lt;br /&gt;
    default_prepare&lt;br /&gt;
    # your custom code here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== build() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the compilation stage.  This function will be called as the current user (unless the &#039;&#039;package()&#039;&#039; function is missing - for compatibility reasons).  If no compilation is needed, this function can contain a single line: &amp;lt;code&amp;gt;return 0&amp;lt;/code&amp;gt;&lt;br /&gt;
==== check() ====&lt;br /&gt;
: &#039;&#039;&#039;Recommended.&#039;&#039;&#039; This function is called right after the build stage.  It should check that the packaged thing is actually working, typically by running (integration) tests, if provided by upstream.  If there’s no (easy) way how to test the package, you can declare that it does not want to use &#039;&#039;check()&#039;&#039; by adding &amp;quot;!check&amp;quot; into the &#039;&#039;options&#039;&#039; variable (&amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
==== package() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the packaging stage.  Here, the built application and support files should be installed into &#039;&#039;&#039;$pkgdir&#039;&#039;&#039;.  If this is a metapackage, this function can contain a single line: &amp;lt;code&amp;gt;mkdir -p &amp;quot;$pkgdir&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Building in fakeroot will reduce performance for parallel builds dramatically.  It is for this reason that we split the build and package process into two separate functions.}}&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
The [[APKBUILD examples]] page will assist you in understanding how to create an APKBUILD.&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=14153</id>
		<title>APKBUILD Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=14153"/>
		<updated>2017-11-26T14:04:18Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: /* prepare() */ remove the obvious&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;APKBUILDs are the scripts that are created in order to build Alpine packages using the [[abuild]] tool.&lt;br /&gt;
&lt;br /&gt;
See [[aports]] for details on Alpine&#039;s official ports repository.&lt;br /&gt;
&lt;br /&gt;
This page is intended to serve as a reference for creating APKBUILDs; if this is your first time creating a package for Alpine Linux, please see [[Creating an Alpine package]].&lt;br /&gt;
&lt;br /&gt;
= Legend =&lt;br /&gt;
The following notes will assist you in understanding this document.&lt;br /&gt;
&lt;br /&gt;
In description text:&lt;br /&gt;
* If a variable is not prefixed with a &#039;&#039;$&#039;&#039;, it will be represented by italics (i.e., &#039;&#039;srcdir&#039;&#039; ).&lt;br /&gt;
* Functions will also be represented by italics, but will also end with a pair of parentheses (i.e., &#039;&#039;build()&#039;&#039; ).&lt;br /&gt;
* Shell commands will be represented &amp;lt;code&amp;gt;like this&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Variables =&lt;br /&gt;
{{Note|Variables that contain a path (e.g. &#039;&#039;$srcdir&#039;&#039; and &#039;&#039;$pkgdir&#039;&#039;) should always be quoted using double quotes (i.e., &#039;&#039;&amp;quot;$srcdir&amp;quot;&#039;&#039;).  This is done to prevent things from breaking, should the user have the APKBUILD in a directory path that contains spaces.}}&lt;br /&gt;
{{Note|All arbitrary variable and function names should be prefixed with an underscore character ( _ ) to avoid name clashes with the internals of abuild (for example, &#039;&#039;_luaversions&#039;&#039;).}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined variables ==&lt;br /&gt;
The following variables are defined by abuild:&lt;br /&gt;
&lt;br /&gt;
==== startdir ====&lt;br /&gt;
: The directory where the APKBUILD script is.&lt;br /&gt;
==== srcdir ====&lt;br /&gt;
: The directory where sources, from the &#039;&#039;source&#039;&#039; variable, are downloaded to and unpacked to.&lt;br /&gt;
==== pkgdir ====&lt;br /&gt;
: This directory should receive the files for the main package.  For example, a normal [http://en.wikipedia.org/wiki/GNU_build_system autotools] package would have &amp;lt;code&amp;gt;make DESTDIR=&amp;quot;$pkgdir&amp;quot; install&amp;lt;/code&amp;gt; in the &#039;&#039;package()&#039;&#039; function.&lt;br /&gt;
==== subpkgdir ====&lt;br /&gt;
: This directory should receive the files for a subpackage. This variable should only be used from subpackage functions.&lt;br /&gt;
==== builddir ====&lt;br /&gt;
: This variable should point to the directory inside the &#039;&#039;srcdir&#039;&#039; where the main package source is unpacked.  This is typically &#039;&#039;$srcdir/$pkgname-$pkgver&#039;&#039;.  It’s used by the default &#039;&#039;prepare()&#039;&#039; function as a working directory when applying patches.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User-defined variables ==&lt;br /&gt;
The following variables should be defined by the user:&lt;br /&gt;
==== arch ====&lt;br /&gt;
: Package architecture(s) to build for.  Can be one of: &#039;&#039;&#039;[[x86]], [[x86_64]], [[armhf]], [[aarch64]], [[ppc64le]], [[s390x]], all&#039;&#039;&#039;, or &#039;&#039;&#039;noarch&#039;&#039;&#039;, where &#039;&#039;&#039;all&#039;&#039;&#039; means all architectures, and &#039;&#039;&#039;noarch&#039;&#039;&#039; means it&#039;s architecture-independent (e.g., a pure-python package).&lt;br /&gt;
: {{Tip|To determine if your APKBUILD can use &#039;&#039;&#039;noarch&#039;&#039;&#039;: First specify &#039;&#039;&#039;all&#039;&#039;&#039; and then build the package by executing &amp;lt;code&amp;gt;abuild -r&amp;lt;/code&amp;gt;.  Watch the output towards the end for warnings saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used.  If the main package and all subpackages, if you have any subpackages, give a warning saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used, then you can use &#039;&#039;&#039;noarch&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
==== depends ====&lt;br /&gt;
: Run-time dependency package(s) that are not shared-object dependencies.  Shared objects dependencies are auto-detected and should not be specified here.&lt;br /&gt;
==== depends_dev ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
: {{Note|From ncopa on IRC: To find out if you need to add a package to depends_dev have a look at *requires* in usr/lib/pkgconfig/*.pc. With libtool it gets more complicated, but we should delete the .la files. Also check if there are any  /usr/bin/*-configure #!/bin/bash #!/usr/bin/perl or Python. Sometimes scripts or similar are generated at build time (i.e autoconf automake) then you normally don&#039;t need add those to depends_dev. You can also just add all -dev makedepends to depends_dev but it will slow the build process a little bit (more build dependencies).}}&lt;br /&gt;
==== giturl ====&lt;br /&gt;
:Git repository from which &amp;lt;code&amp;gt;abuild checkout&amp;lt;/code&amp;gt; checks out. You can checkout a specific branch in git by adding &amp;lt;code&amp;gt;-b $branch&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== install ====&lt;br /&gt;
: There are 6 different types of install scripts.  Install scripts are named &#039;&#039;&#039;$pkgname.action&#039;&#039;&#039;, where &#039;&#039;&#039;action&#039;&#039;&#039; can be:  &#039;&#039;&#039;pre-install, post-install, pre-upgrade, post-upgrade, pre-deinstall&#039;&#039;&#039;, or &#039;&#039;&#039;post-deinstall&#039;&#039;&#039;.  For example, if &#039;&#039;pkgname&#039;&#039; is set to &#039;&#039;&#039;mypackage&#039;&#039;&#039; and &#039;&#039;install&#039;&#039; is set to &#039;&#039;&#039;$pkgname.post-install&#039;&#039;&#039;, then a script named &#039;&#039;&#039;mypackage.post-install&#039;&#039;&#039; must exist along-side the APKBUILD.&lt;br /&gt;
&lt;br /&gt;
: First, a few notes regarding install scripts:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;{{Note|When using install scripts, &#039;&#039;$install&#039;&#039; should be included in &#039;&#039;source&#039;&#039; so that checksums can be generated and used for the install scripts specified in &#039;&#039;install&#039;&#039;.  For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install=&amp;quot;$pkgname.pre-install $pkgname.post-install&amp;quot;&lt;br /&gt;
source=&amp;quot;http://....&lt;br /&gt;
       $install&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;}}&lt;br /&gt;
{{Note|Always use &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt; for the command-line interpreter on the [http://en.wikipedia.org/wiki/Shebang_%28Unix%29 shebang line] of your install scripts.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the different types of install scripts in detail:&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-install =====&lt;br /&gt;
: This script is executed &#039;&#039;before installing&#039;&#039; the package.  Typical use is when the package needs a group and a user to be created. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
addgroup -S clamav 2&amp;gt;/dev/null&lt;br /&gt;
adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|If the script exits with a failure (e.g., if the user already exists), the package will not be installed and &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will exit with failure, hence the &amp;lt;code&amp;gt;exit 0&amp;lt;/code&amp;gt; at the end.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-install =====&lt;br /&gt;
: This script is executed &#039;&#039;after installing&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;before upgrading/downgrading/reinstalling&#039;&#039; the package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;after upgrading/downgrading/reinstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;before uninstalling&#039;&#039; the package.&lt;br /&gt;
: {{Note|If the script exits with failure, &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will not uninstall the package.}}&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;after uninstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
==== install_if ====&lt;br /&gt;
:install_if can be used when a package needs to be installed when some packages are already installed or are in the dependency tree. It works in reverse to the &#039;&#039;recommends&#039;&#039; feature, that other package managers provide.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example:&#039;&#039;&#039; When package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; has &amp;lt;code&amp;gt;install_if=&amp;quot;B C&amp;quot;&amp;lt;/code&amp;gt;, and the user runs &amp;lt;code&amp;gt;apk add B C&amp;lt;/code&amp;gt;, then package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; will get automatically installed.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example 2:&#039;&#039;&#039; A real use-case in Alpine is open-vm-tools. Currently it contains the userspace tools and separate packages for the kernel modules (grsec and vserver). When we install the userspace tools, apk should automatically install the correct kernel modules and will need to figure out for which kernel. This is where install_if jumps in. For any of the kernel modules package we would use:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;pre&amp;gt;install_if=&amp;quot;linux-${_flavor}=${_kernelver} open-vm-tools&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:This will automatically install the package when the specified packages are installed or are in dependency tree.&lt;br /&gt;
&lt;br /&gt;
==== license ====&lt;br /&gt;
: License(s) for the package, for example &amp;lt;code&amp;gt;GPL3+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;BSD&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;MIT&amp;lt;/code&amp;gt; [[Creating_an_Alpine_package#license|(details)]].&lt;br /&gt;
&lt;br /&gt;
==== makedepends ====&lt;br /&gt;
: Build-time dependency package(s).&lt;br /&gt;
==== md5sums ====&lt;br /&gt;
: Checksums for the files/URLs listed in &#039;&#039;source&#039;&#039;.  The checksums are normally generated and updated by executing &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; and should be the last item in the APKBUILD.&lt;br /&gt;
==== options ====&lt;br /&gt;
: Build-time options for the package.&lt;br /&gt;
&lt;br /&gt;
: {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!archcheck&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to verify that the architecture of the binary files is the same architecture as abuild should build for. One example where it makes sense to set this are packages with firmware files, that get executed on another CPU (such as WiFi firmware).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to run the &amp;lt;code&amp;gt;check()&amp;lt;/code&amp;gt; function. Please always add a short comment after the &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt; about why it&#039;s disabled. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142545300] Creating a very simple check function, that calls &amp;lt;code&amp;gt;program --version&amp;lt;/code&amp;gt; is better than disabling tests completely. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142543002]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!strip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Avoid stripping symbols from binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;suid&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allow [https://en.wikipedia.org/wiki/Setuid setuid] binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!tracedeps&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not automatically find dependencies (e.g. by using &amp;lt;code&amp;gt;ldd&amp;lt;/code&amp;gt; to find dynamic libraries, which the resulting binary links against).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== pkgdesc ====&lt;br /&gt;
: A brief, one-line description of what the package does.&lt;br /&gt;
&lt;br /&gt;
: Here&#039;s an example from the OpenSSH client package:&lt;br /&gt;
: &amp;lt;pre&amp;gt;pkgdesc=&amp;quot;Port of OpenBSD&#039;s free SSH release - client&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== pkggroups ====&lt;br /&gt;
: System group(s) to be created during build-time.  System group(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system group(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgname ====&lt;br /&gt;
: The name of the package.  All letters should be lowercase.&lt;br /&gt;
: {{Note|When creating an APKBUILD of a module or library for another package, we use some common package prefixes, such as: &#039;&#039;lua-&#039;&#039;, &#039;&#039;perl-&#039;&#039;, &#039;&#039;php-&#039;&#039;, and &#039;&#039;py-&#039;&#039;.  Search aports for other common prefixes.}}&lt;br /&gt;
&lt;br /&gt;
==== pkgrel ====&lt;br /&gt;
: Alpine package release number.  Starts at 0 (zero).  Always increment &#039;&#039;pkgrel&#039;&#039; when making updates to an aport; reset &#039;&#039;pkgrel&#039;&#039; to 0 (zero) when incrementing &#039;&#039;pkgver&#039;&#039;.&lt;br /&gt;
==== pkgusers ====&lt;br /&gt;
: System user(s) to be created during build-time.  System user(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system user(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgver ====&lt;br /&gt;
: The version of the software being packaged.&lt;br /&gt;
==== provides ====&lt;br /&gt;
: List of package names (and optionally version info) this package provides.&lt;br /&gt;
&lt;br /&gt;
: If package with a version is provided (provides=&#039;foo=1.2&#039;) apk will consider it as an alternate name and it will automatically consider the package for installation by the alternate name, and conflict with other packages having the same name, or provides.&lt;br /&gt;
&lt;br /&gt;
: If version is not provided (provides=&#039;foo&#039;), apk will consider it as virtual package name. Several package with same non-versioned provides can be installed simultaneously. However, none of them will be installed by default when requested by the virtual name - instead, error message is given and user is asked to choose which package providing the virtual name should be installed.&lt;br /&gt;
==== replaces ====&lt;br /&gt;
: Package(s) that this package replaces.  This package will &amp;quot;take over&amp;quot; files owned by packages listed in the &#039;&#039;replaces&#039;&#039; variable.  This is useful when files move from one package to another, or when a package gets renamed.&lt;br /&gt;
==== replaces_priority ====&lt;br /&gt;
: The priority of the replaces. If multiple packages replace each other, then will the package with highest &#039;&#039;replaces_priority&#039;&#039; win.&lt;br /&gt;
==== source ====&lt;br /&gt;
: The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[APKBUILD Reference#install|install variable]]), patches, and all other necessary files.&lt;br /&gt;
&lt;br /&gt;
: Here are few things to note:&lt;br /&gt;
&lt;br /&gt;
:* When you are finished adding local and/or remote files to &#039;&#039;source&#039;&#039;, you can execute the following command to add their checksums to the APKBUILD file:&lt;br /&gt;
:: {{Cmd|abuild checksum}}&lt;br /&gt;
:: {{Note|When later updating the content of &#039;&#039;source&#039;&#039;, or updating a file that is listed in &#039;&#039;source&#039;&#039;, you must also update their checksums again with the same command.}}&lt;br /&gt;
&lt;br /&gt;
:* When the remote file is hosted at SourceForge, it&#039;s best to specify the special mirrors link used by SourceForge:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: (or similar depending on the package).&lt;br /&gt;
&lt;br /&gt;
:* You can set target filename (eg &#039;save as...&#039;) by prefixing the URI with &#039;&#039;filename::&#039;&#039;. This is useful when the remote filename is not specified in the URI (ie, does not end in &#039;/software-1.0.tar.gz&#039;), such as:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: or when the filename is braindead, like githubs&#039; download tags:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: The above two examples needs a target filename prefix:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::http://oss.example.org/?get=software&amp;amp;ver=$pkgver&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: and:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following protocols for remote file retrieval:&lt;br /&gt;
:** http&lt;br /&gt;
:** https&lt;br /&gt;
:** ftp&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following archive types/archive file extensions:&lt;br /&gt;
:** .tar.gz / .tgz&lt;br /&gt;
:** .tar.bz2&lt;br /&gt;
:** .tar.lzma&lt;br /&gt;
:** .tar.xz&lt;br /&gt;
:** .zip&lt;br /&gt;
&lt;br /&gt;
:: {{Note|Legacy APKBUILD scripts define &#039;&#039;source&#039;&#039; variable as &amp;quot;saveas-[brain-dead-url]/[target-filename]&amp;quot; format instead of the modern [target-filename]::[brain-dead-url].&amp;lt;br /&amp;gt;&#039;&#039;BAD&#039;&#039;:   source&amp;amp;#61;&amp;quot;saveas-http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC/$pkgname-$pkgver.tar.gz&amp;quot;&amp;lt;br /&amp;gt;&#039;&#039;GOOD&#039;&#039;:   source&amp;amp;#61;$pkgname-$pkgver.tar.gz::http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
==== subpackages ====&lt;br /&gt;
: Subpackages built from this APKBUILD.  abuild will parse this variable and try to find a subpackage split function.  The split function must &#039;&#039;move&#039;&#039; files that do not belong in the main package, from &#039;&#039;$pkgdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.  Files and directories can also be &#039;&#039;copied&#039;&#039; from &#039;&#039;$startdir&#039;&#039; and &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: The split function can be specified in 1 of 3 different methods:&lt;br /&gt;
:# subpkgname:&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# $pkgname-&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# &#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
: {{Note|Split function names &#039;&#039;&#039;cannot&#039;&#039;&#039; use hyphens; use the first method above if the subpackage name contains a hyphen (-) character, like this: &#039;&#039;subpkg-name:subpkg_name&#039;&#039;, where &amp;lt;code&amp;gt;subpkg-name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;&#039;&#039; and &amp;lt;code&amp;gt;subpkg_name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;s split function&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
: {{Tip|For more information, see the [[APKBUILD_examples:Subpackages|Subpackages example]].}}&lt;br /&gt;
&lt;br /&gt;
==== triggers ====&lt;br /&gt;
: Apk-tools can &amp;quot;monitor&amp;quot; directories and execute a trigger if any package installed/uninstalled any file in the monitored dir. The triggers are always execute after the apk action (install, uninstall, upgrade).&lt;br /&gt;
&lt;br /&gt;
: The triggers are specified in the format: &#039;&#039;scriptname&#039;&#039;=&#039;&#039;pathlist&#039;&#039; where &#039;&#039;scriptname&#039;&#039; is the (sub)package name + .trigger suffix and pathlist is : separated list of the dirs to monitor.&lt;br /&gt;
&lt;br /&gt;
: The &#039;&#039;&#039;triggers&#039;&#039;&#039; variable must include the triggers for subpackages too if they have any.&lt;br /&gt;
&lt;br /&gt;
: It is possible to use wildcards (*) in the dir list.&lt;br /&gt;
&lt;br /&gt;
==== url ====&lt;br /&gt;
: The homepage for the package.  This is to help users find upstream documentation and other information regarding the package.&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
{{Note|All functions should consider the current working directory as undefined, and should therefore use the [[APKBUILD Reference#abuild-defined_variables|abuild-defined directory variables]] to their advantage.}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined functions ==&lt;br /&gt;
The following functions are provided by abuild and can be overridden:&lt;br /&gt;
&lt;br /&gt;
==== fetch() ====&lt;br /&gt;
: Downloads remote sources listed in &#039;&#039;source&#039;&#039; to &#039;&#039;SRCDEST&#039;&#039; (&#039;&#039;SRCDEST&#039;&#039; is configured in &#039;&#039;/etc/abuild.conf&#039;&#039;) and creates symlinks in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== unpack() ====&lt;br /&gt;
: Unpacks .tgz, .tar.gz, .tar.bz2, .tar.lzma, .tar.xz, and .zip archives in &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== dev() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;dev()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;dev()&#039;&#039; function, which in turn calls &#039;&#039;default_dev()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/include&#039;&#039;, &#039;&#039;*.a&#039;&#039;, &#039;&#039;*.la&#039;&#039; and similar files to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
==== doc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;doc()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;doc()&#039;&#039; function, which in turn calls &#039;&#039;default_doc()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/doc&#039;&#039;, &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/man&#039;&#039; and similar to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== User-defined functions ==&lt;br /&gt;
The following functions should be defined by the user: &lt;br /&gt;
&lt;br /&gt;
==== prepare() ====&lt;br /&gt;
: {{note|Please adjust old APKBUILDs, which still have a &#039;&#039;prepare()&#039;&#039; function that does the same as the &#039;&#039;default_prepare()&#039;&#039; when you edit them anyway.}}&lt;br /&gt;
: &#039;&#039;&#039;&#039;&#039;Optional&#039;&#039;.&#039;&#039;&#039;  Used for build preparation: patches, etc, should be applied here. When you don&#039;t specify a custom &#039;&#039;prepare()&#039;&#039;, the built-in &#039;&#039;default_prepare()&#039;&#039; from abuild will be used. It applies patches already (always prepare them in the &amp;lt;code&amp;gt;-p1&amp;lt;/code&amp;gt; format), so &#039;&#039;&#039;usually it makes sense to not create a custom &#039;&#039;prepare()&#039;&#039; function at all!&#039;&#039;&#039; If you do create one, call &#039;&#039;default_prepare()&#039;&#039; inside it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
prepare() {&lt;br /&gt;
    default_prepare&lt;br /&gt;
    # your custom code here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== build() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the compilation stage.  This function will be called as the current user (unless the &#039;&#039;package()&#039;&#039; function is missing - for compatibility reasons).  If no compilation is needed, this function can contain a single line: &amp;lt;code&amp;gt;return 0&amp;lt;/code&amp;gt;&lt;br /&gt;
==== check() ====&lt;br /&gt;
: &#039;&#039;&#039;Recommended.&#039;&#039;&#039; This function is called right after the build stage.  It should check that the packaged thing is actually working, typically by running (integration) tests, if provided by upstream.  If there’s no (easy) way how to test the package, you can declare that it does not want to use &#039;&#039;check()&#039;&#039; by adding &amp;quot;!check&amp;quot; into the &#039;&#039;options&#039;&#039; variable (&amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
==== package() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the packaging stage.  Here, the built application and support files should be installed into &#039;&#039;&#039;$pkgdir&#039;&#039;&#039;.  If this is a metapackage, this function can contain a single line: &amp;lt;code&amp;gt;mkdir -p &amp;quot;$pkgdir&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Building in fakeroot will reduce performance for parallel builds dramatically.  It is for this reason that we split the build and package process into two separate functions.}}&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
The [[APKBUILD examples]] page will assist you in understanding how to create an APKBUILD.&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=14152</id>
		<title>APKBUILD Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=14152"/>
		<updated>2017-11-26T14:03:20Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: /* prepare() */ rewrote this part, it still said &amp;quot;default_prepare || return&amp;quot; and didn&amp;#039;t have a good example of how to use the default_prepare inside a custom prepare function&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;APKBUILDs are the scripts that are created in order to build Alpine packages using the [[abuild]] tool.&lt;br /&gt;
&lt;br /&gt;
See [[aports]] for details on Alpine&#039;s official ports repository.&lt;br /&gt;
&lt;br /&gt;
This page is intended to serve as a reference for creating APKBUILDs; if this is your first time creating a package for Alpine Linux, please see [[Creating an Alpine package]].&lt;br /&gt;
&lt;br /&gt;
= Legend =&lt;br /&gt;
The following notes will assist you in understanding this document.&lt;br /&gt;
&lt;br /&gt;
In description text:&lt;br /&gt;
* If a variable is not prefixed with a &#039;&#039;$&#039;&#039;, it will be represented by italics (i.e., &#039;&#039;srcdir&#039;&#039; ).&lt;br /&gt;
* Functions will also be represented by italics, but will also end with a pair of parentheses (i.e., &#039;&#039;build()&#039;&#039; ).&lt;br /&gt;
* Shell commands will be represented &amp;lt;code&amp;gt;like this&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Variables =&lt;br /&gt;
{{Note|Variables that contain a path (e.g. &#039;&#039;$srcdir&#039;&#039; and &#039;&#039;$pkgdir&#039;&#039;) should always be quoted using double quotes (i.e., &#039;&#039;&amp;quot;$srcdir&amp;quot;&#039;&#039;).  This is done to prevent things from breaking, should the user have the APKBUILD in a directory path that contains spaces.}}&lt;br /&gt;
{{Note|All arbitrary variable and function names should be prefixed with an underscore character ( _ ) to avoid name clashes with the internals of abuild (for example, &#039;&#039;_luaversions&#039;&#039;).}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined variables ==&lt;br /&gt;
The following variables are defined by abuild:&lt;br /&gt;
&lt;br /&gt;
==== startdir ====&lt;br /&gt;
: The directory where the APKBUILD script is.&lt;br /&gt;
==== srcdir ====&lt;br /&gt;
: The directory where sources, from the &#039;&#039;source&#039;&#039; variable, are downloaded to and unpacked to.&lt;br /&gt;
==== pkgdir ====&lt;br /&gt;
: This directory should receive the files for the main package.  For example, a normal [http://en.wikipedia.org/wiki/GNU_build_system autotools] package would have &amp;lt;code&amp;gt;make DESTDIR=&amp;quot;$pkgdir&amp;quot; install&amp;lt;/code&amp;gt; in the &#039;&#039;package()&#039;&#039; function.&lt;br /&gt;
==== subpkgdir ====&lt;br /&gt;
: This directory should receive the files for a subpackage. This variable should only be used from subpackage functions.&lt;br /&gt;
==== builddir ====&lt;br /&gt;
: This variable should point to the directory inside the &#039;&#039;srcdir&#039;&#039; where the main package source is unpacked.  This is typically &#039;&#039;$srcdir/$pkgname-$pkgver&#039;&#039;.  It’s used by the default &#039;&#039;prepare()&#039;&#039; function as a working directory when applying patches.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User-defined variables ==&lt;br /&gt;
The following variables should be defined by the user:&lt;br /&gt;
==== arch ====&lt;br /&gt;
: Package architecture(s) to build for.  Can be one of: &#039;&#039;&#039;[[x86]], [[x86_64]], [[armhf]], [[aarch64]], [[ppc64le]], [[s390x]], all&#039;&#039;&#039;, or &#039;&#039;&#039;noarch&#039;&#039;&#039;, where &#039;&#039;&#039;all&#039;&#039;&#039; means all architectures, and &#039;&#039;&#039;noarch&#039;&#039;&#039; means it&#039;s architecture-independent (e.g., a pure-python package).&lt;br /&gt;
: {{Tip|To determine if your APKBUILD can use &#039;&#039;&#039;noarch&#039;&#039;&#039;: First specify &#039;&#039;&#039;all&#039;&#039;&#039; and then build the package by executing &amp;lt;code&amp;gt;abuild -r&amp;lt;/code&amp;gt;.  Watch the output towards the end for warnings saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used.  If the main package and all subpackages, if you have any subpackages, give a warning saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used, then you can use &#039;&#039;&#039;noarch&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
==== depends ====&lt;br /&gt;
: Run-time dependency package(s) that are not shared-object dependencies.  Shared objects dependencies are auto-detected and should not be specified here.&lt;br /&gt;
==== depends_dev ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
: {{Note|From ncopa on IRC: To find out if you need to add a package to depends_dev have a look at *requires* in usr/lib/pkgconfig/*.pc. With libtool it gets more complicated, but we should delete the .la files. Also check if there are any  /usr/bin/*-configure #!/bin/bash #!/usr/bin/perl or Python. Sometimes scripts or similar are generated at build time (i.e autoconf automake) then you normally don&#039;t need add those to depends_dev. You can also just add all -dev makedepends to depends_dev but it will slow the build process a little bit (more build dependencies).}}&lt;br /&gt;
==== giturl ====&lt;br /&gt;
:Git repository from which &amp;lt;code&amp;gt;abuild checkout&amp;lt;/code&amp;gt; checks out. You can checkout a specific branch in git by adding &amp;lt;code&amp;gt;-b $branch&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== install ====&lt;br /&gt;
: There are 6 different types of install scripts.  Install scripts are named &#039;&#039;&#039;$pkgname.action&#039;&#039;&#039;, where &#039;&#039;&#039;action&#039;&#039;&#039; can be:  &#039;&#039;&#039;pre-install, post-install, pre-upgrade, post-upgrade, pre-deinstall&#039;&#039;&#039;, or &#039;&#039;&#039;post-deinstall&#039;&#039;&#039;.  For example, if &#039;&#039;pkgname&#039;&#039; is set to &#039;&#039;&#039;mypackage&#039;&#039;&#039; and &#039;&#039;install&#039;&#039; is set to &#039;&#039;&#039;$pkgname.post-install&#039;&#039;&#039;, then a script named &#039;&#039;&#039;mypackage.post-install&#039;&#039;&#039; must exist along-side the APKBUILD.&lt;br /&gt;
&lt;br /&gt;
: First, a few notes regarding install scripts:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;{{Note|When using install scripts, &#039;&#039;$install&#039;&#039; should be included in &#039;&#039;source&#039;&#039; so that checksums can be generated and used for the install scripts specified in &#039;&#039;install&#039;&#039;.  For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install=&amp;quot;$pkgname.pre-install $pkgname.post-install&amp;quot;&lt;br /&gt;
source=&amp;quot;http://....&lt;br /&gt;
       $install&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;}}&lt;br /&gt;
{{Note|Always use &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt; for the command-line interpreter on the [http://en.wikipedia.org/wiki/Shebang_%28Unix%29 shebang line] of your install scripts.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the different types of install scripts in detail:&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-install =====&lt;br /&gt;
: This script is executed &#039;&#039;before installing&#039;&#039; the package.  Typical use is when the package needs a group and a user to be created. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
addgroup -S clamav 2&amp;gt;/dev/null&lt;br /&gt;
adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|If the script exits with a failure (e.g., if the user already exists), the package will not be installed and &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will exit with failure, hence the &amp;lt;code&amp;gt;exit 0&amp;lt;/code&amp;gt; at the end.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-install =====&lt;br /&gt;
: This script is executed &#039;&#039;after installing&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;before upgrading/downgrading/reinstalling&#039;&#039; the package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;after upgrading/downgrading/reinstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;before uninstalling&#039;&#039; the package.&lt;br /&gt;
: {{Note|If the script exits with failure, &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will not uninstall the package.}}&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;after uninstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
==== install_if ====&lt;br /&gt;
:install_if can be used when a package needs to be installed when some packages are already installed or are in the dependency tree. It works in reverse to the &#039;&#039;recommends&#039;&#039; feature, that other package managers provide.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example:&#039;&#039;&#039; When package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; has &amp;lt;code&amp;gt;install_if=&amp;quot;B C&amp;quot;&amp;lt;/code&amp;gt;, and the user runs &amp;lt;code&amp;gt;apk add B C&amp;lt;/code&amp;gt;, then package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; will get automatically installed.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example 2:&#039;&#039;&#039; A real use-case in Alpine is open-vm-tools. Currently it contains the userspace tools and separate packages for the kernel modules (grsec and vserver). When we install the userspace tools, apk should automatically install the correct kernel modules and will need to figure out for which kernel. This is where install_if jumps in. For any of the kernel modules package we would use:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;pre&amp;gt;install_if=&amp;quot;linux-${_flavor}=${_kernelver} open-vm-tools&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:This will automatically install the package when the specified packages are installed or are in dependency tree.&lt;br /&gt;
&lt;br /&gt;
==== license ====&lt;br /&gt;
: License(s) for the package, for example &amp;lt;code&amp;gt;GPL3+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;BSD&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;MIT&amp;lt;/code&amp;gt; [[Creating_an_Alpine_package#license|(details)]].&lt;br /&gt;
&lt;br /&gt;
==== makedepends ====&lt;br /&gt;
: Build-time dependency package(s).&lt;br /&gt;
==== md5sums ====&lt;br /&gt;
: Checksums for the files/URLs listed in &#039;&#039;source&#039;&#039;.  The checksums are normally generated and updated by executing &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; and should be the last item in the APKBUILD.&lt;br /&gt;
==== options ====&lt;br /&gt;
: Build-time options for the package.&lt;br /&gt;
&lt;br /&gt;
: {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!archcheck&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to verify that the architecture of the binary files is the same architecture as abuild should build for. One example where it makes sense to set this are packages with firmware files, that get executed on another CPU (such as WiFi firmware).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to run the &amp;lt;code&amp;gt;check()&amp;lt;/code&amp;gt; function. Please always add a short comment after the &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt; about why it&#039;s disabled. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142545300] Creating a very simple check function, that calls &amp;lt;code&amp;gt;program --version&amp;lt;/code&amp;gt; is better than disabling tests completely. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142543002]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!strip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Avoid stripping symbols from binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;suid&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allow [https://en.wikipedia.org/wiki/Setuid setuid] binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!tracedeps&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not automatically find dependencies (e.g. by using &amp;lt;code&amp;gt;ldd&amp;lt;/code&amp;gt; to find dynamic libraries, which the resulting binary links against).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== pkgdesc ====&lt;br /&gt;
: A brief, one-line description of what the package does.&lt;br /&gt;
&lt;br /&gt;
: Here&#039;s an example from the OpenSSH client package:&lt;br /&gt;
: &amp;lt;pre&amp;gt;pkgdesc=&amp;quot;Port of OpenBSD&#039;s free SSH release - client&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== pkggroups ====&lt;br /&gt;
: System group(s) to be created during build-time.  System group(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system group(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgname ====&lt;br /&gt;
: The name of the package.  All letters should be lowercase.&lt;br /&gt;
: {{Note|When creating an APKBUILD of a module or library for another package, we use some common package prefixes, such as: &#039;&#039;lua-&#039;&#039;, &#039;&#039;perl-&#039;&#039;, &#039;&#039;php-&#039;&#039;, and &#039;&#039;py-&#039;&#039;.  Search aports for other common prefixes.}}&lt;br /&gt;
&lt;br /&gt;
==== pkgrel ====&lt;br /&gt;
: Alpine package release number.  Starts at 0 (zero).  Always increment &#039;&#039;pkgrel&#039;&#039; when making updates to an aport; reset &#039;&#039;pkgrel&#039;&#039; to 0 (zero) when incrementing &#039;&#039;pkgver&#039;&#039;.&lt;br /&gt;
==== pkgusers ====&lt;br /&gt;
: System user(s) to be created during build-time.  System user(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system user(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgver ====&lt;br /&gt;
: The version of the software being packaged.&lt;br /&gt;
==== provides ====&lt;br /&gt;
: List of package names (and optionally version info) this package provides.&lt;br /&gt;
&lt;br /&gt;
: If package with a version is provided (provides=&#039;foo=1.2&#039;) apk will consider it as an alternate name and it will automatically consider the package for installation by the alternate name, and conflict with other packages having the same name, or provides.&lt;br /&gt;
&lt;br /&gt;
: If version is not provided (provides=&#039;foo&#039;), apk will consider it as virtual package name. Several package with same non-versioned provides can be installed simultaneously. However, none of them will be installed by default when requested by the virtual name - instead, error message is given and user is asked to choose which package providing the virtual name should be installed.&lt;br /&gt;
==== replaces ====&lt;br /&gt;
: Package(s) that this package replaces.  This package will &amp;quot;take over&amp;quot; files owned by packages listed in the &#039;&#039;replaces&#039;&#039; variable.  This is useful when files move from one package to another, or when a package gets renamed.&lt;br /&gt;
==== replaces_priority ====&lt;br /&gt;
: The priority of the replaces. If multiple packages replace each other, then will the package with highest &#039;&#039;replaces_priority&#039;&#039; win.&lt;br /&gt;
==== source ====&lt;br /&gt;
: The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[APKBUILD Reference#install|install variable]]), patches, and all other necessary files.&lt;br /&gt;
&lt;br /&gt;
: Here are few things to note:&lt;br /&gt;
&lt;br /&gt;
:* When you are finished adding local and/or remote files to &#039;&#039;source&#039;&#039;, you can execute the following command to add their checksums to the APKBUILD file:&lt;br /&gt;
:: {{Cmd|abuild checksum}}&lt;br /&gt;
:: {{Note|When later updating the content of &#039;&#039;source&#039;&#039;, or updating a file that is listed in &#039;&#039;source&#039;&#039;, you must also update their checksums again with the same command.}}&lt;br /&gt;
&lt;br /&gt;
:* When the remote file is hosted at SourceForge, it&#039;s best to specify the special mirrors link used by SourceForge:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: (or similar depending on the package).&lt;br /&gt;
&lt;br /&gt;
:* You can set target filename (eg &#039;save as...&#039;) by prefixing the URI with &#039;&#039;filename::&#039;&#039;. This is useful when the remote filename is not specified in the URI (ie, does not end in &#039;/software-1.0.tar.gz&#039;), such as:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: or when the filename is braindead, like githubs&#039; download tags:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: The above two examples needs a target filename prefix:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::http://oss.example.org/?get=software&amp;amp;ver=$pkgver&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: and:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following protocols for remote file retrieval:&lt;br /&gt;
:** http&lt;br /&gt;
:** https&lt;br /&gt;
:** ftp&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following archive types/archive file extensions:&lt;br /&gt;
:** .tar.gz / .tgz&lt;br /&gt;
:** .tar.bz2&lt;br /&gt;
:** .tar.lzma&lt;br /&gt;
:** .tar.xz&lt;br /&gt;
:** .zip&lt;br /&gt;
&lt;br /&gt;
:: {{Note|Legacy APKBUILD scripts define &#039;&#039;source&#039;&#039; variable as &amp;quot;saveas-[brain-dead-url]/[target-filename]&amp;quot; format instead of the modern [target-filename]::[brain-dead-url].&amp;lt;br /&amp;gt;&#039;&#039;BAD&#039;&#039;:   source&amp;amp;#61;&amp;quot;saveas-http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC/$pkgname-$pkgver.tar.gz&amp;quot;&amp;lt;br /&amp;gt;&#039;&#039;GOOD&#039;&#039;:   source&amp;amp;#61;$pkgname-$pkgver.tar.gz::http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
==== subpackages ====&lt;br /&gt;
: Subpackages built from this APKBUILD.  abuild will parse this variable and try to find a subpackage split function.  The split function must &#039;&#039;move&#039;&#039; files that do not belong in the main package, from &#039;&#039;$pkgdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.  Files and directories can also be &#039;&#039;copied&#039;&#039; from &#039;&#039;$startdir&#039;&#039; and &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: The split function can be specified in 1 of 3 different methods:&lt;br /&gt;
:# subpkgname:&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# $pkgname-&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# &#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
: {{Note|Split function names &#039;&#039;&#039;cannot&#039;&#039;&#039; use hyphens; use the first method above if the subpackage name contains a hyphen (-) character, like this: &#039;&#039;subpkg-name:subpkg_name&#039;&#039;, where &amp;lt;code&amp;gt;subpkg-name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;&#039;&#039; and &amp;lt;code&amp;gt;subpkg_name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;s split function&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
: {{Tip|For more information, see the [[APKBUILD_examples:Subpackages|Subpackages example]].}}&lt;br /&gt;
&lt;br /&gt;
==== triggers ====&lt;br /&gt;
: Apk-tools can &amp;quot;monitor&amp;quot; directories and execute a trigger if any package installed/uninstalled any file in the monitored dir. The triggers are always execute after the apk action (install, uninstall, upgrade).&lt;br /&gt;
&lt;br /&gt;
: The triggers are specified in the format: &#039;&#039;scriptname&#039;&#039;=&#039;&#039;pathlist&#039;&#039; where &#039;&#039;scriptname&#039;&#039; is the (sub)package name + .trigger suffix and pathlist is : separated list of the dirs to monitor.&lt;br /&gt;
&lt;br /&gt;
: The &#039;&#039;&#039;triggers&#039;&#039;&#039; variable must include the triggers for subpackages too if they have any.&lt;br /&gt;
&lt;br /&gt;
: It is possible to use wildcards (*) in the dir list.&lt;br /&gt;
&lt;br /&gt;
==== url ====&lt;br /&gt;
: The homepage for the package.  This is to help users find upstream documentation and other information regarding the package.&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
{{Note|All functions should consider the current working directory as undefined, and should therefore use the [[APKBUILD Reference#abuild-defined_variables|abuild-defined directory variables]] to their advantage.}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined functions ==&lt;br /&gt;
The following functions are provided by abuild and can be overridden:&lt;br /&gt;
&lt;br /&gt;
==== fetch() ====&lt;br /&gt;
: Downloads remote sources listed in &#039;&#039;source&#039;&#039; to &#039;&#039;SRCDEST&#039;&#039; (&#039;&#039;SRCDEST&#039;&#039; is configured in &#039;&#039;/etc/abuild.conf&#039;&#039;) and creates symlinks in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== unpack() ====&lt;br /&gt;
: Unpacks .tgz, .tar.gz, .tar.bz2, .tar.lzma, .tar.xz, and .zip archives in &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== dev() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;dev()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;dev()&#039;&#039; function, which in turn calls &#039;&#039;default_dev()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/include&#039;&#039;, &#039;&#039;*.a&#039;&#039;, &#039;&#039;*.la&#039;&#039; and similar files to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
==== doc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;doc()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;doc()&#039;&#039; function, which in turn calls &#039;&#039;default_doc()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/doc&#039;&#039;, &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/man&#039;&#039; and similar to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== User-defined functions ==&lt;br /&gt;
The following functions should be defined by the user: &lt;br /&gt;
&lt;br /&gt;
==== prepare() ====&lt;br /&gt;
: {{note|Please adjust old APKBUILDs, which still have a &#039;&#039;prepare()&#039;&#039; function that does the same as the &#039;&#039;default_prepare()&#039;&#039; when you edit them anyway.}}&lt;br /&gt;
: &#039;&#039;&#039;&#039;&#039;Optional&#039;&#039;.&#039;&#039;&#039;  Used for build preparation: patches, etc, should be applied here. When you don&#039;t specify a custom &#039;&#039;prepare()&#039;&#039;, the built-in &#039;&#039;default_prepare()&#039;&#039; from abuild will be used. It applies patches already (always prepare them in the &amp;lt;code&amp;gt;-p1&amp;lt;/code&amp;gt; format), so &#039;&#039;&#039;usually it makes sense to not create a custom &#039;&#039;prepare()&#039;&#039; function at all!&#039;&#039;&#039; If you do create one, call &#039;&#039;default_prepare()&#039;&#039; inside it, and your custom code below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
prepare() {&lt;br /&gt;
    default_prepare&lt;br /&gt;
    # your custom code here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== build() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the compilation stage.  This function will be called as the current user (unless the &#039;&#039;package()&#039;&#039; function is missing - for compatibility reasons).  If no compilation is needed, this function can contain a single line: &amp;lt;code&amp;gt;return 0&amp;lt;/code&amp;gt;&lt;br /&gt;
==== check() ====&lt;br /&gt;
: &#039;&#039;&#039;Recommended.&#039;&#039;&#039; This function is called right after the build stage.  It should check that the packaged thing is actually working, typically by running (integration) tests, if provided by upstream.  If there’s no (easy) way how to test the package, you can declare that it does not want to use &#039;&#039;check()&#039;&#039; by adding &amp;quot;!check&amp;quot; into the &#039;&#039;options&#039;&#039; variable (&amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
==== package() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the packaging stage.  Here, the built application and support files should be installed into &#039;&#039;&#039;$pkgdir&#039;&#039;&#039;.  If this is a metapackage, this function can contain a single line: &amp;lt;code&amp;gt;mkdir -p &amp;quot;$pkgdir&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Building in fakeroot will reduce performance for parallel builds dramatically.  It is for this reason that we split the build and package process into two separate functions.}}&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
The [[APKBUILD examples]] page will assist you in understanding how to create an APKBUILD.&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=14095</id>
		<title>APKBUILD Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=14095"/>
		<updated>2017-10-21T00:48:44Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: /* options */ document !archcheck&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;APKBUILDs are the scripts that are created in order to build Alpine packages using the [[abuild]] tool.&lt;br /&gt;
&lt;br /&gt;
See [[aports]] for details on Alpine&#039;s official ports repository.&lt;br /&gt;
&lt;br /&gt;
This page is intended to serve as a reference for creating APKBUILDs; if this is your first time creating a package for Alpine Linux, please see [[Creating an Alpine package]].&lt;br /&gt;
&lt;br /&gt;
= Legend =&lt;br /&gt;
The following notes will assist you in understanding this document.&lt;br /&gt;
&lt;br /&gt;
In description text:&lt;br /&gt;
* If a variable is not prefixed with a &#039;&#039;$&#039;&#039;, it will be represented by italics (i.e., &#039;&#039;srcdir&#039;&#039; ).&lt;br /&gt;
* Functions will also be represented by italics, but will also end with a pair of parentheses (i.e., &#039;&#039;build()&#039;&#039; ).&lt;br /&gt;
* Shell commands will be represented &amp;lt;code&amp;gt;like this&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Variables =&lt;br /&gt;
{{Note|Variables that contain a path (e.g. &#039;&#039;$srcdir&#039;&#039; and &#039;&#039;$pkgdir&#039;&#039;) should always be quoted using double quotes (i.e., &#039;&#039;&amp;quot;$srcdir&amp;quot;&#039;&#039;).  This is done to prevent things from breaking, should the user have the APKBUILD in a directory path that contains spaces.}}&lt;br /&gt;
{{Note|All arbitrary variable and function names should be prefixed with an underscore character ( _ ) to avoid name clashes with the internals of abuild (for example, &#039;&#039;_luaversions&#039;&#039;).}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined variables ==&lt;br /&gt;
The following variables are defined by abuild:&lt;br /&gt;
&lt;br /&gt;
==== startdir ====&lt;br /&gt;
: The directory where the APKBUILD script is.&lt;br /&gt;
==== srcdir ====&lt;br /&gt;
: The directory where sources, from the &#039;&#039;source&#039;&#039; variable, are downloaded to and unpacked to.&lt;br /&gt;
==== pkgdir ====&lt;br /&gt;
: This directory should receive the files for the main package.  For example, a normal [http://en.wikipedia.org/wiki/GNU_build_system autotools] package would have &amp;lt;code&amp;gt;make DESTDIR=&amp;quot;$pkgdir&amp;quot; install&amp;lt;/code&amp;gt; in the &#039;&#039;package()&#039;&#039; function.&lt;br /&gt;
==== subpkgdir ====&lt;br /&gt;
: This directory should receive the files for a subpackage. This variable should only be used from subpackage functions.&lt;br /&gt;
==== builddir ====&lt;br /&gt;
: This variable should point to the directory inside the &#039;&#039;srcdir&#039;&#039; where the main package source is unpacked.  This is typically &#039;&#039;$srcdir/$pkgname-$pkgver&#039;&#039;.  It’s used by the default &#039;&#039;prepare()&#039;&#039; function as a working directory when applying patches.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User-defined variables ==&lt;br /&gt;
The following variables should be defined by the user:&lt;br /&gt;
==== arch ====&lt;br /&gt;
: Package architecture(s) to build for.  Can be one of: &#039;&#039;&#039;[[x86]], [[x86_64]], [[armhf]], [[aarch64]], [[ppc64le]], [[s390x]], all&#039;&#039;&#039;, or &#039;&#039;&#039;noarch&#039;&#039;&#039;, where &#039;&#039;&#039;all&#039;&#039;&#039; means all architectures, and &#039;&#039;&#039;noarch&#039;&#039;&#039; means it&#039;s architecture-independent (e.g., a pure-python package).&lt;br /&gt;
: {{Tip|To determine if your APKBUILD can use &#039;&#039;&#039;noarch&#039;&#039;&#039;: First specify &#039;&#039;&#039;all&#039;&#039;&#039; and then build the package by executing &amp;lt;code&amp;gt;abuild -r&amp;lt;/code&amp;gt;.  Watch the output towards the end for warnings saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used.  If the main package and all subpackages, if you have any subpackages, give a warning saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used, then you can use &#039;&#039;&#039;noarch&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
==== depends ====&lt;br /&gt;
: Run-time dependency package(s) that are not shared-object dependencies.  Shared objects dependencies are auto-detected and should not be specified here.&lt;br /&gt;
==== depends_dev ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
: {{Note|From ncopa on IRC: To find out if you need to add a package to depends_dev have a look at *requires* in usr/lib/pkgconfig/*.pc. With libtool it gets more complicated, but we should delete the .la files. Also check if there are any  /usr/bin/*-configure #!/bin/bash #!/usr/bin/perl or Python. Sometimes scripts or similar are generated at build time (i.e autoconf automake) then you normally don&#039;t need add those to depends_dev. You can also just add all -dev makedepends to depends_dev but it will slow the build process a little bit (more build dependencies).}}&lt;br /&gt;
==== giturl ====&lt;br /&gt;
:Git repository from which &amp;lt;code&amp;gt;abuild checkout&amp;lt;/code&amp;gt; checks out. You can checkout a specific branch in git by adding &amp;lt;code&amp;gt;-b $branch&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== install ====&lt;br /&gt;
: There are 6 different types of install scripts.  Install scripts are named &#039;&#039;&#039;$pkgname.action&#039;&#039;&#039;, where &#039;&#039;&#039;action&#039;&#039;&#039; can be:  &#039;&#039;&#039;pre-install, post-install, pre-upgrade, post-upgrade, pre-deinstall&#039;&#039;&#039;, or &#039;&#039;&#039;post-deinstall&#039;&#039;&#039;.  For example, if &#039;&#039;pkgname&#039;&#039; is set to &#039;&#039;&#039;mypackage&#039;&#039;&#039; and &#039;&#039;install&#039;&#039; is set to &#039;&#039;&#039;$pkgname.post-install&#039;&#039;&#039;, then a script named &#039;&#039;&#039;mypackage.post-install&#039;&#039;&#039; must exist along-side the APKBUILD.&lt;br /&gt;
&lt;br /&gt;
: First, a few notes regarding install scripts:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;{{Note|When using install scripts, &#039;&#039;$install&#039;&#039; should be included in &#039;&#039;source&#039;&#039; so that checksums can be generated and used for the install scripts specified in &#039;&#039;install&#039;&#039;.  For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install=&amp;quot;$pkgname.pre-install $pkgname.post-install&amp;quot;&lt;br /&gt;
source=&amp;quot;http://....&lt;br /&gt;
       $install&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;}}&lt;br /&gt;
{{Note|Always use &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt; for the command-line interpreter on the [http://en.wikipedia.org/wiki/Shebang_%28Unix%29 shebang line] of your install scripts.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the different types of install scripts in detail:&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-install =====&lt;br /&gt;
: This script is executed &#039;&#039;before installing&#039;&#039; the package.  Typical use is when the package needs a group and a user to be created. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
addgroup -S clamav 2&amp;gt;/dev/null&lt;br /&gt;
adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|If the script exits with a failure (e.g., if the user already exists), the package will not be installed and &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will exit with failure, hence the &amp;lt;code&amp;gt;exit 0&amp;lt;/code&amp;gt; at the end.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-install =====&lt;br /&gt;
: This script is executed &#039;&#039;after installing&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;before upgrading/downgrading/reinstalling&#039;&#039; the package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;after upgrading/downgrading/reinstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;before uninstalling&#039;&#039; the package.&lt;br /&gt;
: {{Note|If the script exits with failure, &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will not uninstall the package.}}&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;after uninstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
==== install_if ====&lt;br /&gt;
:install_if can be used when a package needs to be installed when some packages are already installed or are in the dependency tree. It works in reverse to the &#039;&#039;recommends&#039;&#039; feature, that other package managers provide.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example:&#039;&#039;&#039; When package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; has &amp;lt;code&amp;gt;install_if=&amp;quot;B C&amp;quot;&amp;lt;/code&amp;gt;, and the user runs &amp;lt;code&amp;gt;apk add B C&amp;lt;/code&amp;gt;, then package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; will get automatically installed.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example 2:&#039;&#039;&#039; A real use-case in Alpine is open-vm-tools. Currently it contains the userspace tools and separate packages for the kernel modules (grsec and vserver). When we install the userspace tools, apk should automatically install the correct kernel modules and will need to figure out for which kernel. This is where install_if jumps in. For any of the kernel modules package we would use:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;pre&amp;gt;install_if=&amp;quot;linux-${_flavor}=${_kernelver} open-vm-tools&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:This will automatically install the package when the specified packages are installed or are in dependency tree.&lt;br /&gt;
&lt;br /&gt;
==== license ====&lt;br /&gt;
: License(s) for the package, for example &amp;lt;code&amp;gt;GPL3+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;BSD&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;MIT&amp;lt;/code&amp;gt; [[Creating_an_Alpine_package#license|(details)]].&lt;br /&gt;
&lt;br /&gt;
==== makedepends ====&lt;br /&gt;
: Build-time dependency package(s).&lt;br /&gt;
==== md5sums ====&lt;br /&gt;
: Checksums for the files/URLs listed in &#039;&#039;source&#039;&#039;.  The checksums are normally generated and updated by executing &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; and should be the last item in the APKBUILD.&lt;br /&gt;
==== options ====&lt;br /&gt;
: Build-time options for the package.&lt;br /&gt;
&lt;br /&gt;
: {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!archcheck&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to verify that the architecture of the binary files is the same architecture as abuild should build for. One example where it makes sense to set this are packages with firmware files, that get executed on another CPU (such as WiFi firmware).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to run the &amp;lt;code&amp;gt;check()&amp;lt;/code&amp;gt; function. Please always add a short comment after the &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt; about why it&#039;s disabled. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142545300] Creating a very simple check function, that calls &amp;lt;code&amp;gt;program --version&amp;lt;/code&amp;gt; is better than disabling tests completely. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142543002]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!strip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Avoid stripping symbols from binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;suid&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allow [https://en.wikipedia.org/wiki/Setuid setuid] binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!tracedeps&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not automatically find dependencies (e.g. by using &amp;lt;code&amp;gt;ldd&amp;lt;/code&amp;gt; to find dynamic libraries, which the resulting binary links against).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== pkgdesc ====&lt;br /&gt;
: A brief, one-line description of what the package does.&lt;br /&gt;
&lt;br /&gt;
: Here&#039;s an example from the OpenSSH client package:&lt;br /&gt;
: &amp;lt;pre&amp;gt;pkgdesc=&amp;quot;Port of OpenBSD&#039;s free SSH release - client&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== pkggroups ====&lt;br /&gt;
: System group(s) to be created during build-time.  System group(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system group(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgname ====&lt;br /&gt;
: The name of the package.  All letters should be lowercase.&lt;br /&gt;
: {{Note|When creating an APKBUILD of a module or library for another package, we use some common package prefixes, such as: &#039;&#039;lua-&#039;&#039;, &#039;&#039;perl-&#039;&#039;, &#039;&#039;php-&#039;&#039;, and &#039;&#039;py-&#039;&#039;.  Search aports for other common prefixes.}}&lt;br /&gt;
&lt;br /&gt;
==== pkgrel ====&lt;br /&gt;
: Alpine package release number.  Starts at 0 (zero).  Always increment &#039;&#039;pkgrel&#039;&#039; when making updates to an aport; reset &#039;&#039;pkgrel&#039;&#039; to 0 (zero) when incrementing &#039;&#039;pkgver&#039;&#039;.&lt;br /&gt;
==== pkgusers ====&lt;br /&gt;
: System user(s) to be created during build-time.  System user(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system user(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgver ====&lt;br /&gt;
: The version of the software being packaged.&lt;br /&gt;
==== provides ====&lt;br /&gt;
: List of package names (and optionally version info) this package provides.&lt;br /&gt;
&lt;br /&gt;
: If package with a version is provided (provides=&#039;foo=1.2&#039;) apk will consider it as an alternate name and it will automatically consider the package for installation by the alternate name, and conflict with other packages having the same name, or provides.&lt;br /&gt;
&lt;br /&gt;
: If version is not provided (provides=&#039;foo&#039;), apk will consider it as virtual package name. Several package with same non-versioned provides can be installed simultaneously. However, none of them will be installed by default when requested by the virtual name - instead, error message is given and user is asked to choose which package providing the virtual name should be installed.&lt;br /&gt;
==== replaces ====&lt;br /&gt;
: Package(s) that this package replaces.  This package will &amp;quot;take over&amp;quot; files owned by packages listed in the &#039;&#039;replaces&#039;&#039; variable.  This is useful when files move from one package to another, or when a package gets renamed.&lt;br /&gt;
==== replaces_priority ====&lt;br /&gt;
: The priority of the replaces. If multiple packages replace each other, then will the package with highest &#039;&#039;replaces_priority&#039;&#039; win.&lt;br /&gt;
==== source ====&lt;br /&gt;
: The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[APKBUILD Reference#install|install variable]]), patches, and all other necessary files.&lt;br /&gt;
&lt;br /&gt;
: Here are few things to note:&lt;br /&gt;
&lt;br /&gt;
:* When you are finished adding local and/or remote files to &#039;&#039;source&#039;&#039;, you can execute the following command to add their checksums to the APKBUILD file:&lt;br /&gt;
:: {{Cmd|abuild checksum}}&lt;br /&gt;
:: {{Note|When later updating the content of &#039;&#039;source&#039;&#039;, or updating a file that is listed in &#039;&#039;source&#039;&#039;, you must also update their checksums again with the same command.}}&lt;br /&gt;
&lt;br /&gt;
:* When the remote file is hosted at SourceForge, it&#039;s best to specify the special mirrors link used by SourceForge:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: (or similar depending on the package).&lt;br /&gt;
&lt;br /&gt;
:* You can set target filename (eg &#039;save as...&#039;) by prefixing the URI with &#039;&#039;filename::&#039;&#039;. This is useful when the remote filename is not specified in the URI (ie, does not end in &#039;/software-1.0.tar.gz&#039;), such as:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: or when the filename is braindead, like githubs&#039; download tags:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: The above two examples needs a target filename prefix:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::http://oss.example.org/?get=software&amp;amp;ver=$pkgver&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: and:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following protocols for remote file retrieval:&lt;br /&gt;
:** http&lt;br /&gt;
:** https&lt;br /&gt;
:** ftp&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following archive types/archive file extensions:&lt;br /&gt;
:** .tar.gz / .tgz&lt;br /&gt;
:** .tar.bz2&lt;br /&gt;
:** .tar.lzma&lt;br /&gt;
:** .tar.xz&lt;br /&gt;
:** .zip&lt;br /&gt;
&lt;br /&gt;
:: {{Note|Legacy APKBUILD scripts define &#039;&#039;source&#039;&#039; variable as &amp;quot;saveas-[brain-dead-url]/[target-filename]&amp;quot; format instead of the modern [target-filename]::[brain-dead-url].&amp;lt;br /&amp;gt;&#039;&#039;BAD&#039;&#039;:   source&amp;amp;#61;&amp;quot;saveas-http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC/$pkgname-$pkgver.tar.gz&amp;quot;&amp;lt;br /&amp;gt;&#039;&#039;GOOD&#039;&#039;:   source&amp;amp;#61;$pkgname-$pkgver.tar.gz::http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
==== subpackages ====&lt;br /&gt;
: Subpackages built from this APKBUILD.  abuild will parse this variable and try to find a subpackage split function.  The split function must &#039;&#039;move&#039;&#039; files that do not belong in the main package, from &#039;&#039;$pkgdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.  Files and directories can also be &#039;&#039;copied&#039;&#039; from &#039;&#039;$startdir&#039;&#039; and &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: The split function can be specified in 1 of 3 different methods:&lt;br /&gt;
:# subpkgname:&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# $pkgname-&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# &#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
: {{Note|Split function names &#039;&#039;&#039;cannot&#039;&#039;&#039; use hyphens; use the first method above if the subpackage name contains a hyphen (-) character, like this: &#039;&#039;subpkg-name:subpkg_name&#039;&#039;, where &amp;lt;code&amp;gt;subpkg-name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;&#039;&#039; and &amp;lt;code&amp;gt;subpkg_name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;s split function&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
: {{Tip|For more information, see the [[APKBUILD_examples:Subpackages|Subpackages example]].}}&lt;br /&gt;
&lt;br /&gt;
==== triggers ====&lt;br /&gt;
: Apk-tools can &amp;quot;monitor&amp;quot; directories and execute a trigger if any package installed/uninstalled any file in the monitored dir. The triggers are always execute after the apk action (install, uninstall, upgrade).&lt;br /&gt;
&lt;br /&gt;
: The triggers are specified in the format: &#039;&#039;scriptname&#039;&#039;=&#039;&#039;pathlist&#039;&#039; where &#039;&#039;scriptname&#039;&#039; is the (sub)package name + .trigger suffix and pathlist is : separated list of the dirs to monitor.&lt;br /&gt;
&lt;br /&gt;
: The &#039;&#039;&#039;triggers&#039;&#039;&#039; variable must include the triggers for subpackages too if they have any.&lt;br /&gt;
&lt;br /&gt;
: It is possible to use wildcards (*) in the dir list.&lt;br /&gt;
&lt;br /&gt;
==== url ====&lt;br /&gt;
: The homepage for the package.  This is to help users find upstream documentation and other information regarding the package.&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
{{Note|All functions should consider the current working directory as undefined, and should therefore use the [[APKBUILD Reference#abuild-defined_variables|abuild-defined directory variables]] to their advantage.}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined functions ==&lt;br /&gt;
The following functions are provided by abuild and can be overridden:&lt;br /&gt;
&lt;br /&gt;
==== fetch() ====&lt;br /&gt;
: Downloads remote sources listed in &#039;&#039;source&#039;&#039; to &#039;&#039;SRCDEST&#039;&#039; (&#039;&#039;SRCDEST&#039;&#039; is configured in &#039;&#039;/etc/abuild.conf&#039;&#039;) and creates symlinks in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== unpack() ====&lt;br /&gt;
: Unpacks .tgz, .tar.gz, .tar.bz2, .tar.lzma, .tar.xz, and .zip archives in &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== dev() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;dev()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;dev()&#039;&#039; function, which in turn calls &#039;&#039;default_dev()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/include&#039;&#039;, &#039;&#039;*.a&#039;&#039;, &#039;&#039;*.la&#039;&#039; and similar files to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
==== doc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;doc()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;doc()&#039;&#039; function, which in turn calls &#039;&#039;default_doc()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/doc&#039;&#039;, &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/man&#039;&#039; and similar to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== User-defined functions ==&lt;br /&gt;
The following functions should be defined by the user: &lt;br /&gt;
&lt;br /&gt;
==== prepare() ====&lt;br /&gt;
: &#039;&#039;&#039;&#039;&#039;Optional&#039;&#039;.&#039;&#039;&#039;  Used for build preparation: patches, etc, should be applied here.  This function is available for your convenience. It is better to use &amp;quot;default_prepare || return&amp;quot; to handle *.patch file, and the patch file should always be prepared as -p1 format.&lt;br /&gt;
==== build() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the compilation stage.  This function will be called as the current user (unless the &#039;&#039;package()&#039;&#039; function is missing - for compatibility reasons).  If no compilation is needed, this function can contain a single line: &amp;lt;code&amp;gt;return 0&amp;lt;/code&amp;gt;&lt;br /&gt;
==== check() ====&lt;br /&gt;
: &#039;&#039;&#039;Recommended.&#039;&#039;&#039; This function is called right after the build stage.  It should check that the packaged thing is actually working, typically by running (integration) tests, if provided by upstream.  If there’s no (easy) way how to test the package, you can declare that it does not want to use &#039;&#039;check()&#039;&#039; by adding &amp;quot;!check&amp;quot; into the &#039;&#039;options&#039;&#039; variable (&amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
==== package() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the packaging stage.  Here, the built application and support files should be installed into &#039;&#039;&#039;$pkgdir&#039;&#039;&#039;.  If this is a metapackage, this function can contain a single line: &amp;lt;code&amp;gt;mkdir -p &amp;quot;$pkgdir&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Building in fakeroot will reduce performance for parallel builds dramatically.  It is for this reason that we split the build and package process into two separate functions.}}&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
The [[APKBUILD examples]] page will assist you in understanding how to create an APKBUILD.&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Syslog&amp;diff=14091</id>
		<title>Syslog</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Syslog&amp;diff=14091"/>
		<updated>2017-10-18T18:45:39Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: /* Reading logs */ fix logread command example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Syslog collects log data from multiple programs either to RAM or to a file, and handles log rotation (similar to &amp;lt;code&amp;gt;journald&amp;lt;/code&amp;gt; on systemd-based systems). Alpine installs &amp;lt;code&amp;gt;syslog&amp;lt;/code&amp;gt; as provided by &amp;lt;code&amp;gt;busybox&amp;lt;/code&amp;gt; per default, but it also packages [https://pkgs.alpinelinux.org/packages?name=*syslog* other implementations], such as &amp;lt;code&amp;gt;rsyslog&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;syslog-ng&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== busybox syslog ==&lt;br /&gt;
=== Running syslogd ===&lt;br /&gt;
Depending on how you have installed Alpine, it is already running (check with &amp;lt;code&amp;gt;ps a | grep syslogd&amp;lt;/code&amp;gt;). Otherwise enable it at boot and start it with the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rc-update add syslog boot&lt;br /&gt;
# rc-service syslog start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configuration ===&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/etc/conf.d/syslog.cfg&amp;lt;/code&amp;gt; to change the options used when running &amp;lt;code&amp;gt;syslogd&amp;lt;/code&amp;gt;. All available options can be looked up with &amp;lt;code&amp;gt;syslogd --help&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Reading logs ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /var/log/messages&lt;br /&gt;
Shows all messages and follows the log&lt;br /&gt;
# tail -f /var/log/messages | grep ssh&lt;br /&gt;
Only shows SSH related messages, also follows the log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;-C&amp;lt;/code&amp;gt; is enabled in the configuration:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# logread -f&lt;br /&gt;
# logread -f | grep ssh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Writing logs ===&lt;br /&gt;
Many applications are able to write to the syslog by default (e.g. &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt;). If you wish to write manually to it, use the &amp;lt;code&amp;gt;logger&amp;lt;/code&amp;gt; program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ logger &amp;quot;hello world&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Syslog&amp;diff=14086</id>
		<title>Syslog</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Syslog&amp;diff=14086"/>
		<updated>2017-10-17T19:47:30Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: Created page with &amp;quot;Syslog collects log data from multiple programs either to RAM or to a file, and handles log rotation (similar to &amp;lt;code&amp;gt;journald&amp;lt;/code&amp;gt; on systemd-based systems). Alpine instal...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Syslog collects log data from multiple programs either to RAM or to a file, and handles log rotation (similar to &amp;lt;code&amp;gt;journald&amp;lt;/code&amp;gt; on systemd-based systems). Alpine installs &amp;lt;code&amp;gt;syslog&amp;lt;/code&amp;gt; as provided by &amp;lt;code&amp;gt;busybox&amp;lt;/code&amp;gt; per default, but it also packages [https://pkgs.alpinelinux.org/packages?name=*syslog* other implementations], such as &amp;lt;code&amp;gt;rsyslog&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;syslog-ng&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== busybox syslog ==&lt;br /&gt;
=== Running syslogd ===&lt;br /&gt;
Depending on how you have installed Alpine, it is already running (check with &amp;lt;code&amp;gt;ps a | grep syslogd&amp;lt;/code&amp;gt;). Otherwise enable it at boot and start it with the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rc-update add syslog boot&lt;br /&gt;
# rc-service syslog start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configuration ===&lt;br /&gt;
Edit &amp;lt;code&amp;gt;/etc/conf.d/syslog.cfg&amp;lt;/code&amp;gt; to change the options used when running &amp;lt;code&amp;gt;syslogd&amp;lt;/code&amp;gt;. All available options can be looked up with &amp;lt;code&amp;gt;syslogd --help&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Reading logs ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /var/log/messages&lt;br /&gt;
Shows all messages and follows the log&lt;br /&gt;
# tail -f /var/log/messages | grep ssh&lt;br /&gt;
Only shows SSH related messages, also follows the log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;-C&amp;lt;/code&amp;gt; is enabled in the configuration:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# logread -f /var/log/messages&lt;br /&gt;
# logread -f /var/log/messages | grep ssh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Writing logs ===&lt;br /&gt;
Many applications are able to write to the syslog by default (e.g. &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt;). If you wish to write manually to it, use the &amp;lt;code&amp;gt;logger&amp;lt;/code&amp;gt; program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ logger &amp;quot;hello world&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Creating_an_Alpine_package&amp;diff=14083</id>
		<title>Creating an Alpine package</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Creating_an_Alpine_package&amp;diff=14083"/>
		<updated>2017-10-15T01:46:04Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: /* license */ fix Arch Linux spelling&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To build a package for Alpine Linux you need an Alpine Linux installation. Check the [[Installation]] page to see all available installation options.&lt;br /&gt;
&lt;br /&gt;
== Setup your system and account  ==&lt;br /&gt;
{{:Include:Setup_your_system_and_account_for_building_packages}}&lt;br /&gt;
&lt;br /&gt;
== Getting some help ==&lt;br /&gt;
&lt;br /&gt;
It might be wise to start by checking what the [[Abuild|abuild]] program can/cannot do.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|abuild -h}}&lt;br /&gt;
&lt;br /&gt;
== Creating an APKBUILD file  ==&lt;br /&gt;
&lt;br /&gt;
=== Use a template APKBUILD ===&lt;br /&gt;
&lt;br /&gt;
To create the actual APKBUILD file {{Pkg|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. Please check the [[Package_policies| package policies]] page about naming details.&lt;br /&gt;
&lt;br /&gt;
If you doubt to which repository your package belongs to you can safely use &#039;&#039;&#039;testing&#039;&#039;&#039;. Building package in your aports/testing directory is not mandatory but this way the package is already at the right place.&lt;br /&gt;
&lt;br /&gt;
{{:Include:Newapkbuild}}&lt;br /&gt;
&lt;br /&gt;
{{Note|On older Alpine systems, abuild -c -n &#039;&#039;packagename&#039;&#039; was the way to create APKBUILD files. The &#039;packagename&#039; was a parameter to the -n option so order of -c and -n matters. }}&lt;br /&gt;
&lt;br /&gt;
[[Abuild_and_Helpers#apkbuild-cpan|apkbuild-cpan]] simplifies the creation of perl packages from CPAN and [[Abuild_and_Helpers#apkbuild-pypi|apkbuild-pypi]] ease the generation of APKBUILD files for python packages from PyPi.  &lt;br /&gt;
&lt;br /&gt;
If you are create a daemon package which needs initd scripts you can add the -c making it: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|newapkbuild -c &#039;&#039;packagename&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
This will copy the sample initd and confd files to the build directory.&amp;lt;BR&amp;gt;&lt;br /&gt;
A third file sample.install file will be copied as well (we will discuss this later on).&lt;br /&gt;
&lt;br /&gt;
=== Modify your APKBUILD ===&lt;br /&gt;
Edit APKBUILD and fill in the needed info (especially pkgname, pkgver, pkgdesc, url, license, depends and source). &lt;br /&gt;
&lt;br /&gt;
If you are going to use any of the variables for directories like $pkgdir, always make sure they are double quoted like: &lt;br /&gt;
&lt;br /&gt;
 &amp;quot;$pkgdir&amp;quot;/somedir&lt;br /&gt;
&lt;br /&gt;
This will prevent issues with spaces/special characters in the future. &lt;br /&gt;
&lt;br /&gt;
{{Note|If you like syntax highlighting we suggest you to install vim. We have setup vim to recognize the APKBUILD file as a bash scripts so its easier to read them.}}&lt;br /&gt;
&lt;br /&gt;
=== APKBUILD variables/functions  ===&lt;br /&gt;
&lt;br /&gt;
==== source  ====&lt;br /&gt;
&lt;br /&gt;
The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[Creating an Alpine package#install|install variable]]), patches, and all other necessary files.&lt;br /&gt;
&lt;br /&gt;
Here are few things to note:&lt;br /&gt;
&lt;br /&gt;
* When you are finished adding local and/or remote files to &#039;&#039;source&#039;&#039;, you can execute the following command to add their checksums to the APKBUILD file:&lt;br /&gt;
: {{cmd|abuild checksum}}&lt;br /&gt;
: {{Note|When later updating the content of &#039;&#039;source&#039;&#039;, or updating a file that is listed in &#039;&#039;source&#039;&#039;, you must also update their checksums again with the same command.}}&lt;br /&gt;
&lt;br /&gt;
* When the remote file is hosted at SourceForge, it&#039;s best to specify the special mirrors link used by SourceForge:&lt;br /&gt;
: &amp;lt;pre&amp;gt;http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
: (or similar depending on the package).&lt;br /&gt;
&lt;br /&gt;
* When the remote filename is not specified in the URI (ie, does not end in &#039;/software-1.0.tar.gz&#039;), such as:&lt;br /&gt;
: &amp;lt;pre&amp;gt;http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
: You must prepend &#039;${pkgname}-${pkgver}.tar.gz::&#039; to the protocol, like so:&lt;br /&gt;
: &amp;lt;pre&amp;gt;source=&amp;quot;${pkgname}-${pkgver}.tar.gz::http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
: This causes the file to be saved as &#039;&#039;software-1.0.tar.gz&#039;&#039; where abuild can use it, instead of &#039;&#039;?get=software&amp;amp;ver=1.0&#039;&#039;, where abuild cannot use it.&lt;br /&gt;
&lt;br /&gt;
* Some projects didn&#039;t provide a release tarball. Beware that some git services (gitweg, cgit, …?) doesn’t provide &#039;&#039;stable&#039;&#039; tarballs, so when you point source to an tarball like &amp;lt;tt&amp;gt;http://repo.or.cz/w/gitstats.git/snapshot/ad7efbb9399e60cee6cb217c6b47e604174a8093.tar.gz&amp;lt;/tt&amp;gt;, then you will run into issues because the checksum changes when downloading on the build system. This is not a problem on GitHub, GitLab and other decent services provides, they provide &#039;&#039;stable&#039;&#039; tarballs.&lt;br /&gt;
&lt;br /&gt;
* abuild currently supports the following protocols for remote file retrieval:&lt;br /&gt;
** http&lt;br /&gt;
** https&lt;br /&gt;
** ftp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--: {{Note|If the you want to download from https, you need GNU wget installed on your system.}}--&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
* abuild currently supports the following archive types/archive file extensions:&lt;br /&gt;
** .tar.gz / .tgz&lt;br /&gt;
** .tar.bz2&lt;br /&gt;
** .tar.lzma&lt;br /&gt;
** .tar.xz&lt;br /&gt;
** .zip&lt;br /&gt;
&lt;br /&gt;
==== depends &amp;amp;amp; makedepends  ====&lt;br /&gt;
&lt;br /&gt;
Depends are the actual running dependencies that a package would need when it is running. Makedepends are only needed when you are building a package. If you set a package, in depends you do not need to add it to makedepends as well. The best way to find out what the depends and makedepends of a package are is to [http://en.wikipedia.org/wiki/Rtfm RTFM]. &lt;br /&gt;
&lt;br /&gt;
No kidding, lots of important information can be found it the package INSTALL and README file (or the likes). Another good way is the run &amp;lt;code&amp;gt;./configure --help&amp;lt;/code&amp;gt; from the source directory to see which options are needed for configure to finish without errors. If you do not yet have a source directory you can create one with the command: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|abuild unpack}}&lt;br /&gt;
&lt;br /&gt;
Running &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; will also show you how you can disable a specific option for this package. A good example is for instance &amp;quot;--disable-nls&amp;quot; which will disable native language support and thus does not depend on gettext (libiconv, glib, ...). &lt;br /&gt;
&lt;br /&gt;
Alpine likes to keep things small, so we try to disable as much as possible without losing too many features. The exact disable/enable options are decided the package builder but please try to follow Alpine&#039;s design concept as much as possible.&lt;br /&gt;
&lt;br /&gt;
An easy way of quickly finding out the build info for a package is to check Arch Linux (Alpine package management and build scripts are similar) or Gentoo Linux ebuilds (previous versions of Alpine were based on Gentoo).&lt;br /&gt;
&lt;br /&gt;
* [https://gitweb.gentoo.org/repo/gentoo.git/tree/ Gentoo Ebuilds] &lt;br /&gt;
* [http://www.archlinux.org/packages/search/ Arch Linux packages] [https://aur.archlinux.org/ Arch Linux User Repository]&lt;br /&gt;
&lt;br /&gt;
After the package is successfully compiled and created we should make sure it didn&#039;t link to any package that is not present in the &amp;lt;code&amp;gt;$depends&amp;lt;/code&amp;gt; variable. We do this by using &amp;lt;code&amp;gt;scanelf&amp;lt;/code&amp;gt;. If scanelf is not yet installed on your system you can do that by installing {{Pkg|pax-utils}}.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|scanelf -nR pkg}}&lt;br /&gt;
&lt;br /&gt;
An example output of {{Pkg|libcurl}} would be: &lt;br /&gt;
&lt;br /&gt;
 ET_DYN libssl.so.0.9.8,libcrypto.so.0.9.8,libz.so.1,libc.so.0,ld-uClibc.so.0 pkg/usr/lib/libcurl.so.4.1.1&lt;br /&gt;
&lt;br /&gt;
You can see the needed files and should be able to find out which file belongs to which package.&lt;br /&gt;
&lt;br /&gt;
==== license  ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;license&#039;&#039;&#039; tag must reflect the license of the source code. Please check the source tarball for COPYING, LICENSE, or other files with names that indicates that it contains licensing information. Beside the license file most developer include headers in the source code files with licensing details. Please use the short name and the release number in the license tag, e.g &lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Short name&lt;br /&gt;
! Full name&lt;br /&gt;
|-&lt;br /&gt;
| GPL2&lt;br /&gt;
| GNU General Public License Version 2.0&lt;br /&gt;
|-&lt;br /&gt;
| LGPL2+&lt;br /&gt;
| GNU Lesser General Public License Version 2.1&lt;br /&gt;
|-&lt;br /&gt;
| ASL 2.0&lt;br /&gt;
| Apache License Version 2.0&lt;br /&gt;
|-&lt;br /&gt;
| BSD&lt;br /&gt;
| BSD License&lt;br /&gt;
|-&lt;br /&gt;
| MIT&lt;br /&gt;
| MIT license&lt;br /&gt;
|-&lt;br /&gt;
| MPL 2.0&lt;br /&gt;
| Mozilla Public License v2.0&lt;br /&gt;
|-&lt;br /&gt;
| ZPL 2.0 &lt;br /&gt;
| Zope Public License v 2.0&lt;br /&gt;
|-&lt;br /&gt;
| PHP&lt;br /&gt;
| PHP License v3.0&lt;br /&gt;
|-&lt;br /&gt;
| zlib&lt;br /&gt;
| zlib/libpng License&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the GNU General Public License the &#039;+&#039; means &#039;&#039;or (at your option) any later version.&#039;&#039; which covers future releases of that license. We skip the &#039;&#039;v&#039;&#039; because it&#039;s obvious that the number shows the version. If you are unsure about the short name of a license, please check the resources below for additional information.&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.archlinux.org/index.php/Licenses Arch Linux and Licensing] &lt;br /&gt;
* [https://fedoraproject.org/wiki/Licensing:Main?rd=Licensing#Good_Licenses Fedora and Licensing]&lt;br /&gt;
&lt;br /&gt;
If a package has a special/custom license we need to provide it with the release. Because we want to save space and don&#039;t like to have licenses all over our system we have decided to include the license in the doc subpackage. Please follow the following guidelines to add a proper license. Locate the license file inside the source package. Add the doc subpackage to the $subpackages variable as follows: &lt;br /&gt;
&lt;br /&gt;
 subpackages=&amp;quot;$pkgname-doc&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Add a similar line to the following to your package() function, depending on the license description file: &lt;br /&gt;
&lt;br /&gt;
 install -Dm644 COPYING &amp;quot;$pkgdir&amp;quot;/usr/share/licenses/$pkgname/COPYING&lt;br /&gt;
&lt;br /&gt;
If you follow these steps then abuild will automatically add the license to the package-doc apk for you.&lt;br /&gt;
&lt;br /&gt;
==== arch ====&lt;br /&gt;
&lt;br /&gt;
The package architecture(s) to build for.  This can be one of: &#039;&#039;x86, x86_64, all,&#039;&#039; or &#039;&#039;noarch&#039;&#039;, where &#039;&#039;all&#039;&#039; means all architectures, and &#039;&#039;noarch&#039;&#039; means it&#039;s architecture-independent (ie, a pure-python package).&lt;br /&gt;
{{Tip|To determine if your APKBUILD can use &#039;&#039;noarch&#039;&#039;, build the package for your architecture and then run &amp;quot;scanelf -R pkg&amp;quot; from the directory that the APKBUILD resides in, in order to scan for ELF files in the &#039;&#039;./pkg&#039;&#039; directory.  If you do NOT get output from this, then &#039;&#039;noarch&#039;&#039; can be used.}}&lt;br /&gt;
&lt;br /&gt;
==== url  ====&lt;br /&gt;
&lt;br /&gt;
Website address for the program. This is usefully later on when either finding documentation or other information about the package.&lt;br /&gt;
&lt;br /&gt;
==== pkgdesc  ====&lt;br /&gt;
&lt;br /&gt;
A brief, one line, description of what the package does. Useful for the package management system. It should start with a capital letter and does &#039;&#039;&#039;not&#039;&#039;&#039; end with a period.&lt;br /&gt;
&lt;br /&gt;
Here is an example from apk_info for the OpenSSH client package:&lt;br /&gt;
&lt;br /&gt;
 pkgdesc=&amp;quot;Port of OpenBSD&#039;s free SSH release - client&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== pkgver  ====&lt;br /&gt;
&lt;br /&gt;
Provide the release number of the package you are building.&lt;br /&gt;
&lt;br /&gt;
==== pkgrel  ====&lt;br /&gt;
&lt;br /&gt;
The $pkgrel versioning is made so if you change something to your APKBUILD file without changing the actual $pkgver you can higer pkgrel so apk tools will detect it as an update. For instance if you forget to add a dependency you can add it afterward and you can +1 pkgver so apk finds this update and add the missing dependency. When there&#039;s an upstream version changes, we reset the pkgrel to 0.&lt;br /&gt;
&lt;br /&gt;
==== pkgname  ====&lt;br /&gt;
&lt;br /&gt;
The base name of the package you are creating.  For Freeswitch 1.0.6, you would use &amp;quot;freeswitch&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== install  ====&lt;br /&gt;
&lt;br /&gt;
There are 6 different kinds of install scripts. Each script is called with the $pkgname.&#039;&#039;&amp;lt;action&amp;gt;&#039;&#039; where &#039;&#039;&amp;lt;action&amp;gt;&#039;&#039; is one of the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt;$pkgname.pre-install&lt;br /&gt;
&amp;lt;dd&amp;gt;This script is executed before package is installed. Typical use is when package needs a group and a user to be created. For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
addgroup -S clamav 2&amp;gt;/dev/null&lt;br /&gt;
adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note the &#039;&#039;exit 0&#039;&#039; at the end. If the script exits with failure (if the user already exist), the package will not be installed and &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt; will exit with failure.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;$pkgname.post-install&lt;br /&gt;
&amp;lt;dd&amp;gt;This script is executed after package is installed. Can be used to generate font cache and similar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;$pkgname.pre-upgrade&lt;br /&gt;
&amp;lt;dd&amp;gt;Same as pre-install but is executed before upgrading/downgrading/reinstalling an already installed package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;$pkgname.post-upgrade&lt;br /&gt;
&amp;lt;dd&amp;gt;Same as post-install but is executed after upgrading/downgrading/reinstalling an already installed package. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;$pkgname.pre-deinstall&lt;br /&gt;
&amp;lt;dd&amp;gt;This script is executed before uninstalling a package. If script exits with failure apk will not uninstall the package.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;$pkgname.post-deinstall&lt;br /&gt;
&amp;lt;dd&amp;gt;This script is executed after a package have been uninstalled. Can be used to update font caches and restore busybox links. For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
busybox --install -s&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the package have an pre-install and post-install script the APKBUILD should have the &#039;&#039;install&#039;&#039; variable defined:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
install=&amp;quot;$pkgname.pre-install $pkgname.post-install&amp;quot;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== subpackages  ====&lt;br /&gt;
&lt;br /&gt;
$subpackages are made to split up the normal &amp;quot;make install&amp;quot; into separate packages. The most common subpackages we use are doc and dev. Because we like to keep our target system small we move documentation and development files (only needed when building packages) into separate packages. To use the specific program a user only need to install the base apk without package-doc or package-dev, but if he wants to read the manual he will need to install package-doc. &lt;br /&gt;
&lt;br /&gt;
The easiest way to find out if you need to use -dev and -doc is to first build the package without these options set and wait until the build finishes. When its finished you should have a pkg directory which is the fake root directory. Inside this directory you will see the structure as how it would be installed in / on the target system. &lt;br /&gt;
&lt;br /&gt;
To see if you need the -dev package you can run the following cmd: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|find pkg/usr/ -name &#039;*.[acho]&#039; -o -name &#039;*.la&#039;}}&lt;br /&gt;
&lt;br /&gt;
If this returns any files you need to include the -dev package. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; To see if you need the -doc package you can run the following cmd: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|find pkg/usr/share -name doc -o -name man -o -name info -o -name html -o -name sgml -o -name licenses}}&lt;br /&gt;
&lt;br /&gt;
If this returns any directories you need to include the -doc package. &lt;br /&gt;
&lt;br /&gt;
===== Custom subpackages  =====&lt;br /&gt;
&lt;br /&gt;
Some software additionally has non-essential files that do not qualify as either documentation or development content. These files should be placed in their own, specialized subpackage(s). Some packages include large test suites which are only needed in specific circumstances or binaries which have depends which we prefer not to install. To handle those we create our own package/function. In the APKBUILD below the build() function we create another function: &lt;br /&gt;
&lt;br /&gt;
 test() {&lt;br /&gt;
        mkdir -p &amp;quot;$subpkgdir&amp;quot;/usr&lt;br /&gt;
        mv &amp;quot;$pkgdir&amp;quot;/usr/package-test &amp;quot;$subpkgdir&amp;quot;/usr/&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
We also need to add the package info to $subpackages variable: &lt;br /&gt;
&lt;br /&gt;
 subpackages=&amp;quot;$pkgname-doc $pkgname-dev $pkgname-test&amp;quot;&lt;br /&gt;
&lt;br /&gt;
After we finish building the package you should see another apk called packagename-test.apk which includes the files which we moved to the $subpkgdir dir. &lt;br /&gt;
&lt;br /&gt;
The above mentioned variables can also be used in our custom function. If we want for instance to build the test() function with perl support we would add: &lt;br /&gt;
&lt;br /&gt;
 depends=&amp;quot;perl&amp;quot;&lt;br /&gt;
 makedepends=&amp;quot;perl-dev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
If we would install the base package it would not install perl, but if we install the package-test package it would.&lt;br /&gt;
&lt;br /&gt;
==== Patches  ====&lt;br /&gt;
&lt;br /&gt;
Please make sure you always submit human readable patches. Way&#039;s to create them are: &lt;br /&gt;
&lt;br /&gt;
directory compare: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|diff -urp original_directory new_directory &amp;amp;gt; filename.patch}}&lt;br /&gt;
&lt;br /&gt;
file compare: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|diff -up original.file new.file &amp;amp;gt; filename.patch}}&lt;br /&gt;
&lt;br /&gt;
Because multiple patches can patch the same file, we could create offset for the next patch. To make sure we always patch in a specified way we should number the patches as followed: &lt;br /&gt;
&lt;br /&gt;
 10-patch1.patch 20-patch2.patch 30-patch3.patch&lt;br /&gt;
&lt;br /&gt;
This way we are always sure patch 1 is first and if we want to add additional patches between them we can use 11,12,21,22...&lt;br /&gt;
&lt;br /&gt;
Add names of the patch files to the &#039;&#039;source&#039;&#039; variable. If you haven&#039;t declared custom &#039;&#039;prepare&#039;&#039; function, then it&#039;s all what you need to do. Otherwise call &#039;&#039;default_prepare&#039;&#039; in your &#039;&#039;prepare&#039;&#039; function, for example:&lt;br /&gt;
&lt;br /&gt;
 prepare() {&lt;br /&gt;
 	default_prepare&lt;br /&gt;
 &lt;br /&gt;
 	# do your stuff&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Note: Some older packages contain for loop in the &#039;&#039;prepare&#039;&#039; function to apply patches. This is not needed anymore, patches are handled by &#039;&#039;default_prepare&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Configure options  ====&lt;br /&gt;
&lt;br /&gt;
Alpine has some default configure options we set by default. We use /usr for prefix to make sure everything is installed with /usr in front of it. If you notice that anything is installed in the wrong directory please run {{Cmd|./configure --help}} and see if you can set the correct location. &lt;br /&gt;
&lt;br /&gt;
We are not covering the depend switches here we have discussed this already in the depend section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Make options  ====&lt;br /&gt;
&lt;br /&gt;
If you notice weird problems when compiling or installing the package with make/make install you could try to disable [http://www.gnu.org/software/make/manual/make.html#Parallel parallel] building/installing. A normal make line would be: &lt;br /&gt;
&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
To disable parallel we use: &lt;br /&gt;
&lt;br /&gt;
 make -j1&lt;br /&gt;
&lt;br /&gt;
We can use the same for make install. &lt;br /&gt;
&lt;br /&gt;
Because we do not want to install the package in our build environment but we want to install it in a fake root directory we need to tell &#039;make install&#039; to use another destination directory instead of &#039;/&#039;. We do this by setting a variable when we execute make install as followed: &lt;br /&gt;
&lt;br /&gt;
 make DESTDIR=&amp;quot;$pkgdir&amp;quot; install&lt;br /&gt;
&lt;br /&gt;
Please note that some Makefiles do not support this variable and will always install software in &#039;/&#039;. To make sure you do not mess up your build system NEVER run your build system as root but always use a custom user and sudo when needed. If by accident the Makefile does not support DESTDIR variable it will fail to install in our build system system directories.&lt;br /&gt;
&lt;br /&gt;
==== builddir ====&lt;br /&gt;
If you used &amp;lt;tt&amp;gt;newapkbuild&amp;lt;/tt&amp;gt; to create your APKBUILD file, you must specify the path to your unpacked sources. Inside the sections during the prepare/build/install process &#039;&#039;builddir&#039;&#039; is used. Most of the time a combination of &#039;&#039;$srcdir&#039;&#039; and &#039;&#039;$pkgname-$pkgver&#039;&#039; will work. When not, check the /src directory or the source tarball for the right string. Especially when you are working with automatically generated tarballs (like from github and gitorious), this needs to be adjusted.&lt;br /&gt;
&lt;br /&gt;
builddir=&amp;quot;$srcdir&amp;quot;/$pkgname-$pkgver&lt;br /&gt;
&lt;br /&gt;
==== Additional files  ====&lt;br /&gt;
&lt;br /&gt;
If you want/need to install additional files not mentioned above you can use the following cmd (this is an example of a conf file): &lt;br /&gt;
&lt;br /&gt;
 install -Dm644 doc/$pkgname.conf &amp;quot;$pkgdir&amp;quot;/etc/$pkgname.conf&lt;br /&gt;
&lt;br /&gt;
== Build the package  ==&lt;br /&gt;
&lt;br /&gt;
If you did not already create the checksums as mentioned above you can do so now: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|cd $pkgname&lt;br /&gt;
abuild checksum}}&lt;br /&gt;
&lt;br /&gt;
It&#039;s about time we build our package. Because a build system should never have all the package installed to prevent linking to packages we don&#039;t want it to link we use a abuild recursively with the &#039;&#039;&#039;-r&#039;&#039;&#039; switch. It will install all dependency&#039;s from your repository and builds it, afterwards it will uninstall all those depending packages again. You could also use the &#039;&#039;&#039;-R&#039;&#039;&#039; switch which would build your package including the dependency packages. &lt;br /&gt;
&lt;br /&gt;
{{Cmd|abuild -r}}&lt;br /&gt;
&lt;br /&gt;
== Commit your work  ==&lt;br /&gt;
&lt;br /&gt;
After you successfully build your package you can submit your APKBUILD to Alpine&#039;s git repository. &lt;br /&gt;
&lt;br /&gt;
Update your git repo, before adding new files: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|cd $aportsdir&lt;br /&gt;
git pull}}&lt;br /&gt;
&lt;br /&gt;
This should pull all the changes made by others into you local git repo.&lt;br /&gt;
&lt;br /&gt;
When you think you are ready you can add your files to git: &lt;br /&gt;
&lt;br /&gt;
NOTE: when using our github repo, you can create PR&#039;s for each package. Please squash all commits into a single one per PR.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|cd $aportsdir&lt;br /&gt;
git add  testing/$pkgdir (include any other files needed for the build; $pkgname.install...)&lt;br /&gt;
git commit}}&lt;br /&gt;
&lt;br /&gt;
In the commit message, add the following (remove the comments in the last four lines):&lt;br /&gt;
&lt;br /&gt;
{{Cmd| # Please enter the commit message for your changes&lt;br /&gt;
 #[snip]&lt;br /&gt;
 #&lt;br /&gt;
 testing/$pkgname: new aport   # this will be the subject line&lt;br /&gt;
                               # a blank line&lt;br /&gt;
 $pkgurl                       # homepage of project&lt;br /&gt;
 $pkgdesc                      # a one line description}}&lt;br /&gt;
&lt;br /&gt;
Or you could add the following to your `aports/.git/hooks/prepare-commit-msg` to automatically generate the commit message:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 case &amp;quot;$2,$3&amp;quot; in&lt;br /&gt;
   ,|template,)&lt;br /&gt;
     if git status --porcelain | grep -q &#039;^A.*APKBUILD$&#039;; then&lt;br /&gt;
       meta() { git diff --staged | grep &amp;quot;^+$1&amp;quot; | sed &#039;s/.*=&amp;quot;\?//;s/&amp;quot;$//&#039;;}&lt;br /&gt;
       cat &amp;gt; &amp;quot;$1&amp;quot; &amp;lt;&amp;lt;EOF&lt;br /&gt;
 testing/$(meta pkgname): new aport&lt;br /&gt;
 &lt;br /&gt;
 $(meta url)&lt;br /&gt;
 $(meta pkgdesc)&lt;br /&gt;
 EOF&lt;br /&gt;
     else&lt;br /&gt;
       git status --porcelain | sed -n &#039;s/...\(.*\)\/APKBUILD/\1: /p;T;q&#039; &amp;gt; &amp;quot;$1&amp;quot;&lt;br /&gt;
     fi;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now your changes are only available locally in your repository.&lt;br /&gt;
&lt;br /&gt;
Because you do not have push rights to the Alpine aports repository you need to create a pull request to [https://github.com/alpinelinux/aports/ Alpine&#039;s mirror on GitHub] (read instructions [https://github.com/alpinelinux/aports/blob/master/.github/CONTRIBUTING.md here]).&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a diff (patch) of the changes you made and send this patch to the &lt;br /&gt;
[http://lists.alpinelinux.org/alpine-aports/  alpine-aports mailinglist].&lt;br /&gt;
&lt;br /&gt;
To create a diff patch:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|git format-patch HEAD^}}&lt;br /&gt;
&lt;br /&gt;
or if you have sprunge, you can create a link to your patch for convenience&lt;br /&gt;
&lt;br /&gt;
{{Cmd|git format-patch HEAD^ --stdout &amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt; sprunge}}&lt;br /&gt;
&lt;br /&gt;
== Send a patch ==&lt;br /&gt;
&lt;br /&gt;
[[Creating_patches#Only_the_last_commit_with_.27git_send-email.27|git send-email]] will do that for you.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[APKBUILD Reference]]&lt;br /&gt;
* [[APKBUILD examples]]&lt;br /&gt;
* [[Development using git]]&lt;br /&gt;
* [[Development using git:Quality assurance]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=14082</id>
		<title>APKBUILD Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=14082"/>
		<updated>2017-10-15T01:28:18Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: /* license */ add examples and link to the detailed description&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;APKBUILDs are the scripts that are created in order to build Alpine packages using the [[abuild]] tool.&lt;br /&gt;
&lt;br /&gt;
See [[aports]] for details on Alpine&#039;s official ports repository.&lt;br /&gt;
&lt;br /&gt;
This page is intended to serve as a reference for creating APKBUILDs; if this is your first time creating a package for Alpine Linux, please see [[Creating an Alpine package]].&lt;br /&gt;
&lt;br /&gt;
= Legend =&lt;br /&gt;
The following notes will assist you in understanding this document.&lt;br /&gt;
&lt;br /&gt;
In description text:&lt;br /&gt;
* If a variable is not prefixed with a &#039;&#039;$&#039;&#039;, it will be represented by italics (i.e., &#039;&#039;srcdir&#039;&#039; ).&lt;br /&gt;
* Functions will also be represented by italics, but will also end with a pair of parentheses (i.e., &#039;&#039;build()&#039;&#039; ).&lt;br /&gt;
* Shell commands will be represented &amp;lt;code&amp;gt;like this&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Variables =&lt;br /&gt;
{{Note|Variables that contain a path (e.g. &#039;&#039;$srcdir&#039;&#039; and &#039;&#039;$pkgdir&#039;&#039;) should always be quoted using double quotes (i.e., &#039;&#039;&amp;quot;$srcdir&amp;quot;&#039;&#039;).  This is done to prevent things from breaking, should the user have the APKBUILD in a directory path that contains spaces.}}&lt;br /&gt;
{{Note|All arbitrary variable and function names should be prefixed with an underscore character ( _ ) to avoid name clashes with the internals of abuild (for example, &#039;&#039;_luaversions&#039;&#039;).}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined variables ==&lt;br /&gt;
The following variables are defined by abuild:&lt;br /&gt;
&lt;br /&gt;
==== startdir ====&lt;br /&gt;
: The directory where the APKBUILD script is.&lt;br /&gt;
==== srcdir ====&lt;br /&gt;
: The directory where sources, from the &#039;&#039;source&#039;&#039; variable, are downloaded to and unpacked to.&lt;br /&gt;
==== pkgdir ====&lt;br /&gt;
: This directory should receive the files for the main package.  For example, a normal [http://en.wikipedia.org/wiki/GNU_build_system autotools] package would have &amp;lt;code&amp;gt;make DESTDIR=&amp;quot;$pkgdir&amp;quot; install&amp;lt;/code&amp;gt; in the &#039;&#039;package()&#039;&#039; function.&lt;br /&gt;
==== subpkgdir ====&lt;br /&gt;
: This directory should receive the files for a subpackage. This variable should only be used from subpackage functions.&lt;br /&gt;
==== builddir ====&lt;br /&gt;
: This variable should point to the directory inside the &#039;&#039;srcdir&#039;&#039; where the main package source is unpacked.  This is typically &#039;&#039;$srcdir/$pkgname-$pkgver&#039;&#039;.  It’s used by the default &#039;&#039;prepare()&#039;&#039; function as a working directory when applying patches.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User-defined variables ==&lt;br /&gt;
The following variables should be defined by the user:&lt;br /&gt;
==== arch ====&lt;br /&gt;
: Package architecture(s) to build for.  Can be one of: &#039;&#039;&#039;[[x86]], [[x86_64]], [[armhf]], [[aarch64]], [[ppc64le]], [[s390x]], all&#039;&#039;&#039;, or &#039;&#039;&#039;noarch&#039;&#039;&#039;, where &#039;&#039;&#039;all&#039;&#039;&#039; means all architectures, and &#039;&#039;&#039;noarch&#039;&#039;&#039; means it&#039;s architecture-independent (e.g., a pure-python package).&lt;br /&gt;
: {{Tip|To determine if your APKBUILD can use &#039;&#039;&#039;noarch&#039;&#039;&#039;: First specify &#039;&#039;&#039;all&#039;&#039;&#039; and then build the package by executing &amp;lt;code&amp;gt;abuild -r&amp;lt;/code&amp;gt;.  Watch the output towards the end for warnings saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used.  If the main package and all subpackages, if you have any subpackages, give a warning saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used, then you can use &#039;&#039;&#039;noarch&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
==== depends ====&lt;br /&gt;
: Run-time dependency package(s) that are not shared-object dependencies.  Shared objects dependencies are auto-detected and should not be specified here.&lt;br /&gt;
==== depends_dev ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
: {{Note|From ncopa on IRC: To find out if you need to add a package to depends_dev have a look at *requires* in usr/lib/pkgconfig/*.pc. With libtool it gets more complicated, but we should delete the .la files. Also check if there are any  /usr/bin/*-configure #!/bin/bash #!/usr/bin/perl or Python. Sometimes scripts or similar are generated at build time (i.e autoconf automake) then you normally don&#039;t need add those to depends_dev. You can also just add all -dev makedepends to depends_dev but it will slow the build process a little bit (more build dependencies).}}&lt;br /&gt;
==== giturl ====&lt;br /&gt;
:Git repository from which &amp;lt;code&amp;gt;abuild checkout&amp;lt;/code&amp;gt; checks out. You can checkout a specific branch in git by adding &amp;lt;code&amp;gt;-b $branch&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== install ====&lt;br /&gt;
: There are 6 different types of install scripts.  Install scripts are named &#039;&#039;&#039;$pkgname.action&#039;&#039;&#039;, where &#039;&#039;&#039;action&#039;&#039;&#039; can be:  &#039;&#039;&#039;pre-install, post-install, pre-upgrade, post-upgrade, pre-deinstall&#039;&#039;&#039;, or &#039;&#039;&#039;post-deinstall&#039;&#039;&#039;.  For example, if &#039;&#039;pkgname&#039;&#039; is set to &#039;&#039;&#039;mypackage&#039;&#039;&#039; and &#039;&#039;install&#039;&#039; is set to &#039;&#039;&#039;$pkgname.post-install&#039;&#039;&#039;, then a script named &#039;&#039;&#039;mypackage.post-install&#039;&#039;&#039; must exist along-side the APKBUILD.&lt;br /&gt;
&lt;br /&gt;
: First, a few notes regarding install scripts:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;{{Note|When using install scripts, &#039;&#039;$install&#039;&#039; should be included in &#039;&#039;source&#039;&#039; so that checksums can be generated and used for the install scripts specified in &#039;&#039;install&#039;&#039;.  For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install=&amp;quot;$pkgname.pre-install $pkgname.post-install&amp;quot;&lt;br /&gt;
source=&amp;quot;http://....&lt;br /&gt;
       $install&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;}}&lt;br /&gt;
{{Note|Always use &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt; for the command-line interpreter on the [http://en.wikipedia.org/wiki/Shebang_%28Unix%29 shebang line] of your install scripts.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the different types of install scripts in detail:&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-install =====&lt;br /&gt;
: This script is executed &#039;&#039;before installing&#039;&#039; the package.  Typical use is when the package needs a group and a user to be created. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
addgroup -S clamav 2&amp;gt;/dev/null&lt;br /&gt;
adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|If the script exits with a failure (e.g., if the user already exists), the package will not be installed and &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will exit with failure, hence the &amp;lt;code&amp;gt;exit 0&amp;lt;/code&amp;gt; at the end.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-install =====&lt;br /&gt;
: This script is executed &#039;&#039;after installing&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;before upgrading/downgrading/reinstalling&#039;&#039; the package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;after upgrading/downgrading/reinstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;before uninstalling&#039;&#039; the package.&lt;br /&gt;
: {{Note|If the script exits with failure, &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will not uninstall the package.}}&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;after uninstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
==== install_if ====&lt;br /&gt;
:install_if can be used when a package needs to be installed when some packages are already installed or are in the dependency tree. It works in reverse to the &#039;&#039;recommends&#039;&#039; feature, that other package managers provide.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example:&#039;&#039;&#039; When package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; has &amp;lt;code&amp;gt;install_if=&amp;quot;B C&amp;quot;&amp;lt;/code&amp;gt;, and the user runs &amp;lt;code&amp;gt;apk add B C&amp;lt;/code&amp;gt;, then package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; will get automatically installed.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example 2:&#039;&#039;&#039; A real use-case in Alpine is open-vm-tools. Currently it contains the userspace tools and separate packages for the kernel modules (grsec and vserver). When we install the userspace tools, apk should automatically install the correct kernel modules and will need to figure out for which kernel. This is where install_if jumps in. For any of the kernel modules package we would use:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;pre&amp;gt;install_if=&amp;quot;linux-${_flavor}=${_kernelver} open-vm-tools&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:This will automatically install the package when the specified packages are installed or are in dependency tree.&lt;br /&gt;
&lt;br /&gt;
==== license ====&lt;br /&gt;
: License(s) for the package, for example &amp;lt;code&amp;gt;GPL3+&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;BSD&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;MIT&amp;lt;/code&amp;gt; [[Creating_an_Alpine_package#license|(details)]].&lt;br /&gt;
&lt;br /&gt;
==== makedepends ====&lt;br /&gt;
: Build-time dependency package(s).&lt;br /&gt;
==== md5sums ====&lt;br /&gt;
: Checksums for the files/URLs listed in &#039;&#039;source&#039;&#039;.  The checksums are normally generated and updated by executing &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; and should be the last item in the APKBUILD.&lt;br /&gt;
==== options ====&lt;br /&gt;
: Build-time options for the package.&lt;br /&gt;
&lt;br /&gt;
: {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to run the &amp;lt;code&amp;gt;check()&amp;lt;/code&amp;gt; function. Please always add a short comment after the &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt; about why it&#039;s disabled. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142545300] Creating a very simple check function, that calls &amp;lt;code&amp;gt;program --version&amp;lt;/code&amp;gt; is better than disabling tests completely. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142543002]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!strip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Avoid stripping symbols from binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;suid&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allow [https://en.wikipedia.org/wiki/Setuid setuid] binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!tracedeps&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not automatically find dependencies (e.g. by using &amp;lt;code&amp;gt;ldd&amp;lt;/code&amp;gt; to find dynamic libraries, which the resulting binary links against).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== pkgdesc ====&lt;br /&gt;
: A brief, one-line description of what the package does.&lt;br /&gt;
&lt;br /&gt;
: Here&#039;s an example from the OpenSSH client package:&lt;br /&gt;
: &amp;lt;pre&amp;gt;pkgdesc=&amp;quot;Port of OpenBSD&#039;s free SSH release - client&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== pkggroups ====&lt;br /&gt;
: System group(s) to be created during build-time.  System group(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system group(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgname ====&lt;br /&gt;
: The name of the package.  All letters should be lowercase.&lt;br /&gt;
: {{Note|When creating an APKBUILD of a module or library for another package, we use some common package prefixes, such as: &#039;&#039;lua-&#039;&#039;, &#039;&#039;perl-&#039;&#039;, &#039;&#039;php-&#039;&#039;, and &#039;&#039;py-&#039;&#039;.  Search aports for other common prefixes.}}&lt;br /&gt;
&lt;br /&gt;
==== pkgrel ====&lt;br /&gt;
: Alpine package release number.  Starts at 0 (zero).  Always increment &#039;&#039;pkgrel&#039;&#039; when making updates to an aport; reset &#039;&#039;pkgrel&#039;&#039; to 0 (zero) when incrementing &#039;&#039;pkgver&#039;&#039;.&lt;br /&gt;
==== pkgusers ====&lt;br /&gt;
: System user(s) to be created during build-time.  System user(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system user(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgver ====&lt;br /&gt;
: The version of the software being packaged.&lt;br /&gt;
==== provides ====&lt;br /&gt;
: List of package names (and optionally version info) this package provides.&lt;br /&gt;
&lt;br /&gt;
: If package with a version is provided (provides=&#039;foo=1.2&#039;) apk will consider it as an alternate name and it will automatically consider the package for installation by the alternate name, and conflict with other packages having the same name, or provides.&lt;br /&gt;
&lt;br /&gt;
: If version is not provided (provides=&#039;foo&#039;), apk will consider it as virtual package name. Several package with same non-versioned provides can be installed simultaneously. However, none of them will be installed by default when requested by the virtual name - instead, error message is given and user is asked to choose which package providing the virtual name should be installed.&lt;br /&gt;
==== replaces ====&lt;br /&gt;
: Package(s) that this package replaces.  This package will &amp;quot;take over&amp;quot; files owned by packages listed in the &#039;&#039;replaces&#039;&#039; variable.  This is useful when files move from one package to another, or when a package gets renamed.&lt;br /&gt;
==== replaces_priority ====&lt;br /&gt;
: The priority of the replaces. If multiple packages replace each other, then will the package with highest &#039;&#039;replaces_priority&#039;&#039; win.&lt;br /&gt;
==== source ====&lt;br /&gt;
: The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[APKBUILD Reference#install|install variable]]), patches, and all other necessary files.&lt;br /&gt;
&lt;br /&gt;
: Here are few things to note:&lt;br /&gt;
&lt;br /&gt;
:* When you are finished adding local and/or remote files to &#039;&#039;source&#039;&#039;, you can execute the following command to add their checksums to the APKBUILD file:&lt;br /&gt;
:: {{Cmd|abuild checksum}}&lt;br /&gt;
:: {{Note|When later updating the content of &#039;&#039;source&#039;&#039;, or updating a file that is listed in &#039;&#039;source&#039;&#039;, you must also update their checksums again with the same command.}}&lt;br /&gt;
&lt;br /&gt;
:* When the remote file is hosted at SourceForge, it&#039;s best to specify the special mirrors link used by SourceForge:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: (or similar depending on the package).&lt;br /&gt;
&lt;br /&gt;
:* You can set target filename (eg &#039;save as...&#039;) by prefixing the URI with &#039;&#039;filename::&#039;&#039;. This is useful when the remote filename is not specified in the URI (ie, does not end in &#039;/software-1.0.tar.gz&#039;), such as:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: or when the filename is braindead, like githubs&#039; download tags:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: The above two examples needs a target filename prefix:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::http://oss.example.org/?get=software&amp;amp;ver=$pkgver&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: and:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following protocols for remote file retrieval:&lt;br /&gt;
:** http&lt;br /&gt;
:** https&lt;br /&gt;
:** ftp&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following archive types/archive file extensions:&lt;br /&gt;
:** .tar.gz / .tgz&lt;br /&gt;
:** .tar.bz2&lt;br /&gt;
:** .tar.lzma&lt;br /&gt;
:** .tar.xz&lt;br /&gt;
:** .zip&lt;br /&gt;
&lt;br /&gt;
:: {{Note|Legacy APKBUILD scripts define &#039;&#039;source&#039;&#039; variable as &amp;quot;saveas-[brain-dead-url]/[target-filename]&amp;quot; format instead of the modern [target-filename]::[brain-dead-url].&amp;lt;br /&amp;gt;&#039;&#039;BAD&#039;&#039;:   source&amp;amp;#61;&amp;quot;saveas-http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC/$pkgname-$pkgver.tar.gz&amp;quot;&amp;lt;br /&amp;gt;&#039;&#039;GOOD&#039;&#039;:   source&amp;amp;#61;$pkgname-$pkgver.tar.gz::http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
==== subpackages ====&lt;br /&gt;
: Subpackages built from this APKBUILD.  abuild will parse this variable and try to find a subpackage split function.  The split function must &#039;&#039;move&#039;&#039; files that do not belong in the main package, from &#039;&#039;$pkgdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.  Files and directories can also be &#039;&#039;copied&#039;&#039; from &#039;&#039;$startdir&#039;&#039; and &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: The split function can be specified in 1 of 3 different methods:&lt;br /&gt;
:# subpkgname:&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# $pkgname-&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# &#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
: {{Note|Split function names &#039;&#039;&#039;cannot&#039;&#039;&#039; use hyphens; use the first method above if the subpackage name contains a hyphen (-) character, like this: &#039;&#039;subpkg-name:subpkg_name&#039;&#039;, where &amp;lt;code&amp;gt;subpkg-name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;&#039;&#039; and &amp;lt;code&amp;gt;subpkg_name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;s split function&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
: {{Tip|For more information, see the [[APKBUILD_examples:Subpackages|Subpackages example]].}}&lt;br /&gt;
&lt;br /&gt;
==== triggers ====&lt;br /&gt;
: Apk-tools can &amp;quot;monitor&amp;quot; directories and execute a trigger if any package installed/uninstalled any file in the monitored dir. The triggers are always execute after the apk action (install, uninstall, upgrade).&lt;br /&gt;
&lt;br /&gt;
: The triggers are specified in the format: &#039;&#039;scriptname&#039;&#039;=&#039;&#039;pathlist&#039;&#039; where &#039;&#039;scriptname&#039;&#039; is the (sub)package name + .trigger suffix and pathlist is : separated list of the dirs to monitor.&lt;br /&gt;
&lt;br /&gt;
: The &#039;&#039;&#039;triggers&#039;&#039;&#039; variable must include the triggers for subpackages too if they have any.&lt;br /&gt;
&lt;br /&gt;
: It is possible to use wildcards (*) in the dir list.&lt;br /&gt;
&lt;br /&gt;
==== url ====&lt;br /&gt;
: The homepage for the package.  This is to help users find upstream documentation and other information regarding the package.&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
{{Note|All functions should consider the current working directory as undefined, and should therefore use the [[APKBUILD Reference#abuild-defined_variables|abuild-defined directory variables]] to their advantage.}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined functions ==&lt;br /&gt;
The following functions are provided by abuild and can be overridden:&lt;br /&gt;
&lt;br /&gt;
==== fetch() ====&lt;br /&gt;
: Downloads remote sources listed in &#039;&#039;source&#039;&#039; to &#039;&#039;SRCDEST&#039;&#039; (&#039;&#039;SRCDEST&#039;&#039; is configured in &#039;&#039;/etc/abuild.conf&#039;&#039;) and creates symlinks in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== unpack() ====&lt;br /&gt;
: Unpacks .tgz, .tar.gz, .tar.bz2, .tar.lzma, .tar.xz, and .zip archives in &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== dev() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;dev()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;dev()&#039;&#039; function, which in turn calls &#039;&#039;default_dev()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/include&#039;&#039;, &#039;&#039;*.a&#039;&#039;, &#039;&#039;*.la&#039;&#039; and similar files to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
==== doc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;doc()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;doc()&#039;&#039; function, which in turn calls &#039;&#039;default_doc()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/doc&#039;&#039;, &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/man&#039;&#039; and similar to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== User-defined functions ==&lt;br /&gt;
The following functions should be defined by the user: &lt;br /&gt;
&lt;br /&gt;
==== prepare() ====&lt;br /&gt;
: &#039;&#039;&#039;&#039;&#039;Optional&#039;&#039;.&#039;&#039;&#039;  Used for build preparation: patches, etc, should be applied here.  This function is available for your convenience. It is better to use &amp;quot;default_prepare || return&amp;quot; to handle *.patch file, and the patch file should always be prepared as -p1 format.&lt;br /&gt;
==== build() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the compilation stage.  This function will be called as the current user (unless the &#039;&#039;package()&#039;&#039; function is missing - for compatibility reasons).  If no compilation is needed, this function can contain a single line: &amp;lt;code&amp;gt;return 0&amp;lt;/code&amp;gt;&lt;br /&gt;
==== check() ====&lt;br /&gt;
: &#039;&#039;&#039;Recommended.&#039;&#039;&#039; This function is called right after the build stage.  It should check that the packaged thing is actually working, typically by running (integration) tests, if provided by upstream.  If there’s no (easy) way how to test the package, you can declare that it does not want to use &#039;&#039;check()&#039;&#039; by adding &amp;quot;!check&amp;quot; into the &#039;&#039;options&#039;&#039; variable (&amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
==== package() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the packaging stage.  Here, the built application and support files should be installed into &#039;&#039;&#039;$pkgdir&#039;&#039;&#039;.  If this is a metapackage, this function can contain a single line: &amp;lt;code&amp;gt;mkdir -p &amp;quot;$pkgdir&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Building in fakeroot will reduce performance for parallel builds dramatically.  It is for this reason that we split the build and package process into two separate functions.}}&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
The [[APKBUILD examples]] page will assist you in understanding how to create an APKBUILD.&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=14055</id>
		<title>APKBUILD Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=14055"/>
		<updated>2017-10-06T17:59:44Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: /* options */ indent properly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;APKBUILDs are the scripts that are created in order to build Alpine packages using the [[abuild]] tool.&lt;br /&gt;
&lt;br /&gt;
See [[aports]] for details on Alpine&#039;s official ports repository.&lt;br /&gt;
&lt;br /&gt;
This page is intended to serve as a reference for creating APKBUILDs; if this is your first time creating a package for Alpine Linux, please see [[Creating an Alpine package]].&lt;br /&gt;
&lt;br /&gt;
= Legend =&lt;br /&gt;
The following notes will assist you in understanding this document.&lt;br /&gt;
&lt;br /&gt;
In description text:&lt;br /&gt;
* If a variable is not prefixed with a &#039;&#039;$&#039;&#039;, it will be represented by italics (i.e., &#039;&#039;srcdir&#039;&#039; ).&lt;br /&gt;
* Functions will also be represented by italics, but will also end with a pair of parentheses (i.e., &#039;&#039;build()&#039;&#039; ).&lt;br /&gt;
* Shell commands will be represented &amp;lt;code&amp;gt;like this&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Variables =&lt;br /&gt;
{{Note|Variables that contain a path (e.g. &#039;&#039;$srcdir&#039;&#039; and &#039;&#039;$pkgdir&#039;&#039;) should always be quoted using double quotes (i.e., &#039;&#039;&amp;quot;$srcdir&amp;quot;&#039;&#039;).  This is done to prevent things from breaking, should the user have the APKBUILD in a directory path that contains spaces.}}&lt;br /&gt;
{{Note|All arbitrary variable and function names should be prefixed with an underscore character ( _ ) to avoid name clashes with the internals of abuild (for example, &#039;&#039;_luaversions&#039;&#039;).}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined variables ==&lt;br /&gt;
The following variables are defined by abuild:&lt;br /&gt;
&lt;br /&gt;
==== startdir ====&lt;br /&gt;
: The directory where the APKBUILD script is.&lt;br /&gt;
==== srcdir ====&lt;br /&gt;
: The directory where sources, from the &#039;&#039;source&#039;&#039; variable, are downloaded to and unpacked to.&lt;br /&gt;
==== pkgdir ====&lt;br /&gt;
: This directory should receive the files for the main package.  For example, a normal [http://en.wikipedia.org/wiki/GNU_build_system autotools] package would have &amp;lt;code&amp;gt;make DESTDIR=&amp;quot;$pkgdir&amp;quot; install&amp;lt;/code&amp;gt; in the &#039;&#039;package()&#039;&#039; function.&lt;br /&gt;
==== subpkgdir ====&lt;br /&gt;
: This directory should receive the files for a subpackage. This variable should only be used from subpackage functions.&lt;br /&gt;
==== builddir ====&lt;br /&gt;
: This variable should point to the directory inside the &#039;&#039;srcdir&#039;&#039; where the main package source is unpacked.  This is typically &#039;&#039;$srcdir/$pkgname-$pkgver&#039;&#039;.  It’s used by the default &#039;&#039;prepare()&#039;&#039; function as a working directory when applying patches.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User-defined variables ==&lt;br /&gt;
The following variables should be defined by the user:&lt;br /&gt;
==== arch ====&lt;br /&gt;
: Package architecture(s) to build for.  Can be one of: &#039;&#039;&#039;[[x86]], [[x86_64]], [[armhf]], [[aarch64]], [[ppc64le]], [[s390x]], all&#039;&#039;&#039;, or &#039;&#039;&#039;noarch&#039;&#039;&#039;, where &#039;&#039;&#039;all&#039;&#039;&#039; means all architectures, and &#039;&#039;&#039;noarch&#039;&#039;&#039; means it&#039;s architecture-independent (e.g., a pure-python package).&lt;br /&gt;
: {{Tip|To determine if your APKBUILD can use &#039;&#039;&#039;noarch&#039;&#039;&#039;: First specify &#039;&#039;&#039;all&#039;&#039;&#039; and then build the package by executing &amp;lt;code&amp;gt;abuild -r&amp;lt;/code&amp;gt;.  Watch the output towards the end for warnings saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used.  If the main package and all subpackages, if you have any subpackages, give a warning saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used, then you can use &#039;&#039;&#039;noarch&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
==== depends ====&lt;br /&gt;
: Run-time dependency package(s) that are not shared-object dependencies.  Shared objects dependencies are auto-detected and should not be specified here.&lt;br /&gt;
==== depends_dev ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
: {{Note|From ncopa on IRC: To find out if you need to add a package to depends_dev have a look at *requires* in usr/lib/pkgconfig/*.pc. With libtool it gets more complicated, but we should delete the .la files. Also check if there are any  /usr/bin/*-configure #!/bin/bash #!/usr/bin/perl or Python. Sometimes scripts or similar are generated at build time (i.e autoconf automake) then you normally don&#039;t need add those to depends_dev. You can also just add all -dev makedepends to depends_dev but it will slow the build process a little bit (more build dependencies).}}&lt;br /&gt;
==== giturl ====&lt;br /&gt;
:Git repository from which &amp;lt;code&amp;gt;abuild checkout&amp;lt;/code&amp;gt; checks out. You can checkout a specific branch in git by adding &amp;lt;code&amp;gt;-b $branch&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== install ====&lt;br /&gt;
: There are 6 different types of install scripts.  Install scripts are named &#039;&#039;&#039;$pkgname.action&#039;&#039;&#039;, where &#039;&#039;&#039;action&#039;&#039;&#039; can be:  &#039;&#039;&#039;pre-install, post-install, pre-upgrade, post-upgrade, pre-deinstall&#039;&#039;&#039;, or &#039;&#039;&#039;post-deinstall&#039;&#039;&#039;.  For example, if &#039;&#039;pkgname&#039;&#039; is set to &#039;&#039;&#039;mypackage&#039;&#039;&#039; and &#039;&#039;install&#039;&#039; is set to &#039;&#039;&#039;$pkgname.post-install&#039;&#039;&#039;, then a script named &#039;&#039;&#039;mypackage.post-install&#039;&#039;&#039; must exist along-side the APKBUILD.&lt;br /&gt;
&lt;br /&gt;
: First, a few notes regarding install scripts:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;{{Note|When using install scripts, &#039;&#039;$install&#039;&#039; should be included in &#039;&#039;source&#039;&#039; so that checksums can be generated and used for the install scripts specified in &#039;&#039;install&#039;&#039;.  For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install=&amp;quot;$pkgname.pre-install $pkgname.post-install&amp;quot;&lt;br /&gt;
source=&amp;quot;http://....&lt;br /&gt;
       $install&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;}}&lt;br /&gt;
{{Note|Always use &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt; for the command-line interpreter on the [http://en.wikipedia.org/wiki/Shebang_%28Unix%29 shebang line] of your install scripts.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the different types of install scripts in detail:&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-install =====&lt;br /&gt;
: This script is executed &#039;&#039;before installing&#039;&#039; the package.  Typical use is when the package needs a group and a user to be created. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
addgroup -S clamav 2&amp;gt;/dev/null&lt;br /&gt;
adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|If the script exits with a failure (e.g., if the user already exists), the package will not be installed and &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will exit with failure, hence the &amp;lt;code&amp;gt;exit 0&amp;lt;/code&amp;gt; at the end.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-install =====&lt;br /&gt;
: This script is executed &#039;&#039;after installing&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;before upgrading/downgrading/reinstalling&#039;&#039; the package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;after upgrading/downgrading/reinstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;before uninstalling&#039;&#039; the package.&lt;br /&gt;
: {{Note|If the script exits with failure, &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will not uninstall the package.}}&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;after uninstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
==== install_if ====&lt;br /&gt;
:install_if can be used when a package needs to be installed when some packages are already installed or are in the dependency tree. It works in reverse to the &#039;&#039;recommends&#039;&#039; feature, that other package managers provide.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example:&#039;&#039;&#039; When package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; has &amp;lt;code&amp;gt;install_if=&amp;quot;B C&amp;quot;&amp;lt;/code&amp;gt;, and the user runs &amp;lt;code&amp;gt;apk add B C&amp;lt;/code&amp;gt;, then package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; will get automatically installed.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example 2:&#039;&#039;&#039; A real use-case in Alpine is open-vm-tools. Currently it contains the userspace tools and separate packages for the kernel modules (grsec and vserver). When we install the userspace tools, apk should automatically install the correct kernel modules and will need to figure out for which kernel. This is where install_if jumps in. For any of the kernel modules package we would use:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;pre&amp;gt;install_if=&amp;quot;linux-${_flavor}=${_kernelver} open-vm-tools&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:This will automatically install the package when the specified packages are installed or are in dependency tree.&lt;br /&gt;
&lt;br /&gt;
==== license ====&lt;br /&gt;
: License(s) for the package.&lt;br /&gt;
==== makedepends ====&lt;br /&gt;
: Build-time dependency package(s).&lt;br /&gt;
==== md5sums ====&lt;br /&gt;
: Checksums for the files/URLs listed in &#039;&#039;source&#039;&#039;.  The checksums are normally generated and updated by executing &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; and should be the last item in the APKBUILD.&lt;br /&gt;
==== options ====&lt;br /&gt;
: Build-time options for the package.&lt;br /&gt;
&lt;br /&gt;
: {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to run the &amp;lt;code&amp;gt;check()&amp;lt;/code&amp;gt; function. Please always add a short comment after the &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt; about why it&#039;s disabled. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142545300] Creating a very simple check function, that calls &amp;lt;code&amp;gt;program --version&amp;lt;/code&amp;gt; is better than disabling tests completely. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142543002]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!strip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Avoid stripping symbols from binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;suid&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allow [https://en.wikipedia.org/wiki/Setuid setuid] binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!tracedeps&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not automatically find dependencies (e.g. by using &amp;lt;code&amp;gt;ldd&amp;lt;/code&amp;gt; to find dynamic libraries, which the resulting binary links against).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== pkgdesc ====&lt;br /&gt;
: A brief, one-line description of what the package does.&lt;br /&gt;
&lt;br /&gt;
: Here&#039;s an example from the OpenSSH client package:&lt;br /&gt;
: &amp;lt;pre&amp;gt;pkgdesc=&amp;quot;Port of OpenBSD&#039;s free SSH release - client&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== pkggroups ====&lt;br /&gt;
: System group(s) to be created during build-time.  System group(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system group(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgname ====&lt;br /&gt;
: The name of the package.  All letters should be lowercase.&lt;br /&gt;
: {{Note|When creating an APKBUILD of a module or library for another package, we use some common package prefixes, such as: &#039;&#039;lua-&#039;&#039;, &#039;&#039;perl-&#039;&#039;, &#039;&#039;php-&#039;&#039;, and &#039;&#039;py-&#039;&#039;.  Search aports for other common prefixes.}}&lt;br /&gt;
&lt;br /&gt;
==== pkgrel ====&lt;br /&gt;
: Alpine package release number.  Starts at 0 (zero).  Always increment &#039;&#039;pkgrel&#039;&#039; when making updates to an aport; reset &#039;&#039;pkgrel&#039;&#039; to 0 (zero) when incrementing &#039;&#039;pkgver&#039;&#039;.&lt;br /&gt;
==== pkgusers ====&lt;br /&gt;
: System user(s) to be created during build-time.  System user(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system user(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgver ====&lt;br /&gt;
: The version of the software being packaged.&lt;br /&gt;
==== provides ====&lt;br /&gt;
: List of package names (and optionally version info) this package provides.&lt;br /&gt;
&lt;br /&gt;
: If package with a version is provided (provides=&#039;foo=1.2&#039;) apk will consider it as an alternate name and it will automatically consider the package for installation by the alternate name, and conflict with other packages having the same name, or provides.&lt;br /&gt;
&lt;br /&gt;
: If version is not provided (provides=&#039;foo&#039;), apk will consider it as virtual package name. Several package with same non-versioned provides can be installed simultaneously. However, none of them will be installed by default when requested by the virtual name - instead, error message is given and user is asked to choose which package providing the virtual name should be installed.&lt;br /&gt;
==== replaces ====&lt;br /&gt;
: Package(s) that this package replaces.  This package will &amp;quot;take over&amp;quot; files owned by packages listed in the &#039;&#039;replaces&#039;&#039; variable.  This is useful when files move from one package to another, or when a package gets renamed.&lt;br /&gt;
==== replaces_priority ====&lt;br /&gt;
: The priority of the replaces. If multiple packages replace each other, then will the package with highest &#039;&#039;replaces_priority&#039;&#039; win.&lt;br /&gt;
==== source ====&lt;br /&gt;
: The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[APKBUILD Reference#install|install variable]]), patches, and all other necessary files.&lt;br /&gt;
&lt;br /&gt;
: Here are few things to note:&lt;br /&gt;
&lt;br /&gt;
:* When you are finished adding local and/or remote files to &#039;&#039;source&#039;&#039;, you can execute the following command to add their checksums to the APKBUILD file:&lt;br /&gt;
:: {{Cmd|abuild checksum}}&lt;br /&gt;
:: {{Note|When later updating the content of &#039;&#039;source&#039;&#039;, or updating a file that is listed in &#039;&#039;source&#039;&#039;, you must also update their checksums again with the same command.}}&lt;br /&gt;
&lt;br /&gt;
:* When the remote file is hosted at SourceForge, it&#039;s best to specify the special mirrors link used by SourceForge:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: (or similar depending on the package).&lt;br /&gt;
&lt;br /&gt;
:* You can set target filename (eg &#039;save as...&#039;) by prefixing the URI with &#039;&#039;filename::&#039;&#039;. This is useful when the remote filename is not specified in the URI (ie, does not end in &#039;/software-1.0.tar.gz&#039;), such as:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: or when the filename is braindead, like githubs&#039; download tags:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: The above two examples needs a target filename prefix:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::http://oss.example.org/?get=software&amp;amp;ver=$pkgver&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: and:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following protocols for remote file retrieval:&lt;br /&gt;
:** http&lt;br /&gt;
:** https&lt;br /&gt;
:** ftp&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following archive types/archive file extensions:&lt;br /&gt;
:** .tar.gz / .tgz&lt;br /&gt;
:** .tar.bz2&lt;br /&gt;
:** .tar.lzma&lt;br /&gt;
:** .tar.xz&lt;br /&gt;
:** .zip&lt;br /&gt;
&lt;br /&gt;
:: {{Note|Legacy APKBUILD scripts define &#039;&#039;source&#039;&#039; variable as &amp;quot;saveas-[brain-dead-url]/[target-filename]&amp;quot; format instead of the modern [target-filename]::[brain-dead-url].&amp;lt;br /&amp;gt;&#039;&#039;BAD&#039;&#039;:   source&amp;amp;#61;&amp;quot;saveas-http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC/$pkgname-$pkgver.tar.gz&amp;quot;&amp;lt;br /&amp;gt;&#039;&#039;GOOD&#039;&#039;:   source&amp;amp;#61;$pkgname-$pkgver.tar.gz::http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
==== subpackages ====&lt;br /&gt;
: Subpackages built from this APKBUILD.  abuild will parse this variable and try to find a subpackage split function.  The split function must &#039;&#039;move&#039;&#039; files that do not belong in the main package, from &#039;&#039;$pkgdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.  Files and directories can also be &#039;&#039;copied&#039;&#039; from &#039;&#039;$startdir&#039;&#039; and &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: The split function can be specified in 1 of 3 different methods:&lt;br /&gt;
:# subpkgname:&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# $pkgname-&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# &#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
: {{Note|Split function names &#039;&#039;&#039;cannot&#039;&#039;&#039; use hyphens; use the first method above if the subpackage name contains a hyphen (-) character, like this: &#039;&#039;subpkg-name:subpkg_name&#039;&#039;, where &amp;lt;code&amp;gt;subpkg-name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;&#039;&#039; and &amp;lt;code&amp;gt;subpkg_name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;s split function&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
: {{Tip|For more information, see the [[APKBUILD_examples:Subpackages|Subpackages example]].}}&lt;br /&gt;
&lt;br /&gt;
==== triggers ====&lt;br /&gt;
: Apk-tools can &amp;quot;monitor&amp;quot; directories and execute a trigger if any package installed/uninstalled any file in the monitored dir. The triggers are always execute after the apk action (install, uninstall, upgrade).&lt;br /&gt;
&lt;br /&gt;
: The triggers are specified in the format: &#039;&#039;scriptname&#039;&#039;=&#039;&#039;pathlist&#039;&#039; where &#039;&#039;scriptname&#039;&#039; is the (sub)package name + .trigger suffix and pathlist is : separated list of the dirs to monitor.&lt;br /&gt;
&lt;br /&gt;
: The &#039;&#039;&#039;triggers&#039;&#039;&#039; variable must include the triggers for subpackages too if they have any.&lt;br /&gt;
&lt;br /&gt;
: It is possible to use wildcards (*) in the dir list.&lt;br /&gt;
&lt;br /&gt;
==== url ====&lt;br /&gt;
: The homepage for the package.  This is to help users find upstream documentation and other information regarding the package.&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
{{Note|All functions should consider the current working directory as undefined, and should therefore use the [[APKBUILD Reference#abuild-defined_variables|abuild-defined directory variables]] to their advantage.}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined functions ==&lt;br /&gt;
The following functions are provided by abuild and can be overridden:&lt;br /&gt;
&lt;br /&gt;
==== fetch() ====&lt;br /&gt;
: Downloads remote sources listed in &#039;&#039;source&#039;&#039; to &#039;&#039;SRCDEST&#039;&#039; (&#039;&#039;SRCDEST&#039;&#039; is configured in &#039;&#039;/etc/abuild.conf&#039;&#039;) and creates symlinks in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== unpack() ====&lt;br /&gt;
: Unpacks .tgz, .tar.gz, .tar.bz2, .tar.lzma, .tar.xz, and .zip archives in &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== dev() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;dev()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;dev()&#039;&#039; function, which in turn calls &#039;&#039;default_dev()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/include&#039;&#039;, &#039;&#039;*.a&#039;&#039;, &#039;&#039;*.la&#039;&#039; and similar files to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
==== doc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;doc()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;doc()&#039;&#039; function, which in turn calls &#039;&#039;default_doc()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/doc&#039;&#039;, &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/man&#039;&#039; and similar to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== User-defined functions ==&lt;br /&gt;
The following functions should be defined by the user: &lt;br /&gt;
&lt;br /&gt;
==== prepare() ====&lt;br /&gt;
: &#039;&#039;&#039;&#039;&#039;Optional&#039;&#039;.&#039;&#039;&#039;  Used for build preparation: patches, etc, should be applied here.  This function is available for your convenience. It is better to use &amp;quot;default_prepare || return&amp;quot; to handle *.patch file, and the patch file should always be prepared as -p1 format.&lt;br /&gt;
==== build() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the compilation stage.  This function will be called as the current user (unless the &#039;&#039;package()&#039;&#039; function is missing - for compatibility reasons).  If no compilation is needed, this function can contain a single line: &amp;lt;code&amp;gt;return 0&amp;lt;/code&amp;gt;&lt;br /&gt;
==== check() ====&lt;br /&gt;
: &#039;&#039;&#039;Recommended.&#039;&#039;&#039; This function is called right after the build stage.  It should check that the packaged thing is actually working, typically by running (integration) tests, if provided by upstream.  If there’s no (easy) way how to test the package, you can declare that it does not want to use &#039;&#039;check()&#039;&#039; by adding &amp;quot;!check&amp;quot; into the &#039;&#039;options&#039;&#039; variable (&amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
==== package() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the packaging stage.  Here, the built application and support files should be installed into &#039;&#039;&#039;$pkgdir&#039;&#039;&#039;.  If this is a metapackage, this function can contain a single line: &amp;lt;code&amp;gt;mkdir -p &amp;quot;$pkgdir&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Building in fakeroot will reduce performance for parallel builds dramatically.  It is for this reason that we split the build and package process into two separate functions.}}&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
The [[APKBUILD examples]] page will assist you in understanding how to create an APKBUILD.&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=14054</id>
		<title>APKBUILD Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=14054"/>
		<updated>2017-10-06T17:58:48Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: /* options */ add a table, add new descriptions for: !check, suid, !tracedeps&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;APKBUILDs are the scripts that are created in order to build Alpine packages using the [[abuild]] tool.&lt;br /&gt;
&lt;br /&gt;
See [[aports]] for details on Alpine&#039;s official ports repository.&lt;br /&gt;
&lt;br /&gt;
This page is intended to serve as a reference for creating APKBUILDs; if this is your first time creating a package for Alpine Linux, please see [[Creating an Alpine package]].&lt;br /&gt;
&lt;br /&gt;
= Legend =&lt;br /&gt;
The following notes will assist you in understanding this document.&lt;br /&gt;
&lt;br /&gt;
In description text:&lt;br /&gt;
* If a variable is not prefixed with a &#039;&#039;$&#039;&#039;, it will be represented by italics (i.e., &#039;&#039;srcdir&#039;&#039; ).&lt;br /&gt;
* Functions will also be represented by italics, but will also end with a pair of parentheses (i.e., &#039;&#039;build()&#039;&#039; ).&lt;br /&gt;
* Shell commands will be represented &amp;lt;code&amp;gt;like this&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Variables =&lt;br /&gt;
{{Note|Variables that contain a path (e.g. &#039;&#039;$srcdir&#039;&#039; and &#039;&#039;$pkgdir&#039;&#039;) should always be quoted using double quotes (i.e., &#039;&#039;&amp;quot;$srcdir&amp;quot;&#039;&#039;).  This is done to prevent things from breaking, should the user have the APKBUILD in a directory path that contains spaces.}}&lt;br /&gt;
{{Note|All arbitrary variable and function names should be prefixed with an underscore character ( _ ) to avoid name clashes with the internals of abuild (for example, &#039;&#039;_luaversions&#039;&#039;).}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined variables ==&lt;br /&gt;
The following variables are defined by abuild:&lt;br /&gt;
&lt;br /&gt;
==== startdir ====&lt;br /&gt;
: The directory where the APKBUILD script is.&lt;br /&gt;
==== srcdir ====&lt;br /&gt;
: The directory where sources, from the &#039;&#039;source&#039;&#039; variable, are downloaded to and unpacked to.&lt;br /&gt;
==== pkgdir ====&lt;br /&gt;
: This directory should receive the files for the main package.  For example, a normal [http://en.wikipedia.org/wiki/GNU_build_system autotools] package would have &amp;lt;code&amp;gt;make DESTDIR=&amp;quot;$pkgdir&amp;quot; install&amp;lt;/code&amp;gt; in the &#039;&#039;package()&#039;&#039; function.&lt;br /&gt;
==== subpkgdir ====&lt;br /&gt;
: This directory should receive the files for a subpackage. This variable should only be used from subpackage functions.&lt;br /&gt;
==== builddir ====&lt;br /&gt;
: This variable should point to the directory inside the &#039;&#039;srcdir&#039;&#039; where the main package source is unpacked.  This is typically &#039;&#039;$srcdir/$pkgname-$pkgver&#039;&#039;.  It’s used by the default &#039;&#039;prepare()&#039;&#039; function as a working directory when applying patches.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User-defined variables ==&lt;br /&gt;
The following variables should be defined by the user:&lt;br /&gt;
==== arch ====&lt;br /&gt;
: Package architecture(s) to build for.  Can be one of: &#039;&#039;&#039;[[x86]], [[x86_64]], [[armhf]], [[aarch64]], [[ppc64le]], [[s390x]], all&#039;&#039;&#039;, or &#039;&#039;&#039;noarch&#039;&#039;&#039;, where &#039;&#039;&#039;all&#039;&#039;&#039; means all architectures, and &#039;&#039;&#039;noarch&#039;&#039;&#039; means it&#039;s architecture-independent (e.g., a pure-python package).&lt;br /&gt;
: {{Tip|To determine if your APKBUILD can use &#039;&#039;&#039;noarch&#039;&#039;&#039;: First specify &#039;&#039;&#039;all&#039;&#039;&#039; and then build the package by executing &amp;lt;code&amp;gt;abuild -r&amp;lt;/code&amp;gt;.  Watch the output towards the end for warnings saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used.  If the main package and all subpackages, if you have any subpackages, give a warning saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used, then you can use &#039;&#039;&#039;noarch&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
==== depends ====&lt;br /&gt;
: Run-time dependency package(s) that are not shared-object dependencies.  Shared objects dependencies are auto-detected and should not be specified here.&lt;br /&gt;
==== depends_dev ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
: {{Note|From ncopa on IRC: To find out if you need to add a package to depends_dev have a look at *requires* in usr/lib/pkgconfig/*.pc. With libtool it gets more complicated, but we should delete the .la files. Also check if there are any  /usr/bin/*-configure #!/bin/bash #!/usr/bin/perl or Python. Sometimes scripts or similar are generated at build time (i.e autoconf automake) then you normally don&#039;t need add those to depends_dev. You can also just add all -dev makedepends to depends_dev but it will slow the build process a little bit (more build dependencies).}}&lt;br /&gt;
==== giturl ====&lt;br /&gt;
:Git repository from which &amp;lt;code&amp;gt;abuild checkout&amp;lt;/code&amp;gt; checks out. You can checkout a specific branch in git by adding &amp;lt;code&amp;gt;-b $branch&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== install ====&lt;br /&gt;
: There are 6 different types of install scripts.  Install scripts are named &#039;&#039;&#039;$pkgname.action&#039;&#039;&#039;, where &#039;&#039;&#039;action&#039;&#039;&#039; can be:  &#039;&#039;&#039;pre-install, post-install, pre-upgrade, post-upgrade, pre-deinstall&#039;&#039;&#039;, or &#039;&#039;&#039;post-deinstall&#039;&#039;&#039;.  For example, if &#039;&#039;pkgname&#039;&#039; is set to &#039;&#039;&#039;mypackage&#039;&#039;&#039; and &#039;&#039;install&#039;&#039; is set to &#039;&#039;&#039;$pkgname.post-install&#039;&#039;&#039;, then a script named &#039;&#039;&#039;mypackage.post-install&#039;&#039;&#039; must exist along-side the APKBUILD.&lt;br /&gt;
&lt;br /&gt;
: First, a few notes regarding install scripts:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;{{Note|When using install scripts, &#039;&#039;$install&#039;&#039; should be included in &#039;&#039;source&#039;&#039; so that checksums can be generated and used for the install scripts specified in &#039;&#039;install&#039;&#039;.  For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install=&amp;quot;$pkgname.pre-install $pkgname.post-install&amp;quot;&lt;br /&gt;
source=&amp;quot;http://....&lt;br /&gt;
       $install&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;}}&lt;br /&gt;
{{Note|Always use &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt; for the command-line interpreter on the [http://en.wikipedia.org/wiki/Shebang_%28Unix%29 shebang line] of your install scripts.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the different types of install scripts in detail:&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-install =====&lt;br /&gt;
: This script is executed &#039;&#039;before installing&#039;&#039; the package.  Typical use is when the package needs a group and a user to be created. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
addgroup -S clamav 2&amp;gt;/dev/null&lt;br /&gt;
adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|If the script exits with a failure (e.g., if the user already exists), the package will not be installed and &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will exit with failure, hence the &amp;lt;code&amp;gt;exit 0&amp;lt;/code&amp;gt; at the end.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-install =====&lt;br /&gt;
: This script is executed &#039;&#039;after installing&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;before upgrading/downgrading/reinstalling&#039;&#039; the package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;after upgrading/downgrading/reinstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;before uninstalling&#039;&#039; the package.&lt;br /&gt;
: {{Note|If the script exits with failure, &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will not uninstall the package.}}&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;after uninstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
==== install_if ====&lt;br /&gt;
:install_if can be used when a package needs to be installed when some packages are already installed or are in the dependency tree. It works in reverse to the &#039;&#039;recommends&#039;&#039; feature, that other package managers provide.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example:&#039;&#039;&#039; When package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; has &amp;lt;code&amp;gt;install_if=&amp;quot;B C&amp;quot;&amp;lt;/code&amp;gt;, and the user runs &amp;lt;code&amp;gt;apk add B C&amp;lt;/code&amp;gt;, then package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; will get automatically installed.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example 2:&#039;&#039;&#039; A real use-case in Alpine is open-vm-tools. Currently it contains the userspace tools and separate packages for the kernel modules (grsec and vserver). When we install the userspace tools, apk should automatically install the correct kernel modules and will need to figure out for which kernel. This is where install_if jumps in. For any of the kernel modules package we would use:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;pre&amp;gt;install_if=&amp;quot;linux-${_flavor}=${_kernelver} open-vm-tools&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:This will automatically install the package when the specified packages are installed or are in dependency tree.&lt;br /&gt;
&lt;br /&gt;
==== license ====&lt;br /&gt;
: License(s) for the package.&lt;br /&gt;
==== makedepends ====&lt;br /&gt;
: Build-time dependency package(s).&lt;br /&gt;
==== md5sums ====&lt;br /&gt;
: Checksums for the files/URLs listed in &#039;&#039;source&#039;&#039;.  The checksums are normally generated and updated by executing &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; and should be the last item in the APKBUILD.&lt;br /&gt;
==== options ====&lt;br /&gt;
: Build-time options for the package.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Option&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not try to run the &amp;lt;code&amp;gt;check()&amp;lt;/code&amp;gt; function. Please always add a short comment after the &amp;lt;code&amp;gt;!check&amp;lt;/code&amp;gt; about why it&#039;s disabled. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142545300] Creating a very simple check function, that calls &amp;lt;code&amp;gt;program --version&amp;lt;/code&amp;gt; is better than disabling tests completely. [https://github.com/alpinelinux/aports/pull/2322#discussion_r142543002]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!strip&amp;lt;/code&amp;gt;&lt;br /&gt;
| Avoid stripping symbols from binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;suid&amp;lt;/code&amp;gt;&lt;br /&gt;
| Allow [https://en.wikipedia.org/wiki/Setuid setuid] binaries.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;!tracedeps&amp;lt;/code&amp;gt;&lt;br /&gt;
| Do not automatically find dependencies (e.g. by using &amp;lt;code&amp;gt;ldd&amp;lt;/code&amp;gt; to find dynamic libraries, which the resulting binary links against).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== pkgdesc ====&lt;br /&gt;
: A brief, one-line description of what the package does.&lt;br /&gt;
&lt;br /&gt;
: Here&#039;s an example from the OpenSSH client package:&lt;br /&gt;
: &amp;lt;pre&amp;gt;pkgdesc=&amp;quot;Port of OpenBSD&#039;s free SSH release - client&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== pkggroups ====&lt;br /&gt;
: System group(s) to be created during build-time.  System group(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system group(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgname ====&lt;br /&gt;
: The name of the package.  All letters should be lowercase.&lt;br /&gt;
: {{Note|When creating an APKBUILD of a module or library for another package, we use some common package prefixes, such as: &#039;&#039;lua-&#039;&#039;, &#039;&#039;perl-&#039;&#039;, &#039;&#039;php-&#039;&#039;, and &#039;&#039;py-&#039;&#039;.  Search aports for other common prefixes.}}&lt;br /&gt;
&lt;br /&gt;
==== pkgrel ====&lt;br /&gt;
: Alpine package release number.  Starts at 0 (zero).  Always increment &#039;&#039;pkgrel&#039;&#039; when making updates to an aport; reset &#039;&#039;pkgrel&#039;&#039; to 0 (zero) when incrementing &#039;&#039;pkgver&#039;&#039;.&lt;br /&gt;
==== pkgusers ====&lt;br /&gt;
: System user(s) to be created during build-time.  System user(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system user(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgver ====&lt;br /&gt;
: The version of the software being packaged.&lt;br /&gt;
==== provides ====&lt;br /&gt;
: List of package names (and optionally version info) this package provides.&lt;br /&gt;
&lt;br /&gt;
: If package with a version is provided (provides=&#039;foo=1.2&#039;) apk will consider it as an alternate name and it will automatically consider the package for installation by the alternate name, and conflict with other packages having the same name, or provides.&lt;br /&gt;
&lt;br /&gt;
: If version is not provided (provides=&#039;foo&#039;), apk will consider it as virtual package name. Several package with same non-versioned provides can be installed simultaneously. However, none of them will be installed by default when requested by the virtual name - instead, error message is given and user is asked to choose which package providing the virtual name should be installed.&lt;br /&gt;
==== replaces ====&lt;br /&gt;
: Package(s) that this package replaces.  This package will &amp;quot;take over&amp;quot; files owned by packages listed in the &#039;&#039;replaces&#039;&#039; variable.  This is useful when files move from one package to another, or when a package gets renamed.&lt;br /&gt;
==== replaces_priority ====&lt;br /&gt;
: The priority of the replaces. If multiple packages replace each other, then will the package with highest &#039;&#039;replaces_priority&#039;&#039; win.&lt;br /&gt;
==== source ====&lt;br /&gt;
: The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[APKBUILD Reference#install|install variable]]), patches, and all other necessary files.&lt;br /&gt;
&lt;br /&gt;
: Here are few things to note:&lt;br /&gt;
&lt;br /&gt;
:* When you are finished adding local and/or remote files to &#039;&#039;source&#039;&#039;, you can execute the following command to add their checksums to the APKBUILD file:&lt;br /&gt;
:: {{Cmd|abuild checksum}}&lt;br /&gt;
:: {{Note|When later updating the content of &#039;&#039;source&#039;&#039;, or updating a file that is listed in &#039;&#039;source&#039;&#039;, you must also update their checksums again with the same command.}}&lt;br /&gt;
&lt;br /&gt;
:* When the remote file is hosted at SourceForge, it&#039;s best to specify the special mirrors link used by SourceForge:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: (or similar depending on the package).&lt;br /&gt;
&lt;br /&gt;
:* You can set target filename (eg &#039;save as...&#039;) by prefixing the URI with &#039;&#039;filename::&#039;&#039;. This is useful when the remote filename is not specified in the URI (ie, does not end in &#039;/software-1.0.tar.gz&#039;), such as:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: or when the filename is braindead, like githubs&#039; download tags:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: The above two examples needs a target filename prefix:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::http://oss.example.org/?get=software&amp;amp;ver=$pkgver&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: and:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following protocols for remote file retrieval:&lt;br /&gt;
:** http&lt;br /&gt;
:** https&lt;br /&gt;
:** ftp&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following archive types/archive file extensions:&lt;br /&gt;
:** .tar.gz / .tgz&lt;br /&gt;
:** .tar.bz2&lt;br /&gt;
:** .tar.lzma&lt;br /&gt;
:** .tar.xz&lt;br /&gt;
:** .zip&lt;br /&gt;
&lt;br /&gt;
:: {{Note|Legacy APKBUILD scripts define &#039;&#039;source&#039;&#039; variable as &amp;quot;saveas-[brain-dead-url]/[target-filename]&amp;quot; format instead of the modern [target-filename]::[brain-dead-url].&amp;lt;br /&amp;gt;&#039;&#039;BAD&#039;&#039;:   source&amp;amp;#61;&amp;quot;saveas-http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC/$pkgname-$pkgver.tar.gz&amp;quot;&amp;lt;br /&amp;gt;&#039;&#039;GOOD&#039;&#039;:   source&amp;amp;#61;$pkgname-$pkgver.tar.gz::http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
==== subpackages ====&lt;br /&gt;
: Subpackages built from this APKBUILD.  abuild will parse this variable and try to find a subpackage split function.  The split function must &#039;&#039;move&#039;&#039; files that do not belong in the main package, from &#039;&#039;$pkgdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.  Files and directories can also be &#039;&#039;copied&#039;&#039; from &#039;&#039;$startdir&#039;&#039; and &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: The split function can be specified in 1 of 3 different methods:&lt;br /&gt;
:# subpkgname:&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# $pkgname-&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# &#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
: {{Note|Split function names &#039;&#039;&#039;cannot&#039;&#039;&#039; use hyphens; use the first method above if the subpackage name contains a hyphen (-) character, like this: &#039;&#039;subpkg-name:subpkg_name&#039;&#039;, where &amp;lt;code&amp;gt;subpkg-name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;&#039;&#039; and &amp;lt;code&amp;gt;subpkg_name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;s split function&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
: {{Tip|For more information, see the [[APKBUILD_examples:Subpackages|Subpackages example]].}}&lt;br /&gt;
&lt;br /&gt;
==== triggers ====&lt;br /&gt;
: Apk-tools can &amp;quot;monitor&amp;quot; directories and execute a trigger if any package installed/uninstalled any file in the monitored dir. The triggers are always execute after the apk action (install, uninstall, upgrade).&lt;br /&gt;
&lt;br /&gt;
: The triggers are specified in the format: &#039;&#039;scriptname&#039;&#039;=&#039;&#039;pathlist&#039;&#039; where &#039;&#039;scriptname&#039;&#039; is the (sub)package name + .trigger suffix and pathlist is : separated list of the dirs to monitor.&lt;br /&gt;
&lt;br /&gt;
: The &#039;&#039;&#039;triggers&#039;&#039;&#039; variable must include the triggers for subpackages too if they have any.&lt;br /&gt;
&lt;br /&gt;
: It is possible to use wildcards (*) in the dir list.&lt;br /&gt;
&lt;br /&gt;
==== url ====&lt;br /&gt;
: The homepage for the package.  This is to help users find upstream documentation and other information regarding the package.&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
{{Note|All functions should consider the current working directory as undefined, and should therefore use the [[APKBUILD Reference#abuild-defined_variables|abuild-defined directory variables]] to their advantage.}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined functions ==&lt;br /&gt;
The following functions are provided by abuild and can be overridden:&lt;br /&gt;
&lt;br /&gt;
==== fetch() ====&lt;br /&gt;
: Downloads remote sources listed in &#039;&#039;source&#039;&#039; to &#039;&#039;SRCDEST&#039;&#039; (&#039;&#039;SRCDEST&#039;&#039; is configured in &#039;&#039;/etc/abuild.conf&#039;&#039;) and creates symlinks in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== unpack() ====&lt;br /&gt;
: Unpacks .tgz, .tar.gz, .tar.bz2, .tar.lzma, .tar.xz, and .zip archives in &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== dev() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;dev()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;dev()&#039;&#039; function, which in turn calls &#039;&#039;default_dev()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/include&#039;&#039;, &#039;&#039;*.a&#039;&#039;, &#039;&#039;*.la&#039;&#039; and similar files to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
==== doc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;doc()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;doc()&#039;&#039; function, which in turn calls &#039;&#039;default_doc()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/doc&#039;&#039;, &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/man&#039;&#039; and similar to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== User-defined functions ==&lt;br /&gt;
The following functions should be defined by the user: &lt;br /&gt;
&lt;br /&gt;
==== prepare() ====&lt;br /&gt;
: &#039;&#039;&#039;&#039;&#039;Optional&#039;&#039;.&#039;&#039;&#039;  Used for build preparation: patches, etc, should be applied here.  This function is available for your convenience. It is better to use &amp;quot;default_prepare || return&amp;quot; to handle *.patch file, and the patch file should always be prepared as -p1 format.&lt;br /&gt;
==== build() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the compilation stage.  This function will be called as the current user (unless the &#039;&#039;package()&#039;&#039; function is missing - for compatibility reasons).  If no compilation is needed, this function can contain a single line: &amp;lt;code&amp;gt;return 0&amp;lt;/code&amp;gt;&lt;br /&gt;
==== check() ====&lt;br /&gt;
: &#039;&#039;&#039;Recommended.&#039;&#039;&#039; This function is called right after the build stage.  It should check that the packaged thing is actually working, typically by running (integration) tests, if provided by upstream.  If there’s no (easy) way how to test the package, you can declare that it does not want to use &#039;&#039;check()&#039;&#039; by adding &amp;quot;!check&amp;quot; into the &#039;&#039;options&#039;&#039; variable (&amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
==== package() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the packaging stage.  Here, the built application and support files should be installed into &#039;&#039;&#039;$pkgdir&#039;&#039;&#039;.  If this is a metapackage, this function can contain a single line: &amp;lt;code&amp;gt;mkdir -p &amp;quot;$pkgdir&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Building in fakeroot will reduce performance for parallel builds dramatically.  It is for this reason that we split the build and package process into two separate functions.}}&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
The [[APKBUILD examples]] page will assist you in understanding how to create an APKBUILD.&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_examples:Simple&amp;diff=13951</id>
		<title>APKBUILD examples:Simple</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_examples:Simple&amp;diff=13951"/>
		<updated>2017-09-23T01:14:46Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: Removed all &amp;quot;|| return&amp;quot; statements, these are not necessary anymore with abuild&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Simple APKBUILD with -doc subpackage, using abuild&#039;s default &#039;&#039;doc()&#039;&#039; and &#039;&#039;prepare()&#039;&#039; functions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Contributor: William Pitcock &amp;lt;nenolod@dereferenced.org&amp;gt;&lt;br /&gt;
# Maintainer:&lt;br /&gt;
pkgname=gnuplot&lt;br /&gt;
pkgver=4.4.4&lt;br /&gt;
pkgrel=0&lt;br /&gt;
pkgdesc=&amp;quot;Utility for plotting graphs&amp;quot;&lt;br /&gt;
url=&amp;quot;http://www.gnuplot.info/&amp;quot;&lt;br /&gt;
arch=&amp;quot;all&amp;quot;&lt;br /&gt;
license=&amp;quot;GPL&amp;quot;&lt;br /&gt;
depends=&amp;quot;&amp;quot;&lt;br /&gt;
depends_dev=&amp;quot;cairo-dev pango-dev gd-dev lua-dev readline-dev libpng-dev jpeg-dev&amp;quot;&lt;br /&gt;
makedepends=&amp;quot;$depends_dev&amp;quot;&lt;br /&gt;
install=&amp;quot;&amp;quot;&lt;br /&gt;
subpackages=&amp;quot;$pkgname-doc&amp;quot;&lt;br /&gt;
source=&amp;quot;http://downloads.sourceforge.net/project/$pkgname/$pkgname/$pkgver/$pkgname-$pkgver.tar.gz&amp;quot;&lt;br /&gt;
builddir=&amp;quot;$srcdir/$pkgname-$pkgver&amp;quot;&lt;br /&gt;
&lt;br /&gt;
prepare() {&lt;br /&gt;
        default_prepare&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
build() {&lt;br /&gt;
	cd &amp;quot;$builddir&amp;quot;&lt;br /&gt;
	./configure --prefix=/usr \&lt;br /&gt;
		--sysconfdir=/etc \&lt;br /&gt;
		--mandir=/usr/share/man \&lt;br /&gt;
		--infodir=/usr/share/info \&lt;br /&gt;
		--localstatedir=/var \&lt;br /&gt;
		--disable-wxwidgets \&lt;br /&gt;
		--disable-qt&lt;br /&gt;
	make&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
check() {&lt;br /&gt;
	cd &amp;quot;$builddir&amp;quot;&lt;br /&gt;
        make check&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
package() {&lt;br /&gt;
	cd &amp;quot;$builddir&amp;quot;&lt;br /&gt;
	make DESTDIR=&amp;quot;$pkgdir&amp;quot; install&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
sha512sums=&amp;quot;d65a43b834b1926097...c0b8c6017ffc6d9e011217fb7e86e80  gnuplot-4.4.4.tar.gz&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=13791</id>
		<title>APKBUILD Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=APKBUILD_Reference&amp;diff=13791"/>
		<updated>2017-09-15T18:46:43Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: /* install_if */ Add a less complex example.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;APKBUILDs are the scripts that are created in order to build Alpine packages using the [[abuild]] tool.&lt;br /&gt;
&lt;br /&gt;
See [[aports]] for details on Alpine&#039;s official ports repository.&lt;br /&gt;
&lt;br /&gt;
This page is intended to serve as a reference for creating APKBUILDs; if this is your first time creating a package for Alpine Linux, please see [[Creating an Alpine package]].&lt;br /&gt;
&lt;br /&gt;
= Legend =&lt;br /&gt;
The following notes will assist you in understanding this document.&lt;br /&gt;
&lt;br /&gt;
In description text:&lt;br /&gt;
* If a variable is not prefixed with a &#039;&#039;$&#039;&#039;, it will be represented by italics (i.e., &#039;&#039;srcdir&#039;&#039; ).&lt;br /&gt;
* Functions will also be represented by italics, but will also end with a pair of parentheses (i.e., &#039;&#039;build()&#039;&#039; ).&lt;br /&gt;
* Shell commands will be represented &amp;lt;code&amp;gt;like this&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Variables =&lt;br /&gt;
{{Note|Variables that contain a path (e.g. &#039;&#039;$srcdir&#039;&#039; and &#039;&#039;$pkgdir&#039;&#039;) should always be quoted using double quotes (i.e., &#039;&#039;&amp;quot;$srcdir&amp;quot;&#039;&#039;).  This is done to prevent things from breaking, should the user have the APKBUILD in a directory path that contains spaces.}}&lt;br /&gt;
{{Note|All arbitrary variable and function names should be prefixed with an underscore character ( _ ) to avoid name clashes with the internals of abuild (for example, &#039;&#039;_luaversions&#039;&#039;).}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined variables ==&lt;br /&gt;
The following variables are defined by abuild:&lt;br /&gt;
&lt;br /&gt;
==== startdir ====&lt;br /&gt;
: The directory where the APKBUILD script is.&lt;br /&gt;
==== srcdir ====&lt;br /&gt;
: The directory where sources, from the &#039;&#039;source&#039;&#039; variable, are downloaded to and unpacked to.&lt;br /&gt;
==== pkgdir ====&lt;br /&gt;
: This directory should receive the files for the main package.  For example, a normal [http://en.wikipedia.org/wiki/GNU_build_system autotools] package would have &amp;lt;code&amp;gt;make DESTDIR=&amp;quot;$pkgdir&amp;quot; install&amp;lt;/code&amp;gt; in the &#039;&#039;package()&#039;&#039; function.&lt;br /&gt;
==== subpkgdir ====&lt;br /&gt;
: This directory should receive the files for a subpackage. This variable should only be used from subpackage functions.&lt;br /&gt;
==== builddir ====&lt;br /&gt;
: This variable should point to the directory inside the &#039;&#039;srcdir&#039;&#039; where the main package source is unpacked.  This is typically &#039;&#039;$srcdir/$pkgname-$pkgver&#039;&#039;.  It’s used by the default &#039;&#039;prepare()&#039;&#039; function as a working directory when applying patches.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User-defined variables ==&lt;br /&gt;
The following variables should be defined by the user:&lt;br /&gt;
==== arch ====&lt;br /&gt;
: Package architecture(s) to build for.  Can be one of: &#039;&#039;&#039;[[x86]], [[x86_64]], [[armhf]], [[aarch64]], [[ppc64le]], [[s390x]], all&#039;&#039;&#039;, or &#039;&#039;&#039;noarch&#039;&#039;&#039;, where &#039;&#039;&#039;all&#039;&#039;&#039; means all architectures, and &#039;&#039;&#039;noarch&#039;&#039;&#039; means it&#039;s architecture-independent (e.g., a pure-python package).&lt;br /&gt;
: {{Tip|To determine if your APKBUILD can use &#039;&#039;&#039;noarch&#039;&#039;&#039;: First specify &#039;&#039;&#039;all&#039;&#039;&#039; and then build the package by executing &amp;lt;code&amp;gt;abuild -r&amp;lt;/code&amp;gt;.  Watch the output towards the end for warnings saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used.  If the main package and all subpackages, if you have any subpackages, give a warning saying that &#039;&#039;&#039;noarch&#039;&#039;&#039; can be used, then you can use &#039;&#039;&#039;noarch&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
==== depends ====&lt;br /&gt;
: Run-time dependency package(s) that are not shared-object dependencies.  Shared objects dependencies are auto-detected and should not be specified here.&lt;br /&gt;
==== depends_dev ====&lt;br /&gt;
: Run-time dependency package(s) for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; subpackage.&lt;br /&gt;
&lt;br /&gt;
: {{Note|From ncopa on IRC: To find out if you need to add a package to depends_dev have a look at *requires* in usr/lib/pkgconfig/*.pc. With libtool it gets more complicated, but we should delete the .la files. Also check if there are any  /usr/bin/*-configure #!/bin/bash #!/usr/bin/perl or Python. Sometimes scripts or similar are generated at build time (i.e autoconf automake) then you normally don&#039;t need add those to depends_dev. You can also just add all -dev makedepends to depends_dev but it will slow the build process a little bit (more build dependencies).}}&lt;br /&gt;
==== giturl ====&lt;br /&gt;
:Git repository from which &amp;lt;code&amp;gt;abuild checkout&amp;lt;/code&amp;gt; checks out. You can checkout a specific branch in git by adding &amp;lt;code&amp;gt;-b $branch&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== install ====&lt;br /&gt;
: There are 6 different types of install scripts.  Install scripts are named &#039;&#039;&#039;$pkgname.action&#039;&#039;&#039;, where &#039;&#039;&#039;action&#039;&#039;&#039; can be:  &#039;&#039;&#039;pre-install, post-install, pre-upgrade, post-upgrade, pre-deinstall&#039;&#039;&#039;, or &#039;&#039;&#039;post-deinstall&#039;&#039;&#039;.  For example, if &#039;&#039;pkgname&#039;&#039; is set to &#039;&#039;&#039;mypackage&#039;&#039;&#039; and &#039;&#039;install&#039;&#039; is set to &#039;&#039;&#039;$pkgname.post-install&#039;&#039;&#039;, then a script named &#039;&#039;&#039;mypackage.post-install&#039;&#039;&#039; must exist along-side the APKBUILD.&lt;br /&gt;
&lt;br /&gt;
: First, a few notes regarding install scripts:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;{{Note|When using install scripts, &#039;&#039;$install&#039;&#039; should be included in &#039;&#039;source&#039;&#039; so that checksums can be generated and used for the install scripts specified in &#039;&#039;install&#039;&#039;.  For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install=&amp;quot;$pkgname.pre-install $pkgname.post-install&amp;quot;&lt;br /&gt;
source=&amp;quot;http://....&lt;br /&gt;
       $install&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;}}&lt;br /&gt;
{{Note|Always use &amp;lt;code&amp;gt;/bin/sh&amp;lt;/code&amp;gt; for the command-line interpreter on the [http://en.wikipedia.org/wiki/Shebang_%28Unix%29 shebang line] of your install scripts.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the different types of install scripts in detail:&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-install =====&lt;br /&gt;
: This script is executed &#039;&#039;before installing&#039;&#039; the package.  Typical use is when the package needs a group and a user to be created. For example:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
addgroup -S clamav 2&amp;gt;/dev/null&lt;br /&gt;
adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|If the script exits with a failure (e.g., if the user already exists), the package will not be installed and &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will exit with failure, hence the &amp;lt;code&amp;gt;exit 0&amp;lt;/code&amp;gt; at the end.}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-install =====&lt;br /&gt;
: This script is executed &#039;&#039;after installing&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;before upgrading/downgrading/reinstalling&#039;&#039; the package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-upgrade =====&lt;br /&gt;
: This script is executed &#039;&#039;after upgrading/downgrading/reinstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.pre-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;before uninstalling&#039;&#039; the package.&lt;br /&gt;
: {{Note|If the script exits with failure, &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; will not uninstall the package.}}&lt;br /&gt;
&lt;br /&gt;
===== $pkgname.post-deinstall =====&lt;br /&gt;
: This script is executed &#039;&#039;after uninstalling&#039;&#039; the package.&lt;br /&gt;
&lt;br /&gt;
==== install_if ====&lt;br /&gt;
:install_if can be used when a package needs to be installed when some packages are already installed or are in the dependency tree. It works in reverse to the &#039;&#039;recommends&#039;&#039; feature, that other package managers provide.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example:&#039;&#039;&#039; When package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; has &amp;lt;code&amp;gt;install_if=&amp;quot;B C&amp;quot;&amp;lt;/code&amp;gt;, and the user runs &amp;lt;code&amp;gt;apk add B C&amp;lt;/code&amp;gt;, then package &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; will get automatically installed.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Example 2:&#039;&#039;&#039; A real use-case in Alpine is open-vm-tools. Currently it contains the userspace tools and separate packages for the kernel modules (grsec and vserver). When we install the userspace tools, apk should automatically install the correct kernel modules and will need to figure out for which kernel. This is where install_if jumps in. For any of the kernel modules package we would use:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;pre&amp;gt;install_if=&amp;quot;linux-${_flavor}=${_kernelver} open-vm-tools&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:This will automatically install the package when the specified packages are installed or are in dependency tree.&lt;br /&gt;
&lt;br /&gt;
==== license ====&lt;br /&gt;
: License(s) for the package.&lt;br /&gt;
==== makedepends ====&lt;br /&gt;
: Build-time dependency package(s).&lt;br /&gt;
==== md5sums ====&lt;br /&gt;
: Checksums for the files/URLs listed in &#039;&#039;source&#039;&#039;.  The checksums are normally generated and updated by executing &amp;lt;code&amp;gt;abuild checksum&amp;lt;/code&amp;gt; and should be the last item in the APKBUILD.&lt;br /&gt;
==== options ====&lt;br /&gt;
: Build-time options for the package.  Can be: &#039;&#039;&#039;!strip&#039;&#039;&#039; - to avoid stripping symbols from binaries.&lt;br /&gt;
==== pkgdesc ====&lt;br /&gt;
: A brief, one-line description of what the package does.&lt;br /&gt;
&lt;br /&gt;
: Here&#039;s an example from the OpenSSH client package:&lt;br /&gt;
: &amp;lt;pre&amp;gt;pkgdesc=&amp;quot;Port of OpenBSD&#039;s free SSH release - client&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== pkggroups ====&lt;br /&gt;
: System group(s) to be created during build-time.  System group(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system group(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgname ====&lt;br /&gt;
: The name of the package.  All letters should be lowercase.&lt;br /&gt;
: {{Note|When creating an APKBUILD of a module or library for another package, we use some common package prefixes, such as: &#039;&#039;lua-&#039;&#039;, &#039;&#039;perl-&#039;&#039;, &#039;&#039;php-&#039;&#039;, and &#039;&#039;py-&#039;&#039;.  Search aports for other common prefixes.}}&lt;br /&gt;
&lt;br /&gt;
==== pkgrel ====&lt;br /&gt;
: Alpine package release number.  Starts at 0 (zero).  Always increment &#039;&#039;pkgrel&#039;&#039; when making updates to an aport; reset &#039;&#039;pkgrel&#039;&#039; to 0 (zero) when incrementing &#039;&#039;pkgver&#039;&#039;.&lt;br /&gt;
==== pkgusers ====&lt;br /&gt;
: System user(s) to be created during build-time.  System user(s) should also be created in the &#039;&#039;&#039;[[APKBUILD Reference#.24pkgname.pre-install|$pkgname.pre-install]]&#039;&#039;&#039; script, so that the system user(s) are also created prior to package installation for run-time use.&lt;br /&gt;
==== pkgver ====&lt;br /&gt;
: The version of the software being packaged.&lt;br /&gt;
==== provides ====&lt;br /&gt;
: List of package names (and optionally version info) this package provides.&lt;br /&gt;
&lt;br /&gt;
: If package with a version is provided (provides=&#039;foo=1.2&#039;) apk will consider it as an alternate name and it will automatically consider the package for installation by the alternate name, and conflict with other packages having the same name, or provides.&lt;br /&gt;
&lt;br /&gt;
: If version is not provided (provides=&#039;foo&#039;), apk will consider it as virtual package name. Several package with same non-versioned provides can be installed simultaneously. However, none of them will be installed by default when requested by the virtual name - instead, error message is given and user is asked to choose which package providing the virtual name should be installed.&lt;br /&gt;
==== replaces ====&lt;br /&gt;
: Package(s) that this package replaces.  This package will &amp;quot;take over&amp;quot; files owned by packages listed in the &#039;&#039;replaces&#039;&#039; variable.  This is useful when files move from one package to another, or when a package gets renamed.&lt;br /&gt;
==== replaces_priority ====&lt;br /&gt;
: The priority of the replaces. If multiple packages replace each other, then will the package with highest &#039;&#039;replaces_priority&#039;&#039; win.&lt;br /&gt;
==== source ====&lt;br /&gt;
: The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[APKBUILD Reference#install|install variable]]), patches, and all other necessary files.&lt;br /&gt;
&lt;br /&gt;
: Here are few things to note:&lt;br /&gt;
&lt;br /&gt;
:* When you are finished adding local and/or remote files to &#039;&#039;source&#039;&#039;, you can execute the following command to add their checksums to the APKBUILD file:&lt;br /&gt;
:: {{Cmd|abuild checksum}}&lt;br /&gt;
:: {{Note|When later updating the content of &#039;&#039;source&#039;&#039;, or updating a file that is listed in &#039;&#039;source&#039;&#039;, you must also update their checksums again with the same command.}}&lt;br /&gt;
&lt;br /&gt;
:* When the remote file is hosted at SourceForge, it&#039;s best to specify the special mirrors link used by SourceForge:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: (or similar depending on the package).&lt;br /&gt;
&lt;br /&gt;
:* You can set target filename (eg &#039;save as...&#039;) by prefixing the URI with &#039;&#039;filename::&#039;&#039;. This is useful when the remote filename is not specified in the URI (ie, does not end in &#039;/software-1.0.tar.gz&#039;), such as:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: or when the filename is braindead, like githubs&#039; download tags:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: The above two examples needs a target filename prefix:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::http://oss.example.org/?get=software&amp;amp;ver=$pkgver&amp;lt;/pre&amp;gt;&lt;br /&gt;
:: and:&lt;br /&gt;
:: &amp;lt;pre&amp;gt;$pkgname-$pkgver.tar.gz::https://github.com/software/software/archive/v$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following protocols for remote file retrieval:&lt;br /&gt;
:** http&lt;br /&gt;
:** https&lt;br /&gt;
:** ftp&lt;br /&gt;
&lt;br /&gt;
:* abuild currently supports the following archive types/archive file extensions:&lt;br /&gt;
:** .tar.gz / .tgz&lt;br /&gt;
:** .tar.bz2&lt;br /&gt;
:** .tar.lzma&lt;br /&gt;
:** .tar.xz&lt;br /&gt;
:** .zip&lt;br /&gt;
&lt;br /&gt;
:: {{Note|Legacy APKBUILD scripts define &#039;&#039;source&#039;&#039; variable as &amp;quot;saveas-[brain-dead-url]/[target-filename]&amp;quot; format instead of the modern [target-filename]::[brain-dead-url].&amp;lt;br /&amp;gt;&#039;&#039;BAD&#039;&#039;:   source&amp;amp;#61;&amp;quot;saveas-http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC/$pkgname-$pkgver.tar.gz&amp;quot;&amp;lt;br /&amp;gt;&#039;&#039;GOOD&#039;&#039;:   source&amp;amp;#61;$pkgname-$pkgver.tar.gz::http://releases.ddvtech.com/download.php?pack&amp;amp;#61;libmist_dist&amp;amp;ver&amp;amp;#61;RC&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
==== subpackages ====&lt;br /&gt;
: Subpackages built from this APKBUILD.  abuild will parse this variable and try to find a subpackage split function.  The split function must &#039;&#039;move&#039;&#039; files that do not belong in the main package, from &#039;&#039;$pkgdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.  Files and directories can also be &#039;&#039;copied&#039;&#039; from &#039;&#039;$startdir&#039;&#039; and &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
: The split function can be specified in 1 of 3 different methods:&lt;br /&gt;
:# subpkgname:&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# $pkgname-&#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
:# &#039;&#039;&#039;splitfunc&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
: {{Note|Split function names &#039;&#039;&#039;cannot&#039;&#039;&#039; use hyphens; use the first method above if the subpackage name contains a hyphen (-) character, like this: &#039;&#039;subpkg-name:subpkg_name&#039;&#039;, where &amp;lt;code&amp;gt;subpkg-name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;&#039;&#039; and &amp;lt;code&amp;gt;subpkg_name&amp;lt;/code&amp;gt; is the name of the &#039;&#039;&#039;subpackage&#039;s split function&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
: {{Tip|For more information, see the [[APKBUILD_examples:Subpackages|Subpackages example]].}}&lt;br /&gt;
&lt;br /&gt;
==== triggers ====&lt;br /&gt;
: Apk-tools can &amp;quot;monitor&amp;quot; directories and execute a trigger if any package installed/uninstalled any file in the monitored dir. The triggers are always execute after the apk action (install, uninstall, upgrade).&lt;br /&gt;
&lt;br /&gt;
: The triggers are specified in the format: &#039;&#039;scriptname&#039;&#039;=&#039;&#039;pathlist&#039;&#039; where &#039;&#039;scriptname&#039;&#039; is the (sub)package name + .trigger suffix and pathlist is : separated list of the dirs to monitor.&lt;br /&gt;
&lt;br /&gt;
: The &#039;&#039;&#039;triggers&#039;&#039;&#039; variable must include the triggers for subpackages too if they have any.&lt;br /&gt;
&lt;br /&gt;
: It is possible to use wildcards (*) in the dir list.&lt;br /&gt;
&lt;br /&gt;
==== url ====&lt;br /&gt;
: The homepage for the package.  This is to help users find upstream documentation and other information regarding the package.&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
{{Note|All functions should consider the current working directory as undefined, and should therefore use the [[APKBUILD Reference#abuild-defined_variables|abuild-defined directory variables]] to their advantage.}}&lt;br /&gt;
&lt;br /&gt;
== abuild-defined functions ==&lt;br /&gt;
The following functions are provided by abuild and can be overridden:&lt;br /&gt;
&lt;br /&gt;
==== fetch() ====&lt;br /&gt;
: Downloads remote sources listed in &#039;&#039;source&#039;&#039; to &#039;&#039;SRCDEST&#039;&#039; (&#039;&#039;SRCDEST&#039;&#039; is configured in &#039;&#039;/etc/abuild.conf&#039;&#039;) and creates symlinks in &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== unpack() ====&lt;br /&gt;
: Unpacks .tgz, .tar.gz, .tar.bz2, .tar.lzma, .tar.xz, and .zip archives in &#039;&#039;$srcdir&#039;&#039; to &#039;&#039;$srcdir&#039;&#039;.&lt;br /&gt;
==== dev() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-dev&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;dev()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;dev()&#039;&#039; function, which in turn calls &#039;&#039;default_dev()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/include&#039;&#039;, &#039;&#039;*.a&#039;&#039;, &#039;&#039;*.la&#039;&#039; and similar files to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
==== doc() ====&lt;br /&gt;
: Subpackage function for the &#039;&#039;&#039;$pkgname-doc&#039;&#039;&#039; package.  Without specifying a custom &#039;&#039;doc()&#039;&#039; function, abuild will call it&#039;s internal &#039;&#039;doc()&#039;&#039; function, which in turn calls &#039;&#039;default_doc()&#039;&#039;, which will move &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/doc&#039;&#039;, &#039;&#039;&amp;quot;$pkgdir&amp;quot;/usr/share/man&#039;&#039; and similar to &#039;&#039;$subpkgdir&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== User-defined functions ==&lt;br /&gt;
The following functions should be defined by the user: &lt;br /&gt;
&lt;br /&gt;
==== prepare() ====&lt;br /&gt;
: &#039;&#039;&#039;&#039;&#039;Optional&#039;&#039;.&#039;&#039;&#039;  Used for build preparation: patches, etc, should be applied here.  This function is available for your convenience. It is better to use &amp;quot;default_prepare || return&amp;quot; to handle *.patch file, and the patch file should always be prepared as -p1 format.&lt;br /&gt;
==== build() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the compilation stage.  This function will be called as the current user (unless the &#039;&#039;package()&#039;&#039; function is missing - for compatibility reasons).  If no compilation is needed, this function can contain a single line: &amp;lt;code&amp;gt;return 0&amp;lt;/code&amp;gt;&lt;br /&gt;
==== check() ====&lt;br /&gt;
: &#039;&#039;&#039;Recommended.&#039;&#039;&#039; This function is called right after the build stage.  It should check that the packaged thing is actually working, typically by running (integration) tests, if provided by upstream.  If there’s no (easy) way how to test the package, you can declare that it does not want to use &#039;&#039;check()&#039;&#039; by adding &amp;quot;!check&amp;quot; into the &#039;&#039;options&#039;&#039; variable (&amp;lt;code&amp;gt;options=&amp;quot;!check&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
==== package() ====&lt;br /&gt;
: &#039;&#039;&#039;Required.&#039;&#039;&#039;  This is the packaging stage.  Here, the built application and support files should be installed into &#039;&#039;&#039;$pkgdir&#039;&#039;&#039;.  If this is a metapackage, this function can contain a single line: &amp;lt;code&amp;gt;mkdir -p &amp;quot;$pkgdir&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Building in fakeroot will reduce performance for parallel builds dramatically.  It is for this reason that we split the build and package process into two separate functions.}}&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
The [[APKBUILD examples]] page will assist you in understanding how to create an APKBUILD.&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Creating_an_Alpine_package&amp;diff=13691</id>
		<title>Creating an Alpine package</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Creating_an_Alpine_package&amp;diff=13691"/>
		<updated>2017-07-19T16:34:03Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: Removed &amp;quot;|| return 1&amp;quot; statements, which are not necessary anymore&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To build a package for Alpine Linux you need an Alpine Linux installation. Check the [[Installation]] page to see all available installation options.&lt;br /&gt;
&lt;br /&gt;
== Setup your system and account  ==&lt;br /&gt;
{{:Include:Setup_your_system_and_account_for_building_packages}}&lt;br /&gt;
&lt;br /&gt;
== Getting some help ==&lt;br /&gt;
&lt;br /&gt;
It might be wise to start by checking what the [[Abuild|abuild]] program can/cannot do.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|abuild -h}}&lt;br /&gt;
&lt;br /&gt;
== Creating an APKBUILD file  ==&lt;br /&gt;
&lt;br /&gt;
=== Use a template APKBUILD ===&lt;br /&gt;
&lt;br /&gt;
To create the actual APKBUILD file {{Pkg|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. Please check the [[Package_policies| package policies]] page about naming details.&lt;br /&gt;
&lt;br /&gt;
If you doubt to which repository your package belongs to you can safely use &#039;&#039;&#039;testing&#039;&#039;&#039;. Building package in your aports/testing directory is not mandatory but this way the package is already at the right place.&lt;br /&gt;
&lt;br /&gt;
{{:Include:Newapkbuild}}&lt;br /&gt;
&lt;br /&gt;
{{Note|On older Alpine systems, abuild -c -n &#039;&#039;packagename&#039;&#039; was the way to create APKBUILD files. The &#039;packagename&#039; was a parameter to the -n option so order of -c and -n matters. }}&lt;br /&gt;
&lt;br /&gt;
[[Abuild_and_Helpers#apkbuild-cpan|apkbuild-cpan]] simplifies the creation of perl packages from CPAN and [[Abuild_and_Helpers#apkbuild-pypi|apkbuild-pypi]] ease the generation of APKBUILD files for python packages from PyPi.  &lt;br /&gt;
&lt;br /&gt;
If you are create a daemon package which needs initd scripts you can add the -c making it: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|newapkbuild -c &#039;&#039;packagename&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
This will copy the sample initd and confd files to the build directory.&amp;lt;BR&amp;gt;&lt;br /&gt;
A third file sample.install file will be copied as well (we will discuss this later on).&lt;br /&gt;
&lt;br /&gt;
=== Modify your APKBUILD ===&lt;br /&gt;
Edit APKBUILD and fill in the needed info (especially pkgname, pkgver, pkgdesc, url, license, depends and source). &lt;br /&gt;
&lt;br /&gt;
If you are going to use any of the variables for directories like $pkgdir, always make sure they are double quoted like: &lt;br /&gt;
&lt;br /&gt;
 &amp;quot;$pkgdir&amp;quot;/somedir&lt;br /&gt;
&lt;br /&gt;
This will prevent issues with spaces/special characters in the future. &lt;br /&gt;
&lt;br /&gt;
{{Note|If you like syntax highlighting we suggest you to install vim. We have setup vim to recognize the APKBUILD file as a bash scripts so its easier to read them.}}&lt;br /&gt;
&lt;br /&gt;
=== APKBUILD variables/functions  ===&lt;br /&gt;
&lt;br /&gt;
==== source  ====&lt;br /&gt;
&lt;br /&gt;
The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[Creating an Alpine package#install|install variable]]), patches, and all other necessary files.&lt;br /&gt;
&lt;br /&gt;
Here are few things to note:&lt;br /&gt;
&lt;br /&gt;
* When you are finished adding local and/or remote files to &#039;&#039;source&#039;&#039;, you can execute the following command to add their checksums to the APKBUILD file:&lt;br /&gt;
: {{cmd|abuild checksum}}&lt;br /&gt;
: {{Note|When later updating the content of &#039;&#039;source&#039;&#039;, or updating a file that is listed in &#039;&#039;source&#039;&#039;, you must also update their checksums again with the same command.}}&lt;br /&gt;
&lt;br /&gt;
* When the remote file is hosted at SourceForge, it&#039;s best to specify the special mirrors link used by SourceForge:&lt;br /&gt;
: &amp;lt;pre&amp;gt;http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
: (or similar depending on the package).&lt;br /&gt;
&lt;br /&gt;
* When the remote filename is not specified in the URI (ie, does not end in &#039;/software-1.0.tar.gz&#039;), such as:&lt;br /&gt;
: &amp;lt;pre&amp;gt;http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
: You must prepend &#039;${pkgname}-${pkgver}.tar.gz::&#039; to the protocol, like so:&lt;br /&gt;
: &amp;lt;pre&amp;gt;source=&amp;quot;${pkgname}-${pkgver}.tar.gz::http://oss.example.org/?get=software&amp;amp;ver=1.0&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
: This causes the file to be saved as &#039;&#039;software-1.0.tar.gz&#039;&#039; where abuild can use it, instead of &#039;&#039;?get=software&amp;amp;ver=1.0&#039;&#039;, where abuild cannot use it.&lt;br /&gt;
&lt;br /&gt;
* Some projects didn&#039;t provide a release tarball. Beware that some git services (gitweg, cgit, …?) doesn’t provide &#039;&#039;stable&#039;&#039; tarballs, so when you point source to an tarball like &amp;lt;tt&amp;gt;http://repo.or.cz/w/gitstats.git/snapshot/ad7efbb9399e60cee6cb217c6b47e604174a8093.tar.gz&amp;lt;/tt&amp;gt;, then you will run into issues because the checksum changes when downloading on the build system. This is not a problem on GitHub, GitLab and other decent services provides, they provide &#039;&#039;stable&#039;&#039; tarballs.&lt;br /&gt;
&lt;br /&gt;
* abuild currently supports the following protocols for remote file retrieval:&lt;br /&gt;
** http&lt;br /&gt;
** https&lt;br /&gt;
** ftp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--: {{Note|If the you want to download from https, you need GNU wget installed on your system.}}--&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
* abuild currently supports the following archive types/archive file extensions:&lt;br /&gt;
** .tar.gz / .tgz&lt;br /&gt;
** .tar.bz2&lt;br /&gt;
** .tar.lzma&lt;br /&gt;
** .tar.xz&lt;br /&gt;
** .zip&lt;br /&gt;
&lt;br /&gt;
==== depends &amp;amp;amp; makedepends  ====&lt;br /&gt;
&lt;br /&gt;
Depends are the actual running dependencies that a package would need when it is running. Makedepends are only needed when you are building a package. If you set a package, in depends you do not need to add it to makedepends as well. The best way to find out what the depends and makedepends of a package are is to [http://en.wikipedia.org/wiki/Rtfm RTFM]. &lt;br /&gt;
&lt;br /&gt;
No kidding, lots of important information can be found it the package INSTALL and README file (or the likes). Another good way is the run &amp;lt;code&amp;gt;./configure --help&amp;lt;/code&amp;gt; from the source directory to see which options are needed for configure to finish without errors. If you do not yet have a source directory you can create one with the command: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|abuild unpack}}&lt;br /&gt;
&lt;br /&gt;
Running &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; will also show you how you can disable a specific option for this package. A good example is for instance &amp;quot;--disable-nls&amp;quot; which will disable native language support and thus does not depend on gettext (libiconv, glib, ...). &lt;br /&gt;
&lt;br /&gt;
Alpine likes to keep things small, so we try to disable as much as possible without losing too many features. The exact disable/enable options are decided the package builder but please try to follow Alpine&#039;s design concept as much as possible.&lt;br /&gt;
&lt;br /&gt;
An easy way of quickly finding out the build info for a package is to check Arch Linux (Alpine package management and build scripts are similar) or Gentoo Linux ebuilds (previous versions of Alpine were based on Gentoo).&lt;br /&gt;
&lt;br /&gt;
* [http://www.gentoo-portage.com Search ebuilds] &lt;br /&gt;
* [http://sources.gentoo.org/viewcvs.py/gentoo-x86/ Gentoo CVS] &lt;br /&gt;
* [http://www.archlinux.org/packages/search/ Arch Linux packages] [https://aur.archlinux.org/ Arch Linux User Repository]&lt;br /&gt;
&lt;br /&gt;
After the package is successfully compiled and created we should make sure it didn&#039;t link to any package that is not present in the &amp;lt;code&amp;gt;$depends&amp;lt;/code&amp;gt; variable. We do this by using &amp;lt;code&amp;gt;scanelf&amp;lt;/code&amp;gt;. If scanelf is not yet installed on your system you can do that by installing {{Pkg|pax-utils}}.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|scanelf -nR pkg}}&lt;br /&gt;
&lt;br /&gt;
An example output of {{Pkg|libcurl}} would be: &lt;br /&gt;
&lt;br /&gt;
 ET_DYN libssl.so.0.9.8,libcrypto.so.0.9.8,libz.so.1,libc.so.0,ld-uClibc.so.0 pkg/usr/lib/libcurl.so.4.1.1&lt;br /&gt;
&lt;br /&gt;
You can see the needed files and should be able to find out which file belongs to which package.&lt;br /&gt;
&lt;br /&gt;
==== license  ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;license&#039;&#039;&#039; tag must reflect the license of the source code. Please check the source tarball for COPYING, LICENSE, or other files with names that indicates that it contains licensing information. Beside the license file most developer include headers in the source code files with licensing details. Please use the short name and the release number in the license tag, e.g &lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Short name&lt;br /&gt;
! Full name&lt;br /&gt;
|-&lt;br /&gt;
| GPL2&lt;br /&gt;
| GNU General Public License Version 2.0&lt;br /&gt;
|-&lt;br /&gt;
| LGPL2+&lt;br /&gt;
| GNU Lesser General Public License Version 2.1&lt;br /&gt;
|-&lt;br /&gt;
| ASL 2.0&lt;br /&gt;
| Apache License Version 2.0&lt;br /&gt;
|-&lt;br /&gt;
| BSD&lt;br /&gt;
| BSD License&lt;br /&gt;
|-&lt;br /&gt;
| MIT&lt;br /&gt;
| MIT license&lt;br /&gt;
|-&lt;br /&gt;
| MPL 2.0&lt;br /&gt;
| Mozilla Public License v2.0&lt;br /&gt;
|-&lt;br /&gt;
| ZPL 2.0 &lt;br /&gt;
| Zope Public License v 2.0&lt;br /&gt;
|-&lt;br /&gt;
| PHP&lt;br /&gt;
| PHP License v3.0&lt;br /&gt;
|-&lt;br /&gt;
| zlib&lt;br /&gt;
| zlib/libpng License&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the GNU General Public License the &#039;+&#039; means &#039;&#039;or (at your option) any later version.&#039;&#039; which covers future releases of that license. We skip the &#039;&#039;v&#039;&#039; because it&#039;s obvious that the number shows the version. If you are unsure about the short name of a license, please check the resources below for additional information.&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.archlinux.org/index.php/Licenses ArchLinux and Licensing] &lt;br /&gt;
* [https://fedoraproject.org/wiki/Licensing:Main?rd=Licensing#Good_Licenses Fedora and Licensing]&lt;br /&gt;
&lt;br /&gt;
If a package has a special/custom license we need to provide it with the release. Because we want to save space and don&#039;t like to have licenses all over our system we have decided to include the license in the doc subpackage. Please follow the following guidelines to add a proper license. Locate the license file inside the source package. Add the doc subpackage to the $subpackages variable as follows: &lt;br /&gt;
&lt;br /&gt;
 subpackages=&amp;quot;$pkgname-doc&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Add a similar line to the following to your package() function, depending on the license description file: &lt;br /&gt;
&lt;br /&gt;
 install -Dm644 COPYING &amp;quot;$pkgdir&amp;quot;/usr/share/licenses/$pkgname/COPYING&lt;br /&gt;
&lt;br /&gt;
If you follow these steps then abuild will automatically add the license to the package-doc apk for you.&lt;br /&gt;
&lt;br /&gt;
==== arch ====&lt;br /&gt;
&lt;br /&gt;
The package architecture(s) to build for.  This can be one of: &#039;&#039;x86, x86_64, all,&#039;&#039; or &#039;&#039;noarch&#039;&#039;, where &#039;&#039;all&#039;&#039; means all architectures, and &#039;&#039;noarch&#039;&#039; means it&#039;s architecture-independent (ie, a pure-python package).&lt;br /&gt;
{{Tip|To determine if your APKBUILD can use &#039;&#039;noarch&#039;&#039;, build the package for your architecture and then run &amp;quot;scanelf -R pkg&amp;quot; from the directory that the APKBUILD resides in, in order to scan for ELF files in the &#039;&#039;./pkg&#039;&#039; directory.  If you do NOT get output from this, then &#039;&#039;noarch&#039;&#039; can be used.}}&lt;br /&gt;
&lt;br /&gt;
==== url  ====&lt;br /&gt;
&lt;br /&gt;
Website address for the program. This is usefully later on when either finding documentation or other information about the package.&lt;br /&gt;
&lt;br /&gt;
==== pkgdesc  ====&lt;br /&gt;
&lt;br /&gt;
A brief, one line, description of what the package does. Useful for the package management system. It should start with a capital letter and does &#039;&#039;&#039;not&#039;&#039;&#039; end with a period.&lt;br /&gt;
&lt;br /&gt;
Here is an example from apk_info for the OpenSSH client package:&lt;br /&gt;
&lt;br /&gt;
 pkgdesc=&amp;quot;Port of OpenBSD&#039;s free SSH release - client&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== pkgver  ====&lt;br /&gt;
&lt;br /&gt;
Provide the release number of the package you are building.&lt;br /&gt;
&lt;br /&gt;
==== pkgrel  ====&lt;br /&gt;
&lt;br /&gt;
The $pkgrel versioning is made so if you change something to your APKBUILD file without changing the actual $pkgver you can higer pkgrel so apk tools will detect it as an update. For instance if you forget to add a dependency you can add it afterward and you can +1 pkgver so apk finds this update and add the missing dependency. When there&#039;s an upstream version changes, we reset the pkgrel to 0.&lt;br /&gt;
&lt;br /&gt;
==== pkgname  ====&lt;br /&gt;
&lt;br /&gt;
The base name of the package you are creating.  For Freeswitch 1.0.6, you would use &amp;quot;freeswitch&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== install  ====&lt;br /&gt;
&lt;br /&gt;
There are 6 different kinds of install scripts. Each script is called with the $pkgname.&#039;&#039;&amp;lt;action&amp;gt;&#039;&#039; where &#039;&#039;&amp;lt;action&amp;gt;&#039;&#039; is one of the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt;$pkgname.pre-install&lt;br /&gt;
&amp;lt;dd&amp;gt;This script is executed before package is installed. Typical use is when package needs a group and a user to be created. For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
addgroup -S clamav 2&amp;gt;/dev/null&lt;br /&gt;
adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note the &#039;&#039;exit 0&#039;&#039; at the end. If the script exits with failure (if the user already exist), the package will not be installed and &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt; will exit with failure.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;$pkgname.post-install&lt;br /&gt;
&amp;lt;dd&amp;gt;This script is executed after package is installed. Can be used to generate font cache and similar.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;$pkgname.pre-upgrade&lt;br /&gt;
&amp;lt;dd&amp;gt;Same as pre-install but is executed before upgrading/downgrading/reinstalling an already installed package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;$pkgname.post-upgrade&lt;br /&gt;
&amp;lt;dd&amp;gt;Same as post-install but is executed after upgrading/downgrading/reinstalling an already installed package. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;$pkgname.pre-deinstall&lt;br /&gt;
&amp;lt;dd&amp;gt;This script is executed before uninstalling a package. If script exits with failure apk will not uninstall the package.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;$pkgname.post-deinstall&lt;br /&gt;
&amp;lt;dd&amp;gt;This script is executed after a package have been uninstalled. Can be used to update font caches and restore busybox links. For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
busybox --install -s&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the package have an pre-install and post-install script the APKBUILD should have the &#039;&#039;install&#039;&#039; variable defined:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
install=&amp;quot;$pkgname.pre-install $pkgname.post-install&amp;quot;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== subpackages  ====&lt;br /&gt;
&lt;br /&gt;
$subpackages are made to split up the normal &amp;quot;make install&amp;quot; into separate packages. The most common subpackages we use are doc and dev. Because we like to keep our target system small we move documentation and development files (only needed when building packages) into separate packages. To use the specific program a user only need to install the base apk without package-doc or package-dev, but if he wants to read the manual he will need to install package-doc. &lt;br /&gt;
&lt;br /&gt;
The easiest way to find out if you need to use -dev and -doc is to first build the package without these options set and wait until the build finishes. When its finished you should have a pkg directory which is the fake root directory. Inside this directory you will see the structure as how it would be installed in / on the target system. &lt;br /&gt;
&lt;br /&gt;
To see if you need the -dev package you can run the following cmd: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|find pkg/usr/ -name &#039;*.[acho]&#039; -o -name &#039;*.la&#039;}}&lt;br /&gt;
&lt;br /&gt;
If this returns any files you need to include the -dev package. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; To see if you need the -doc package you can run the following cmd: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|find pkg/usr/share -name doc -o -name man -o -name info -o -name html -o -name sgml -o -name licenses}}&lt;br /&gt;
&lt;br /&gt;
If this returns any directories you need to include the -doc package. &lt;br /&gt;
&lt;br /&gt;
===== Custom subpackages  =====&lt;br /&gt;
&lt;br /&gt;
Some software additionally has non-essential files that do not qualify as either documentation or development content. These files should be placed in their own, specialized subpackage(s). Some packages include large test suites which are only needed in specific circumstances or binaries which have depends which we prefer not to install. To handle those we create our own package/function. In the APKBUILD below the build() function we create another function: &lt;br /&gt;
&lt;br /&gt;
 test() {&lt;br /&gt;
        mkdir -p &amp;quot;$subpkgdir&amp;quot;/usr&lt;br /&gt;
        mv &amp;quot;$pkgdir&amp;quot;/usr/package-test &amp;quot;$subpkgdir&amp;quot;/usr/&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
We also need to add the package info to $subpackages variable: &lt;br /&gt;
&lt;br /&gt;
 subpackages=&amp;quot;$pkgname-doc $pkgname-dev $pkgname-test&amp;quot;&lt;br /&gt;
&lt;br /&gt;
After we finish building the package you should see another apk called packagename-test.apk which includes the files which we moved to the $subpkgdir dir. &lt;br /&gt;
&lt;br /&gt;
The above mentioned variables can also be used in our custom function. If we want for instance to build the test() function with perl support we would add: &lt;br /&gt;
&lt;br /&gt;
 depends=&amp;quot;perl&amp;quot;&lt;br /&gt;
 makedepends=&amp;quot;perl-dev&amp;quot;&lt;br /&gt;
&lt;br /&gt;
If we would install the base package it would not install perl, but if we install the package-test package it would.&lt;br /&gt;
&lt;br /&gt;
==== Patches  ====&lt;br /&gt;
&lt;br /&gt;
Please make sure you always submit human readable patches. Way&#039;s to create them are: &lt;br /&gt;
&lt;br /&gt;
directory compare: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|diff -urp original_directory new_directory &amp;amp;gt; filename.patch}}&lt;br /&gt;
&lt;br /&gt;
file compare: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|diff -up original.file new.file &amp;amp;gt; filename.patch}}&lt;br /&gt;
&lt;br /&gt;
Because multiple patches can patch the same file, we could create offset for the next patch. To make sure we always patch in a specified way we should number the patches as followed: &lt;br /&gt;
&lt;br /&gt;
 10-patch1.patch 20-patch2.patch 30-patch3.patch&lt;br /&gt;
&lt;br /&gt;
This way we are always sure patch 1 is first and if we want to add additional patches between them we can use 11,12,21,22...&lt;br /&gt;
&lt;br /&gt;
Add names of the patch files to the &#039;&#039;source&#039;&#039; variable. If you haven&#039;t declared custom &#039;&#039;prepare&#039;&#039; function, then it&#039;s all what you need to do. Otherwise call &#039;&#039;default_prepare&#039;&#039; in your &#039;&#039;prepare&#039;&#039; function, for example:&lt;br /&gt;
&lt;br /&gt;
 prepare() {&lt;br /&gt;
 	default_prepare&lt;br /&gt;
 &lt;br /&gt;
 	# do your stuff&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Note: Some older packages contain for loop in the &#039;&#039;prepare&#039;&#039; function to apply patches. This is not needed anymore, patches are handled by &#039;&#039;default_prepare&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Configure options  ====&lt;br /&gt;
&lt;br /&gt;
Alpine has some default configure options we set by default. We use /usr for prefix to make sure everything is installed with /usr in front of it. If you notice that anything is installed in the wrong directory please run {{Cmd|./configure --help}} and see if you can set the correct location. &lt;br /&gt;
&lt;br /&gt;
We are not covering the depend switches here we have discussed this already in the depend section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Make options  ====&lt;br /&gt;
&lt;br /&gt;
If you notice weird problems when compiling or installing the package with make/make install you could try to disable [http://www.gnu.org/software/make/manual/make.html#Parallel parallel] building/installing. A normal make line would be: &lt;br /&gt;
&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
To disable parallel we use: &lt;br /&gt;
&lt;br /&gt;
 make -j1&lt;br /&gt;
&lt;br /&gt;
We can use the same for make install. &lt;br /&gt;
&lt;br /&gt;
Because we do not want to install the package in our build environment but we want to install it in a fake root directory we need to tell &#039;make install&#039; to use another destination directory instead of &#039;/&#039;. We do this by setting a variable when we execute make install as followed: &lt;br /&gt;
&lt;br /&gt;
 make DESTDIR=&amp;quot;$pkgdir&amp;quot; install&lt;br /&gt;
&lt;br /&gt;
Please note that some Makefiles do not support this variable and will always install software in &#039;/&#039;. To make sure you do not mess up your build system NEVER run your build system as root but always use a custom user and sudo when needed. If by accident the Makefile does not support DESTDIR variable it will fail to install in our build system system directories.&lt;br /&gt;
&lt;br /&gt;
==== builddir ====&lt;br /&gt;
If you used &amp;lt;tt&amp;gt;newapkbuild&amp;lt;/tt&amp;gt; to create your APKBUILD file, you must specify the path to your unpacked sources. Inside the sections during the prepare/build/install process &#039;&#039;builddir&#039;&#039; is used. Most of the time a combination of &#039;&#039;$srcdir&#039;&#039; and &#039;&#039;$pkgname-$pkgver&#039;&#039; will work. When not, check the /src directory or the source tarball for the right string. Especially when you are working with automatically generated tarballs (like from github and gitorious), this needs to be adjusted.&lt;br /&gt;
&lt;br /&gt;
builddir=&amp;quot;$srcdir&amp;quot;/$pkgname-$pkgver&lt;br /&gt;
&lt;br /&gt;
==== Additional files  ====&lt;br /&gt;
&lt;br /&gt;
If you want/need to install additional files not mentioned above you can use the following cmd (this is an example of a conf file): &lt;br /&gt;
&lt;br /&gt;
 install -Dm644 doc/$pkgname.conf &amp;quot;$pkgdir&amp;quot;/etc/$pkgname.conf&lt;br /&gt;
&lt;br /&gt;
== Build the package  ==&lt;br /&gt;
&lt;br /&gt;
If you did not already create the checksums as mentioned above you can do so now: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|cd $pkgname&lt;br /&gt;
abuild checksum}}&lt;br /&gt;
&lt;br /&gt;
It&#039;s about time we build our package. Because a build system should never have all the package installed to prevent linking to packages we don&#039;t want it to link we use a abuild recursively with the &#039;&#039;&#039;-r&#039;&#039;&#039; switch. It will install all dependency&#039;s from your repository and builds it, afterwards it will uninstall all those depending packages again. You could also use the &#039;&#039;&#039;-R&#039;&#039;&#039; switch which would build your package including the dependency packages. &lt;br /&gt;
&lt;br /&gt;
{{Cmd|abuild -r}}&lt;br /&gt;
&lt;br /&gt;
== Commit your work  ==&lt;br /&gt;
&lt;br /&gt;
After you successfully build your package you can submit your APKBUILD to Alpine&#039;s git repository. &lt;br /&gt;
&lt;br /&gt;
Update your git repo, before adding new files: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|cd $aportsdir&lt;br /&gt;
git pull}}&lt;br /&gt;
&lt;br /&gt;
This should pull all the changes made by others into you local git repo.&lt;br /&gt;
&lt;br /&gt;
When you think you are ready you can add your files to git: &lt;br /&gt;
&lt;br /&gt;
NOTE: when using our github repo, you can create PR&#039;s for each package. Please squash all commits into a single one per PR.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|cd $aportsdir&lt;br /&gt;
git add  testing/$pkgdir (include any other files needed for the build; $pkgname.install...)&lt;br /&gt;
git commit}}&lt;br /&gt;
&lt;br /&gt;
In the commit message, add the following (remove the comments in the last four lines):&lt;br /&gt;
&lt;br /&gt;
{{Cmd| # Please enter the commit message for your changes&lt;br /&gt;
 #[snip]&lt;br /&gt;
 #&lt;br /&gt;
 testing/$pkgname: new aport   # this will be the subject line&lt;br /&gt;
                               # a blank line&lt;br /&gt;
 $pkgurl                       # homepage of project&lt;br /&gt;
 $pkgdesc                      # a one line description}}&lt;br /&gt;
&lt;br /&gt;
Or you could add the following to your `aports/.git/hooks/prepare-commit-msg` to automatically generate the commit message:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 case &amp;quot;$2,$3&amp;quot; in&lt;br /&gt;
   ,|template,)&lt;br /&gt;
     if git status --porcelain | grep -q &#039;^A.*APKBUILD$&#039;; then&lt;br /&gt;
       meta() { git diff --staged | grep &amp;quot;^+$1&amp;quot; | sed &#039;s/.*=&amp;quot;\?//;s/&amp;quot;$//&#039;;}&lt;br /&gt;
       cat &amp;gt; &amp;quot;$1&amp;quot; &amp;lt;&amp;lt;EOF&lt;br /&gt;
 testing/$(meta pkgname): new aport&lt;br /&gt;
 &lt;br /&gt;
 $(meta url)&lt;br /&gt;
 $(meta pkgdesc)&lt;br /&gt;
 EOF&lt;br /&gt;
     else&lt;br /&gt;
       git status --porcelain | sed -n &#039;s/...\(.*\)\/APKBUILD/\1: /p;T;q&#039; &amp;gt; &amp;quot;$1&amp;quot;&lt;br /&gt;
     fi;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now your changes are only available locally in your repository.&lt;br /&gt;
&lt;br /&gt;
Because you do not have push rights to the Alpine aports repository you need to create a pull request to [https://github.com/alpinelinux/aports/ Alpine&#039;s mirror on GitHub] (read instructions [https://github.com/alpinelinux/aports/blob/master/.github/CONTRIBUTING.md here]).&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a diff (patch) of the changes you made and send this patch to the &lt;br /&gt;
[http://lists.alpinelinux.org/alpine-aports/  alpine-aports mailinglist].&lt;br /&gt;
&lt;br /&gt;
To create a diff patch:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|git format-patch HEAD^}}&lt;br /&gt;
&lt;br /&gt;
or if you have sprunge, you can create a link to your patch for convenience&lt;br /&gt;
&lt;br /&gt;
{{Cmd|git format-patch HEAD^ --stdout &amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt; sprunge}}&lt;br /&gt;
&lt;br /&gt;
== Send a patch ==&lt;br /&gt;
&lt;br /&gt;
[[Creating_patches#Only_the_last_commit_with_.27git_send-email.27|git send-email]] will do that for you.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[APKBUILD Reference]]&lt;br /&gt;
* [[APKBUILD examples]]&lt;br /&gt;
* [[Development using git]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:Ollieparanoid&amp;diff=13610</id>
		<title>User:Ollieparanoid</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:Ollieparanoid&amp;diff=13610"/>
		<updated>2017-06-09T15:21:48Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;So why don&#039;t we put Alpine on phones?&lt;br /&gt;
&lt;br /&gt;
https://github.com/postmarketOS&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:Ollieparanoid&amp;diff=13609</id>
		<title>User:Ollieparanoid</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:Ollieparanoid&amp;diff=13609"/>
		<updated>2017-06-09T15:21:16Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: Created page with &amp;quot;I put Alpine on phones: https://github.com/postmarketOS&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I put Alpine on phones: https://github.com/postmarketOS&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_on_ARM&amp;diff=13608</id>
		<title>Alpine on ARM</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_on_ARM&amp;diff=13608"/>
		<updated>2017-06-09T15:20:26Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: Deleted the &amp;quot;currently it does not boot on qemu&amp;quot; note, looks like it does now: https://github.com/postmarketOS/pmbootstrap/pull/56#issuecomment-307376078&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;(this page is WIP, most info are incomplete and some might be incorrect)&lt;br /&gt;
==Supported SoCs==&lt;br /&gt;
Currently Alpine supports armv6/armhf arch on the following SoCs&lt;br /&gt;
(This is taken from the DTBs which Alpine includes)&lt;br /&gt;
{| class=&amp;quot;wikitable collapsible&amp;quot;&lt;br /&gt;
| am335x-base0033&lt;br /&gt;
| am335x-bone&lt;br /&gt;
| am335x-boneblack&lt;br /&gt;
| am335x-evm&lt;br /&gt;
| am335x-evmsk&lt;br /&gt;
| am335x-nano&lt;br /&gt;
| am335x-pepper&lt;br /&gt;
| am3517-craneboard&lt;br /&gt;
| am3517-evm&lt;br /&gt;
| am3517_mt_ventoux&lt;br /&gt;
| am437x-gp-evm&lt;br /&gt;
|-&lt;br /&gt;
| am437x-sk-evm&lt;br /&gt;
| am43x-epos-evm&lt;br /&gt;
| exynos4210-origen&lt;br /&gt;
| exynos4210-smdkv310&lt;br /&gt;
| exynos4210-trats&lt;br /&gt;
| exynos4210-universal_c210&lt;br /&gt;
| exynos4412-odroidu3&lt;br /&gt;
| exynos4412-odroidx&lt;br /&gt;
| exynos4412-odroidx2&lt;br /&gt;
| exynos4412-origen&lt;br /&gt;
| exynos4412-smdk4412&lt;br /&gt;
| exynos4412-tiny4412&lt;br /&gt;
|-&lt;br /&gt;
| exynos4412-trats2&lt;br /&gt;
| exynos5250-arndale&lt;br /&gt;
| exynos5250-smdk5250&lt;br /&gt;
| exynos5250-snow&lt;br /&gt;
| exynos5260-xyref5260&lt;br /&gt;
| exynos5410-smdk5410&lt;br /&gt;
| exynos5420-arndale-octa&lt;br /&gt;
| exynos5420-peach-pit&lt;br /&gt;
| exynos5420-smdk5420&lt;br /&gt;
| exynos5440-sd5v1&lt;br /&gt;
| exynos5440-ssdk5440&lt;br /&gt;
| exynos5800-peach-pi&lt;br /&gt;
|-&lt;br /&gt;
| imx1-ads&lt;br /&gt;
| imx1-apf9328&lt;br /&gt;
| imx25-eukrea-mbimxsd25-baseboard-cmo-qvga&lt;br /&gt;
| imx25-eukrea-mbimxsd25-baseboard-dvi-svga&lt;br /&gt;
| imx25-eukrea-mbimxsd25-baseboard-dvi-vga&lt;br /&gt;
| imx25-eukrea-mbimxsd25-baseboard&lt;br /&gt;
| imx25-karo-tx25&lt;br /&gt;
| imx25-pdk&lt;br /&gt;
| imx27-apf27&lt;br /&gt;
| imx27-apf27dev&lt;br /&gt;
| imx27-eukrea-mbimxsd27-baseboard&lt;br /&gt;
| imx27-pdk&lt;br /&gt;
|-&lt;br /&gt;
| imx27-phytec-phycard-s-rdk&lt;br /&gt;
| imx27-phytec-phycore-rdk&lt;br /&gt;
| imx31-bug&lt;br /&gt;
| imx35-eukrea-mbimxsd35-baseboard&lt;br /&gt;
| imx35-pdk&lt;br /&gt;
| imx50-evk&lt;br /&gt;
| imx51-apf51&lt;br /&gt;
| imx51-apf51dev&lt;br /&gt;
| imx51-babbage&lt;br /&gt;
| imx51-digi-connectcore-jsk&lt;br /&gt;
| imx51-eukrea-mbimxsd51-baseboard&lt;br /&gt;
| imx53-ard&lt;br /&gt;
|-&lt;br /&gt;
| imx53-m53evk&lt;br /&gt;
| imx53-mba53&lt;br /&gt;
| imx53-qsb&lt;br /&gt;
| imx53-qsrb&lt;br /&gt;
| imx53-smd&lt;br /&gt;
| imx53-tx53-x03x&lt;br /&gt;
| imx53-tx53-x13x&lt;br /&gt;
| imx53-voipac-bsb&lt;br /&gt;
| imx6dl-aristainetos_4&lt;br /&gt;
| imx6dl-aristainetos_7&lt;br /&gt;
| imx6dl-cubox-i&lt;br /&gt;
| imx6dl-dfi-fs700-m60&lt;br /&gt;
|-&lt;br /&gt;
| imx6dl-gw51xx&lt;br /&gt;
| imx6dl-gw52xx&lt;br /&gt;
| imx6dl-gw53xx&lt;br /&gt;
| imx6dl-gw54xx&lt;br /&gt;
| imx6dl-gw552x&lt;br /&gt;
| imx6dl-hummingboard&lt;br /&gt;
| imx6dl-nitrogen6x&lt;br /&gt;
| imx6dl-phytec-pbab01&lt;br /&gt;
| imx6dl-rex-basic&lt;br /&gt;
| imx6dl-riotboard&lt;br /&gt;
| imx6dl-sabreauto&lt;br /&gt;
| imx6dl-sabrelite&lt;br /&gt;
|-&lt;br /&gt;
| imx6dl-sabresd&lt;br /&gt;
| imx6dl-tx6dl-comtft&lt;br /&gt;
| imx6dl-tx6u-801x&lt;br /&gt;
| imx6dl-tx6u-811x&lt;br /&gt;
| imx6dl-wandboard-revb1&lt;br /&gt;
| imx6dl-wandboard&lt;br /&gt;
| imx6q-arm2&lt;br /&gt;
| imx6q-cm-fx6&lt;br /&gt;
| imx6q-cubox-i&lt;br /&gt;
| imx6q-dfi-fs700-m60&lt;br /&gt;
| imx6q-dmo-edmqmx6&lt;br /&gt;
| imx6q-gk802&lt;br /&gt;
|-&lt;br /&gt;
| imx6q-gw51xx&lt;br /&gt;
| imx6q-gw52xx&lt;br /&gt;
| imx6q-gw53xx&lt;br /&gt;
| imx6q-gw5400-a&lt;br /&gt;
| imx6q-gw54xx&lt;br /&gt;
| imx6q-gw552x&lt;br /&gt;
| imx6q-hummingboard&lt;br /&gt;
| imx6q-nitrogen6x&lt;br /&gt;
| imx6q-phytec-pbab01&lt;br /&gt;
| imx6q-rex-pro&lt;br /&gt;
| imx6q-sabreauto&lt;br /&gt;
| imx6q-sabrelite&lt;br /&gt;
|-&lt;br /&gt;
| imx6q-sabresd&lt;br /&gt;
| imx6q-sbc6x&lt;br /&gt;
| imx6q-tx6q-1010-comtft&lt;br /&gt;
| imx6q-tx6q-1010&lt;br /&gt;
| imx6q-tx6q-1020-comtft&lt;br /&gt;
| imx6q-tx6q-1020&lt;br /&gt;
| imx6q-tx6q-1110&lt;br /&gt;
| imx6q-udoo&lt;br /&gt;
| imx6q-wandboard-revb1&lt;br /&gt;
| imx6q-wandboard&lt;br /&gt;
| imx6sl-evk&lt;br /&gt;
| imx6sx-sdb&lt;br /&gt;
|-&lt;br /&gt;
| omap3-beagle-xm-ab&lt;br /&gt;
| omap3-beagle-xm&lt;br /&gt;
| omap3-beagle&lt;br /&gt;
| omap3-cm-t3517&lt;br /&gt;
| omap3-cm-t3530&lt;br /&gt;
| omap3-cm-t3730&lt;br /&gt;
| omap3-devkit8000&lt;br /&gt;
| omap3-evm-37xx&lt;br /&gt;
| omap3-evm&lt;br /&gt;
| omap3-gta04a3&lt;br /&gt;
| omap3-gta04a4&lt;br /&gt;
| omap3-gta04a5&lt;br /&gt;
|-&lt;br /&gt;
| omap3-ha-lcd&lt;br /&gt;
| omap3-ha&lt;br /&gt;
| omap3-igep0020&lt;br /&gt;
| omap3-igep0030&lt;br /&gt;
| omap3-ldp&lt;br /&gt;
| omap3-lilly-dbb056&lt;br /&gt;
| omap3-n9&lt;br /&gt;
| omap3-n900&lt;br /&gt;
| omap3-n950&lt;br /&gt;
| omap3-overo-alto35&lt;br /&gt;
| omap3-overo-chestnut43&lt;br /&gt;
| omap3-overo-gallop43&lt;br /&gt;
|-&lt;br /&gt;
| omap3-overo-palo43&lt;br /&gt;
| omap3-overo-storm-alto35&lt;br /&gt;
| omap3-overo-storm-chestnut43&lt;br /&gt;
| omap3-overo-storm-gallop43&lt;br /&gt;
| omap3-overo-storm-palo43&lt;br /&gt;
| omap3-overo-storm-summit&lt;br /&gt;
| omap3-overo-storm-tobi&lt;br /&gt;
| omap3-overo-summit&lt;br /&gt;
| omap3-overo-tobi&lt;br /&gt;
| omap3-sbc-t3517&lt;br /&gt;
| omap3-sbc-t3530&lt;br /&gt;
| omap3-sbc-t3730&lt;br /&gt;
|-&lt;br /&gt;
| omap3-thunder&lt;br /&gt;
| omap3-zoom3&lt;br /&gt;
| omap3430-sdp&lt;br /&gt;
| omap4-duovero-parlor&lt;br /&gt;
| omap4-panda-a4&lt;br /&gt;
| omap4-panda-es&lt;br /&gt;
| omap4-panda&lt;br /&gt;
| omap4-sdp-es23plus&lt;br /&gt;
| omap4-sdp&lt;br /&gt;
| omap4-var-dvk-om44&lt;br /&gt;
| omap4-var-stk-om44&lt;br /&gt;
| omap5-cm-t54&lt;br /&gt;
|-&lt;br /&gt;
| omap5-sbc-t54&lt;br /&gt;
| omap5-uevm&lt;br /&gt;
| qcom-apq8064-cm-qs600&lt;br /&gt;
| qcom-apq8064-ifc6410&lt;br /&gt;
| qcom-apq8074-dragonboard&lt;br /&gt;
| qcom-apq8084-ifc6540&lt;br /&gt;
| qcom-apq8084-mtp&lt;br /&gt;
| qcom-ipq8064-ap148&lt;br /&gt;
| qcom-msm8660-surf&lt;br /&gt;
| qcom-msm8960-cdp&lt;br /&gt;
| qcom-msm8974-sony-xperia-honami&lt;br /&gt;
| sun4i-a10-a1000&lt;br /&gt;
|-&lt;br /&gt;
| sun4i-a10-ba10-tvbox&lt;br /&gt;
| sun4i-a10-cubieboard&lt;br /&gt;
| sun4i-a10-hackberry&lt;br /&gt;
| sun4i-a10-inet97fv2&lt;br /&gt;
| sun4i-a10-mini-xplus&lt;br /&gt;
| sun4i-a10-olinuxino-lime&lt;br /&gt;
| sun4i-a10-pcduino&lt;br /&gt;
| sun5i-a10s-olinuxino-micro&lt;br /&gt;
| sun5i-a10s-r7-tv-dongle&lt;br /&gt;
| sun5i-a13-hsg-h702&lt;br /&gt;
| sun5i-a13-olinuxino-micro&lt;br /&gt;
| sun5i-a13-olinuxino&lt;br /&gt;
|-&lt;br /&gt;
| sun6i-a31-app4-evb1&lt;br /&gt;
| sun6i-a31-colombus&lt;br /&gt;
| sun6i-a31-hummingbird&lt;br /&gt;
| sun6i-a31-m9&lt;br /&gt;
| sun7i-a20-cubieboard2&lt;br /&gt;
| sun7i-a20-cubietruck&lt;br /&gt;
| sun7i-a20-hummingbird&lt;br /&gt;
| sun7i-a20-i12-tvbox&lt;br /&gt;
| sun7i-a20-olinuxino-lime&lt;br /&gt;
| sun7i-a20-olinuxino-micro&lt;br /&gt;
| sun7i-a20-pcduino3&lt;br /&gt;
| sun8i-a23-ippo-q8h-v5&lt;br /&gt;
|-&lt;br /&gt;
| vexpress-v2p-ca15-tc1&lt;br /&gt;
| vexpress-v2p-ca15_a7&lt;br /&gt;
| vexpress-v2p-ca5s&lt;br /&gt;
| vexpress-v2p-ca9&lt;br /&gt;
| vf610-colibri-eval-v3&lt;br /&gt;
| vf610-cosmic&lt;br /&gt;
| vf610-twr&lt;br /&gt;
|}&lt;br /&gt;
===Install Alpine on supported SoCs===&lt;br /&gt;
(If anyone has any of the above device and has successfully install Alpine on it, please consider to add the missing info)&lt;br /&gt;
&lt;br /&gt;
==Unupported SoCs==&lt;br /&gt;
If you have an armv6/armv7 SoC which is not listed above but is supported by mainline uboot/kernel then it&#039;s still possible to install Alpine&lt;br /&gt;
===Requiremnets===&lt;br /&gt;
* Alpine&#039;s forked uboot to support tarballs (fabled?)&lt;br /&gt;
* serial console&lt;br /&gt;
* crosscompiler/toolchain if you can not compile natively&lt;br /&gt;
===The embedded world===&lt;br /&gt;
A lot of the SoCs have their own way of doing things, although they use uboot and Linux kernel but often they are heavily modified to suit easy flashing of &amp;quot;ROMs&amp;quot; or other unknown reasons, e.g. Rockchip&#039;s notion &amp;quot;partition&amp;quot; are neither DOS nor GPT partitions.&lt;br /&gt;
We are to discuss to install Alpine in a more standard way like x86 with either DOS or GPT partitions. You will most likely have to install/flash the mainline uboot, which can be non-destructive if you use external storage.&lt;br /&gt;
&lt;br /&gt;
====Storage====&lt;br /&gt;
One can load uboot from the following block devices if it&#039;s supported.&lt;br /&gt;
* NAND&lt;br /&gt;
* eMMC&lt;br /&gt;
* SD card&lt;br /&gt;
* USB&lt;br /&gt;
&lt;br /&gt;
====Power on====&lt;br /&gt;
Some SoCs need both SPL and uboot, you need to check uboot for your board. Most (if not all) boards boots from the internal storage first (either NAND or eMMC) you will have to check documentation of your board if you wish to boot the SPL/uboot from SD/USB.&lt;br /&gt;
&lt;br /&gt;
One can view SPL+uboot as BIOS and boot-loader on PC. Think that you could put the BIOS on an external storage :D&lt;br /&gt;
&lt;br /&gt;
Once you have loaded the &amp;quot;standard&amp;quot; uboot, things are more or less like on x86.&lt;br /&gt;
&lt;br /&gt;
====Partitioning====&lt;br /&gt;
Either DOS or GPT patitions should work, start of the first partition should be on block 2048 so there are space for SPL/uboot and marked bootable (with&lt;br /&gt;
the MBR bootable flag, or GPT legacy_bios_bootable attribute).&lt;br /&gt;
* SPL starts at block 64 (please consult the docs for your board)&lt;br /&gt;
* uboot starts at block 256 (please consult the docs for your board)&lt;br /&gt;
Just dd SPL and boot with the correct offset to the media you wish to boot&lt;br /&gt;
&lt;br /&gt;
====Booting Linux kernel====&lt;br /&gt;
* uboot uses extlinux.conf file to locate the kernel/initramfs/... just like syslinx, you need to put that file on the partitions which is marked bootable in the /boot directory&lt;br /&gt;
* there should be an extra line &amp;quot;FDTDIR&amp;quot; which points to the DTBs&lt;br /&gt;
e.g.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
label Fedora (3.17.0-0.rc4.git2.1.fc22.armv7hl) 22 (Rawhide)&lt;br /&gt;
	kernel /boot/vmlinuz-3.17.0-0.rc4.git2.1.fc22.armv7hl&lt;br /&gt;
	append ro root=UUID=8eac677f-8ea8-4270-8479-d5ddbb797450 console=ttyS0,115200n8 LANG=en_US.UTF-8 drm.debug=0xf&lt;br /&gt;
	fdtdir /boot/dtb-3.17.0-0.rc4.git2.1.fc22.armv7hl&lt;br /&gt;
	initrd /boot/initramfs-3.17.0-0.rc4.git2.1.fc22.armv7hl.img&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Using QEMU==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
qemu-system-arm -M vexpress-a9 -kernel zImage -initrd initramfs-grsec -dtb vexpress-v2p-ca9.dtb -hda hda.img -serial stdio&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Wayland&amp;diff=13122</id>
		<title>Wayland</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Wayland&amp;diff=13122"/>
		<updated>2017-01-30T09:48:36Z</updated>

		<summary type="html">&lt;p&gt;Ollieparanoid: Created page with &amp;quot;Wayland is a new display protocol, that aims to replace X11.   == XDG_RUNTIME_DIR == Weston and other compositors require the XDG_RUNTIME_DIR variable to be set. Simply save t...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wayland is a new display protocol, that aims to replace X11.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== XDG_RUNTIME_DIR ==&lt;br /&gt;
Weston and other compositors require the XDG_RUNTIME_DIR variable to be set. Simply save the following script in /etc/profile.d/xdg_runtime_dir.sh and re-login to have it set up properly.&lt;br /&gt;
&lt;br /&gt;
  if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
      export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
      if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
          mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
          chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
      fi&lt;br /&gt;
  fi&lt;br /&gt;
&lt;br /&gt;
This code was taken from Weston&#039;s build instructions. Only ${UID} (not present on Alpine Linux) has been replaced with $(id -u).&lt;/div&gt;</summary>
		<author><name>Ollieparanoid</name></author>
	</entry>
</feed>