unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH]: gnu: Add guile-dbi.
@ 2016-06-18  8:09 宋文武
  2016-06-20  8:24 ` Ludovic Courtès
  0 siblings, 1 reply; 11+ messages in thread
From: 宋文武 @ 2016-06-18  8:09 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 47 bytes --]

Here are 'guile-dbi' and 'guile-dbd-sqlite3':


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-Add-guile-dbi.patch --]
[-- Type: text/x-patch, Size: 2338 bytes --]

From 8e73c3e1a798b134e341c71c4b1c17d60956e3d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
Date: Fri, 17 Jun 2016 22:44:56 +0800
Subject: [PATCH 1/2] gnu: Add guile-dbi.

* gnu/packages/guile.scm (guile-dbi): New variable.
---
 gnu/packages/guile.scm | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm
index 6f00edb..284b123 100644
--- a/gnu/packages/guile.scm
+++ b/gnu/packages/guile.scm
@@ -958,4 +958,42 @@ provides access to that interface and its types from the Scheme level.")
     (home-page "http://www.nongnu.org/g-wrap/index.html")
     (license lgpl2.1+)))
 
+(define-public guile-dbi
+  (package
+    (name "guile-dbi")
+    (version "2.1.6")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "http://download.gna.org/guile-dbi/guile-dbi-"
+                    version ".tar.gz"))
+              (sha256
+               (base32
+                "116njrprhgrsv1qm904sp3b02rq01fx639r433d657gyhw3x159n"))))
+    (build-system gnu-build-system)
+    (arguments
+     '(#:configure-flags
+       (list (string-append
+              "--with-guile-site-dir=" %output "/share/guile/site/2.0"))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'install 'patch-extension-path
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out     (assoc-ref outputs "out"))
+                    (dbi.scm (string-append
+                              out "/share/guile/site/2.0/dbi/dbi.scm"))
+                    (ext     (string-append out "/lib/libguile-dbi")))
+               (substitute* dbi.scm (("libguile-dbi") ext))
+               #t))))))
+    (propagated-inputs
+     `(("guile" ,guile-2.0)))
+    (synopsis "Guile database abstraction layer")
+    (home-page "http://home.gna.org/guile-dbi/guile-dbi.html")
+    (description
+     "guile-dbi is a library for Guile that provides a convenient interface to
+SQL databases.  Database programming with guile-dbi is generic in that the same
+programming interface is presented regardless of which database system is used.
+It currently supports MySQL, Postgres and SQLite3.")
+    (license gpl2+)))
+
 ;;; guile.scm ends here
-- 
2.8.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-gnu-Add-guile-dbd-sqlite3.patch --]
[-- Type: text/x-patch, Size: 1730 bytes --]

From 87c3ef658e24035715b48606fb9ef24d55aaddfa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
Date: Sat, 18 Jun 2016 15:49:36 +0800
Subject: [PATCH 2/2] gnu: Add guile-dbd-sqlite3.

* gnu/packages/guile.scm (guile-dbd-sqlite3): New variable.
---
 gnu/packages/guile.scm | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm
index 284b123..29c7ed2 100644
--- a/gnu/packages/guile.scm
+++ b/gnu/packages/guile.scm
@@ -996,4 +996,31 @@ programming interface is presented regardless of which database system is used.
 It currently supports MySQL, Postgres and SQLite3.")
     (license gpl2+)))
 
+(define-public guile-dbd-sqlite3
+  (package
+    (name "guile-dbd-sqlite3")
+    (version "2.1.6")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "http://download.gna.org/guile-dbi/guile-dbd-sqlite3-"
+                    version ".tar.gz"))
+              (sha256
+               (base32
+                "0rg71jchxd2y8x496s8zmfmikr5g8zxi8zv2ar3f7a23pph92iw2"))))
+    (build-system gnu-build-system)
+    (native-inputs
+     `(("pkg-config" ,pkg-config)))
+    (inputs
+     `(("sqlite" ,sqlite)
+       ("zlib" ,(@ (gnu packages compression) zlib))))
+    (propagated-inputs
+     `(("guile-dbi" ,guile-dbi)))
+    (synopsis "Guile DBI driver for SQLite")
+    (home-page "https://github.com/jkalbhenn/guile-dbd-sqlite3")
+    (description
+     "guile-dbi is a library for Guile that provides a convenient interface to
+SQL databases.  This package implements the interface for SQLite.")
+    (license gpl2+)))
+
 ;;; guile.scm ends here
-- 
2.8.4


[-- Attachment #4: Type: text/plain, Size: 139 bytes --]


Unfortunately, Guile DBI loads its backends using `dlopen',
so I have to set 'LD_LIBRARY_PATH' to '$guile-dbd-sqlite/lib'
for loading it.

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH]: gnu: Add guile-dbi.
  2016-06-18  8:09 [PATCH]: gnu: Add guile-dbi 宋文武
@ 2016-06-20  8:24 ` Ludovic Courtès
  2016-06-21  8:35   ` Maurizio Boriani
  0 siblings, 1 reply; 11+ messages in thread
From: Ludovic Courtès @ 2016-06-20  8:24 UTC (permalink / raw)
  To: 宋文武; +Cc: guix-devel

iyzsong@member.fsf.org (宋文武) skribis:

> From 8e73c3e1a798b134e341c71c4b1c17d60956e3d5 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
> Date: Fri, 17 Jun 2016 22:44:56 +0800
> Subject: [PATCH 1/2] gnu: Add guile-dbi.
>
> * gnu/packages/guile.scm (guile-dbi): New variable.

LGTM!

> From 87c3ef658e24035715b48606fb9ef24d55aaddfa Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
> Date: Sat, 18 Jun 2016 15:49:36 +0800
> Subject: [PATCH 2/2] gnu: Add guile-dbd-sqlite3.
>
> * gnu/packages/guile.scm (guile-dbd-sqlite3): New variable.

LGTM.

> Unfortunately, Guile DBI loads its backends using `dlopen',
> so I have to set 'LD_LIBRARY_PATH' to '$guile-dbd-sqlite/lib'
> for loading it.

I don’t have any great ideas.

If it uses lt_dlopen, then we should recommend setting LTDL_LIBRARY_PATH
instead of LD_LIBRARY_PATH, which is a lesser evil.

Otherwise, we could also hard-code the file name of, say,
guile-dbd-sqlite in guile-dbi, such that there’s always at least one
backend available.

WDYT?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH]: gnu: Add guile-dbi.
  2016-06-20  8:24 ` Ludovic Courtès
@ 2016-06-21  8:35   ` Maurizio Boriani
  2016-06-21 14:14     ` Ludovic Courtès
  0 siblings, 1 reply; 11+ messages in thread
From: Maurizio Boriani @ 2016-06-21  8:35 UTC (permalink / raw)
  To: guix-devel

>>>>> "Ludovic" == Ludovic Courtès <ludo@gnu.org> writes:

hi,
  I'm the maintainer and first author of guile-dbi

[...]

    >> Unfortunately, Guile DBI loads its backends using `dlopen', so I
    >> have to set 'LD_LIBRARY_PATH' to '$guile-dbd-sqlite/lib' for
    >> loading it.

    Ludovic> I don’t have any great ideas.

    Ludovic> If it uses lt_dlopen, then we should recommend setting
    Ludovic> LTDL_LIBRARY_PATH instead of LD_LIBRARY_PATH, which is a
    Ludovic> lesser evil.

    Ludovic> Otherwise, we could also hard-code the file name of, say,
    Ludovic> guile-dbd-sqlite in guile-dbi, such that there’s always at
    Ludovic> least one backend available.

may be ok for you if I introduce and 'hardcoded' default search path
for library lookup in guile-dbi source code and do a new release? 

thanks for your great work,

bye

-- 
Maurizio Boriani 
PGP key: 0xCC0FBF8F

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH]: gnu: Add guile-dbi.
  2016-06-21  8:35   ` Maurizio Boriani
@ 2016-06-21 14:14     ` Ludovic Courtès
  2016-06-21 15:09       ` 宋文武
  0 siblings, 1 reply; 11+ messages in thread
From: Ludovic Courtès @ 2016-06-21 14:14 UTC (permalink / raw)
  To: Maurizio Boriani; +Cc: guix-devel

Hi!

Maurizio Boriani <baux@gnu.org> skribis:

>   I'm the maintainer and first author of guile-dbi

Good to see you here!  :-)

>     >> Unfortunately, Guile DBI loads its backends using `dlopen', so I
>     >> have to set 'LD_LIBRARY_PATH' to '$guile-dbd-sqlite/lib' for
>     >> loading it.
>
>     Ludovic> I don’t have any great ideas.
>
>     Ludovic> If it uses lt_dlopen, then we should recommend setting
>     Ludovic> LTDL_LIBRARY_PATH instead of LD_LIBRARY_PATH, which is a
>     Ludovic> lesser evil.
>
>     Ludovic> Otherwise, we could also hard-code the file name of, say,
>     Ludovic> guile-dbd-sqlite in guile-dbi, such that there’s always at
>     Ludovic> least one backend available.
>
> may be ok for you if I introduce and 'hardcoded' default search path
> for library lookup in guile-dbi source code and do a new release? 

I don’t think there’s any good default search path that we could hard
code, though, except arbitrarily choosing one of the backends as I
suggested above.

Ideas?

So I’m tempted to think that it’s best for you not to change anything.

On the Guix side, another thing we could do is a ‘LTDL_LIBRARY_PATH’ as
a ‘native-search-path’ for guile-dbi.

Thoughts?

Ludo’.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH]: gnu: Add guile-dbi.
  2016-06-21 14:14     ` Ludovic Courtès
@ 2016-06-21 15:09       ` 宋文武
  2016-06-21 20:56         ` Ludovic Courtès
  0 siblings, 1 reply; 11+ messages in thread
From: 宋文武 @ 2016-06-21 15:09 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

ludo@gnu.org (Ludovic Courtès) writes:

> Hi!
>
> Maurizio Boriani <baux@gnu.org> skribis:
>
>>   I'm the maintainer and first author of guile-dbi
>
> Good to see you here!  :-)
>
Oh, nice!

>>     >> Unfortunately, Guile DBI loads its backends using `dlopen', so I
>>     >> have to set 'LD_LIBRARY_PATH' to '$guile-dbd-sqlite/lib' for
>>     >> loading it.
>>
>>     Ludovic> I don’t have any great ideas.
>>
>>     Ludovic> If it uses lt_dlopen, then we should recommend setting
>>     Ludovic> LTDL_LIBRARY_PATH instead of LD_LIBRARY_PATH, which is a
>>     Ludovic> lesser evil.
>>
>>     Ludovic> Otherwise, we could also hard-code the file name of, say,
>>     Ludovic> guile-dbd-sqlite in guile-dbi, such that there’s always at
>>     Ludovic> least one backend available.
>>
>> may be ok for you if I introduce and 'hardcoded' default search path
>> for library lookup in guile-dbi source code and do a new release? 
>
> I don’t think there’s any good default search path that we could hard
> code, though, except arbitrarily choosing one of the backends as I
> suggested above.
>
> Ideas?
I think it will be great to introduce a new search path (eg: GUILE_DBD_PATH)
in addition to LD_LIBRARY_PATH.  Find the absolute so filepath in it
ourself, then pass to dlopen.  


Another idea is changing dbd libraries to scheme modules.  Then dbi will
use the '(dbi dbd mysql)' module, the module may use 'load-extension'.
So we can patch the scheme file of each dbd module.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH]: gnu: Add guile-dbi.
  2016-06-21 15:09       ` 宋文武
@ 2016-06-21 20:56         ` Ludovic Courtès
  2016-09-16  3:36           ` guile-dbi: Use libltdl and prefer GUILE_DBD_PATH 宋文武
  0 siblings, 1 reply; 11+ messages in thread
From: Ludovic Courtès @ 2016-06-21 20:56 UTC (permalink / raw)
  To: 宋文武; +Cc: guix-devel

iyzsong@member.fsf.org (宋文武) skribis:

> ludo@gnu.org (Ludovic Courtès) writes:
>
>> Hi!
>>
>> Maurizio Boriani <baux@gnu.org> skribis:
>>
>>>   I'm the maintainer and first author of guile-dbi
>>
>> Good to see you here!  :-)
>>
> Oh, nice!
>
>>>     >> Unfortunately, Guile DBI loads its backends using `dlopen', so I
>>>     >> have to set 'LD_LIBRARY_PATH' to '$guile-dbd-sqlite/lib' for
>>>     >> loading it.
>>>
>>>     Ludovic> I don’t have any great ideas.
>>>
>>>     Ludovic> If it uses lt_dlopen, then we should recommend setting
>>>     Ludovic> LTDL_LIBRARY_PATH instead of LD_LIBRARY_PATH, which is a
>>>     Ludovic> lesser evil.
>>>
>>>     Ludovic> Otherwise, we could also hard-code the file name of, say,
>>>     Ludovic> guile-dbd-sqlite in guile-dbi, such that there’s always at
>>>     Ludovic> least one backend available.
>>>
>>> may be ok for you if I introduce and 'hardcoded' default search path
>>> for library lookup in guile-dbi source code and do a new release? 
>>
>> I don’t think there’s any good default search path that we could hard
>> code, though, except arbitrarily choosing one of the backends as I
>> suggested above.
>>
>> Ideas?
> I think it will be great to introduce a new search path (eg: GUILE_DBD_PATH)
> in addition to LD_LIBRARY_PATH.  Find the absolute so filepath in it
> ourself, then pass to dlopen.  

Why not, but then it would be redundant with LD_LIBRARY_PATH and
LTDL_LIBRARY_PATH, which would further complicate the search rules.

> Another idea is changing dbd libraries to scheme modules.  Then dbi will
> use the '(dbi dbd mysql)' module, the module may use 'load-extension'.
> So we can patch the scheme file of each dbd module.

I like this approach!

Ludo’.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* guile-dbi: Use libltdl and prefer GUILE_DBD_PATH.
  2016-06-21 20:56         ` Ludovic Courtès
@ 2016-09-16  3:36           ` 宋文武
  2016-09-16  6:57             ` baux
  2017-07-10 22:54             ` Linas Vepstas
  0 siblings, 2 replies; 11+ messages in thread
From: 宋文武 @ 2016-09-16  3:36 UTC (permalink / raw)
  To: Maurizio Boriani; +Cc: guix-devel, guile-user

[-- Attachment #1: Type: text/plain, Size: 632 bytes --]

Hi!

To reall, curentlly, guile-dbi use dlopen to load its backends.
So, for Guix we have to set LD_LIBRARY_PATH, which is not desired.

> [...]
> (me:)
>> I think it will be great to introduce a new search path (eg: GUILE_DBD_PATH)
>> in addition to LD_LIBRARY_PATH.  Find the absolute so filepath in it
>> ourself, then pass to dlopen.  
>
> (ludo:)
> Why not, but then it would be redundant with LD_LIBRARY_PATH and
> LTDL_LIBRARY_PATH, which would further complicate the search rules.
>

Yeah, but I just learn that libltdl has a convenient function to do
this..


So, here are patches for using libltdl and a new search path:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Use-libltdl-to-dlopen-backends.patch --]
[-- Type: text/x-patch, Size: 5983 bytes --]

From 59d529388d062ddad581bcd7f0c56690a84bf7df Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
Date: Fri, 16 Sep 2016 10:30:36 +0800
Subject: [PATCH 1/3] Use libltdl to dlopen backends.

* include/guile-dbi/guile-dbi.h (gdbi_db_handle_t): Use 'lt_dlhandle'.
* src/guile-dbi.c: Replace libdl calls with their libltdl equivalences.
* Makefile.am (SUBDIRS): Add libltdl.
* configure.ac: Use LTDL_INIT.  Add LTDLINCL and LIBLTDL to flags.
* src/Makefile.am (libguile_dbi_la_LIBDD): Remove '-ldl'.
---
 guile-dbi/Makefile.am                   |  2 +-
 guile-dbi/configure.ac                  |  8 +++++---
 guile-dbi/include/guile-dbi/guile-dbi.h |  3 ++-
 guile-dbi/src/Makefile.am               |  2 +-
 guile-dbi/src/guile-dbi.c               | 25 ++++++++++---------------
 5 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/guile-dbi/Makefile.am b/guile-dbi/Makefile.am
index e4cae61..011740b 100644
--- a/guile-dbi/Makefile.am
+++ b/guile-dbi/Makefile.am
@@ -24,7 +24,7 @@
 ACLOCAL_AMFLAGS = -I m4
 
 AUTOMAKE_OPTIONS = gnu
-SUBDIRS = src include doc
+SUBDIRS = libltdl src include doc
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = guile-dbi.pc
diff --git a/guile-dbi/configure.ac b/guile-dbi/configure.ac
index cc45703..d902cb0 100644
--- a/guile-dbi/configure.ac
+++ b/guile-dbi/configure.ac
@@ -55,14 +55,16 @@ AC_CHECK_FUNCS([strerror])
 
 # ltmain needs these:
 AC_CONFIG_MACRO_DIR([m4])
-LT_INIT
+LT_INIT([dlopen])
+LT_CONFIG_LTDL_DIR([libltdl])
+LTDL_INIT
 # AC_PROG_INSTALL
 # AC_PROG_MAKE_SET
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [AC_SUBST([AM_DEFAULT_VERBOSITY],1)])
 
 
-CFLAGS=`$GUILECONFIG compile`
-LIBS=`$GUILECONFIG link`
+CFLAGS="$LTDLINCL `$GUILECONFIG compile`"
+LIBS="$LIBLTDL `$GUILECONFIG link`"
 GUILE_SITE=`$GUILECONFIG info sitedir`
 
 AC_ARG_WITH([guile-site-dir],
diff --git a/guile-dbi/include/guile-dbi/guile-dbi.h b/guile-dbi/include/guile-dbi/guile-dbi.h
index b75d3dc..00449ee 100644
--- a/guile-dbi/include/guile-dbi/guile-dbi.h
+++ b/guile-dbi/include/guile-dbi/guile-dbi.h
@@ -24,6 +24,7 @@
 #define __GUILE_DBI_H__
 
 #include <libguile.h>
+#include <ltdl.h>
 
 /* guile smob struct */
 typedef struct
@@ -32,7 +33,7 @@ typedef struct
   SCM constr;
   SCM status;  /* pair: car = error numeric code, cdr = status message */
   SCM closed;  /* boolean, TRUE if closed otherwise FALSE */
-  void* handle;
+  lt_dlhandle handle;
   void* db_info;
   int in_free;  /* boolean, used to avoid alloc during garbage collection */
   const char * bcknd_str;
diff --git a/guile-dbi/src/Makefile.am b/guile-dbi/src/Makefile.am
index a3001db..0795899 100644
--- a/guile-dbi/src/Makefile.am
+++ b/guile-dbi/src/Makefile.am
@@ -35,7 +35,7 @@ SUFFIXES = .x
 lib_LTLIBRARIES = libguile-dbi.la 
 
 libguile_dbi_la_SOURCES = guile-dbi.c guile-dbi.x 
-libguile_dbi_la_LIBADD = -ldl $(LIBS)
+libguile_dbi_la_LIBADD = $(LIBS)
 libguile_dbi_la_LDFLAGS = -export-dynamic -version-info @DBI_INTERFACE@
 libguile_dbi_la_DEPENDENCIES = $(LTLIBOBJS)
 
diff --git a/guile-dbi/src/guile-dbi.c b/guile-dbi/src/guile-dbi.c
index 5d797d9..d4ae040 100644
--- a/guile-dbi/src/guile-dbi.c
+++ b/guile-dbi/src/guile-dbi.c
@@ -24,7 +24,6 @@
 #include <guile-dbi/guile-dbi.h>
 #include <string.h>
 #include <errno.h>
-#include <dlfcn.h>
 #include <stdio.h>
 
 
@@ -59,9 +58,8 @@ SCM_DEFINE (make_g_db_handle, "dbi-open", 2, 0, 0,
   g_db_handle->bcknd_str = scm_to_locale_string (bcknd);
   g_db_handle->bcknd_strlen = strlen(g_db_handle->bcknd_str);
 
-  /* The +20 allos for .so or .dylib on MacOS */
   sodbd_len = sizeof(char) * (strlen("libguile-dbd-") +
-                   g_db_handle->bcknd_strlen + 20);
+                   g_db_handle->bcknd_strlen + 1);
   sodbd = (char*) malloc (sodbd_len);
   if (sodbd == NULL)
     {
@@ -70,18 +68,14 @@ SCM_DEFINE (make_g_db_handle, "dbi-open", 2, 0, 0,
       SCM_RETURN_NEWSMOB (g_db_handle_tag, g_db_handle);
     }
 
-#ifdef  __APPLE__
-  snprintf(sodbd, sodbd_len, "libguile-dbd-%s.dylib", g_db_handle->bcknd_str);
-#else
-  snprintf(sodbd, sodbd_len, "libguile-dbd-%s.so", g_db_handle->bcknd_str);
-#endif
+  snprintf(sodbd, sodbd_len, "libguile-dbd-%s", g_db_handle->bcknd_str);
 
-  g_db_handle->handle = dlopen(sodbd, RTLD_NOW);
+  g_db_handle->handle = lt_dlopenext(sodbd);
   if (g_db_handle->handle == NULL)
     {
       free(sodbd);
       g_db_handle->status =  scm_cons(scm_from_int(1),
-                              scm_from_locale_string(dlerror()));      
+                              scm_from_locale_string(lt_dlerror()));
       SCM_RETURN_NEWSMOB (g_db_handle_tag, g_db_handle);
     }
 
@@ -174,7 +168,7 @@ SCM_DEFINE (close_g_db_handle, "dbi-close", 1, 0, 0,
   (*dbd_close)(g_db_handle);
   if (g_db_handle->handle)
     {
-      dlclose(g_db_handle->handle);
+      lt_dlclose(g_db_handle->handle);
       g_db_handle->handle = NULL;
     }
   scm_remember_upto_here_1(db_handle);
@@ -311,6 +305,7 @@ init_dbi(void)
   if (is_inited) return;
   is_inited = 1;
   init_db_handle_type();
+  lt_dlinit();
 
 #ifndef SCM_MAGIC_SNARFER
 #include "guile-dbi.x"
@@ -324,7 +319,7 @@ void
 __gdbi_dbd_wrap(gdbi_db_handle_t* dbh, const char* function_name,
                 void** function_pointer)
 {
-  char *ret   = NULL;
+  const char *ret   = NULL;
   char *func  = NULL;
   size_t func_len;
 
@@ -340,9 +335,9 @@ __gdbi_dbd_wrap(gdbi_db_handle_t* dbh, const char* function_name,
 
   /* I assume this is correct for all OS'es */
   snprintf(func, func_len, "__%s_%s", dbh->bcknd_str, function_name);
-  dlerror();    /* Clear any existing error -- Solaris needs this */
-  *function_pointer = dlsym(dbh->handle, func);
-  if ((ret = dlerror()) != NULL)
+  lt_dlerror();    /* Clear any existing error -- Solaris needs this */
+  *function_pointer = lt_dlsym(dbh->handle, func);
+  if ((ret = lt_dlerror()) != NULL)
     {
       free(func);
       if (dbh->in_free) return; /* do not SCM anything while in GC */
-- 
2.10.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Prefer-GUILE_DBD_PATH-as-search-path-for-backends.patch --]
[-- Type: text/x-patch, Size: 887 bytes --]

From 495a47aaf79fd501e793562a340a7528ef587144 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
Date: Fri, 16 Sep 2016 11:07:59 +0800
Subject: [PATCH 2/3] Prefer GUILE_DBD_PATH as search path for backends.

* src/guile-dbi.c (init_dbi): Call 'lt_dlsetsearchpath'.
---
 guile-dbi/src/guile-dbi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/guile-dbi/src/guile-dbi.c b/guile-dbi/src/guile-dbi.c
index d4ae040..b609a88 100644
--- a/guile-dbi/src/guile-dbi.c
+++ b/guile-dbi/src/guile-dbi.c
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <errno.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 
 static scm_t_bits g_db_handle_tag;
@@ -306,6 +307,7 @@ init_dbi(void)
   is_inited = 1;
   init_db_handle_type();
   lt_dlinit();
+  lt_dlsetsearchpath(getenv("GUILE_DBD_PATH"));
 
 #ifndef SCM_MAGIC_SNARFER
 #include "guile-dbi.x"
-- 
2.10.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-Update-documentation-for-the-usage-of-libltdl.patch --]
[-- Type: text/x-patch, Size: 2889 bytes --]

From 1a2fc824fa81324ceb2a310104ea26d0ecd0be4e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
Date: Fri, 16 Sep 2016 11:13:29 +0800
Subject: [PATCH 3/3] Update documentation for the usage of libltdl.

* doc/guile-dbi.texi: Adjust to the usage of libltdl.
---
 guile-dbi/doc/guile-dbi.texi | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/guile-dbi/doc/guile-dbi.texi b/guile-dbi/doc/guile-dbi.texi
index 4b0015f..02821c0 100644
--- a/guile-dbi/doc/guile-dbi.texi
+++ b/guile-dbi/doc/guile-dbi.texi
@@ -312,7 +312,7 @@ typedef struct g_db_handle
   SCM constr;
   SCM status;  /* pair: car = error numeric code, cdr = status message */
   SCM closed;  /* boolean, TRUE if closed otherwise FALSE */
-  void* handle;
+  lt_dlhandle handle;
   void* db_info;
   int in_free; /* boolean, used to avoid alloc during garbage collection */
 @} gdbi_db_handle_t;
@@ -327,7 +327,7 @@ backend to the dbi interface library. Its car is returns a status code number,
 cdr is a status return message.
 @item @code{closed} boolean, @code{#t} if the connection is closed, and
 @code{#f} otherwise.
-@item @code{handle} is a void pointer used to point to dynamically
+@item @code{handle} is a lt_dlhandle used to point to dynamically
 loaded back-end library, filled by dbi-open @code{__gdbi_dbd_wrap}.
 Set to ``NULL'' at connection close.
 @item @code{db_info} is a void pointer used by the backends as a data
@@ -364,18 +364,21 @@ Used to expose guile-dbi symbols so, scheme can call them.
 @node How plugins are loaded, How to write plugins, Internal functions, Internals and Database Drivers
 @section How plugins are loaded
 
-Everything starts at @code{s_make_db_handle}. This function uses dlopen
-to load a shared library named ``libguile-dbd-bcknd.so''. bcknd is the
-first param of dbi-open.
+Everything starts at @code{s_make_db_handle}. This function uses
+libltdl to load a shared library named ``libguile-dbd-bcknd'' with the
+extension of ``.la'', ``.so'', etc. It's searched in the value of
+environment variable @code{GUILE_DBD_PATH} first, then libltdl's
+search patch and system library search path. bcknd is the first param
+of dbi-open.
 
 @*
 If the shared library is successfully loaded, the dbh's field ``handle''
-is filled with the pointer returned by ``dlopen'' and dbh->status is
+is filled with the pointer returned by ``lt_dlopen'' and dbh->status is
 set.  Otherwise the status is set to an error code in the car location,
 while cdr is filled with an error message returned by @code{strerror}.
 
 @*
-Once ``dlopen'' is ok, @code{__gdbi_dbd_wrap} is used to call the backend
+Once ``lt_dlopen'' is ok, @code{__gdbi_dbd_wrap} is used to call the backend
 plugin connect function passing it the connection string. If this
 step also succeeds, then the db should be connected.
 @sp 1
-- 
2.10.0


[-- Attachment #5: Type: text/plain, Size: 27 bytes --]


Hope they are obvious :-)

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: guile-dbi: Use libltdl and prefer GUILE_DBD_PATH.
  2016-09-16  3:36           ` guile-dbi: Use libltdl and prefer GUILE_DBD_PATH 宋文武
@ 2016-09-16  6:57             ` baux
  2017-07-10 22:54             ` Linas Vepstas
  1 sibling, 0 replies; 11+ messages in thread
From: baux @ 2016-09-16  6:57 UTC (permalink / raw)
  To: iyzsong; +Cc: guix-devel, guile-user

>>>>> "iyzsong" == <iyzsong@member.fsf.org> writes:

    iyzsong> Hi!

nice to meet you :-)

    iyzsong> To reall, curentlly, guile-dbi use dlopen to load its
    iyzsong> backends.  So, for Guix we have to set LD_LIBRARY_PATH,
    iyzsong> which is not desired.

[...]

    iyzsong> So, here are patches for using libltdl and a new search

ok. I'm working on a new release about dbd search path and guix.

thanks.

-- 
Maurizio Boriani 
PGP key: 0xCC0FBF8F

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: guile-dbi: Use libltdl and prefer GUILE_DBD_PATH.
  2016-09-16  3:36           ` guile-dbi: Use libltdl and prefer GUILE_DBD_PATH 宋文武
  2016-09-16  6:57             ` baux
@ 2017-07-10 22:54             ` Linas Vepstas
  2017-07-11 11:02               ` 宋文武
  1 sibling, 1 reply; 11+ messages in thread
From: Linas Vepstas @ 2017-07-10 22:54 UTC (permalink / raw)
  To: 宋文武; +Cc: Maurizio Boriani, guix-devel, Guile User

Sorry for the very late reply.  I applied these patches to

https://github.com/opencog/guile-dbi

which will have to serve as the official repo for guile-dbi, since gna.org
is now dead.

Maurizio Boriani, I was surprised to see you answer -- do you have some
other repo somwhere that contains the guile-dbi code?

--linas



On Thu, Sep 15, 2016 at 10:36 PM, 宋文武 <iyzsong@member.fsf.org> wrote:

> Hi!
>
> To reall, curentlly, guile-dbi use dlopen to load its backends.
> So, for Guix we have to set LD_LIBRARY_PATH, which is not desired.
>
> > [...]
> > (me:)
> >> I think it will be great to introduce a new search path (eg:
> GUILE_DBD_PATH)
> >> in addition to LD_LIBRARY_PATH.  Find the absolute so filepath in it
> >> ourself, then pass to dlopen.
> >
> > (ludo:)
> > Why not, but then it would be redundant with LD_LIBRARY_PATH and
> > LTDL_LIBRARY_PATH, which would further complicate the search rules.
> >
>
> Yeah, but I just learn that libltdl has a convenient function to do
> this..
>
>
> So, here are patches for using libltdl and a new search path:
>
>
>
> Hope they are obvious :-)
>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: guile-dbi: Use libltdl and prefer GUILE_DBD_PATH.
  2017-07-10 22:54             ` Linas Vepstas
@ 2017-07-11 11:02               ` 宋文武
  2017-07-11 18:31                 ` Nala Ginrut
  0 siblings, 1 reply; 11+ messages in thread
From: 宋文武 @ 2017-07-11 11:02 UTC (permalink / raw)
  To: Linas Vepstas; +Cc: Maurizio Boriani, guix-devel, Guile User

Linas Vepstas <linasvepstas@gmail.com> writes:

> Sorry for the very late reply. I applied these patches to 
>
> https://github.com/opencog/guile-dbi
>
> which will have to serve as the official repo for guile-dbi, since gna.org is now dead.

Oh, thanks!

Is there a plan for a new release with tarballs?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: guile-dbi: Use libltdl and prefer GUILE_DBD_PATH.
  2017-07-11 11:02               ` 宋文武
@ 2017-07-11 18:31                 ` Nala Ginrut
  0 siblings, 0 replies; 11+ messages in thread
From: Nala Ginrut @ 2017-07-11 18:31 UTC (permalink / raw)
  To: 宋文武
  Cc: guix-devel, Maurizio Boriani, Linas Vepstas, Guile User

[-- Attachment #1: Type: text/plain, Size: 567 bytes --]

BTW, http://home.gna.org/guile-dbi/ occasionally unavailable for me, it's
better to have an official mirror on gitlab or github

Best regards


2017年7月11日 19:04,"宋文武" <iyzsong@member.fsf.org>写道:

> Linas Vepstas <linasvepstas@gmail.com> writes:
>
> > Sorry for the very late reply. I applied these patches to
> >
> > https://github.com/opencog/guile-dbi
> >
> > which will have to serve as the official repo for guile-dbi, since
> gna.org is now dead.
>
> Oh, thanks!
>
> Is there a plan for a new release with tarballs?
>
>

[-- Attachment #2: Type: text/html, Size: 1824 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-07-11 18:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-18  8:09 [PATCH]: gnu: Add guile-dbi 宋文武
2016-06-20  8:24 ` Ludovic Courtès
2016-06-21  8:35   ` Maurizio Boriani
2016-06-21 14:14     ` Ludovic Courtès
2016-06-21 15:09       ` 宋文武
2016-06-21 20:56         ` Ludovic Courtès
2016-09-16  3:36           ` guile-dbi: Use libltdl and prefer GUILE_DBD_PATH 宋文武
2016-09-16  6:57             ` baux
2017-07-10 22:54             ` Linas Vepstas
2017-07-11 11:02               ` 宋文武
2017-07-11 18:31                 ` Nala Ginrut

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).