ports/152693: [patch] databases/dbf2mysql can be compiled with current MySQL client library
Miroslav Lachman
000.fbsd at quip.cz
Tue Nov 30 02:10:13 UTC 2010
>Number: 152693
>Category: ports
>Synopsis: [patch] databases/dbf2mysql can be compiled with current MySQL client library
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Tue Nov 30 02:10:12 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Miroslav Lachman
>Release: FreeBSD 7.3-RELEASE-p2 i386
>Organization:
codeLab.cz
>Environment:
7.3-RELEASE-p2 FreeBSD 7.3-RELEASE-p2 #0: Mon Jul 12 19:04:04 UTC 2010 root at i386-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC i386
>Description:
The port databases/dbf2mysql has hardoced dependency on mysql-client-3.23.59.n.20050301_2 which is too old in these days and can't be compiled with newer gcc.
root at roxy dbf2mysql/# make
===> Extracting for dbf2mysql-1.14_2
=> MD5 Checksum OK for dbf2mysql-1.14.tar.gz.
=> SHA256 Checksum OK for dbf2mysql-1.14.tar.gz.
===> Patching for dbf2mysql-1.14_2
===> Applying FreeBSD patches for dbf2mysql-1.14_2
===> dbf2mysql-1.14_2 depends on shared library: mysqlclient.10 - not found
===> Verifying install for mysqlclient.10 in /usr/ports/databases/mysql323-client
===> mysql-client-3.23.59.n.20050301_2 obsolete and does not build with gcc4.2; use mysql 5 or later.
*** Error code 1
Stop in /usr/ports/databases/mysql323-client.
*** Error code 1
Stop in /usr/ports/databases/dbf2mysql.
It is better to make it compilable with current versions of MySQL client library (5.0 or 5.1 for example) and use generic:
USE_MYSQL= yes
instead of
LIB_DEPENDS= mysqlclient.10:${PORTSDIR}/databases/mysql323-client
>How-To-Repeat:
Try to build and use dbf2mysql in todays systems (GCC 4.2, MySQL 5.0.x etc.)
>Fix:
The problem is first discussed here
http://lists.freebsd.org/pipermail/freebsd-ports/2010-November/064714.html
And working patch is attached.
Now it works with MySQL 5.0.90 client library.
Patch attached with submission follows:
Index: databases/dbf2mysql/Makefile
===================================================================
--- Makefile.orig 2010-11-28 18:34:26.000000000 +0100
+++ Makefile 2010-11-28 19:11:05.000000000 +0100
@@ -18,7 +18,7 @@
MAINTAINER= ports at FreeBSD.org
COMMENT= Programs to convert .dbf files to MySQL tables and vice versa
-LIB_DEPENDS= mysqlclient.10:${PORTSDIR}/databases/mysql323-client
+USE_MYSQL= yes
PORTDOCS= README
Index: databases/dbf2mysql/work/dbf2mysql-1.14/mysql2dbf.c
===================================================================
--- mysql2dbf.c.orig 2010-11-28 19:46:34.000000000 +0100
+++ mysql2dbf.c 2010-11-28 21:23:22.000000000 +0100
@@ -1,6 +1,11 @@
/* utility to read out an mySQL-table, and store it into a DBF-file
M. Boekhold (boekhold at cindy.et.tudelft.nl) April 1996
+
+ M. Lachman Nov 2010
+ Replaced mysql_connect with mysql_real_connect, SQLsock isn't used anymore
+ Can be compiled with MySQL client 5.0.x
+
*/
#include <stdio.h>
@@ -47,7 +52,7 @@
int main(int argc, char **argv) {
int i;
- MYSQL *SQLsock,mysql;
+ MYSQL mysql;
extern int optind;
extern char *optarg;
char *query = NULL;
@@ -148,7 +153,9 @@
printf("Making connection with mySQL-server\n");
}
- if (!(SQLsock = mysql_connect(&mysql,host,user,pass))) {
+ mysql_init(&mysql);
+
+ if (!mysql_real_connect(&mysql,host,user,pass, dbase, 0, NULL,0)) {
fprintf(stderr, "Couldn't get a connection with the ");
fprintf(stderr, "designated host!\n");
fprintf(stderr, "Detailed report: %s\n", mysql_error(&mysql));
@@ -157,37 +164,24 @@
exit(1);
}
- if (verbose > 1) {
- printf("Selecting database\n");
- }
-
- if ((mysql_select_db(SQLsock, dbase)) == -1) {
- fprintf(stderr, "Couldn't select database %s.\n", dbase);
- fprintf(stderr, "Detailed report: %s\n", mysql_error(SQLsock));
- close(dbh->db_fd);
- free(dbh);
- mysql_close(SQLsock);
- exit(1);
- }
-
if (verbose > 1) {
printf("Sending query\n");
}
- if (mysql_query(SQLsock, query) == -1) {
+ if (mysql_query(&mysql, query) == -1) {
fprintf(stderr, "Error sending query.\nDetailed report: %s\n",
- mysql_error(SQLsock));
+ mysql_error(&mysql));
if (verbose > 1) {
fprintf(stderr, "%s\n", query);
}
- mysql_close(SQLsock);
+ mysql_close(&mysql);
close(dbh->db_fd);
free(dbh);
exit(1);
}
- qres = mysql_store_result(SQLsock);
+ qres = mysql_store_result(&mysql);
numfields = mysql_num_fields(qres);
numrows = mysql_num_rows(qres);
@@ -303,7 +297,7 @@
}
mysql_free_result(qres);
- mysql_close(SQLsock);
+ mysql_close(&mysql);
close(dbh->db_fd);
free(dbh);
exit(0);
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list