[pacman-dev] makepkg patch - simple pkg class feature

K. Piche kpiche at rogers.com
Thu Dec 27 00:27:29 EST 2007


Hi,

I hope everyone had a great holiday!

Perl module PKGBUILDs tend to be a mess and some build() functions are
not "standard".  Now with the new upcoming perl policy all of the
PKGBUILDs need to be "standardized" again.  To help combat this problem
I hacked up a package class feature where all the functions and package
defaults are set in a class file and sourced before the package is
built.  The class file can define a set of build functions to call
instead of just build().

Some advantages:
- standardization of package types, even AUR packages could be uniform
- code in makepkg could be moved to a class so that it could easily be
override by people doing non-standard things: no man pages, i585 ports
- anything set in the PKGBUILD takes precedence over the class
- defined build functions can be optional (see the sample perl class)

The patch is backwards compatible with non-class PKGBUILDs and I have
been using my classy makepkg for 5 days.

Attached is the patch, a perl class, and sample PKGBUILD for
Sys::Syslog.  Right now the class file has to be in the same directory
as the PKGBUILD.

Happy New Year!

k


-- 
K. Piche <kpiche at rogers.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Add-a-simple-package-class-feature.patch
Type: application/mbox
Size: 3936 bytes
Desc: not available
URL: <http://archlinux.org/pipermail/pacman-dev/attachments/20071227/2f5b107c/attachment.bin>
-------------- next part --------------
# Maintainer: Kevin <kevin at archlinux.org>

pkgname=perl-sys-syslog
_realname=Sys-Syslog
pkgver=0.23
pkgrel=1
pkgdesc="Syslog"
arch=(i686 x86_64)
source=(http://search.cpan.org/CPAN/authors/id/S/SA/SAPER/${_realname}-${pkgver}.tar.gz)
md5sums=('b9bc456b725f620e6b8b9318286e8746')

pkgclass=perl-make
-------------- next part --------------
# Class to build perl modules.

# Default pkg attributes.
url="http://search.cpan.org/dist/${_realname}/"
license=('GPL' 'PerlArtistic')
depends=('perl')
options=(!emptydirs)


pre_build() {
	if [ -z $_realname ]; then
		error "Variable _realname not set"
		return 1
	fi
}


perl_build() {
	cd ${startdir}/src/${_realname}-${pkgver}
	eval `perl -V:archname`
	perl Makefile.PL \
		INSTALLARCHLIB=/usr/lib/perl5/current/${archname} \
		INSTALLSITELIB=/usr/lib/perl5/site_perl/current \
		INSTALLSITEARCH=/usr/lib/perl5/site_perl/current/${archname}
	make || return 1
	make install DESTDIR=${startdir}/pkg
}


post_build() {
	# remove perllocal.pod and .packlist.
	find ${startdir}/pkg -name perllocal.pod -delete
	find ${startdir}/pkg -name .packlist -delete
}


class_build_funcs=(pre_build perl_build post_build optional)



More information about the pacman-dev mailing list