Merge lp:~flameeyes/gearmand/gentoo-fixes into lp:gearmand/1.0

Proposed by Diego Elio Pettenò on 2010-04-08
Status: Work in progress
Proposed branch: lp:~flameeyes/gearmand/gentoo-fixes
Merge into: lp:gearmand/1.0
Diff against target: 96 lines (+32/-21)
3 files modified
libgearman-server/include.am (+2/-0)
libgearman-server/queue_libpq.c (+10/-8)
m4/pandora_have_libpq.m4 (+20/-13)
To merge this branch: bzr merge lp:~flameeyes/gearmand/gentoo-fixes
Reviewer Review Type Date Requested Status
Brian Aker (community) 2010-04-08 Needs Information on 2010-06-15
Monty Taylor 2010-06-15 Pending
Review via email: mp+22991@code.launchpad.net

Description of the change

Fix building of the libpq-based queue manager for gearmand, which has been disabled in Gentoo since start of packaging.

In our system, libpq-fe.h is available in /usr/include, but pg_config_manual is only available in, e.g. /usr/include/postgresql-8.4 (we may have multiple postgresql installs available at the same time), so we have to use pg_config to discover the right place for it.

HTH!
Diego

To post a comment you must log in.
Brian Aker (brianaker) wrote :
Download full text (3.6 KiB)

Monty, is this something you want for Pandora?

On Apr 7, 2010, at 6:16 PM, Diego E. Flameeyes Pettenò wrote:

> Diego E. "Flameeyes" Pettenò has proposed merging lp:~flameeyes/
> gearmand/gentoo-fixes into lp:gearmand.
>
> Requested reviews:
> Gearman-developers (gearman-developers)
>
>
> Fix building of the libpq-based queue manager for gearmand, which
> has been disabled in Gentoo since start of packaging.
>
> In our system, libpq-fe.h is available in /usr/include, but
> pg_config_manual is only available in, e.g. /usr/include/
> postgresql-8.4 (we may have multiple postgresql installs available
> at the same time), so we have to use pg_config to discover the right
> place for it.
>
> HTH!
> Diego
> --
> https://code.launchpad.net/~flameeyes/gearmand/gentoo-fixes/+merge/22991
> Your team Gearman-developers is subscribed to branch lp:gearmand.
> === modified file 'libgearman-server/include.am'
> --- libgearman-server/include.am 2010-04-02 02:04:04 +0000
> +++ libgearman-server/include.am 2010-04-08 01:16:15 +0000
> @@ -88,6 +88,7 @@
>
> libgearman_server_libgearman_server_la_CFLAGS= \
> ${AM_CFLAGS} \
> + $(POSTGRESQL_CFLAGS) \
> -DBUILDING_LIBGEARMAN
>
> libgearman_server_libgearman_server_la_LIBADD= \
> @@ -97,5 +98,6 @@
> $(LTLIBPQ) \
> $(LTLIBSQLITE3) \
> $(LTLIBTOKYOCABINET) \
> + $(POSTGRESQL_LIBS) \
> libgearman/libgearman.la \
> libgearman/libgearmancore.la
>
> === modified file 'libgearman-server/queue_libpq.c'
> --- libgearman-server/queue_libpq.c 2010-04-02 02:04:04 +0000
> +++ libgearman-server/queue_libpq.c 2010-04-08 01:16:15 +0000
> @@ -11,18 +11,20 @@
> * @brief libpq Queue Storage Definitions
> */
>
> +#include <libpq-fe.h>
> +#include <pg_config.h>
> +#include <pg_config_manual.h>
> +
> +#undef PACKAGE_BUGREPORT
> +#undef PACKAGE_NAME
> +#undef PACKAGE_STRING
> +#undef PACKAGE_TARNAME
> +#undef PACKAGE_VERSION
> +
> #include "common.h"
>
> #include <libgearman-server/queue_libpq.h>
>
> -#if defined(HAVE_LIBPQ_FE_H)
> -# include <libpq-fe.h>
> -# include <pg_config_manual.h>
> -#else
> -# include <postgresql/libpq-fe.h>
> -# include <postgresql/pg_config_manual.h>
> -#endif
> -
> /**
> * @addtogroup gearman_queue_libpq_static Static libpq Queue Storage
> Definitions
> * @ingroup gearman_queue_libpq
>
> === modified file 'm4/pandora_have_libpq.m4'
> --- m4/pandora_have_libpq.m4 2009-07-29 18:13:26 +0000
> +++ m4/pandora_have_libpq.m4 2010-04-08 01:16:15 +0000
> @@ -17,21 +17,28 @@
> [ac_enable_libpq="yes"])
>
> AS_IF([test "x$ac_enable_libpq" = "xyes"],[
> - AC_CHECK_HEADERS([libpq-fe.h])
> - AC_LIB_HAVE_LINKFLAGS(pq,,[
> - #ifdef HAVE_LIBPQ_FE_H
> - # include <libpq-fe.h>
> - #else
> - # include <postgresql/libpq-fe.h>
> - #endif
> + AS_IF([test -z "$PG_CONFIG"], [
> + AC_PATH_PROG([PG_CONFIG], [pg_config], [])
> + ])
> +
> + AS_IF([test ! -x "$PG_CONFIG"], [
> + AC_MSG_WARN([$PG_CONFIG does not exist or it is not an
> exectuable file])
> + PG_CONFIG="no"
> + ac_cv_libpq="no"
> ], [
> - PGconn *conn;
> - conn = PQconnectd...

Read more...

Brian Aker (brianaker) wrote :

I am marking this as Needs Information, since Monty will need to be the person to fix this.

review: Needs Information
Monty Taylor (mordred) wrote :

Yeah - so I see what you're doing, but I'm going to need to poke at this some on the other platforms. I _really_ don't like trusting things like pg_config.

Also- why did you add and include of the pg_config.h include? That's going to have values from their run of configure which we do not care about?

Diego Elio Pettenò (flameeyes) wrote :

Il giorno lun, 05/07/2010 alle 16.44 +0000, Monty Taylor ha scritto:
>
> Yeah - so I see what you're doing, but I'm going to need to poke at
> this some on the other platforms. I _really_ don't like trusting
> things like pg_config.

Not sure on Ubuntu but Gentoo tries to keep these scripts valid because
they _are_ the only way upstream has to signal them..
>
> Also- why did you add and include of the pg_config.h include? That's
> going to have values from their run of configure which we do not care
> about?

That's how most other projects get the correct build parameters, without
this it fails here ... I sincerely forgot the error message right now.

--
Diego Elio Pettenò — “Flameeyes”
http://blog.flameeyes.eu/

If you found a .asc file in this mail and know not what it is,
it's a GnuPG digital signature: http://www.gnupg.org/

Monty Taylor (mordred) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/05/2010 09:55 AM, Diego E. "Flameeyes" Pettenò wrote:
> Il giorno lun, 05/07/2010 alle 16.44 +0000, Monty Taylor ha scritto:
>>
>> Yeah - so I see what you're doing, but I'm going to need to poke at
>> this some on the other platforms. I _really_ don't like trusting
>> things like pg_config.
>
> Not sure on Ubuntu but Gentoo tries to keep these scripts valid because
> they _are_ the only way upstream has to signal them..

Sure - the problem is that using autoconf at all is about making sure
that I can also build on broken platforms like OSX and Solaris... so
trusting that a script or a system config has been properly maintained
is just asking for failure. (This is the reason I hate pkg-config,
too... did they learn nothing from imake?)

It works _great_ when it works, but I _still_ need to test that it's not
lying or broken, which is why I'd prefer to just actually test the files
in the first place.

I'll see if I can merge the approaches though...

>> Also- why did you add and include of the pg_config.h include? That's
>> going to have values from their run of configure which we do not care
>> about?
>
> That's how most other projects get the correct build parameters, without
> this it fails here ... I sincerely forgot the error message right now.

I really need to blog more about this. It's so fundamentally wrong to do
that. Every project that does it is completely breaking everything.
MySQL does it - it was the first thing I fixed in Drizzle.

I guess it's time to go make a patch to postgres. :)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwyECAACgkQ2Jv7/VK1RgErngCgvcFuXpV9ymns8Ya4fPphgTY7
uLsAn3BRXSCCwiu6Vg+ak2VbhRZxYFZM
=YhS+
-----END PGP SIGNATURE-----

Diego Elio Pettenò (flameeyes) wrote :

Il giorno lun, 05/07/2010 alle 17.04 +0000, Monty Taylor ha scritto:
>
> I really need to blog more about this. It's so fundamentally wrong to
> do
> that. Every project that does it is completely breaking everything.
> MySQL does it - it was the first thing I fixed in Drizzle.

You have no idea how much I know it's wrong... sigh.

Olaf van der Spek (olafvdspek) wrote :

> (we may have multiple postgresql installs available at the same time), so we have to use pg_config to discover the right place for it.

Can't the pkg system use the build dependencies to ensure the compiler paths include all necessary includes and libs?

Unmerged revisions

352. By Diego Elio Pettenò on 2010-04-08

Fix PostgreSQL queue manager building on Gentoo and other platforms.

When the includes are installed in non-standard positions, and especially
when libpq-fe.h is available without -I directives, but pg_config_manual.h
isn't, you cannot rely on just finding one to get the other.

What you have to do in this case is use the pg_config script shipped with
PostgreSQL to get the right include directory, and use the simple basename
for the include headers.

Also, on modern (glibc-2.10) systems, using simply pg_config_manual.h
without pg_config.h or without adding further checks in configure, the
build will fail with this error:

In file included from libgearman-server/queue_libpq.c:19:
/usr/include/postgresql-8.4/pg_config_manual.h:128:5: error: "HAVE_DECL_POSIX_FADVISE" is not defined
make[1]: *** [libgearman-server/libgearman_server_libgearman_server_la-queue_libpq.lo] Error 1

So include the PostgreSQL headers first thing, undefine package-specific
entries, and proceed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libgearman-server/include.am'
2--- libgearman-server/include.am 2010-04-02 02:04:04 +0000
3+++ libgearman-server/include.am 2010-04-08 01:16:15 +0000
4@@ -88,6 +88,7 @@
5
6 libgearman_server_libgearman_server_la_CFLAGS= \
7 ${AM_CFLAGS} \
8+ $(POSTGRESQL_CFLAGS) \
9 -DBUILDING_LIBGEARMAN
10
11 libgearman_server_libgearman_server_la_LIBADD= \
12@@ -97,5 +98,6 @@
13 $(LTLIBPQ) \
14 $(LTLIBSQLITE3) \
15 $(LTLIBTOKYOCABINET) \
16+ $(POSTGRESQL_LIBS) \
17 libgearman/libgearman.la \
18 libgearman/libgearmancore.la
19
20=== modified file 'libgearman-server/queue_libpq.c'
21--- libgearman-server/queue_libpq.c 2010-04-02 02:04:04 +0000
22+++ libgearman-server/queue_libpq.c 2010-04-08 01:16:15 +0000
23@@ -11,18 +11,20 @@
24 * @brief libpq Queue Storage Definitions
25 */
26
27+#include <libpq-fe.h>
28+#include <pg_config.h>
29+#include <pg_config_manual.h>
30+
31+#undef PACKAGE_BUGREPORT
32+#undef PACKAGE_NAME
33+#undef PACKAGE_STRING
34+#undef PACKAGE_TARNAME
35+#undef PACKAGE_VERSION
36+
37 #include "common.h"
38
39 #include <libgearman-server/queue_libpq.h>
40
41-#if defined(HAVE_LIBPQ_FE_H)
42-# include <libpq-fe.h>
43-# include <pg_config_manual.h>
44-#else
45-# include <postgresql/libpq-fe.h>
46-# include <postgresql/pg_config_manual.h>
47-#endif
48-
49 /**
50 * @addtogroup gearman_queue_libpq_static Static libpq Queue Storage Definitions
51 * @ingroup gearman_queue_libpq
52
53=== modified file 'm4/pandora_have_libpq.m4'
54--- m4/pandora_have_libpq.m4 2009-07-29 18:13:26 +0000
55+++ m4/pandora_have_libpq.m4 2010-04-08 01:16:15 +0000
56@@ -17,21 +17,28 @@
57 [ac_enable_libpq="yes"])
58
59 AS_IF([test "x$ac_enable_libpq" = "xyes"],[
60- AC_CHECK_HEADERS([libpq-fe.h])
61- AC_LIB_HAVE_LINKFLAGS(pq,,[
62- #ifdef HAVE_LIBPQ_FE_H
63- # include <libpq-fe.h>
64- #else
65- # include <postgresql/libpq-fe.h>
66- #endif
67+ AS_IF([test -z "$PG_CONFIG"], [
68+ AC_PATH_PROG([PG_CONFIG], [pg_config], [])
69+ ])
70+
71+ AS_IF([test ! -x "$PG_CONFIG"], [
72+ AC_MSG_WARN([$PG_CONFIG does not exist or it is not an exectuable file])
73+ PG_CONFIG="no"
74+ ac_cv_libpq="no"
75 ], [
76- PGconn *conn;
77- conn = PQconnectdb(NULL);
78+ AC_MSG_CHECKING([for PostgreSQL libraries])
79+
80+ POSTGRESQL_CFLAGS="-I`$PG_CONFIG --includedir`"
81+ POSTGRESQL_LIBS="-L`$PG_CONFIG --libdir` -lpq"
82+ AC_SUBST([POSTGRESQL_CFLAGS])
83+ AC_SUBST([POSTGRESQL_LIBS])
84+
85+ ac_cv_libpq=yes
86+ AC_MSG_RESULT([yes])
87 ])
88- ],[
89- ac_cv_libpq="no"
90- ])
91-
92+ ],
93+ [ac_cv_libpq=no])
94+
95 AM_CONDITIONAL(HAVE_LIBPQ, [test "x${ac_cv_libpq}" = "xyes"])
96 ])
97

Subscribers

People subscribed via source and target branches