Subject: pkg/36145: db support doesn't work in www/apache22 + devel/apr-util
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: Todd Kover <kovert@omniscient.com>
List: pkgsrc-bugs
Date: 04/13/2007 17:10:01
>Number:         36145
>Category:       pkg
>Synopsis:       db support does not work with www/apache22 + devl/apr-util
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 13 17:10:01 +0000 2007
>Originator:     Todd Kover
>Release:        NetBSD 4.0_BETA2
>Organization:
Omniscient Technologies
>Environment:
System: NetBSD guinness.omniscient.com 4.0_BETA2 NetBSD 4.0_BETA2 (GENERIC) #3: Fri Dec 22 16:16:13 EST 2006 kovert@saidin.omniscient.com:/usr/obj/4.0-stable/i386/omniscient/os/NetBSD-4.0-branch/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:

        Apache 2.2 added mod_dbd which encourages (requires?) database
        calls to go through it, or at least some database modules do.
        I specifically ran into issues with pgsql not working with php
        and didn't dig deep enough to determine if this could be turned
        off, but it also didn't seem like it should be...
	
>How-To-Repeat:
	build something that uses the php pgsql extention and try to use it.
	(my choice was serendipity, from www.s9y.org using php5-pgsql).
	
>Fix:
        The first of the attached patches adds some options to
        devel/apr-util to accomodate additional options for the db types
        pgsql, sqlite and sqlite3.  If they're not set, the old behavior
        of no dbs is retained.  I tested that all three compile but only
	actually used pgsql.

	There is support for mysql, but it requires going and downloading
	something not included in apr-util, specifically:

	http://apache.webthing.com/svn/apache/apr/apr_dbd_mysql.c

        which gets stuffed into ${WRKSRC}/dbd, so I went and hacked
        in support for that in the second patch, which is mutually
        exclusive to the other one.  It makes the fetch and extract
        phases a little ugly. I tested that the mysql bits compiled, but
        didn't atually try it, yet. (I will in a few days, most likely).

================================ wo/mysql ==================================

Index: buildlink3.mk
===================================================================
RCS file: /cvsroot/pkgsrc/devel/apr-util/buildlink3.mk,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 buildlink3.mk
--- buildlink3.mk	24 Jan 2007 19:37:20 -0000	1.1.1.1
+++ buildlink3.mk	13 Apr 2007 15:54:17 -0000
@@ -36,6 +36,18 @@
 .  include "../../databases/openldap-client/buildlink3.mk"
 .endif
 
+.if !empty(PKG_BUILD_OPTIONS.apr-util:Mpgsql)
+.  include "../../mk/pgsql.buildlink3.mk"
+.endif
+
+.if !empty(PKG_BUILD_OPTIONS.apr-util:Msqlite)
+.  include "../../databases/sqlite/buildlink3.mk"
+.endif
+
+.if !empty(PKG_BUILD_OPTIONS.apr-util:Msqlite3)
+.  include "../../databases/sqlite3/buildlink3.mk"
+.endif
+
 .include "../../converters/libiconv/buildlink3.mk"
 .include "../../devel/apr/buildlink3.mk"
 .include "../../textproc/expat/buildlink3.mk"
Index: options.mk
===================================================================
RCS file: /cvsroot/pkgsrc/devel/apr-util/options.mk,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 options.mk
--- options.mk	24 Jan 2007 19:37:20 -0000	1.1.1.1
+++ options.mk	13 Apr 2007 15:54:17 -0000
@@ -1,7 +1,7 @@
 # $NetBSD: options.mk,v 1.1.1.1 2007/01/24 19:37:20 epg Exp $
 
 PKG_OPTIONS_VAR=	PKG_OPTIONS.apr-util
-PKG_SUPPORTED_OPTIONS=	db4 ldap
+PKG_SUPPORTED_OPTIONS=	db4 ldap pgsql sqlite sqlite3
 
 .include "../../mk/bsd.options.mk"
 
@@ -18,3 +18,18 @@
 CONFIGURE_ARGS+=	--with-ldap
 .  include "../../databases/openldap-client/buildlink3.mk"
 .endif
+
+.if !empty(PKG_OPTIONS:Mpgsql)
+CONFIGURE_ARGS+=	--with-pgsql=${BUILDLINK_PREFIX.pgsql}
+.  include "../../mk/pgsql.buildlink3.mk"
+.endif
+
+.if !empty(PKG_OPTIONS:Msqlite)
+CONFIGURE_ARGS+=	--with-sqlite2=${BUILDLINK_PREFIX.sqlite}
+.  include "../../databases/sqlite/buildlink3.mk"
+.endif
+
+.if !empty(PKG_OPTIONS:Msqlite3)
+CONFIGURE_ARGS+=	--with-sqlite2=${BUILDLINK_PREFIX.sqlite3}
+.  include "../../databases/sqlite3/buildlink3.mk"
+.endif

================================ w/mysql ==================================

Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/devel/apr-util/Makefile,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Makefile
--- Makefile	24 Jan 2007 19:37:20 -0000	1.1.1.1
+++ Makefile	13 Apr 2007 16:59:59 -0000
@@ -4,7 +4,7 @@
 DISTNAME=	apr-util-1.2.8
 CATEGORIES=	devel
 MASTER_SITES=	${MASTER_SITE_APACHE:=apr/}
-
+DISTFILES= 	${PKGNAME}.tar.gz
 MAINTAINER=	xtraeme@NetBSD.org
 HOMEPAGE=	http://apr.apache.org/
 COMMENT=	Apache Portable Runtime utilities
@@ -24,6 +24,10 @@
 		--with-expat=${BUILDLINK_PREFIX.expat} \
 		--without-gdbm
 
+post-extract: post-extract-mysql
+
+post-extract-mysql:
+
 .include "../../mk/bsd.prefs.mk"
 .include "options.mk"
 
Index: buildlink3.mk
===================================================================
RCS file: /cvsroot/pkgsrc/devel/apr-util/buildlink3.mk,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 buildlink3.mk
--- buildlink3.mk	24 Jan 2007 19:37:20 -0000	1.1.1.1
+++ buildlink3.mk	13 Apr 2007 16:59:59 -0000
@@ -36,6 +36,22 @@
 .  include "../../databases/openldap-client/buildlink3.mk"
 .endif
 
+.if !empty(PKG_BUILD_OPTIONS.apr-util:Mpgsql)
+.  include "../../mk/pgsql.buildlink3.mk"
+.endif
+
+.if !empty(PKG_BUILD_OPTIONS.apr-util:Mmysql)
+.  include "../../mk/mysql.buildlink3.mk"
+.endif
+
+.if !empty(PKG_BUILD_OPTIONS.apr-util:Msqlite)
+.  include "../../databases/sqlite/buildlink3.mk"
+.endif
+
+.if !empty(PKG_BUILD_OPTIONS.apr-util:Msqlite3)
+.  include "../../databases/sqlite3/buildlink3.mk"
+.endif
+
 .include "../../converters/libiconv/buildlink3.mk"
 .include "../../devel/apr/buildlink3.mk"
 .include "../../textproc/expat/buildlink3.mk"
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/devel/apr-util/distinfo,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 distinfo
--- distinfo	24 Jan 2007 19:37:20 -0000	1.1.1.1
+++ distinfo	13 Apr 2007 16:59:59 -0000
@@ -3,3 +3,6 @@
 SHA1 (apr-util-1.2.8.tar.gz) = 49260d98b863756974bd83cd28bc39338d4f3a82
 RMD160 (apr-util-1.2.8.tar.gz) = 00b10ef0aab26f3ea5d374e2400c1dba566a9020
 Size (apr-util-1.2.8.tar.gz) = 646379 bytes
+SHA1 (apr_dbd_mysql.c) = 04c82a4dda00bbeaddc713b29dae826562fc0db6
+RMD160 (apr_dbd_mysql.c) = 9d665f2e964b09f58b182829563a203f59e16640
+Size (apr_dbd_mysql.c) = 49110 bytes
Index: options.mk
===================================================================
RCS file: /cvsroot/pkgsrc/devel/apr-util/options.mk,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 options.mk
--- options.mk	24 Jan 2007 19:37:20 -0000	1.1.1.1
+++ options.mk	13 Apr 2007 16:59:59 -0000
@@ -1,7 +1,7 @@
 # $NetBSD: options.mk,v 1.1.1.1 2007/01/24 19:37:20 epg Exp $
 
 PKG_OPTIONS_VAR=	PKG_OPTIONS.apr-util
-PKG_SUPPORTED_OPTIONS=	db4 ldap
+PKG_SUPPORTED_OPTIONS=	db4 ldap pgsql mysql sqlite sqlite3
 
 .include "../../mk/bsd.options.mk"
 
@@ -18,3 +18,29 @@
 CONFIGURE_ARGS+=	--with-ldap
 .  include "../../databases/openldap-client/buildlink3.mk"
 .endif
+
+.if !empty(PKG_OPTIONS:Mpgsql)
+CONFIGURE_ARGS+=	--with-pgsql=${BUILDLINK_PREFIX.pgsql}
+.  include "../../mk/pgsql.buildlink3.mk"
+.endif
+
+.if !empty(PKG_OPTIONS:Mmysql)
+CONFIGURE_ARGS+=	--with-pgsql=${BUILDLINK_PREFIX.mysql}
+.  include "../../mk/mysql.buildlink3.mk"
+
+post-extract-mysql:
+	cp ${WRKDIR}/apr_dbd_mysql.c ${WRKSRC}/dbd/apr_dbd_mysql.c
+
+DISTFILES+=             apr_dbd_mysql.c
+SITES.apr_dbd_mysql.c= http://apache.webthing.com/svn/apache/apr/
+.endif
+
+.if !empty(PKG_OPTIONS:Msqlite)
+CONFIGURE_ARGS+=	--with-sqlite2=${BUILDLINK_PREFIX.sqlite}
+.  include "../../databases/sqlite/buildlink3.mk"
+.endif
+
+.if !empty(PKG_OPTIONS:Msqlite3)
+CONFIGURE_ARGS+=	--with-sqlite2=${BUILDLINK_PREFIX.sqlite3}
+.  include "../../databases/sqlite3/buildlink3.mk"
+.endif