Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 6D92CB5DBCB for ; Fri, 17 Jun 2011 12:25:10 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 18151-02 for ; Fri, 17 Jun 2011 15:25:03 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from kepler.df7cb.de (kepler.df7cb.de [178.63.218.14]) by mail.postgresql.org (Postfix) with ESMTP id C93FBB5D944 for ; Fri, 17 Jun 2011 12:25:02 -0300 (ADT) Received: from benz.df7cb.de (benz.df7cb.de [IPv6:2001:6f8:10ee:e:134::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "benz.df7cb.de", Issuer "df7cb.de CA" (verified OK)) by kepler.df7cb.de (Postfix) with ESMTPS id F151D1019B1 for ; Fri, 17 Jun 2011 17:25:00 +0200 (CEST) Received: by benz.df7cb.de (Postfix, from userid 2062) id 7CAB26F083; Fri, 17 Jun 2011 17:25:00 +0200 (CEST) Date: Fri, 17 Jun 2011 17:25:00 +0200 From: Christoph Berg To: PostgreSQL in Debian Subject: Updated pg_buildext Message-ID: <20110617152500.GH4130@msgid.df7cb.de> Mail-Followup-To: Christoph Berg , PostgreSQL in Debian MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WChQLJJJfbwij+9x" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/3 X-Sequence-Number: 3 --WChQLJJJfbwij+9x Content-Type: multipart/mixed; boundary="2/5bycvrmDh4d1IB" Content-Disposition: inline --2/5bycvrmDh4d1IB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, here's my updated pg_buildext script. Most notable changes are the addtion of the "configure" and "install" actions and that it catches more errors (set -e, die() calls). Dimitri, do you think that should go into the next postgresql-common version? (Todo: think about a smart and policy-compliant way to update debian/control. Also, try using with 9.1 modules.) Christoph --=20 cb@df7cb.de | http://www.df7cb.de/ --2/5bycvrmDh4d1IB Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=pg_buildext #!/bin/sh # # build a PostgreSQL module based on PGXS for give list of supported major # versions # # Author: Dimitri Fontaine set -e action="$1" srcdir="$2" 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 exit" } 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() { [ -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 } [ "$srcdir" ] || die "syntax: pg_buildext ..." [ -d $srcdir ] || die "no such directory '$srcdir'" for v in `versions` do case "$action" in "supported-versions") echo $v ;; configure|build|install|clean) [ "$target" ] || die "syntax: pg_buildext $action ..." # be verbose? $action $v ;; *) die "unsupported $action." ;; esac done exit 0 # POD follows here =head1 NAME pg_buildext - Build and install a PostgreSQL extension =head1 SYNOPSIS B I I I I =head1 DESCRIPTION B is a script that will build a PostgreSQL extension in a C way. It supports the B, B, B, and B actions, and will choose to build for the intersection of versions known in C (versions supported by the package) and in C (versions supported in this release). =head1 OPTIONS =over 4 =item B One of B, B, B, or B. =item B Where to find the extension sources, including the C subdirectory. (Usually C<$(CURDIR)>.) =item B The target directory where to build the sources, it will get created for you if it does not exist. If the B contains a C<%v> sign, it will get replaced by the specific version of PostgreSQL being built against. (Usually C.) =item B C<%v> signs in B will get replaced as in B. =over 4 =item B Options to pass to the I script. (Most PostgreSQL extensions do not have a configure script.) =item B Custom C options to use for the build. =item B Package name to install for. Make will be called with DESTDIR="I/debian/I". =item B B does not take extra options. =back =back =head1 USAGE As B invokes B for the B, B, and B actions, invocations from C (which is a makefile) should be prefixed with B<+> so the sub-makes can talk with the make jobserver. =head1 EXAMPLE build-stamp: +pg_buildext configure $(CURDIR) build-%v "--libdir=/usr/lib/postgresql/%v/lib --datadir=/usr/share/postgresql-%v-plsh" +pg_buildext build $(CURDIR) build-%v install: build +pg_buildext install $(CURDIR) build-%v postgresql-%v-plsh clean: +pg_buildext clean $(CURDIR) build-%v =head1 AUTHOR Dimitri Fontaine Ldim@tapoueh.orgE>, with extensions by Christoph Berg Lmyon@debian.orgE>. --2/5bycvrmDh4d1IB Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pg_buildext.diff" Content-Transfer-Encoding: quoted-printable --- postgresql-common/postgresql-common/pg_buildext 2011-06-17 15:58:53.000= 000000 +0200 +++ pg_buildext 2011-06-17 17:06:22.000000000 +0200 @@ -5,44 +5,76 @@ # # Author: Dimitri Fontaine =20 +set -e + action=3D"$1" srcdir=3D"$2" target=3D"$3" opt=3D"$4" =20 +die() { + echo "`basename $0`: error: $*" >&2 + exit 1 +} + prepare_env() { - if [ ! -d $srcdir ]; then - echo "Error: no such directory '$srcdir'" - exit 1 - fi version=3D$1 - vtarget=3D`echo $target | sed -e "s:%v:$version:"` + vtarget=3D`echo $target | sed -e "s:%v:$version:g"` pgc=3D"/usr/lib/postgresql/$version/bin/pg_config" - cflags=3D`$pgc --cflags` + [ -e "$pgc" ] || die "$pgc does not exit" +} + +configure() { + prepare_env $1 + confopts=3D`echo $opt | sed -e "s:%v:$version:g"` + + mkdir -p $vtarget + ( echo "calling configure in $vtarget" && + cd $vtarget && $srcdir/configure $confopts PG_CONFIG=3D"$pgc" ) } =20 build() { prepare_env $1 + cflags=3D"`$pgc --cflags` `echo $opt | sed -e "s:%v:$version:g"`" =20 mkdir -p $vtarget - cd $vtarget - make -f $srcdir/Makefile CFLAGS=3D"$cflags $opt" PG_CONFIG=3D"$pgc" VP= ATH=3D"$srcdir" - cd - + # if a Makefile was created by configure, use it, else the top level M= akefile + [ -f $vtarget/Makefile ] || makefile=3D"-f $srcdir/Makefile" + make -C $vtarget $makefile CFLAGS=3D"$cflags" PG_CONFIG=3D"$pgc" VPATH= =3D"$srcdir" +} + +install() { + prepare_env $1 + package=3D`echo $opt | sed -e "s:%v:$version:g"` + + mkdir -p $vtarget + # if a Makefile was created by configure, use it, else the top level M= akefile + [ -f $vtarget/Makefile ] || makefile=3D"-f $srcdir/Makefile" + make -C $vtarget $makefile install DESTDIR=3D"$srcdir/debian/$package"= PG_CONFIG=3D"$pgc" VPATH=3D"$srcdir" } =20 clean() { prepare_env $1 - make clean PG_CONFIG=3D"$pgc" + + # if a Makefile was created by configure, use it, else the top level M= akefile + [ -f $vtarget/Makefile ] || makefile=3D"-f $srcdir/Makefile" + [ -d $vtarget ] && make -C $vtarget clean $makefile PG_CONFIG=3D"$pgc"= VPATH=3D"$srcdir" rm -rf $vtarget } =20 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 } =20 +[ "$srcdir" ] || die "syntax: pg_buildext ..." +[ -d $srcdir ] || die "no such directory '$srcdir'" + for v in `versions` do case "$action" in @@ -50,13 +82,14 @@ echo $v ;; =20 - build|clean) + configure|build|install|clean) + [ "$target" ] || die "syntax: pg_buildext $action .= =2E." # be verbose? $action $v ;; =20 *) - echo "$0: unsupported $action." + die "unsupported $action." ;; esac done @@ -75,10 +108,12 @@ =20 =3Dhead1 DESCRIPTION =20 -B is a script that will build a PostgreSQL extension in a -C way. It only supports the B and B actions, and will -choose to build the versions known in C and in -C. +B is a script that will build a PostgreSQL extension in a C +way. It supports the B, B, B, and B acti= ons, +and will choose to build for the intersection of versions known in +C (versions supported by the package) and in +C (versions supported in = this +release). =20 =3Dhead1 OPTIONS =20 @@ -86,24 +121,67 @@ =20 =3Ditem B =20 -Either I or I. +One of B, B, B, or B. =20 =3Ditem B =20 Where to find the extension sources, including the C subdirectory. +(Usually C<$(CURDIR)>.) =20 =3Ditem B =20 The target directory where to build the sources, it will get created for y= ou if it does not exist. If the B contains a C<%v> sign, it will get replaced by the specific version of PostgreSQL being built against. +(Usually C.) =20 =3Ditem B =20 +C<%v> signs in B will get replaced as in B. + +=3Dover 4 + +=3Ditem B + +Options to pass to the I script. (Most PostgreSQL extensions do= not +have a configure script.) + +=3Ditem B + Custom C options to use for the build. =20 +=3Ditem B + +Package name to install for. Make will be called with DESTDIR=3D"I= /debian/I". + +=3Ditem B + +B does not take extra options. + =3Dback =20 +=3Dback + +=3Dhead1 USAGE + +As B invokes B for the B, B, and B +actions, invocations from C (which is a makefile) should be = prefixed +with B<+> so the sub-makes can talk with the make jobserver. + +=3Dhead1 EXAMPLE + + build-stamp: + +pg_buildext configure $(CURDIR) build-%v "--libdir=3D/usr/lib/postgres= ql/%v/lib --datadir=3D/usr/share/postgresql-%v-plsh" + +pg_buildext build $(CURDIR) build-%v + + install: build + +pg_buildext install $(CURDIR) build-%v postgresql-%v-plsh + + clean: + +pg_buildext clean $(CURDIR) build-%v + + =3Dhead1 AUTHOR =20 -Dimitri Fontaine Ldim@tapoueh.orgE> +Dimitri Fontaine Ldim@tapoueh.orgE>, with extensions by +Christoph Berg Lmyon@debian.orgE>. --2/5bycvrmDh4d1IB-- --WChQLJJJfbwij+9x Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBCAAGBQJN+3HJAAoJEExaa6sS0qeu2kwP/i14PEZ5uO3x+uLguv+6VRGe 7+xn2BndSiM+NcumQBGMsRxhQ2DT3e1izYUqHDhV7gICISD2dKCaAHPUJuJMtFXk W2mNUcWkqlAAJpnOrGsmh1KQl7MwumRp9Gr0F9SlDsHYfjLxNcrLojpn2OMG+ziH MjEgpszXjjKFFwdJOqwk1kzjogVsyuxwMcyepV+Jg7s8ZpHg22pX3aXRBBFYr93S q1FVeVDd86FgYioFBoiHn/6K5krobBsctCIWCNEg4RdR/4HUFykbjuDgn7ZIRUu2 6L/1rFDGViIYp5HN7K6Vxv4N9bhttbUH7EgDGGza7KqOQrmaRrxclcBeJ6CpCykQ bfD8N9E/S7csWJmFdBKyifPHLVf40YNvXNWyviO+JL/ZpFGoJiqxmY1YDUfyJssm 5OeUh7PEeEPx908NW2IE1qR1T7DvO31VWr42ozwY4TkyT9zAoosTTa3UnphiKRIK csnDpJr10dDIp73Zrmn15S9awB9gUaeE1oOfZiHZ3B4bOoCvsedbOA5RBFwARoUx gZBc0irFop6ngaw90l7YROO7XZa8XUKOvgb8innlagEaWYf5IQuVB2RboJRRPVMq 4mKaoGe3N3yZQ+ZHmOxe7a3covYld7iMBLCBh/MNYafDgghGPRkEaD0ZxkUqZ7AW rjBT4pK+u+9RHpPVrFJH =nF5e -----END PGP SIGNATURE----- --WChQLJJJfbwij+9x--