Added support for build_style=perl_module. That means that perl modules

now work on pkgfs.

While doing this work I added some new variables that can be used in
templates:

run_stuff_before="<stage>"
run_stuff_after="<stage>"
run_stuff_before_<stage>_file
run_stuff_after_<stage>_file

These can be used in a template when you need to do some stuff before
or after the stage specified, and the file will be read and the commands
on it executed.

Now that finally perl modules work, add the following templates:

intltool-0.40.4 and perl-XML-Parser-2.36.

Also mktmpl.sh has been updated to understand build_style=perl_module.

ENJOY!

--HG--
extra : convert_revision : 53c5148f1ba703e2b5af6e43f71668aac54a37d2
This commit is contained in:
Juan RP 2008-10-02 01:38:12 +02:00
parent 0220b27822
commit 0fdfc94802
12 changed files with 273 additions and 45 deletions

BIN
dependencies/intltool-0.40.4-deps.db vendored Normal file

Binary file not shown.

Binary file not shown.

92
helper-templates/perl-module.sh Executable file
View file

@ -0,0 +1,92 @@
# This helper does the required steps to be able to build and install
# perl modules into the correct location.
#
# Required vars to be set by a template:
#
# build_style=perl_module
#
# Optionally if the module needs more directories to be configured other
# than $PKGFS_BUILDDIR/$wrksrc, one can use (relative to $wrksrc):
#
# perl_configure_dirs=blob/bob foo/blah
#
# Override the paths to get desired results.
: ${_arch:=$(uname -m)}
: ${perl_thrmulti:=${_arch}-netbsd-thread-multi}
: ${perl_cmd:=$PKGFS_MASTERDIR/bin/perl}
: ${PERL_DESTDIR:=$PKGFS_MASTERDIR}
: ${PERL_PREFIX:=$PERL_DESTDIR}
: ${PERL_DPREFIX:=$PKGFS_DESTDIR/$pkgname}
: ${PERL_VERSION:=5.10.0}
: ${PERL_LDDLFLAGS:=--whole-archive -shared -L$PKGFS_MASTERDIR/lib}
: ${PERL_SITELIBEXP:=$PERL_DPREFIX/lib/perl5/site_perl/$PERL_VERSION}
: ${PERL_SITEARCHEXP:=$PERL_SITELIBEXP/$perl_thrmulti}
: ${PERL_SITEPREFIX:=$PERL_PREFIX}
: ${PERL_INSTALLPRIVLIB:=$PERL_DPREFIX/lib/perl5/$PERL_VERSION}
: ${PERL_INSTALLSITELIB:=$PERL_DPREFIX/lib/perl5/site_perl/$PERL_VERSION}
: ${PERL_INSTALLARCHLIB:=$PERL_DPREFIX/lib/perl5/$PERL_VERSION/$perl_thrmulti}
: ${PERL_INSTALLSITEARCH:=$PERL_SITELIBEXP}
: ${PERL_INSTALLBIN:=$PERL_DPREFIX/bin}
: ${PERL_INSTALLSITEBIN:=$PERL_INSTALLBIN}
: ${PERL_INSTALLSCRIPT:=$PERL_DPREFIX/bin}
: ${PERL_INSTALLSITESCRIPT:=$PERL_INSTALLSCRIPT}
: ${PERL_INSTALLMAN1DIR:=$PERL_DPREFIX/man/man1}
: ${PERL_INSTALLSITEMAN1DIR=$PERL_INSTALLMAN1DIR}
: ${PERL_INSTALLMAN3DIR:=$PERL_DPREFIX/man/man3}
: ${PERL_INSTALLSITEMAN3DIR:=$PERL_INSTALLMAN3DIR}
: ${PERL_PERLLIB:=$PERL_PREFIX/lib/perl5/$PERL_VERSION}
: ${PERL_ARCHLIB:=$PERL_PREFIX/lib/perl5/$PERL_VERSION/$perl_thrmulti}
: ${PERL_INC:=$PERL_PREFIX/lib/perl5/$PERL_VERSION/$perl_thrmulti/CORE}
: ${PERL_MAKE_VARS:=LDFLAGS=$LDFLAGS LDDLFLAGS=$PERL_LDDLFLAGS \
SITELIBEXP=$PERL_SITELIBEXP SITEARCHEXP=$PERL_SITEARCHEXP \
PERLPREFIX=$PERL_DESTDIR SITEPREFIX=$PERL_SITEPREFIX \
INSTALLPRIVLIB=$PERL_INSTALLPRIVLIB \
INSTALLSITELIB=$PERL_INSTALLSITELIB \
INSTALLARCHLIB=$PERL_INSTALLARCHLIB \
INSTALLSITEARCH=$PERL_INSTALLSITEARCH \
INSTALLBIN=$PERL_INSTALLBIN \
INSTALLSITEBIN=$PERL_INSTALLSITEBIN \
INSTALLSCRIPT=$PERL_INSTALLSCRIPT \
INSTALLSITESCRIPT=$PERL_INSTALLSITESCRIPT \
INSTALLMAN1DIR=$PERL_INSTALLMAN1DIR \
INSTALLSITEMAN1DIR=$PERL_INSTALLSITEMAN1DIR \
INSTALLMAN3DIR=$PERL_INSTALLMAN3DIR \
INSTALLSITEMAN3DIR=$PERL_INSTALLSITEMAN3DIR \
PERL_LIB=$PERL_PERLLIB PERL_ARCHLIB=$PERL_ARCHLIB}
perl_module_build()
{
local builddir="$wrksrc"
local perlmkf=
if [ -z "$perl_configure_dirs" ]; then
perlmkf="$builddir/Makefile.PL"
if [ ! -f $perlmkf ]; then
echo "*** ERROR couldn't find $perlmkf, aborting"
exit 1
fi
cd $builddir && \
$perl_cmd Makefile.PL ${PERL_MAKE_VARS} $make_build_args
if [ "$?" -ne 0 ]; then
echo "*** ERROR building perl module for $pkgname ***"
exit 1
fi
fi
for i in "$perl_configure_dirs"; do
perlmkf="$builddir/$i/Makefile.PL"
if [ -f $perlmkf ]; then
cd $builddir/$i && \
$perl_cmd Makefile.PL \
${PERL_MAKE_VARS} $make_build_args
[ "$?" -ne 0 ] && exit 1
else
echo -n "*** ERROR: couldn't find $perlmkf"
echo ", aborting ***"
exit 1
fi
done
}

View file

@ -1,13 +1,7 @@
#! /bin/sh
#
# This script will transform the pkg-config files with correct
# directories pointing at PKGFS_MASTERDIR specified in the config file.
#
: ${sed_cmd:=/usr/bin/sed}
: ${mv_cmd:=/bin/mv}
transform_pkgconfig_file()
pkgconfig_transform_file()
{
local file="$1"
@ -21,6 +15,3 @@ transform_pkgconfig_file()
[ "$?" -eq 0 ] && \
echo "=> Transformed pkg-config file: $(basename $file)."
}
transform_pkgconfig_file "$1"
exit 0

View file

@ -32,7 +32,8 @@
# At least it will fetch the distfile and compute the checksum, plus
# other stuff for free... so it's not that bad, heh.
#
# Supports GNU configure, configure and perl module templates for now.
#
: ${ftp_cmd:=/usr/bin/ftp -a}
: ${awk_cmd:=/usr/bin/awk}
: ${cksum_cmd:=/usr/bin/cksum -a rmd160}
@ -48,6 +49,7 @@ write_new_template()
local distdir="$PKGFS_SRCDISTDIR"
local checksum=
local dfile=
local tmplname=
[ ! -d $distdir -o ! -d $tmpldir -o ! -d $depsdir ] && exit 1
@ -67,6 +69,9 @@ write_new_template()
if [ "$build_style" = "g" ]; then
build_style=gnu_configure
elif [ "$build_style" = "p" ]; then
build_style=perl_module
tmplname="perl-"
else
build_style=configure
fi
@ -84,8 +89,11 @@ write_new_template()
fi
( \
echo "# Template build file for '$pkg'."; \
echo "pkgname=$pkg"; \
echo "# Template build file for '$tmplname$pkg'."; \
echo "pkgname=$tmplname$pkg"; \
if [ -n "$perl_module" ]; then \
echo "distfiles=\"$pkg\""; \
fi; \
echo "extract_sufx=\"$pkg_sufx\""; \
echo "url=${url%%/$dfile}"; \
echo "build_style=$build_style"; \
@ -99,9 +107,9 @@ write_new_template()
echo "maintainer=\"$maintainer\""; \
echo "checksum=$checksum"; \
echo "long_desc=\"...\""; \
) > $tmpldir/$pkg.tmpl
) > $tmpldir/$tmplname$pkg.tmpl
if [ ! -r "$tmpldir/$pkg.tmpl" ]; then
if [ ! -r "$tmpldir/$tmplname$pkg.tmpl" ]; then
echo "Couldn't write template, aborting."
exit 1
fi
@ -111,15 +119,16 @@ write_new_template()
deps="$i $deps"
done
[ -n "$pcfiles" ] && deps="pkg-config-0.23 $deps"
[ -n "$perl_module" ] && deps="perl-5.10.0 $deps"
$db_cmd -C -P 512 -w btree $depsdir/$pkg-deps.db deps \
$db_cmd -C -P 512 -w btree $depsdir/$tmplname$pkg-deps.db deps \
"$deps" 2>&1 >/dev/null
[ "$?" -ne 0 ] && \
echo "Errong writing dependencies db file." && exit 1
fi
echo
echo "=> Template created at: $tmpldir/$pkg.tmpl"
echo "=> Template created at: $tmpldir/$tmplname$pkg.tmpl"
echo
echo "If you need more changes, do them manually. You can also look"
echo "at $tmpldir/example.tmpl to know what variables can be used and"
@ -148,7 +157,7 @@ read_parameters()
[ -z "$version" ] && echo "-- Empty value --" && exit 1
echo "What's the build style for this template?"
echo -n "(g)nu_configure, (c)onfigure: "
echo -n "(g)nu_configure, (c)onfigure, (p)erl_module: "
read build_style
echo
@ -159,6 +168,8 @@ read_parameters()
gnu_configure=yes
elif [ "$build_style" = "c" ]; then
configure=yes
elif [ "$build_style" = "p" ]; then
perl_module=yes
else
echo " -- Invalid answer --"
exit 1
@ -179,8 +190,8 @@ read_parameters()
echo "Please enter exact dependencies required for this template."
echo "They must be separated by whitespaces, e.g: foo-1.0 blah-2.0."
echo
echo "There's no need to add gmake or pkg-config if you answered"
echo "yes before..."
echo "If it's a perl module or uses libtool/gmake, the dependency"
echo "will be added automatically so don't add them here again!"
echo -n "> "
read deps
echo

101
pkgfs.sh
View file

@ -62,6 +62,7 @@
: ${ln_cmd:=/bin/ln}
: ${chmod_cmd:=/bin/chmod}
: ${db_cmd:=/usr/bin/db -q}
: ${chmod_cmd:=/bin/chmod}
: ${xstow_version:=xstow-0.6.1-unstable}
: ${xstow_args:=-ap}
@ -228,7 +229,7 @@ apply_tmpl_patches()
continue
fi
cd $pkg_builddir && $patch_cmd < $patch 2>/dev/null
cd $wrksrc && $patch_cmd < $patch 2>/dev/null
if [ "$?" -eq 0 ]; then
echo "=> Patch applied: \`$i'."
else
@ -426,7 +427,7 @@ extract_tmpl_sources()
fixup_tmpl_libtool()
{
local lt_file="$pkg_builddir/libtool"
local lt_file="$wrksrc/libtool"
#
# If package has a libtool file replace it with ours, so that
@ -434,37 +435,33 @@ fixup_tmpl_libtool()
# once the package is stowned.
#
if [ -f "$lt_file" -a -f "$PKGFS_MASTERDIR/bin/libtool" ]; then
$rm_cmd -f $pkg_builddir/libtool
$rm_cmd -f $pkg_builddir/ltmain.sh
$rm_cmd -f $wrksrc/libtool
$rm_cmd -f $wrksrc/ltmain.sh
$ln_cmd -s $PKGFS_MASTERDIR/bin/libtool $lt_file
$ln_cmd -s $PKGFS_MASTERDIR/share/libtool/config/ltmain.sh \
$pkg_builddir/ltmain.sh
$wrksrc/ltmain.sh
fi
}
build_tmpl_sources()
{
local pkg_builddir=""
local wrksrc=""
[ -z "$pkgname" ] && return 1
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:$PKGFS_MASTERDIR/bin:$PKGFS_MASTERDIR/sbin"
if [ -z "$wrksrc" ]; then
if [ -z "$distfiles" ]; then
pkg_builddir=$PKGFS_BUILDDIR/$pkgname
else
pkg_builddir=$PKGFS_BUILDDIR/$distfiles
fi
if [ -n "$distfiles" ]; then
wrksrc=$PKGFS_BUILDDIR/$distfiles
else
pkg_builddir=$PKGFS_BUILDDIR/$wrksrc
wrksrc=$PKGFS_BUILDDIR/$pkgname
fi
if [ ! -d "$pkg_builddir" ]; then
if [ ! -d "$wrksrc" ]; then
echo "*** ERROR: unexistent build directory, aborting ***"
exit 1
fi
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:$PKGFS_MASTERDIR/bin:$PKGFS_MASTERDIR/sbin"
# Apply patches if requested by template file
apply_tmpl_patches
@ -476,6 +473,12 @@ build_tmpl_sources()
export LDFLAGS="-L$PKGFS_MASTERDIR/lib -Wl,-R$PKGFS_MASTERDIR/lib $LDFLAGS"
export PKG_CONFIG="$PKGFS_MASTERDIR/bin/pkg-config"
# Run stuff before configure.
if [ "$run_stuff_before" = "configure" ]; then
[ -f $PKGFS_TEMPLATESDIR/$run_stuff_before_configure_file ] && \
. $PKGFS_TEMPLATESDIR/$run_stuff_before_configure_file
fi
#
# Packages using GNU autoconf
#
@ -483,8 +486,7 @@ build_tmpl_sources()
for i in ${configure_env}; do
[ -n "$i" ] && export $i
done
cd $pkg_builddir
cd $wrksrc
#
# Pass consistent arguments to not have unexpected
# surprises later.
@ -498,17 +500,28 @@ build_tmpl_sources()
# Packages using propietary configure scripts.
#
elif [ "$build_style" = "configure" ]; then
cd $pkg_builddir
cd $wrksrc
if [ -n "$configure_script" ]; then
./$configure_script ${configure_args}
else
./configure ${configure_args}
fi
#
# Packages that are perl modules and use Makefile.PL files.
# They are all handled by the helper perl-module.sh.
#
elif [ "$build_style" = "perl_module" ]; then
. $PKGFS_TMPLHELPDIR/perl-module.sh
perl_module_build $pkgname
#
# Unknown build_style type won't work :-)
#
else
echo "*** ERROR unknown build_style $build_style, aborting ***"
exit 1
fi
if [ "$?" -ne 0 ]; then
if [ "$build_style" != "perl_module" -a "$?" -ne 0 ]; then
echo "*** ERROR building (configure state) \`$pkgname' ***"
exit 1
fi
@ -522,12 +535,34 @@ build_tmpl_sources()
# Fixup libtool script if necessary
fixup_tmpl_libtool
#
# Run template stuff before building.
#
if [ "$run_stuff_before" = "build" ]; then
[ -f $PKGFS_TEMPLATESDIR/$run_stuff_before_build_file ] && \
. $PKGFS_TEMPLATESDIR/$run_stuff_before_build_file
fi
#
# Build package via make.
#
${MAKE_CMD} ${make_build_args}
if [ "$?" -ne 0 ]; then
echo "*** ERROR building (make stage) \`$pkgname' ***"
exit 1
fi
#
# Run template stuff before installing.
#
if [ "$run_stuff_before" = "install" ]; then
[ -f $PKGFS_TEMPLATESDIR/$run_stuff_before_install_file ] && \
. $PKGFS_TEMPLATESDIR/$run_stuff_before_install_file
fi
#
# Install package via make.
#
${MAKE_CMD} ${make_install_args} \
install prefix="$PKGFS_DESTDIR/$pkgname"
if [ "$?" -ne 0 ]; then
@ -535,18 +570,34 @@ build_tmpl_sources()
exit 1
fi
#
# Run template stuff after installing.
#
if [ "$run_stuff_after" = "install" ]; then
[ -f $PKGFS_TEMPLATESDIR/$run_stuff_after_install_file ] && \
. $PKGFS_TEMPLATESDIR/$run_stuff_after_install_file
fi
#
# Transform pkg-config files if requested by template.
#
for i in ${pkgconfig_override}; do
local tmpf="$PKGFS_DESTDIR/$pkgname/lib/pkgconfig/$i"
[ -f "$tmpf" ] && $PKGFS_TMPLHELPDIR/pkg-config-transform.sh ${tmpf}
[ -f "$tmpf" ] && \
[ -f $PKGFS_TMPLHELPDIR/pkg-config-transform.sh ] && \
. $PKGFS_TMPLHELPDIR/pkg-config-transform.sh
pkgconfig_transform_file $tmpf
done
unset LDFLAGS PKG_CONFIG
echo "==> Installed \`$pkgname' into $PKGFS_DESTDIR/$pkgname."
if [ -d "$pkg_builddir" -a -z "$dontrm_builddir" ]; then
$rm_cmd -rf $pkg_builddir
#
# Remove $wrksrc if -C not specified.
#
if [ -d "$wrksrc" -a -z "$dontrm_builddir" ]; then
$rm_cmd -rf $wrksrc
[ "$?" -eq 0 ] && \
echo "=> Removed \`$pkgname' build directory."
fi

26
templates/intltool-0.40.4.tmpl Executable file
View file

@ -0,0 +1,26 @@
# Template build file for 'intltool-0.40.4'.
pkgname=intltool-0.40.4
extract_sufx=".tar.bz2"
url=http://ftp.gnome.org/pub/GNOME/sources/intltool/0.40
build_style=gnu_configure
make_cmd="$PKGFS_MASTERDIR/bin/gmake"
short_desc="Toolbox for internationalisation"
maintainer="Juan RP <xtraeme@gmail.com>"
checksum=2d6bf321d83a6ac6967bad8f4439af7a14d84314
long_desc="
The intltool collection can be used to do these things:
o Extract translatable strings from various source files (.xml.in,
.glade, .desktop.in, .server.in, .oaf.in).
o Collect the extracted strings together with messages from traditional
source files (.c, .h) in po/\$(PACKAGE).pot.
o Merge back the translations from .po files into .xml, .desktop and
.oaf files. This merge step will happen at build resp. installation
time.
The intltool package has a script, intltoolize, which copies the various
scripts and does the other magic to your module. So users building
from tarballs don't need intltool, only folks building from cvs.
(This is modeled on gettextize.)"

View file

@ -0,0 +1,16 @@
Do not hardcode rpath dirs into binaries or modules that would cause
unexpected results with pkgfs.
--- hints/netbsd.sh.orig 2008-10-02 01:03:43.000000000 +0200
+++ hints/netbsd.sh 2008-10-02 01:04:38.000000000 +0200
@@ -178,8 +178,8 @@ EOCBU
# Set sensible defaults for NetBSD: look for local software in
# /usr/pkg (NetBSD Packages Collection) and in /usr/local.
#
-loclibpth="/usr/pkg/lib /usr/local/lib"
-locincpth="/usr/pkg/include /usr/local/include"
+loclibpth=""
+locincpth=""
case "$rpathflag" in
'')
ldflags=

View file

@ -1,5 +1,6 @@
# Template build file for 'perl-5.10.0'.
pkgname=perl-5.10.0
patch_files="perl-5.10.0-dont-hardcode-rpath.diff"
extract_sufx=".tar.gz"
url=http://www.cpan.org/src
configure_script="Configure"
@ -19,3 +20,10 @@ long_desc="
procedural and object-oriented (OO) programming, has powerful built-in
support for text processing, and has one of the world's most impressive
collections of third-party modules."
# Perl needs to be handled specially and we have to transform some
# definitions to look at the correct directory.
run_stuff_before="build"
run_stuff_before_build_file="perl-runstuff-before-build.sh"
run_stuff_after="install"
run_stuff_after_install_file="perl-runstuff-after-install.sh"

View file

@ -0,0 +1,15 @@
# Template build file for 'perl-XML-Parser-2.36'.
pkgname=perl-XML-Parser-2.36
distfiles="XML-Parser-2.36"
extract_sufx=".tar.gz"
url=http://cpan.perl.org/modules/by-module/XML
build_style=perl_module
make_build_args="EXPATLIBPATH=$PKGFS_MASTERDIR/lib
EXPATINCPATH=$PKGFS_MASTERDIR/include"
short_desc="Perl extension interface to James Clark's XML parser, expat"
maintainer="Juan RP <xtraeme@gmail.com>"
checksum=1c31a2398ada943efd5d2451389e163914168253
long_desc="
This module provides ways to parse XML documents. It is built on top of
XML::Parser::Expat, which is a lower level interface to James Clark's
expat library."

View file

@ -0,0 +1,12 @@
# Fixup Config.pm to look at PKGFS_MASTERDIR, this helps modules
# to use correct dirs while building/installing them.
perl_version=5.10.0
perl_arch=$(uname -m)
perl_libdir=$PKGFS_DESTDIR/$pkgname/lib/perl5
config_pm=$perl_libdir/$perl_version/$perl_arch-netbsd-thread-multi/Config.pm
$sed_cmd -e "s|$PKGFS_DESTDIR\/$pkgname|$PKGFS_MASTERDIR|g" \
$config_pm > $config_pm.in
$chmod_cmd 444 $config_pm.in
$mv_cmd -f $config_pm.in $config_pm

View file

@ -0,0 +1,6 @@
# This fixes the definitions that the perl binary uses to look at
# PKGFS_MASTERDIR and not PKGFS_DESTDIR!
$sed_cmd -e "s|$PKGFS_DESTDIR\/$pkgname|$PKGFS_MASTERDIR|g" \
$wrksrc/config.h > $wrksrc/config.h.in && \
$mv_cmd -f $wrksrc/config.h.in $wrksrc/config.h