Create a package
Create a template for a new package called
$ pmbootstrap newapkbuild main mynewpackage [21:34:27] Create /home/user/code/pmbootstrap/aports/main/mynewpackage [21:34:27] Done
We directly use
newapkbuild from Alpine, which has lots of parameters to quickly customize the templates it generates:
$ pmbootstrap newapkbuild main -h newapkbuild 3.1.0-r4 - generate a new APKBUILD Usage: newapkbuild [-n NAME] [-d DESC] [-l LICENSE] [-u URL] [-aCpy] [-s] [-cfh] PKGNAME[-PKGVER]|SRCURL Options: -n Set package name to NAME -d Set package description (pkgdesc) to DESC -l Set package license to LICENSE -u Set package URL -a Create autotools package (use ./configure ...) -C Create CMake pakckage (Assume cmake/ is there) -m Create meson package (Assume meson.build is there) -p Create perl package (Assume Makefile.PL is there) -y Create python package (Assume setup.py is there) -s Use sourceforge source URL -c Copy a sample init.d, conf.d, and install script to new directory -f Force even if directory already exist -h Show this help
- Please read this section from our upstream friends wiki (which we should also extend and improve)
- Please always package the latest version of a software (unless it is impossible because of software that depends on it, but try to avoid that!)
- Please do not copy maintainers/contributors from the other packages to your new ports (so they won't get annoyed by questions for pmOS/Alpine packages!). Instead please credit them in the commit messages (maybe with a link to the original build recipe)
- Alpine Linux uses
muslas libc, not
glibc. Never add
- Alpine uses busybox'
shfor building packages. Do not use bash specific features.
- Manpages and other documentation goes into an extra -doc package in Alpine, and abuild will complain if the main package contains them. The solution is to add this:
- You can look up the exact meaning of every variable and function in the APKBUILD Reference
- Set up the git hook from the development guide article to automatically verify checksums in your APKBUILDs and therefore making your life easier
- How to create a patch when packaging software
Beware of legacy APKBUILDs
Alpine's program to build packages,
abuild evolves constantly. But the APKBUILDs sometimes lack behind. Some APKBUILDs still have the following, which is unnecessary:
|| return 1statements after every line (e.g.
make || return 1is not needed anymore, use
- a custom
prepare()function that does nothing but apply patches (more information))
- not using the
builddirvariable to point to the extracted source location (usually:
Packaging git commits
Only package git commits when necessary. Stable releases are preferred. Consider asking upstream to tag releases.
pkgver: We use the following format:
1.0_git20171101(that makes it easy to see how old the commit is and
apkis able to upgrade the package properly when the next release, e.g.
1.1, comes out)
- Save the git commit in a variable
_commit=....and use it throughout the
APKBUILD(e.g. in the
builddir), so it's easy to update it.
sourceshould be saved with the
$_commitin the filename. For GitHub links, this means:
When should pkgver/pkgrel get increased?
Whenever you update a package, it must have a new version. A version consists of
$pkgver-r$pkgrel. The APKBUILD_Reference says:
pkgver: The version of the software being packaged.
pkgrel: Alpine/postmarketOS package release number. Starts at 0 (zero). Always increment
pkgrelwhen making updates to an aport; reset
pkgrelto 0 (zero) when incrementing
Special cases, where this is not so obvious:
linux-*packages: We always set the
pkgverto the kernel version number and only increase it when the kernel source code has a new version number. All kernel config changes only increase the
pkgrelnumber. In the case, that the linux kernel sources need to be updated, but the kernel version was not changed (Android kernel forks often do this), we can add a
_gitYYYYMMDDsuffix (see "Packaging git commits" above).
device-*packages: This was not done consistently in the past, but it makes sense to update the
pkgverwhen anything but the
APKBUILDwas changed. Because that is essentially the version of the software being packaged.
Porting packages from Arch Linux
PKBUILD format is similar to
APKBUILD of Alpine. If you don't know how to package a new program, check out how Arch does it.
Find the package
Search here, click the package name, click on "Source Files" on the top right. A git repo with the
PKGBUILD and all other files (such as patches) appears.
Differences between APKBUILDs and PKGBUILDs
APKBUILDs do not have the arrays from bash, use flat strings instead
- There's no
-docsubpackages (see above)
APKBUILDhas different options (!makeflags won't work, but it has !strip and !check)