APKBUILD Reference: Difference between revisions
(fix heading for examples) |
m (added arch= info, updated example APKBUILDs, made different variable types (abuild-/user-defined) more visible) |
||
Line 2: | Line 2: | ||
= Variables = | = Variables = | ||
== abuild-defined variables == | |||
The following variables are defined by abuild: | The following variables are defined by abuild: | ||
; startdir | ; startdir | ||
Line 13: | Line 14: | ||
{{Note|All variables that holds a path (i.e ''$srcdir'' and ''$pkgdir'') should always be within quotes in the APKBUILD (for example: ''"$srcdir"''). This is so things don't break in case user has the APKBUILD in a directory with spaces.}} | {{Note|All variables that holds a path (i.e ''$srcdir'' and ''$pkgdir'') should always be within quotes in the APKBUILD (for example: ''"$srcdir"''). This is so things don't break in case user has the APKBUILD in a directory with spaces.}} | ||
== User-defined variables == | |||
The following variables should be defined by user in APKBUILD: | The following variables should be defined by user in APKBUILD: | ||
; arch | |||
: Package architecture(s) to build for. Can be one of: ''x86, x86_64, all,'' or ''noarch''. ''all'' means all architectures, and ''noarch'' means it's architecture-independent (ie, a pure-python package). | |||
{{Tip|To determine if your APKBUILD can use ''noarch'', build the package for your architecture and then run "scanelf -R pkg" from the directory that the APKBUILD resides in, to scan for ELF files in the <package>/pkg directory. If you get output from this, then you can't use ''noarch''.}} | |||
; depends | ; depends | ||
: Runtime dependencies that are not shared-object dependencies. Shared objects dependencies are autodetected and should not be specified here. | : Runtime dependencies that are not shared-object dependencies. Shared objects dependencies are autodetected and should not be specified here. | ||
Line 65: | Line 70: | ||
: download remote sources listed in $source to ''$SRCDEST'' and create symlinks to ''$srcdir''. | : download remote sources listed in $source to ''$SRCDEST'' and create symlinks to ''$srcdir''. | ||
; unpack() | ; unpack() | ||
: unpacks .tar.gz .tar.bz2 .tgz and .zip | : unpacks .tar.gz .tar.bz2 .tgz and .zip archives in ''$srcdir''. | ||
; dev() | ; dev() | ||
: Subpackage function for -dev packages. By default this will only call ''default_dev'' which will move ''$pkgdir/usr/include'', ''*.a'', ''*.la'' and similar files to ''$subpkgdir''. | : Subpackage function for -dev packages. By default this will only call ''default_dev'' which will move ''$pkgdir/usr/include'', ''*.a'', ''*.la'' and similar files to ''$subpkgdir''. | ||
Line 102: | Line 107: | ||
# Maintainer: Natanael Copa <ncopa@alpinelinux.org> | # Maintainer: Natanael Copa <ncopa@alpinelinux.org> | ||
pkgname=m4 | pkgname=m4 | ||
pkgver=1.4. | pkgver=1.4.15 | ||
pkgrel=0 | pkgrel=0 | ||
pkgdesc="GNU macro processor" | pkgdesc="GNU macro processor" | ||
url="http://www.gnu.org/software/m4" | url="http://www.gnu.org/software/m4" | ||
depends= | depends= | ||
arch="all" | |||
license="GPL" | license="GPL" | ||
subpackages="m4-doc" | subpackages="m4-doc" | ||
source="ftp://ftp.gnu.org/gnu/m4/$pkgname-$pkgver.tar.gz | |||
gnulib-uclibc.patch" | |||
_builddir="$srcdir"/$pkgname-$pkgver | _builddir="$srcdir"/$pkgname-$pkgver | ||
prepare() { | |||
cd "$_builddir" | |||
patch -p1 -i "$srcdir"/gnulib-uclibc.patch | |||
} | |||
build() { | build() { | ||
cd "$_builddir" | cd "$_builddir" | ||
Line 123: | Line 135: | ||
} | } | ||
md5sums=" | md5sums="5649a2e593b6c639deae9e72ede777dd m4-1.4.15.tar.gz | ||
20a7dedec0e9e0ee7107e33e798ffdbe gnulib-uclibc.patch" | |||
</pre> | </pre> | ||
Line 131: | Line 144: | ||
# Maintainer: Carlo Landmeter <clandmeter at gmail> | # Maintainer: Carlo Landmeter <clandmeter at gmail> | ||
pkgname=libxml2 | pkgname=libxml2 | ||
pkgver=2.7. | pkgver=2.7.8 | ||
pkgrel=0 | pkgrel=0 | ||
pkgdesc="XML parsing library, version 2" | pkgdesc="XML parsing library, version 2" | ||
url="http://www.xmlsoft.org/" | url="http://www.xmlsoft.org/" | ||
arch="all" | |||
license="MIT" | license="MIT" | ||
depends= | depends= | ||
depends_dev="zlib-dev python-dev" | |||
makedepends="zlib-dev python-dev" | makedepends="zlib-dev python-dev" | ||
subpackages="$pkgname-doc $pkgname-dev py-$pkgname:py" | subpackages="$pkgname-doc $pkgname-dev py-$pkgname:py $pkgname-utils" | ||
source="ftp://ftp.xmlsoft.org/${pkgname}/${pkgname}-${pkgver}.tar.gz | source="ftp://ftp.xmlsoft.org/${pkgname}/${pkgname}-${pkgver}.tar.gz | ||
largefile64.patch" | |||
options="!strip" | options="!strip" | ||
Line 146: | Line 161: | ||
_builddir="$srcdir/$pkgname-$pkgver" | _builddir="$srcdir/$pkgname-$pkgver" | ||
prepare() { | prepare() { | ||
cd "$_builddir" | |||
for _i in "$srcdir"/*.patch; do | |||
patch -p1 -i "$_i" | |||
done | |||
} | } | ||
build() { | build() { | ||
cd "$_builddir" | |||
./configure --prefix=/usr \ | |||
--sysconfdir=/etc \ | |||
--mandir=/usr/share/man \ | |||
--infodir=/usr/share/info | |||
make | |||
} | } | ||
package() { | package() { | ||
cd "$_builddir" | |||
make -j1 DESTDIR="$pkgdir" install | |||
install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING | |||
} | } | ||
py() { | py() { | ||
cd "$_builddir" | |||
pkgdesc="$pkgname python bindings" | |||
install -d "$subpkgdir"/usr/lib | |||
mv "$pkgdir"/usr/lib/python* "$subpkgdir"/usr/lib/ | |||
} | } | ||
utils() { | |||
pkgdesc="XML utilities" | |||
replaces="libxml2" | |||
mkdir -p "$subpkgdir"/usr | |||
mv "$pkgdir"/usr/bin "$subpkgdir"/usr/ | |||
} | |||
md5sums=" | md5sums="8127a65e8c3b08856093099b52599c86 libxml2-2.7.8.tar.gz | ||
5ad4915665608ebfa5b89f7908467a72 largefile64.patch" | 5ad4915665608ebfa5b89f7908467a72 largefile64.patch" | ||
</pre> | </pre> |
Revision as of 00:32, 18 December 2010
APKBUILDs are scripts to build alpine packages using the abuild tool.
Variables
abuild-defined variables
The following variables are defined by abuild:
- startdir
- The directory where APKBUILD script is found.
- srcdir
- The directory here sources are downloaded to and unpacked.
- pkgdir
- This directory should hold the data files for main package. A normal autotools package has a make DESTDIR="$pkgdir" install.
- subpkgdir
- This directory should have the data files for a subpackage. This variable should only be used from subpackage functions.
User-defined variables
The following variables should be defined by user in APKBUILD:
- arch
- Package architecture(s) to build for. Can be one of: x86, x86_64, all, or noarch. all means all architectures, and noarch means it's architecture-independent (ie, a pure-python package).
- depends
- Runtime dependencies that are not shared-object dependencies. Shared objects dependencies are autodetected and should not be specified here.
- depends_dev
- Runtime dependencies for -dev subpackage.
- install
- pre/post install/deinstall/remove scripts.
- license
- License(s) for the package.
- makedepends
- Build time dependencies.
- md5sums
- Checksums for sources and patches. This is generated with abuild checksum and should be located last in the APKBUILD.
- options
- build time options for package. Valid values are currently only !strip for avoid stripping the binaries.
- pkgdesc
- Short package description.
- pkggroups
- Groups to be created during buildtime. This group should be created in a $pkgname.pre-install script as well so group is created during runtime.
- pkgname
- The name of the package. All letters should be lowercase. Lua libraries/modules should be prefixed with lua- (for example lua-posix), perl modules with perl- (for example perl-xml-parser), php modules with php- and python modules with py--.
- pkgusers
- Users to be created during buildtime. Use $pkgname.pre-install for creating the user(s) during runtime.
- pkgver
- The package version.
- replaces
- package(s) that this package replaces. This package will "take over" files owned by packages listed in replaces. Useful when files moves from one (sub)package to another, or packages gets renamed.
- source
- URL(s) to sources and patches.
- subpackages
- Subpackages built from this APKBUILD.
- url
- The homepage for the package. This is to help users find upstream developer, documentation etc.
Functions
The following functions should be specified in the APKBUILD. The functions should consider current work directory as undefined.
- prepare()
- Optional. Build preparation. Here should patches etc be applied. This is function is for convenience while working with the APKBUILD.
- build()
- Required. This is the compilation stage. This function will be called as normal user (unless the package() function is missing - for compatibility reasons). If no compilation is needed this function can contain a single return 0.
- package()
- Required. In this function the built application and files should be installed in "$pkgdir".
The following functions are provided by abuild and is overrideable:
- fetch()
- download remote sources listed in $source to $SRCDEST and create symlinks to $srcdir.
- unpack()
- unpacks .tar.gz .tar.bz2 .tgz and .zip archives in $srcdir.
- dev()
- Subpackage function for -dev packages. By default this will only call default_dev which will move $pkgdir/usr/include, *.a, *.la and similar files to $subpkgdir.
- doc()
- Subpackage function for -doc packages. By default this will only call default_doc which will move $pkgdir/usr/share/doc, $pkgdir/usr/share/man and similar to $subpkgdir.
Subpackages
Subpackages are specified in the $subpackages variable. abuild will parse this variable and try find a subpackage split function. The split function must move files from $pkgdir to $subpkgdir.
The split function can be specified in 3 different ways:
- subpkgname:splitfunc
- pkgname-splitfunc
- splitfunc
Subpackages example
pkgname="foo" subpackages="$pkgname-dev $pkgname-doc py-$pkgname:pysub libfoo"
will create totally 5 packages:
- foo (main)
- foo-dev (sub)
- foo-doc (sub)
- py-foo (sub)
- libfoo (sub)
The split functions for the 4 sub packages are:
- dev() (provided by abuild)
- doc() (provided by abuild)
- pysub() (provided by user)
- libfoo() (provided by user)
Examples
Simple package with separate -doc subpackage.
# Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=m4 pkgver=1.4.15 pkgrel=0 pkgdesc="GNU macro processor" url="http://www.gnu.org/software/m4" depends= arch="all" license="GPL" subpackages="m4-doc" source="ftp://ftp.gnu.org/gnu/m4/$pkgname-$pkgver.tar.gz gnulib-uclibc.patch" _builddir="$srcdir"/$pkgname-$pkgver prepare() { cd "$_builddir" patch -p1 -i "$srcdir"/gnulib-uclibc.patch } build() { cd "$_builddir" ./configure --prefix=/usr make } package() { cd "$_builddir" make install DESTDIR="$pkgdir" } md5sums="5649a2e593b6c639deae9e72ede777dd m4-1.4.15.tar.gz 20a7dedec0e9e0ee7107e33e798ffdbe gnulib-uclibc.patch"
Example with -doc, -dev and python subpackages.
# Contributor: Carlo Landmeter <clandmeter at gmail> # Maintainer: Carlo Landmeter <clandmeter at gmail> pkgname=libxml2 pkgver=2.7.8 pkgrel=0 pkgdesc="XML parsing library, version 2" url="http://www.xmlsoft.org/" arch="all" license="MIT" depends= depends_dev="zlib-dev python-dev" makedepends="zlib-dev python-dev" subpackages="$pkgname-doc $pkgname-dev py-$pkgname:py $pkgname-utils" source="ftp://ftp.xmlsoft.org/${pkgname}/${pkgname}-${pkgver}.tar.gz largefile64.patch" options="!strip" _builddir="$srcdir/$pkgname-$pkgver" prepare() { cd "$_builddir" for _i in "$srcdir"/*.patch; do patch -p1 -i "$_i" done } build() { cd "$_builddir" ./configure --prefix=/usr \ --sysconfdir=/etc \ --mandir=/usr/share/man \ --infodir=/usr/share/info make } package() { cd "$_builddir" make -j1 DESTDIR="$pkgdir" install install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING } py() { cd "$_builddir" pkgdesc="$pkgname python bindings" install -d "$subpkgdir"/usr/lib mv "$pkgdir"/usr/lib/python* "$subpkgdir"/usr/lib/ } utils() { pkgdesc="XML utilities" replaces="libxml2" mkdir -p "$subpkgdir"/usr mv "$pkgdir"/usr/bin "$subpkgdir"/usr/ } md5sums="8127a65e8c3b08856093099b52599c86 libxml2-2.7.8.tar.gz 5ad4915665608ebfa5b89f7908467a72 largefile64.patch"