APKBUILD Reference

From Alpine Linux
Revision as of 03:11, 7 March 2016 by RuthHughes (talk | contribs) (minor updates)

APKBUILDs are the scripts that are created in order to build Alpine packages using the abuild tool.

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.

Legend

The following notes will assist you in understanding this document.

In description text:

  • If a variable is not prefixed with a $, it will be represented by italics (i.e., srcdir ).
  • Functions will also be represented by italics, but will also end with a pair of parentheses (i.e., build() ).
  • Shell commands will be represented like this.


Variables

Note: Variables that contain a path (e.g. $srcdir and $pkgdir) should always be quoted using double quotes (i.e., "$srcdir"). This is done to prevent things from breaking, should the user have the APKBUILD in a directory path that contains spaces.
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, _builddir).

abuild-defined variables

The following variables are defined by abuild:

startdir

The directory where the APKBUILD script is.

srcdir

The directory where sources, from the source variable, are downloaded to and unpacked to.

pkgdir

This directory should receive the files for the main package. For example, a normal autotools package would have make DESTDIR="$pkgdir" install in the package() function.

subpkgdir

This directory should receive the files for a subpackage. This variable should only be used from subpackage functions.
Tip: _builddir is not defined by abuild; instead this should be defined by hand when it's needed. You might define it as:
_builddir="$srcdir/$pkgname-$pkgver"

User-defined variables

The following variables should be defined by the user:

arch

Package architecture(s) to build for. Can be one of: x86, x86_64, all, or noarch, where all means all architectures, and noarch means it's architecture-independent (e.g., a pure-python package).
Tip: To determine if your APKBUILD can use noarch: First specify all and then build the package by executing abuild -r. Watch the output towards the end for warnings saying that noarch can be used. If the main package and all subpackages, if you have any subpackages, give a warning saying that noarch can be used, then you can use noarch.

depends

Run-time dependency package(s) that are not shared-object dependencies. Shared objects dependencies are auto-detected and should not be specified here.

depends_dev

Run-time dependency package(s) for the $pkgname-dev subpackage.
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'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).

install

There are 6 different types of install scripts. Install scripts are named $pkgname.action, where action can be: pre-install, post-install, pre-upgrade, post-upgrade, pre-deinstall, or post-deinstall. For example, if pkgname is set to mypackage and install is set to $pkgname.post-install, then a script named mypackage.post-install must exist along-side the APKBUILD.
First, a few notes regarding install scripts:
Note: When using install scripts, $install should be included in source so that checksums can be generated and used for the install scripts specified in install. For example:
install="$pkgname.pre-install $pkgname.post-install"
source="http://....
       $install"
Note: Always use /bin/sh for the command-line interpreter on the shebang line of your install scripts.

The following are the different types of install scripts in detail:

$pkgname.pre-install
This script is executed before installing the package. Typical use is when the package needs a user/group to be created. For example:
#!/bin/sh
adduser -H -s /bin/false -D clamav 2>/dev/null
exit 0
Note: If the script exits with a failure (e.g., if the user already exists), the package will not be installed and apk will exit with failure, hence the exit 0 at the end.
$pkgname.post-install
This script is executed after installing the package.
$pkgname.pre-upgrade
This script is executed before upgrading the package.
$pkgname.post-upgrade
This script is executed after upgrading the package.
$pkgname.pre-deinstall
This script is executed before uninstalling the package.
Note: If the script exits with failure, apk will not uninstall the package.
$pkgname.post-deinstall
This script is executed after uninstalling the package.

license

License(s) for the package.

makedepends

Build-time dependency package(s).

md5sums

Checksums for the files/URLs listed in source. The checksums are normally generated and updated by executing abuild checksum and should be the last item in the APKBUILD.

options

Build-time options for the package. Can be: !strip - to avoid stripping symbols from binaries.

pkgdesc

A brief, one-line description of what the package does.
Here's an example from the OpenSSH client package:
pkgdesc="Port of OpenBSD's free SSH release - client"

pkggroups

System group(s) to be created during build-time. System group(s) should also be created in the $pkgname.pre-install script, so that the system group(s) are also created prior to package installation for run-time use.

pkgname

The name of the package. All letters should be lowercase.
Note: When creating an APKBUILD of a module or library for another package, we use some common package prefixes, such as: lua-, perl-, php-, and py-. Search aports for other common prefixes.

pkgrel

Alpine package release number. Starts at 0 (zero). Always increment pkgrel when making updates to an aport; reset pkgrel to 0 (zero) when incr ... \n

private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

Offers private label cosmetics with custom design. We produce lip balms, serum, creams and more. Easy to buy with eshop. Private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

Offers private label cosmetics with custom design. We produce lip balms, serum, creams and more. Easy to buy with eshop. Private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

Offers private label cosmetics with custom design. We produce lip balms, serum, creams and more. Easy to buy with eshop. Private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

Offers private label cosmetics with custom design. We produce lip balms, serum, creams and more. Easy to buy with eshop. Private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

Offers private label cosmetics with custom design. We produce lip balms, serum, creams and more. Easy to buy with eshop. Private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]