diff options
author | Marko Kreen | 2012-05-31 17:05:14 +0000 |
---|---|---|
committer | Marko Kreen | 2012-05-31 17:05:14 +0000 |
commit | ede59b7b7008f64c6661fdd10edbb8df5709cb63 (patch) | |
tree | d6278ce61f4e21705de1c297ecd42f3b81ba4648 | |
parent | 119916038f355233ad291c72088b78da07e0588e (diff) |
debian: build modules for all installed server-dev versions
Currently pg_buildext is designed for building official
Debian packages *only*, which makes is unusable for
users building for custom Postgres versions.
Fix:
- include pg_buildext (from 130~bpo60+1)
- patch it to print all installed versions
- include pgxs_debian_control.mk fragment
- use custom pg_buildext everywhere
I think this is bug in pg_buildext as official packages
can simply be built in deps-only environment.
-rwxr-xr-x | debian/pg_buildext | 105 | ||||
-rwxr-xr-x | debian/rules | 44 |
2 files changed, 126 insertions, 23 deletions
diff --git a/debian/pg_buildext b/debian/pg_buildext new file mode 100755 index 00000000..02f29c44 --- /dev/null +++ b/debian/pg_buildext @@ -0,0 +1,105 @@ +#!/bin/sh +# +# build a PostgreSQL module based on PGXS for give list of supported major +# versions +# +# Author: Dimitri Fontaine <dfontaine@hi-media.com> + +set -e + +action="$1" +srcdir="${2:-`pwd`}" +target="$3" +opt="$4" + +die() { + echo "`basename $0`: error: $*" >&2 + exit 1 +} + +prepare_env() { + version=$1 + vtarget=`echo $target | sed -e "s:%v:$version:g"` + pgc="/usr/lib/postgresql/$version/bin/pg_config" + [ -e "$pgc" ] || die "$pgc does not exists" +} + +configure() { + prepare_env $1 + confopts=`echo $opt | sed -e "s:%v:$version:g"` + + mkdir -p $vtarget + ( echo "calling configure in $vtarget" && + cd $vtarget && $srcdir/configure $confopts PG_CONFIG="$pgc" ) +} + +build() { + prepare_env $1 + cflags="`$pgc --cflags` `echo $opt | sed -e "s:%v:$version:g"`" + + mkdir -p $vtarget + # if a Makefile was created by configure, use it, else the top level Makefile + [ -f $vtarget/Makefile ] || makefile="-f $srcdir/Makefile" + make -C $vtarget $makefile CFLAGS="$cflags" PG_CONFIG="$pgc" VPATH="$srcdir" +} + +install() { + prepare_env $1 + package=`echo $opt | sed -e "s:%v:$version:g"` + + mkdir -p $vtarget + # if a Makefile was created by configure, use it, else the top level Makefile + [ -f $vtarget/Makefile ] || makefile="-f $srcdir/Makefile" + make -C $vtarget $makefile install DESTDIR="$srcdir/debian/$package" PG_CONFIG="$pgc" VPATH="$srcdir" +} + +clean() { + prepare_env $1 + + # if a Makefile was created by configure, use it, else the top level Makefile + [ -f $vtarget/Makefile ] || makefile="-f $srcdir/Makefile" + [ -d $vtarget ] && make -C $vtarget clean $makefile PG_CONFIG="$pgc" VPATH="$srcdir" + rm -rf $vtarget +} + +versions() { + if true; then + # print all installed versions. assume deps take care of them. + for v in `cat $srcdir/debian/pgversions`; do + test -x /usr/lib/postgresql/$v/bin/pg_config && echo $v || true + done + else + # print *only* officially supported versions ??? + [ -e /usr/share/postgresql-common/supported-versions ] || + die "/usr/share/postgresql-common/supported-versions not found" + [ -e $srcdir/debian/pgversions ] || die "$srcdir/debian/pgversions not found" + for v in `/usr/share/postgresql-common/supported-versions` + do + grep -q "^$v" $srcdir/debian/pgversions && echo $v + done + fi +} + +[ "$srcdir" ] || die "syntax: pg_buildext <action> <srcdir> ..." +[ -d $srcdir ] || die "no such directory '$srcdir'" + +VERSIONS=`versions` + +for v in $VERSIONS +do + case "$action" in + "supported-versions") + echo $v + ;; + + configure|build|install|clean) + [ "$target" ] || die "syntax: pg_buildext $action <srcdir> <target> ..." + # be verbose? + $action $v + ;; + + *) + die "unsupported $action." + ;; + esac +done diff --git a/debian/rules b/debian/rules index 626575da..42f6c149 100755 --- a/debian/rules +++ b/debian/rules @@ -1,20 +1,11 @@ #!/usr/bin/make -f # -*- makefile -*- -# Sample debian/rules that uses debhelper. -# -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. -# -# Modified to make a template file for a multi-binary package with separated -# build-arch and build-indep targets by Bill Allombert 2001 # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # This has to be exported to make some magic below work. -export DH_OPTIONS +#export DH_OPTIONS # The build system is averse to VPATH building, so we can't properly use # postgresql-server-dev-all @@ -22,14 +13,23 @@ SRCDIR = $(CURDIR) PKGVERS = $(shell dpkg-parsechangelog | awk -F '[:-]' '/^Version:/ { print substr($$2, 2) }') ORIG_EXCLUDE=--exclude-vcs --exclude=debian -include /usr/share/postgresql-common/pgxs_debian_control.mk +PG_BUILDEXT = ./debian/pg_buildext -debian/control-pgver-stamp: debian/control.in debian/pgversions - rm -f debian/control - $(MAKE) -f debian/rules debian/control +## include /usr/share/postgresql-common/pgxs_debian_control.mk +# produce a debian/control file from a debian/control.in +debian/control-pgstamp: debian/control.in debian/pgversions + ( set -e; \ + VERSIONS=`$(PG_BUILDEXT) supported-versions $(CURDIR)`; \ + grep-dctrl -vP PGVERSION debian/control.in > debian/control.tmp; \ + for v in $$VERSIONS; do \ + grep -q "^$$v" debian/pgversions \ + && grep-dctrl -P PGVERSION debian/control.in \ + | sed -e "s:PGVERSION:$$v:" >> debian/control.tmp; \ + done; \ + mv debian/control.tmp debian/control ) || (rm -f debian/control.tmp; exit 1) touch $@ -config.mak: debian/control-pgver-stamp +config.mak: debian/control-pgstamp #./autogen.sh ./configure --prefix=/usr --with-asciidoc --with-sk3-subdir @@ -38,20 +38,18 @@ override_dh_auto_configure: config.mak override_dh_auto_clean: config.mak $(MAKE) -C doc realclean dh_auto_clean -- distclean - for version in $$(pg_buildext supported-versions .) ; do \ - rm -rf debian/postgresql-$${version}-pgq3; \ + for version in `cat $(CURDIR)/debian/pgversions`; do \ + rm -rf "debian/postgresql-$${version}-pgq3"; \ done - rm -f debian/control-pgver-stamp + rm -f debian/control-pgstamp -# upstream build system will build fine for one given PostgreSQL version, -# then we build the PostgreSQL module and files for yet another version of -# it so that we have binary packages for postgresql-8.4-pgq3 and 9.0. -override_dh_auto_install: +# build sql modules for several postgres versions +override_dh_auto_install: config.mak mkdir -p $(CURDIR)/debian/tmp dh_auto_install $(MAKE) -C doc htmlinstall DESTDIR=$(CURDIR)/debian/tmp # now care about any previous supported versions - for version in $$(pg_buildext supported-versions .) ; do \ + for version in $$($(PG_BUILDEXT) supported-versions $(CURDIR)); do \ echo "### Building for PostgreSQL $$version" && \ make -C sql clean install \ PG_CONFIG=/usr/lib/postgresql/$$version/bin/pg_config \ |