pg.ddx.io pgsql-pkg-debian@postgresql.org mailing list archive
help / color / mirror / Atom feedUpdated pg_buildext
5+ messages / 3 participants
[nested] [flat]
* Updated pg_buildext
@ 2011-06-17 15:25 Christoph Berg <myon@debian.org>
2011-06-18 15:36 ` Re: Updated pg_buildext Dimitri Fontaine <dimitri@2ndQuadrant.fr>
2011-08-08 12:37 ` Re: Updated pg_buildext Martin Pitt <mpitt@debian.org>
0 siblings, 2 replies; 5+ messages in thread
From: Christoph Berg @ 2011-06-17 15:25 UTC (permalink / raw)
To: pgsql-pkg-debian
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
--
cb@df7cb.de | http://www.df7cb.de/
Attachments:
pg_buildext (text/plain, 4.5K) download
#!/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"
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 <action> <srcdir> ..."
[ -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 <srcdir> <target> ..."
# 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<pg_buildext> I<action> I<srcdir> I<target> I<opts>
=head1 DESCRIPTION
B<pg_buildext> is a script that will build a PostgreSQL extension in a C<VPATH>
way. It supports the B<configure>, B<build>, B<install>, and B<clean> actions,
and will choose to build for the intersection of versions known in
C<debian/pgversions> (versions supported by the package) and in
C</usr/share/postgresql-common/supported-versions> (versions supported in this
release).
=head1 OPTIONS
=over 4
=item B<action>
One of B<configure>, B<build>, B<install>, or B<clean>.
=item B<srcdir>
Where to find the extension sources, including the C<debian> subdirectory.
(Usually C<$(CURDIR)>.)
=item B<target>
The target directory where to build the sources, it will get created for you
if it does not exist. If the B<target> contains a C<%v> sign, it will get
replaced by the specific version of PostgreSQL being built against.
(Usually C<build-%v>.)
=item B<opts>
C<%v> signs in B<opts> will get replaced as in B<target>.
=over 4
=item B<configure>
Options to pass to the I<configure> script. (Most PostgreSQL extensions do not
have a configure script.)
=item B<build>
Custom C<CFLAGS> options to use for the build.
=item B<install>
Package name to install for. Make will be called with DESTDIR="I<srcdir>/debian/I<package>".
=item B<clean>
B<clean> does not take extra options.
=back
=back
=head1 USAGE
As B<pg_buildext> invokes B<make> for the B<build>, B<install>, and B<clean>
actions, invocations from C<debian/rules> (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 L<E<lt>dim@tapoueh.orgE<gt>>, with extensions by
Christoph Berg L<E<lt>myon@debian.orgE<gt>>.
pg_buildext.diff (text/x-diff, 5.3K) download
--- postgresql-common/postgresql-common/pg_buildext 2011-06-17 15:58:53.000000000 +0200
+++ pg_buildext 2011-06-17 17:06:22.000000000 +0200
@@ -5,44 +5,76 @@
#
# Author: Dimitri Fontaine <dfontaine@hi-media.com>
+set -e
+
action="$1"
srcdir="$2"
target="$3"
opt="$4"
+die() {
+ echo "`basename $0`: error: $*" >&2
+ exit 1
+}
+
prepare_env() {
- if [ ! -d $srcdir ]; then
- echo "Error: no such directory '$srcdir'"
- exit 1
- fi
version=$1
- vtarget=`echo $target | sed -e "s:%v:$version:"`
+ vtarget=`echo $target | sed -e "s:%v:$version:g"`
pgc="/usr/lib/postgresql/$version/bin/pg_config"
- cflags=`$pgc --cflags`
+ [ -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
- cd $vtarget
- make -f $srcdir/Makefile CFLAGS="$cflags $opt" PG_CONFIG="$pgc" VPATH="$srcdir"
- cd -
+ # 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
- make clean PG_CONFIG="$pgc"
+
+ # 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 <action> <srcdir> ..."
+[ -d $srcdir ] || die "no such directory '$srcdir'"
+
for v in `versions`
do
case "$action" in
@@ -50,13 +82,14 @@
echo $v
;;
- build|clean)
+ configure|build|install|clean)
+ [ "$target" ] || die "syntax: pg_buildext $action <srcdir> <target> ..."
# be verbose?
$action $v
;;
*)
- echo "$0: unsupported $action."
+ die "unsupported $action."
;;
esac
done
@@ -75,10 +108,12 @@
=head1 DESCRIPTION
-B<pg_buildext> is a script that will build a PostgreSQL extension in a
-C<VPATH> way. It only supports the B<build> and B<clean> actions, and will
-choose to build the versions known in C<debian/pgversions> and in
-C</usr/share/postgresql-common/supported-versions>.
+B<pg_buildext> is a script that will build a PostgreSQL extension in a C<VPATH>
+way. It supports the B<configure>, B<build>, B<install>, and B<clean> actions,
+and will choose to build for the intersection of versions known in
+C<debian/pgversions> (versions supported by the package) and in
+C</usr/share/postgresql-common/supported-versions> (versions supported in this
+release).
=head1 OPTIONS
@@ -86,24 +121,67 @@
=item B<action>
-Either I<clean> or I<build>.
+One of B<configure>, B<build>, B<install>, or B<clean>.
=item B<srcdir>
Where to find the extension sources, including the C<debian> subdirectory.
+(Usually C<$(CURDIR)>.)
=item B<target>
The target directory where to build the sources, it will get created for you
if it does not exist. If the B<target> contains a C<%v> sign, it will get
replaced by the specific version of PostgreSQL being built against.
+(Usually C<build-%v>.)
=item B<opts>
+C<%v> signs in B<opts> will get replaced as in B<target>.
+
+=over 4
+
+=item B<configure>
+
+Options to pass to the I<configure> script. (Most PostgreSQL extensions do not
+have a configure script.)
+
+=item B<build>
+
Custom C<CFLAGS> options to use for the build.
+=item B<install>
+
+Package name to install for. Make will be called with DESTDIR="I<srcdir>/debian/I<package>".
+
+=item B<clean>
+
+B<clean> does not take extra options.
+
=back
+=back
+
+=head1 USAGE
+
+As B<pg_buildext> invokes B<make> for the B<build>, B<install>, and B<clean>
+actions, invocations from C<debian/rules> (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 L<E<lt>dim@tapoueh.orgE<gt>>
+Dimitri Fontaine L<E<lt>dim@tapoueh.orgE<gt>>, with extensions by
+Christoph Berg L<E<lt>myon@debian.orgE<gt>>.
signature.asc (application/pgp-signature, 835B) download
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Updated pg_buildext
2011-06-17 15:25 Updated pg_buildext Christoph Berg <myon@debian.org>
@ 2011-06-18 15:36 ` Dimitri Fontaine <dimitri@2ndQuadrant.fr>
2011-06-18 18:12 ` Re: Updated pg_buildext Christoph Berg <myon@debian.org>
1 sibling, 1 reply; 5+ messages in thread
From: Dimitri Fontaine @ 2011-06-18 15:36 UTC (permalink / raw)
To: Christoph Berg <myon@debian.org>; +Cc: pgsql-pkg-debian
Hi,
Christoph Berg <myon@debian.org> writes:
> 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).
I like your changes!
I recall that doing the build in the vtarget directory was important in
my usage, but it could be that you new -f $makefile style allows to run
the build from any directory…
> Dimitri, do you think that should go into the next postgresql-common
> version?
Yes.
> (Todo: think about a smart and policy-compliant way to update
> debian/control. Also, try using with 9.1 modules.)
As we rely on the extension's Makefile I think we're as good as can be
for 9.1. For debian/control, we have the mechanism to automatically
derive it from supported-versions, we need to reach on a conclusion
about its use being safe.
The other TODO would be what to do about VPATH unfriendly extensions.
Some of them are using subdirectories where to stash regression tests,
docs, etc. Then building from another place is a problem: maybe that's
why you removed my forcing building in $vtarget?
Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Updated pg_buildext
2011-06-17 15:25 Updated pg_buildext Christoph Berg <myon@debian.org>
2011-06-18 15:36 ` Re: Updated pg_buildext Dimitri Fontaine <dimitri@2ndQuadrant.fr>
@ 2011-06-18 18:12 ` Christoph Berg <myon@debian.org>
2011-06-18 18:39 ` Re: Updated pg_buildext Dimitri Fontaine <dimitri@2ndQuadrant.fr>
0 siblings, 1 reply; 5+ messages in thread
From: Christoph Berg @ 2011-06-18 18:12 UTC (permalink / raw)
To: Dimitri Fontaine <dimitri@2ndQuadrant.fr>; +Cc: pgsql-pkg-debian
Re: Dimitri Fontaine 2011-06-18 <m2sjr7m9ra.fsf@2ndQuadrant.fr>
> I recall that doing the build in the vtarget directory was important in
> my usage, but it could be that you new -f $makefile style allows to run
> the build from any directory…
I didn't really change that, I just replaced "cd && make" with "make -C".
Usually, there won't be a Makefile in the build directory, so
$makefile is "-f $srcdir/Makefile" as before. The other case was added
for plsh which uses autoconf.
(build)
- cd $vtarget
- make -f $srcdir/Makefile CFLAGS="$cflags $opt" PG_CONFIG="$pgc" VPATH="$srcdir"
- cd -
+ # 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"
> > (Todo: think about a smart and policy-compliant way to update
> > debian/control. Also, try using with 9.1 modules.)
>
> As we rely on the extension's Makefile I think we're as good as can be
> for 9.1. For debian/control, we have the mechanism to automatically
> derive it from supported-versions, we need to reach on a conclusion
> about its use being safe.
The thread on debian-release wasn't 100% conclusive, but there were
voices against automatically updating:
http://lists.debian.org/debian-release/2011/04/msg00413.html
Here's what I would do:
* add all supported (by the package) versions to debian/control, but
only build those from supported-versions
* have some way to update debian/control (ideally not involving
debian/control.in because manual changes to debian/control get lost)
* have some way to indicate that we want to build a different set of
versions, 1) it would make sense to build 9.1 modules when uploading
to experimental now, 2) we need that for apt.postgresql.org
> The other TODO would be what to do about VPATH unfriendly extensions.
> Some of them are using subdirectories where to stash regression tests,
> docs, etc. Then building from another place is a problem: maybe that's
> why you removed my forcing building in $vtarget?
These probably require full (configure,) build && install cycles for
each version. Usually install is invoked via fakeroot, but maybe we
can go without.
Christoph
--
cb@df7cb.de | http://www.df7cb.de/
Attachments:
signature.asc (application/pgp-signature, 835B) download
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Updated pg_buildext
2011-06-17 15:25 Updated pg_buildext Christoph Berg <myon@debian.org>
2011-06-18 15:36 ` Re: Updated pg_buildext Dimitri Fontaine <dimitri@2ndQuadrant.fr>
2011-06-18 18:12 ` Re: Updated pg_buildext Christoph Berg <myon@debian.org>
@ 2011-06-18 18:39 ` Dimitri Fontaine <dimitri@2ndQuadrant.fr>
0 siblings, 0 replies; 5+ messages in thread
From: Dimitri Fontaine @ 2011-06-18 18:39 UTC (permalink / raw)
To: Christoph Berg <myon@debian.org>; +Cc: Dimitri Fontaine <dimitri@2ndQuadrant.fr>; pgsql-pkg-debian
Christoph Berg <myon@debian.org> writes:
> I didn't really change that, I just replaced "cd && make" with "make -C".
Ahah, I missed that. Objection withdrawn! :)
> Here's what I would do:
>
> * add all supported (by the package) versions to debian/control, but
> only build those from supported-versions
> * have some way to update debian/control (ideally not involving
> debian/control.in because manual changes to debian/control get lost)
> * have some way to indicate that we want to build a different set of
> versions, 1) it would make sense to build 9.1 modules when uploading
> to experimental now, 2) we need that for apt.postgresql.org
Well, for the “local” set of versions to build, I think the answer is to
tweak (dpkg-divert) the supported-versions script. Other than that, the
main situation I want to avoid is having to hand-edit the package when a
major version of PostgreSQL is dropped from sid at testing freeze time.
So +1 for your proposal.
>> The other TODO would be what to do about VPATH unfriendly extensions.
>> Some of them are using subdirectories where to stash regression tests,
>> docs, etc. Then building from another place is a problem: maybe that's
>> why you removed my forcing building in $vtarget?
>
> These probably require full (configure,) build && install cycles for
> each version. Usually install is invoked via fakeroot, but maybe we
> can go without.
I guess it boils down to playing with each extension in debian and
seeing where pg_buildext fails…
Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Updated pg_buildext
2011-06-17 15:25 Updated pg_buildext Christoph Berg <myon@debian.org>
@ 2011-08-08 12:37 ` Martin Pitt <mpitt@debian.org>
1 sibling, 0 replies; 5+ messages in thread
From: Martin Pitt @ 2011-08-08 12:37 UTC (permalink / raw)
To: pgsql-pkg-debian; +Cc: Christoph Berg <myon@debian.org>
Hello Christoph,
Christoph Berg [2011-06-17 17:25 +0200]:
> 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).
Thanks! Updated in VCS, I'll do a new upload soon.
Martin
--
Martin Pitt | http://www.piware.de
Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
Attachments:
signature.asc (application/pgp-signature, 835B) download
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2011-08-08 12:37 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-06-17 15:25 Updated pg_buildext Christoph Berg <myon@debian.org>
2011-06-18 15:36 ` Dimitri Fontaine <dimitri@2ndQuadrant.fr>
2011-06-18 18:12 ` Christoph Berg <myon@debian.org>
2011-06-18 18:39 ` Dimitri Fontaine <dimitri@2ndQuadrant.fr>
2011-08-08 12:37 ` Martin Pitt <mpitt@debian.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox