Content-type: text/html
makeworld can be used to rebuild an entire package group, or the entire build tree.
NOTE: If you have a local copy of the Arch Build System (ABS) tree on your computer, you can copy the PKGBUILD.proto file to your new package build directory and edit it from there. To acquire/sync the ABS tree, use the abs script included with pacman/makepkg.
pkgname=modutils
pkgver=2.4.13
pkgrel=1
pkgdesc="Utilities for inserting and removing modules from the linux kernel"
backup=(etc/modules.conf)
depends=('glibc>=2.2.5' 'bash' 'zlib')
source=(ftp://ftp.server.com/$pkgname-$pkgver.tar.gz modules.conf)
build() {
cd $startdir/src/$pkgname-$pkgver
./configure --prefix=/usr
make || return 1
make prefix=$startdir/pkg/usr install
# copy our custom modules.conf into the package root
mkdir -p $startdir/pkg/etc
cp ../modules.conf $startdir/pkg/etc
}
As you can see, the setup is fairly simple. The first three lines define the package name and version info. They also define the final package name which will be of the form $pkgname-$pkgver-$pkgrel.pkg.tar.gz. The fourth line provides a brief description of the package. These four lines should be present in every PKGBUILD script.
The line with backup= specifies files that should be treated specially when removing or upgrading packages. See HANDLING CONFIG FILES in the pacman manpage for more information on this.
The sixth line lists the dependencies for this package. In order to build/run the package, all dependencies must be satisifed first. makepkg will check this before attempting to build the package.
Once your PKGBUILD is created, you can run makepkg from the build directory. makepkg will then check dependencies and look for the source files required to build. If some are missing it will attempt to download them, provided there is a fully-qualified URL in the source array.
The sources are then extracted into a directory called ./src and the build function is called. This is where all package configuration, building, and installing should be done. Any customization will likely take place here.
After a package is built, the build function must install the package files into a special package root, which can be referenced by $startdir/pkg in the build function. The typical way to do this is one of the following:
make DESTDIR=$startdir/pkg install or make prefix=$startdir/pkg/usr install
Once the package is successfully installed into the package root, makepkg will remove some directories (as per Arch Linux package guidelines; if you use this elsewhere, feel free to change it) like /usr/doc and /usr/info. It will then strip debugging info from libraries and binaries and generate a meta-info file. Finally, it will compress everything into a .pkg.tar.gz file and leave it in the directory you ran makepkg from.
At this point you should have a package file in the current directory, named something like name-version-release.pkg.tar.gz. Done!
The exact time the script is run varies with each operation:
To use this feature, just create a file (eg, pkgname.install) and put it in the same directory as the PKGBUILD script. Then use the install directive:
install=pkgname.install
The install script does not need to be specified in the source array.
# arg 1: the new package version
post_install() {
#
# do post-install stuff here
#
/bin/true
}
# arg 1: the new package version
# arg 2: the old package version
post_upgrade() {
#
# do post-upgrade stuff here
#
/bin/true
}
# arg 1: the old package version
pre_remove() {
#
# do pre-remove stuff here
#
/bin/true
}
op=$1
shift
$op $*
This template is also available in your ABS tree (/usr/abs/install.proto).
NOTE: This does not guarantee that all package Makefiles will use your exported variables. Some of them are flaky...
See the Arch Linux Documentation for package-building guidelines if you wish to contribute packages to the Arch Linux project.
Judd Vinet <jvinet@zeroflux.org>