Date: Wed, 19 Jun 2013 15:18:31 +0200 From: Tijl Coosemans <tijl@FreeBSD.org> To: apache@FreeBSD.org Subject: Splitting up and simplifying devel/apr1 Message-ID: <51C1AFA7.9080700@FreeBSD.org>
next in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2IUMOMDJCCMWIOEJJGBHB Content-Type: multipart/mixed; boundary="------------020604090309070102080306" This is a multi-part message in MIME format. --------------020604090309070102080306 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Hi, In the discussion on src-committers about svnlite it was mentioned that devel/subversion is too heavy to build, pulling in perl, python and all the autotools. I've been going over its dependencies and it turns out these are all pulled in by devel/apr1, so I've been looking into simplifying that port. It seems the port can easily be split up into two simple ports, one for the APR library and one for the APR Utility library. There's no need for autotools, libtool, python, etc. I've attached a patch that creates devel/apr and devel/apr-util. Please take a look at them and let me know what you think. Another patch can then remove devel/apr1 and update all ports that depend on it, but before I spend more time on this, do you agree this is the right approach? --------------020604090309070102080306 Content-Type: text/plain; charset=ISO-8859-15; name="split.apr1.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="split.apr1.patch" Index: devel/apr/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- devel/apr/Makefile (revision 0) +++ devel/apr/Makefile (working copy) @@ -0,0 +1,40 @@ +# $FreeBSD$ + +PORTNAME=3D apr +PORTVERSION=3D 1.4.6 +CATEGORIES=3D devel +MASTER_SITES=3D ${MASTER_SITE_APACHE} +MASTER_SITE_SUBDIR=3D apr + +MAINTAINER=3D apache@FreeBSD.org +COMMENT=3D Apache Portable Runtime library + +CONFLICTS_INSTALL=3D apr-[0-9]*.[0-9]*.[0-9]*.[0-9]* +GNU_CONFIGURE=3D yes +MAKE_JOBS_SAFE=3D yes +USES=3D pathfix +USE_LDCONFIG=3D yes + +OPTIONS_DEFINE=3D THREADS IPV6 DEVRANDOM +OPTIONS_DEFAULT=3DTHREADS IPV6 DEVRANDOM +DEVRANDOM_DESC=3D Use /dev/random or compatible + +CONFIGURE_ARGS=3D --with-installbuilddir=3D${DATADIR}/build-1 +THREADS_CONFIGURE_ENABLE=3D threads +IPV6_CONFIGURE_ENABLE=3D ipv6 +DEVRANDOM_CONFIGURE_OFF=3D --without-devrandom + +SHLIB_MAJOR=3D 4 +PLIST_SUB=3D SHLIB_MAJOR=3D"${SHLIB_MAJOR}" + +post-patch: .SILENT + ${REINPLACE_CMD} -e 's/$$os_version/${OSVERSION}/g' \ + ${WRKSRC}/configure +# Fix pthread: Please do not remove, else apr-1-config returns wrong val= ues + ${REINPLACE_CMD} -e 's/-lpthread/${PTHREAD_LIBS}/g' \ + ${WRKSRC}/configure + +regression-test: build + @cd ${WRKSRC} && ${MAKE} test + +.include <bsd.port.mk> Index: devel/apr/distinfo =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- devel/apr/distinfo (revision 0) +++ devel/apr/distinfo (working copy) @@ -0,0 +1,2 @@ +SHA256 (apr-1.4.6.tar.gz) =3D 538d593d805c36985fc6d200d31bf6c1b5f90df2a5= 0b917902743a13bbc10e05 +SIZE (apr-1.4.6.tar.gz) =3D 982243 Index: devel/apr/pkg-descr =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- devel/apr/pkg-descr (revision 0) +++ devel/apr/pkg-descr (working copy) @@ -0,0 +1,6 @@ +The Apache Portable Runtime library provides a predictable and consisten= t +interface to underlying platform-specific implementations, relieving sof= tware +developers of the need to code special-case conditions to work around or= take +advantage of platform-specific deficiencies or features. + +WWW: http://apr.apache.org/ Index: devel/apr/pkg-plist =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- devel/apr/pkg-plist (revision 0) +++ devel/apr/pkg-plist (working copy) @@ -0,0 +1,51 @@ +bin/apr-1-config +include/apr-1/apr.h +include/apr-1/apr_allocator.h +include/apr-1/apr_atomic.h +include/apr-1/apr_dso.h +include/apr-1/apr_env.h +include/apr-1/apr_errno.h +include/apr-1/apr_file_info.h +include/apr-1/apr_file_io.h +include/apr-1/apr_fnmatch.h +include/apr-1/apr_general.h +include/apr-1/apr_getopt.h +include/apr-1/apr_global_mutex.h +include/apr-1/apr_hash.h +include/apr-1/apr_inherit.h +include/apr-1/apr_lib.h +include/apr-1/apr_mmap.h +include/apr-1/apr_network_io.h +include/apr-1/apr_poll.h +include/apr-1/apr_pools.h +include/apr-1/apr_portable.h +include/apr-1/apr_proc_mutex.h +include/apr-1/apr_random.h +include/apr-1/apr_ring.h +include/apr-1/apr_shm.h +include/apr-1/apr_signal.h +include/apr-1/apr_strings.h +include/apr-1/apr_support.h +include/apr-1/apr_tables.h +include/apr-1/apr_thread_cond.h +include/apr-1/apr_thread_mutex.h +include/apr-1/apr_thread_proc.h +include/apr-1/apr_thread_rwlock.h +include/apr-1/apr_time.h +include/apr-1/apr_user.h +include/apr-1/apr_version.h +include/apr-1/apr_want.h +lib/apr.exp +lib/libapr-1.a +lib/libapr-1.la +lib/libapr-1.so +lib/libapr-1.so.%%SHLIB_MAJOR%% +libdata/pkgconfig/apr-1.pc +%%DATADIR%%/build-1/apr_rules.mk +%%DATADIR%%/build-1/libtool +%%DATADIR%%/build-1/make_exports.awk +%%DATADIR%%/build-1/make_var_export.awk +%%DATADIR%%/build-1/mkdir.sh +@dirrm %%DATADIR%%/build-1 +@dirrm %%DATADIR%% +@dirrm include/apr-1 Index: devel/apr-util/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- devel/apr-util/Makefile (revision 0) +++ devel/apr-util/Makefile (working copy) @@ -0,0 +1,161 @@ +# $FreeBSD$ + +PORTNAME=3D apr-util +PORTVERSION=3D 1.4.1 +CATEGORIES=3D devel +MASTER_SITES=3D ${MASTER_SITE_APACHE} +MASTER_SITE_SUBDIR=3D apr + +MAINTAINER=3D apache@FreeBSD.org +COMMENT=3D Apache Portable Runtime Utility library + +LIB_DEPENDS=3D apr-1:${PORTSDIR}/devel/apr \ + expat:${PORTSDIR}/textproc/expat2 + +CONFLICTS_INSTALL=3D apr-[0-9]*.[0-9]*.[0-9]*.[0-9]* +GNU_CONFIGURE=3D yes +MAKE_JOBS_SAFE=3D yes +USES=3D iconv pathfix +USE_LDCONFIG=3D yes + +OPTIONS_DEFINE=3D BDB GDBM LDAP MYSQL NDBM PGSQL SQLITE FREETDS +OPTIONS_RADIO=3D CRYPTO +OPTIONS_RADIO_CRYPTO=3D SSL +OPTIONS_DEFAULT=3DBDB GDBM SSL +NDBM_DESC=3D NDBM support +SSL_DESC=3D OpenSSL crypto driver +NSS_DESC=3D NSS crypto driver + +CONFIGURE_ARGS=3D --with-apr=3D${LOCALBASE} \ + --with-expat=3D${LOCALBASE} \ + --with-iconv=3D${LOCALBASE} + +SHLIB_MAJOR=3D 4 +PLIST_SUB=3D SHLIB_MAJOR=3D"${SHLIB_MAJOR}" + +.include <bsd.port.options.mk> + +.if ${PORT_OPTIONS:MGDBM} +PLIST_SUB+=3D GDBM=3D"" +APU_EXTRAS=3D yes +LIB_DEPENDS+=3D gdbm:${PORTSDIR}/databases/gdbm +CONFIGURE_ARGS+=3D --with-gdbm=3D${LOCALBASE} +.else +PLIST_SUB+=3D GDBM=3D"@comment " +CONFIGURE_ARGS+=3D --without-gdbm +.endif + +.if ${PORT_OPTIONS:MBDB} +APU_EXTRAS=3D yes +PLIST_SUB+=3D BDB=3D"" +USE_BDB=3D 42+ +CONFIGURE_ARGS+=3D --with-berkeley-db=3D${BDB_INCLUDE_DIR}:${BDB_LIB_DIR= } +.else +PLIST_SUB+=3D BDB=3D"@comment " +CONFIGURE_ARGS+=3D --without-berkeley-db +.endif + +.if ${PORT_OPTIONS:MNDBM} +APU_EXTRAS=3D yes +PLIST_SUB+=3D NDBM=3D"" +CONFIGURE_ARGS+=3D --with-ndbm=3D/usr +.else +PLIST_SUB+=3D NDBM=3D"@comment " +CONFIGURE_ARGS+=3D --without-ndbm +.endif + +.if ${PORT_OPTIONS:MLDAP} +APU_EXTRAS=3D yes +PLIST_SUB+=3D LDAP=3D"" +USE_OPENLDAP=3D yes +CONFIGURE_ARGS+=3D --with-ldap-include=3D${LOCALBASE}/include \ + --with-ldap-lib=3D${LOCALBASE}/lib --with-ldap=3Dldap +.else +PLIST_SUB+=3D LDAP=3D"@comment " +CONFIGURE_ARGS+=3D --without-ldap +.endif + +.if ${PORT_OPTIONS:MFREETDS} +APU_EXTRAS=3D yes +PLIST_SUB+=3D FREETDS=3D"" +CONFIGURE_ARGS+=3D --with-freetds=3D${LOCALBASE} +LIB_DEPENDS+=3D sybdb:${PORTSDIR}/databases/freetds +.else +PLIST_SUB+=3D FREETDS=3D"@comment " +CONFIGURE_ARGS+=3D --without-freetds +.endif + +.if ${PORT_OPTIONS:MMYSQL} +APU_EXTRAS=3D yes +PLIST_SUB+=3D MYSQL=3D"" +USE_MYSQL=3D YES +CONFIGURE_ARGS+=3D --with-mysql=3D${LOCALBASE} +CONFIGURE_ENV+=3D LIBS=3D"${LIBS}" +CFLAGS+=3D -I${LOCALBASE}/include -I${LOCALBASE}/include/mysql -DHAVE_MY= SQL_H +LDFLAGS+=3D -L${LOCALBASE}/lib/mysql +.else +PLIST_SUB+=3D MYSQL=3D"@comment " +CONFIGURE_ARGS+=3D --without-mysql +.endif + +.if ${PORT_OPTIONS:MPGSQL} +APU_EXTRAS=3D yes +PLIST_SUB+=3D PGSQL=3D"" +USE_PGSQL=3D YES +CONFIGURE_ARGS+=3D --with-pgsql=3D${LOCALBASE} +CONFIGURE_ENV+=3D ac_cv_path_PGSQL_CONFIG=3D"" +.else +PLIST_SUB+=3D PGSQL=3D"@comment " +CONFIGURE_ARGS+=3D --without-pgsql +.endif + +.if ${PORT_OPTIONS:MSQLITE} +APU_EXTRAS=3D yes +PLIST_SUB+=3D SQLITE3=3D"" +USE_SQLITE=3D YES +CONFIGURE_ARGS+=3D --with-sqlite3=3D${LOCALBASE} +.else +CONFIGURE_ARGS+=3D --without-sqlite3 +PLIST_SUB+=3D SQLITE3=3D"@comment " +.endif + +# crypto (apache24) +.if ${PORT_OPTIONS:MSSL} || ${PORT_OPTIONS:MNSS} +CONFIGURE_ARGS+=3D --with-crypto +.endif + +.if ${PORT_OPTIONS:MSSL} +APU_EXTRAS=3D yes +USE_OPENSSL=3D yes +PLIST_SUB+=3D SSL=3D"" +CFLAGS+=3D -I${OPENSSLINC} +LDFLAGS+=3D -L${OPENSSLLIB} +CONFIGURE_ARGS+=3D --with-openssl=3D${OPENSSLBASE} +.else +PLIST_SUB+=3D SSL=3D"@comment " +CONFIGURE_ARGS+=3D --without-openssl +.endif + +# TODO figure out why nss flag is ignored if ssl is set +# this works on other OS as expected +.if ${PORT_OPTIONS:MNSS} +APU_EXTRAS=3D yes +PLIST_SUB+=3D NSS=3D"" +LIB_DEPENDS+=3D nss3:${PORTSDIR}/security/nss +CFLAGS+=3D -I${LOCALBASE}/include/nss +LDFLAGS+=3D -L${LOCALBASE}/lib/nss +CONFIGURE_ARGS+=3D --with-nss=3D${LOCALBASE} +.else +PLIST_SUB+=3D NSS=3D"@comment " +.endif + +.if defined(APU_EXTRAS) +PLIST_SUB+=3D APU_EXTRAS=3D"" +.else +PLIST_SUB+=3D APU_EXTRAS=3D"@comment " +.endif + +regression-test: build + @cd ${WRKSRC} && ${MAKE} test + +.include <bsd.port.mk> Index: devel/apr-util/distinfo =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- devel/apr-util/distinfo (revision 0) +++ devel/apr-util/distinfo (working copy) @@ -0,0 +1,2 @@ +SHA256 (apr-util-1.4.1.tar.gz) =3D d636d9ef95c6e50e47fc338d532aa375edd11= e5d7a3c30dee48beb38ddf4ab4c +SIZE (apr-util-1.4.1.tar.gz) =3D 774770 Index: devel/apr-util/files/patch-apr-util__dbd__apr_dbd_freetds.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- devel/apr-util/files/patch-apr-util__dbd__apr_dbd_freetds.c (revision= 0) +++ devel/apr-util/files/patch-apr-util__dbd__apr_dbd_freetds.c (working = copy) @@ -0,0 +1,560 @@ +# http://lists.freebsd.org/pipermail/freebsd-apache/2013-January/003020.= html +#=20 +# From: "Mikhail T." <mi+thun@aldan.algebra.com> +# I've made the FreeTDS-driver work again -- and submitted the patch t= o Apache: +# https://issues.apache.org/bugzilla/show_bug.cgi?id=3D53666 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D +--- dbd/apr_dbd_freetds.c.orig ++++ dbd/apr_dbd_freetds.c +@@ -40,12 +40,12 @@ + #include <freetds/sybdb.h> + #endif + #ifdef HAVE_SYBDB_H ++#include <sybfront.h> + #include <sybdb.h> + #endif +=20 + #include <stdio.h> + #include <sys/types.h> +-#include <regex.h> +=20 + /* This probably needs to change for different applications */ + #define MAX_COL_LEN 256 +@@ -67,6 +67,7 @@ + apr_dbd_transaction_t *trans; + apr_pool_t *pool; + const char *params; ++ const char *lasterror; + RETCODE err; + }; +=20 +@@ -80,20 +81,20 @@ +=20 + struct apr_dbd_row_t { + apr_dbd_results_t *res; +- BYTE buf[MAX_COL_LEN]; ++ apr_pool_t *pool; + }; +=20 + struct apr_dbd_prepared_t { + int nargs; +- regex_t **taint; +- int *sz; +- char *fmt; ++ int fmtlen; ++ const char *fmt, *label; ++ apr_dbd_type_e *types; ++ int offsets[]; + }; +=20 +-#define dbd_freetds_is_success(x) (x =3D=3D SUCCEED) ++const apr_dbd_driver_t apr_dbd_freetds_driver; /* Forward declaration *= / +=20 +-static int labelnum =3D 0; /* FIXME */ +-static regex_t dbd_freetds_find_arg; ++#define dbd_freetds_is_success(x) (x =3D=3D SUCCEED) +=20 + /* execute a query that doesn't return a result set, mop up, + * and return and APR-flavoured status +@@ -102,7 +103,11 @@ + int want_results, int *nrows) + { + /* TBD */ +- RETCODE rv =3D dbcmd(proc, query); ++ RETCODE rv =3D dbcmd(proc, ++#ifndef TDS_STATIC_CAST /* if not compiling against FreeTDS, drop const= :-( */ ++ (char *) ++#endif ++ query); + if (rv !=3D SUCCEED) { + return rv; + } +@@ -143,6 +148,7 @@ + * Ignore seek + */ +=20 ++ sql->lasterror =3D NULL; + sql->err =3D freetds_exec(sql->proc, query, 1, NULL); + if (!dbd_freetds_is_success(sql->err)) { + if (sql->trans) { +@@ -190,51 +196,38 @@ + #endif + return (sql->err =3D=3D SUCCEED) ? 0 : 1; + } +-static const char *dbd_untaint(apr_pool_t *pool, regex_t *rx, const cha= r *val) +-{ +- regmatch_t match[1]; +- if (rx =3D=3D NULL) { +- /* no untaint expression */ +- return val; +- } +- if (regexec(rx, val, 1, match, 0) =3D=3D 0) { +- return apr_pstrndup(pool, val+match[0].rm_so, +- match[0].rm_eo - match[0].rm_so); +- } +- return ""; +-} ++ + static const char *dbd_statement(apr_pool_t *pool, +- apr_dbd_prepared_t *stmt, +- int nargs, const char **args) ++ const apr_dbd_prepared_t *stmt, ++ const char **args) + { + int i; + int len; +- const char *var; + char *ret; +- const char *p_in; ++ const char *p_in, *format; + char *p_out; +- char *q; + =20 +- /* compute upper bound on length (since untaint shrinks) */ +- len =3D strlen(stmt->fmt) +1; +- for (i=3D0; i<nargs; ++i) { +- len +=3D strlen(args[i]) - 2; ++ len =3D stmt->fmtlen; ++ for (i=3D0; i < stmt->nargs; ++i) { ++ len +=3D strlen(args[i]); ++ switch (stmt->types[i]) { ++ case APR_DBD_TYPE_STRING: len +=3D 2; break; /* For the quotes */ ++ default: break;/* Other types are all taken verbatim at the moment */ ++ } + } +- i =3D 0; + p_in =3D stmt->fmt; + p_out =3D ret =3D apr_palloc(pool, len); +- /* FIXME silly bug - this'll catch %%s */ +- while (q =3D strstr(p_in, "%s"), q !=3D NULL) { +- len =3D q-p_in; +- strncpy(p_out, p_in, len); +- p_in +=3D len; +- p_out +=3D len; +- var =3D dbd_untaint(pool, stmt->taint[i], args[i]); +- len =3D strlen(var); +- strncpy(p_out, var, len); +- p_in +=3D 2; +- p_out +=3D len; +- ++i; ++ for (i =3D 0; i < stmt->nargs; i++) { ++ len =3D stmt->offsets[i]; ++ switch (stmt->types[i]) { ++ case APR_DBD_TYPE_STRING: ++ format =3D "%.*s'%s'"; ++ break; ++ default: ++ format =3D "%.*s%s"; ++ } ++ p_out +=3D sprintf(p_out, format, len, p_in, args[i]); ++ p_in +=3D (len + 1); + } + strcpy(p_out, p_in); + return ret; +@@ -244,8 +237,7 @@ + apr_dbd_prepared_t *statement, + int seek, const char **values) + { +- const char *query =3D dbd_statement(pool, statement, +- statement->nargs, values); ++ const char *query =3D dbd_statement(pool, statement, values); + return dbd_freetds_select(pool, sql, results, query, seek); + } + static int dbd_freetds_pvselect(apr_pool_t *pool, apr_dbd_t *sql, +@@ -273,8 +265,7 @@ + int *nrows, apr_dbd_prepared_t *statement= , + const char **values) + { +- const char *query =3D dbd_statement(pool, statement, +- statement->nargs, values); ++ const char *query =3D dbd_statement(pool, statement, values); + return dbd_freetds_query(sql, nrows, query); + } + static int dbd_freetds_pvquery(apr_pool_t *pool, apr_dbd_t *sql, int *n= rows, +@@ -301,11 +292,13 @@ + RETCODE rv =3D 0; + apr_dbd_row_t *row =3D *rowp; + int sequential =3D ((rownum >=3D 0) && res->random) ? 0 : 1; ++ apr_dbd_t *sql =3D (void *)dbgetuserdata(res->proc); +=20 + if (row =3D=3D NULL) { + row =3D apr_palloc(pool, sizeof(apr_dbd_row_t)); + *rowp =3D row; + row->res =3D res; ++ row->pool =3D pool; /* For subsequent calls to get_entry */ + } + /* + else { +@@ -321,18 +314,37 @@ + rv =3D dbnextrow(res->proc); + } + else { ++ /* XXX dbgetrow() only works if DBBUFFER-option is set */ + rv =3D (rownum >=3D 0) ? dbgetrow(res->proc, rownum) : NO_MORE_= ROWS; + } + switch (rv) { + case SUCCEED: return 0; + case REG_ROW: return 0; + case NO_MORE_ROWS: +- apr_pool_cleanup_run(pool, res->proc, clear_result); ++ if (dbisopt(res->proc, DBBUFFER, NULL) || sequential) { ++ sql->lasterror =3D apr_pstrcat(sql->pool, ++ "NO_MORE_ROWS (count: ", apr_itoa(sql->pool, DBCOUNT(res->proc)), ++ ", first: ", apr_itoa(sql->pool, DBFIRSTROW(res->proc)), ++ ", current: ", apr_itoa(sql->pool, DBCURROW(res->proc)), ++ ", last: ", apr_itoa(sql->pool, DBLASTROW(res->proc)), ++ ")", NULL);; ++ } else { ++ sql->lasterror =3D "NO_MORE_ROWS (DBBUFFER option must be on " ++ "for dbgetrow() to work)"; ++ } ++ apr_pool_cleanup_run(res->pool, res->proc, clear_result); + *rowp =3D NULL; + return -1; +- case FAIL: return 1; +- case BUF_FULL: return 2; /* FIXME */ +- default: return 3; ++ case FAIL: ++ sql->lasterror =3D "FAIL"; ++ return 1; ++ case BUF_FULL: ++ sql->lasterror =3D "BUF_FULL"; ++ return 2; /* FIXME */ ++ default: ++ sql->lasterror =3D apr_pstrcat(res->pool, ++ "Unexpected error number ", apr_itoa(res->pool, rv), NULL); ++ return 3; + } +=20 + return 0; +@@ -340,24 +352,27 @@ +=20 + static const char *dbd_freetds_get_entry(const apr_dbd_row_t *row, int = n) + { +- /* FIXME: support different data types */ +- /* this fails - bind gets some vars but not others +- return (const char*)row->res->vars[n].data; +- */ + DBPROCESS* proc =3D row->res->proc; +- BYTE *ptr =3D dbdata(proc, n+1); ++ BYTE *ptr =3D dbdata(proc, n+1); /* XXX No error checking! */ + int t =3D dbcoltype(proc, n+1); +- int l =3D dbcollen(proc, n+1); ++ int l =3D dbdatlen(proc, n+1); ++ if (l =3D=3D -1) ++ return NULL; + if (dbwillconvert(t, SYBCHAR)) { +- dbconvert(proc, t, ptr, l, SYBCHAR, (BYTE *)row->buf, -1); +- return (const char*)row->buf; ++ char *buf =3D apr_palloc(row->pool, l + 1); ++ dbconvert(proc, t, ptr, l, SYBCHAR, buf, -1); ++ return buf; + } + return (char*)ptr; + } +=20 + static const char *dbd_freetds_error(apr_dbd_t *sql, int n) + { +- /* XXX this doesn't seem to exist in the API ??? */ ++ const char *err =3D sql->lasterror; ++ ++ sql->lasterror =3D NULL; /* Reset, so we stop appending */ ++ if (err) ++ return err; + return apr_psprintf(sql->pool, "Error %d", sql->err); + } +=20 +@@ -367,6 +382,7 @@ + return sql->trans->errnum; + } + *nrows =3D 0; ++ sql->lasterror =3D NULL; + sql->err =3D freetds_exec(sql->proc, query, 0, nrows); +=20 + if (sql->err !=3D SUCCEED) { +@@ -384,114 +400,39 @@ + return arg; + } +=20 +-static apr_status_t freetds_regfree(void *rx) +-{ +- regfree((regex_t*)rx); +- return APR_SUCCESS; +-} +-static int recurse_args(apr_pool_t *pool, int n, const char *query, +- apr_dbd_prepared_t *stmt, int offs) +-{ +- +- /* we only support %s arguments for now */ +- int ret; +- char arg[256]; +- regmatch_t matches[3]; +- if (regexec(&dbd_freetds_find_arg, query, 3, matches, 0) !=3D 0) { +- /* No more args */ +- stmt->nargs =3D n; +- stmt->taint =3D apr_palloc(pool, n*sizeof(regex_t*)); +- stmt->sz =3D apr_palloc(pool, n*sizeof(int)); +- ret =3D 0; +- } +- else { +- int i; +- int sz =3D 0; +- int len =3D matches[1].rm_eo - matches[1].rm_so - 2; +- if (len > 255) { +- return 9999; +- } +- +- ret =3D recurse_args(pool, n+1, query+matches[0].rm_eo, +- stmt, offs+matches[0].rm_eo); +- +- memmove(stmt->fmt + offs + matches[1].rm_so, +- stmt->fmt + offs + matches[0].rm_eo-1, +- strlen(stmt->fmt+offs+matches[0].rm_eo)+2); +- +- /* compile untaint to a regex if found */ +- if (matches[1].rm_so =3D=3D -1) { +- stmt->taint[n] =3D NULL; +- } +- else { +- strncpy(arg, query+matches[1].rm_so+1, +- matches[1].rm_eo - matches[1].rm_so - 2); +- arg[matches[1].rm_eo - matches[1].rm_so - 2] =3D '\0'; +- stmt->taint[n] =3D apr_palloc(pool, sizeof(regex_t)); +- if (regcomp(stmt->taint[n], arg, REG_ICASE|REG_EXTENDED) !=3D= 0) { +- ++ret; +- } +- else { +- apr_pool_cleanup_register(pool, stmt->taint[n], freetds= _regfree, +- apr_pool_cleanup_null); +- } +- } +- +- /* record length if specified */ +- for (i=3Dmatches[2].rm_so; i<matches[2].rm_eo; ++i) { +- sz =3D 10*sz + (query[i]-'\0'); +- } +- } +- return ret; +-} +- + static int dbd_freetds_prepare(apr_pool_t *pool, apr_dbd_t *sql, + const char *query, const char *label, + int nargs, int nvals, apr_dbd_type_e *type= s, + apr_dbd_prepared_t **statement) + { ++ int i; ++ const char *p, *op; + apr_dbd_prepared_t *stmt; +=20 +- if (label =3D=3D NULL) { +- label =3D apr_psprintf(pool, "%d", labelnum++); ++ if (!*statement && ++ (*statement =3D apr_palloc(pool, ++ sizeof(apr_dbd_prepared_t) + nargs*sizeof(int))) =3D=3D NULL) { ++ return APR_EGENERAL; + } +=20 +- if (!*statement) { +- *statement =3D apr_palloc(pool, sizeof(apr_dbd_prepared_t)); +- } + stmt =3D *statement; ++ stmt->nargs =3D nargs; ++ stmt->fmt =3D query; ++ stmt->fmtlen =3D strlen(query) - nargs + 1; ++ stmt->types =3D types; ++ stmt->label =3D label; /* XXX Not used anywhere at the moment */ +=20 +-#if 0 +- /* count args */ +- stmt->fmt =3D apr_pstrdup(pool, query); +- stmt->fmt =3D recurse_args(pool, 0, query, stmt, stmt->fmt); +- +- /* overestimate by a byte or two to simplify */ +- len =3D strlen("CREATE PROC apr.") +- + strlen(label) +- + stmt->nargs * strlen(" @arg1 varchar(len1),") +- + strlen(" AS begin ") +- + strlen(stmt->fmt) +- + strlen(" end "); /* extra byte for terminator */ +- +- pquery =3D apr_pcalloc(pool, len); +- sprintf(pquery, "CREATE PROC apr.%s", label); +- for (i=3D0; i<stmt->nargs; ++i) { +- sprintf(pquery+strlen(pquery), " @arg%d varchar(%d)", i, stmt->= sz[i]); +- if (i < stmt->nargs-1) { +- pquery[strlen(pquery)] =3D ','; +- } ++ /* ++ * Run through the query-template looking for the special character= , ++ * which the dbd_prepare inserted into it on our behalf ++ */ ++ for (i =3D 0, op =3D query; i < nargs; i++) { ++ p =3D strchr(op, apr_dbd_freetds_driver.pformat[0]); ++ stmt->offsets[i] =3D p - op; ++ op =3D p + 1; + } +- strcat(pquery, " AS BEGIN "); +- strcat(pquery, stmt->fmt); +- strcat(pquery, " END"); +- +- return (freetds_exec(sql->proc, pquery, 0, &i) =3D=3D SUCCEED) ? 0 = : 1; +-#else +- stmt->fmt =3D apr_pstrdup(pool, query); +- return recurse_args(pool, 0, query, stmt, 0); +-#endif +=20 ++ return APR_SUCCESS; + } +=20 + static int dbd_freetds_start_transaction(apr_pool_t *pool, apr_dbd_t *h= andle, +@@ -541,9 +482,9 @@ + DBPROCESS *process; + LOGINREC *login; + static const char *delims =3D " \r\n\t;|,"; +- char *ptr; +- char *key; +- char *value; ++ const char *ptr; ++ const char *key; ++ const char *value; + int vlen; + int klen; + char *buf; +@@ -564,7 +505,7 @@ + } + for (key =3D ptr-1; apr_isspace(*key); --key); + klen =3D 0; +- while (apr_isalpha(*key)) { ++ while (key >=3D params && apr_isalpha(*key)) { + --key; + ++klen; + } +@@ -627,10 +568,11 @@ + if (process =3D=3D NULL) { + return NULL; + } +- sql =3D apr_palloc (pool, sizeof (apr_dbd_t)); ++ sql =3D apr_pcalloc(pool, sizeof (apr_dbd_t)); + sql->pool =3D pool; + sql->proc =3D process; + sql->params =3D params; ++ dbsetuserdata(process, (BYTE *)sql); + return sql; + } +=20 +@@ -686,24 +628,73 @@ + static apr_status_t freetds_term(void *dummy) + { + dbexit(); +- regfree(&dbd_freetds_find_arg); + return APR_SUCCESS; + } ++ ++static int freetds_msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgs= tate, ++ int severity, char *msgtext, char *srvna= me, ++ char *procname, int line) ++{ ++ char *value; ++ apr_dbd_t *sql; ++ ++ if (dbproc =3D=3D NULL || (sql =3D (void *)dbgetuserdata(dbproc)) =3D= =3D NULL) { ++ /* Initial messages are not interesting */ ++ return 0; ++ } ++ ++ value =3D apr_psprintf(sql->pool, "%s: %s", srvname, msgtext); ++ if (procname && procname[0]) ++ value =3D apr_pstrcat(sql->pool, value, " In procedure ", ++ procname, NULL); ++ if (line) ++ value =3D apr_pstrcat(sql->pool, value, ++ procname && procname[0] ? ", line " : " Line ", ++ apr_itoa(sql->pool, line), NULL); ++ ++ if (sql->lasterror) ++ sql->lasterror =3D apr_pstrcat(sql->pool, sql->lasterror, "\n", value,= NULL); ++ else ++ sql->lasterror =3D value; ++ ++ return 0; ++} ++ + static int freetds_err_handler(DBPROCESS *dbproc, int severity, int dbe= rr, + int oserr, char *dberrstr, char *oserrst= r) + { ++ char *value; ++ apr_dbd_t *sql; ++ ++ if (dbproc =3D=3D NULL || (sql =3D (void *)dbgetuserdata(dbproc)) =3D= =3D NULL) { ++ fprintf(stderr, "%s\n", dberrstr); ++ return INT_CANCEL; ++ } ++ /* ++ * Do not append the useless "general error", if details ++ * are already recorded (by the msg_handler). Just return. ++ * XXX: this skipping currently only works with Sybase's OpenClient= ++ * XXX: because FreeTDS implementation uses bogus dberr values: ++ * XXX: https://sourceforge.net/tracker/?func=3Ddetail&aid=3D355577= 7&group_id=3D33106&atid=3D407806 ++ */ ++ if (dberr =3D=3D SYBESMSG && sql->lasterror) ++ return INT_CANCEL; ++ ++ value =3D apr_psprintf(sql->pool, "%d: %s", dberr, dberrstr); ++ if (oserrstr) { ++ value =3D apr_pstrcat(sql->pool, ". (", oserrstr, ")", NULL); ++ } ++ if (sql->lasterror) ++ sql->lasterror =3D apr_pstrcat(sql->pool, sql->lasterror, "\n", value,= NULL); ++ else ++ sql->lasterror =3D value; + return INT_CANCEL; /* never exit */ + } + static void dbd_freetds_init(apr_pool_t *pool) + { +- int rv =3D regcomp(&dbd_freetds_find_arg, +- "%(\\{[^}]*\\})?([0-9]*)[A-Za-z]", REG_EXTENDED); +- if (rv !=3D 0) { +- char errmsg[256]; +- regerror(rv, &dbd_freetds_find_arg, errmsg, 256); +- fprintf(stderr, "regcomp failed: %s\n", errmsg); +- } +- dbinit(); ++ if (dbinit() =3D=3D FAIL) ++ fprintf(stderr, "dbinit() failed\n"); ++ dbmsghandle(freetds_msg_handler); + dberrhandle(freetds_err_handler); + apr_pool_cleanup_register(pool, NULL, freetds_term, apr_pool_cleanu= p_null); + } +@@ -765,7 +756,11 @@ + #endif +=20 + APU_MODULE_DECLARE_DATA const apr_dbd_driver_t apr_dbd_freetds_driver =3D= { ++#ifndef TI_MODULE_NAME + "freetds", ++#else ++ TI_MODULE_NAME, ++#endif + dbd_freetds_init, + dbd_freetds_native, + dbd_freetds_open, +@@ -787,19 +782,14 @@ + dbd_freetds_pvselect, + dbd_freetds_pquery, + dbd_freetds_pselect, +- /* this is only implemented to support httpd/2.2 standard usage, +- * as in the original DBD implementation. Everything else is NOTIM= PL. +- */ +-#ifdef COMPILE_STUBS + dbd_freetds_get_name, + dbd_freetds_transaction_mode_get, + dbd_freetds_transaction_mode_set, +- "", ++ "\1", /* Would not occur in a real query... */ + dbd_freetds_pvbquery, + dbd_freetds_pvbselect, + dbd_freetds_pbquery, + dbd_freetds_pbselect, + dbd_freetds_datum_get +-#endif + }; + #endif Index: devel/apr-util/pkg-descr =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- devel/apr-util/pkg-descr (revision 0) +++ devel/apr-util/pkg-descr (working copy) @@ -0,0 +1,9 @@ +The Apache Portable Runtime library provides a predictable and consisten= t +interface to underlying platform-specific implementations, relieving sof= tware +developers of the need to code special-case conditions to work around or= take +advantage of platform-specific deficiencies or features. + +This package contains the Apache Portable Runtime Utility library which +provides additional interfaces on top of the Apache Portable Runtime lib= rary. + +WWW: http://apr.apache.org/ Index: devel/apr-util/pkg-plist =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- devel/apr-util/pkg-plist (revision 0) +++ devel/apr-util/pkg-plist (working copy) @@ -0,0 +1,81 @@ +bin/apu-1-config +include/apr-1/apr_anylock.h +include/apr-1/apr_base64.h +include/apr-1/apr_buckets.h +include/apr-1/apr_crypto.h +include/apr-1/apr_date.h +include/apr-1/apr_dbd.h +include/apr-1/apr_dbm.h +include/apr-1/apr_hooks.h +include/apr-1/apr_ldap.h +include/apr-1/apr_ldap_init.h +include/apr-1/apr_ldap_option.h +include/apr-1/apr_ldap_rebind.h +include/apr-1/apr_ldap_url.h +include/apr-1/apr_md4.h +include/apr-1/apr_md5.h +include/apr-1/apr_memcache.h +include/apr-1/apr_optional.h +include/apr-1/apr_optional_hooks.h +include/apr-1/apr_queue.h +include/apr-1/apr_reslist.h +include/apr-1/apr_rmm.h +include/apr-1/apr_sdbm.h +include/apr-1/apr_sha1.h +include/apr-1/apr_strmatch.h +include/apr-1/apr_thread_pool.h +include/apr-1/apr_uri.h +include/apr-1/apr_uuid.h +include/apr-1/apr_xlate.h +include/apr-1/apr_xml.h +include/apr-1/apu.h +include/apr-1/apu_errno.h +include/apr-1/apu_version.h +include/apr-1/apu_want.h +%%NSS%%lib/apr-util-1/apr_crypto_nss-1.so +%%NSS%%lib/apr-util-1/apr_crypto_nss.so +%%NSS%%lib/apr-util-1/apr_crypto_nss.la +%%NSS%%lib/apr-util-1/apr_crypto_nss.a +%%SSL%%lib/apr-util-1/apr_crypto_openssl-1.so +%%SSL%%lib/apr-util-1/apr_crypto_openssl.a +%%SSL%%lib/apr-util-1/apr_crypto_openssl.la +%%SSL%%lib/apr-util-1/apr_crypto_openssl.so +%%FREETDS%%lib/apr-util-1/apr_dbd_freetds-1.so +%%FREETDS%%lib/apr-util-1/apr_dbd_freetds.a +%%FREETDS%%lib/apr-util-1/apr_dbd_freetds.la +%%FREETDS%%lib/apr-util-1/apr_dbd_freetds.so +%%MYSQL%%lib/apr-util-1/apr_dbd_mysql-1.so +%%MYSQL%%lib/apr-util-1/apr_dbd_mysql.a +%%MYSQL%%lib/apr-util-1/apr_dbd_mysql.la +%%MYSQL%%lib/apr-util-1/apr_dbd_mysql.so +%%PGSQL%%lib/apr-util-1/apr_dbd_pgsql-1.so +%%PGSQL%%lib/apr-util-1/apr_dbd_pgsql.a +%%PGSQL%%lib/apr-util-1/apr_dbd_pgsql.la +%%PGSQL%%lib/apr-util-1/apr_dbd_pgsql.so +%%SQLITE3%%lib/apr-util-1/apr_dbd_sqlite3-1.so +%%SQLITE3%%lib/apr-util-1/apr_dbd_sqlite3.a +%%SQLITE3%%lib/apr-util-1/apr_dbd_sqlite3.la +%%SQLITE3%%lib/apr-util-1/apr_dbd_sqlite3.so +%%BDB%%lib/apr-util-1/apr_dbm_db-1.so +%%BDB%%lib/apr-util-1/apr_dbm_db.a +%%BDB%%lib/apr-util-1/apr_dbm_db.la +%%BDB%%lib/apr-util-1/apr_dbm_db.so +%%GDBM%%lib/apr-util-1/apr_dbm_gdbm-1.so +%%GDBM%%lib/apr-util-1/apr_dbm_gdbm.a +%%GDBM%%lib/apr-util-1/apr_dbm_gdbm.la +%%GDBM%%lib/apr-util-1/apr_dbm_gdbm.so +%%NDBM%%lib/apr-util-1/apr_dbm_ndbm-1.so +%%NDBM%%lib/apr-util-1/apr_dbm_ndbm.a +%%NDBM%%lib/apr-util-1/apr_dbm_ndbm.la +%%NDBM%%lib/apr-util-1/apr_dbm_ndbm.so +%%LDAP%%lib/apr-util-1/apr_ldap-1.so +%%LDAP%%lib/apr-util-1/apr_ldap.a +%%LDAP%%lib/apr-util-1/apr_ldap.la +%%LDAP%%lib/apr-util-1/apr_ldap.so +lib/aprutil.exp +lib/libaprutil-1.a +lib/libaprutil-1.la +lib/libaprutil-1.so +lib/libaprutil-1.so.%%SHLIB_MAJOR%% +libdata/pkgconfig/apr-util-1.pc +%%APU_EXTRAS%%@dirrm lib/apr-util-1 --------------020604090309070102080306-- ------enig2IUMOMDJCCMWIOEJJGBHB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (FreeBSD) iF4EAREIAAYFAlHBr64ACgkQfoCS2CCgtitPvAD/RCCKE7I7ohFdvb83UIdOXYcF F3DVb9GSM1E/1NqKB24A/jsAhI29lx6S4rmCHhgWTBW2c6lxlgzVWqjJqKi8OGW2 =VPMG -----END PGP SIGNATURE----- ------enig2IUMOMDJCCMWIOEJJGBHB--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51C1AFA7.9080700>