all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* guile-gdbm doesn't work with gdbm-1.14
@ 2018-03-18  8:39 宋文武
  2018-03-18 13:50 ` Mark H Weaver
  0 siblings, 1 reply; 5+ messages in thread
From: 宋文武 @ 2018-03-18  8:39 UTC (permalink / raw)
  To: guix-devel, guile-user

Hello, since version 1.14, gdbm doesn't export "gdbm_errno" anymore [1],
so the guile-gdbm ffi binding code [2] need updates now (I'm not
confident to do it myself...).

[1] http://git.gnu.org.ua/cgit/gdbm.git/commit/?id=c175231e2781abd17eabf412cfb597654a076c7b
[2] https://github.com/ijp/guile-gdbm/blob/master/gdbm.scm#L156

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

* Re: guile-gdbm doesn't work with gdbm-1.14
  2018-03-18  8:39 guile-gdbm doesn't work with gdbm-1.14 宋文武
@ 2018-03-18 13:50 ` Mark H Weaver
  2018-03-19 10:20   ` Ricardo Wurmus
  2018-03-19 16:47   ` Ludovic Courtès
  0 siblings, 2 replies; 5+ messages in thread
From: Mark H Weaver @ 2018-03-18 13:50 UTC (permalink / raw)
  To: 宋文武; +Cc: guix-devel, guile-user

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

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

> Hello, since version 1.14, gdbm doesn't export "gdbm_errno" anymore [1],
> so the guile-gdbm ffi binding code [2] need updates now (I'm not
> confident to do it myself...).
>
> [1] http://git.gnu.org.ua/cgit/gdbm.git/commit/?id=c175231e2781abd17eabf412cfb597654a076c7b
> [2] https://github.com/ijp/guile-gdbm/blob/master/gdbm.scm#L156

Here's a preliminary fix.

      Mark



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] gnu: guile-gdbm-ffi: Add support for gdbm-1.14 --]
[-- Type: text/x-patch, Size: 5197 bytes --]

From 353abb66adb756c0ad51b4784004034a8a06de8c Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@netris.org>
Date: Sun, 18 Mar 2018 08:43:06 -0400
Subject: [PATCH] gnu: guile-gdbm-ffi: Add support for gdbm-1.14.

* gnu/packages/patches/guile-gdbm-ffi-support-gdbm-1.14.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/guile.scm (guile-gdbm-ffi)[native-inputs]: New field.
[inputs]: Move above arguments.  Add the patch, and the 'patch' program.
[propagated-inputs]: Move above arguments.
[arguments]: In the builder, add code to apply the patch.
---
 gnu/local.mk                                       |  1 +
 gnu/packages/guile.scm                             | 21 +++++++--
 .../patches/guile-gdbm-ffi-support-gdbm-1.14.patch | 53 ++++++++++++++++++++++
 3 files changed, 71 insertions(+), 4 deletions(-)
 create mode 100644 gnu/packages/patches/guile-gdbm-ffi-support-gdbm-1.14.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 010f1417f..a03b482df 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -742,6 +742,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/guile-1.8-cpp-4.5.patch			\
   %D%/packages/patches/guile-2.2-default-utf8.patch		\
   %D%/packages/patches/guile-default-utf8.patch			\
+  %D%/packages/patches/guile-gdbm-ffi-support-gdbm-1.14.patch	\
   %D%/packages/patches/guile-linux-syscalls.patch		\
   %D%/packages/patches/guile-present-coding.patch		\
   %D%/packages/patches/guile-relocatable.patch			\
diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm
index 1c8eaa9ec..f6f8ef9b9 100644
--- a/gnu/packages/guile.scm
+++ b/gnu/packages/guile.scm
@@ -1134,6 +1134,15 @@ inspired by the SCSH regular expression system.")
                (base32
                 "1j8wrsw7v9w6qkl47xz0rdikg50v16nn6kbs3lgzcymjzpa7babj"))))
     (build-system trivial-build-system)
+    (inputs
+     `(("guile" ,guile-2.2)
+       ;; patch-and-repack doesn't work for git checkouts,
+       ;; so we must apply the patch manually.
+       ("patch" ,patch)
+       ("patch-file" ,(search-patch
+                       "guile-gdbm-ffi-support-gdbm-1.14.patch"))))
+    (propagated-inputs
+     `(("gdbm" ,gdbm)))
     (arguments
      `(#:modules
        ((guix build utils))
@@ -1186,12 +1195,16 @@ inspired by the SCSH regular expression system.")
               (format #f "(dynamic-link \"~a/lib/libgdbm.so\")"
                       (assoc-ref %build-inputs "gdbm"))))
 
+           ;; Apply the patch to add support for gdbm-1.14.
+           (let ((patch-command (string-append (assoc-ref %build-inputs "patch")
+                                               "/bin/patch"))
+                 (patch-file (assoc-ref %build-inputs "patch-file")))
+             (with-directory-excursion (dirname gdbm.scm-dest)
+               (format #t "applying '~a'...~%" patch-file)
+               (invoke patch-command "--force" "--input" patch-file)))
+
            ;; compile to the destination
            (compile-file gdbm.scm-dest gdbm.go-dest)))))
-    (inputs
-     `(("guile" ,guile-2.2)))
-    (propagated-inputs
-     `(("gdbm" ,gdbm)))
     (home-page "https://github.com/ijp/guile-gdbm")
     (synopsis "Guile bindings to the GDBM library via Guile's FFI")
     (description
diff --git a/gnu/packages/patches/guile-gdbm-ffi-support-gdbm-1.14.patch b/gnu/packages/patches/guile-gdbm-ffi-support-gdbm-1.14.patch
new file mode 100644
index 000000000..e6b578bdb
--- /dev/null
+++ b/gnu/packages/patches/guile-gdbm-ffi-support-gdbm-1.14.patch
@@ -0,0 +1,53 @@
+From 1da99396dc65993ba34ac0370ca5d6acda6a3322 Mon Sep 17 00:00:00 2001
+From: Mark H Weaver <mhw@netris.org>
+Date: Sun, 18 Mar 2018 07:02:37 -0400
+Subject: [PATCH] Add support for gdbm-1.14.
+
+As of gdbm-1.14, 'gdbm_errno' no longer exists as a binary interface.
+It has been replaced by 'gdbm_errno_location', a function that returns
+int*.  We now use this new interface if it's available.
+---
+ gdbm.scm | 18 ++++++++++++++++--
+ 1 file changed, 16 insertions(+), 2 deletions(-)
+
+diff --git a/gdbm.scm b/gdbm.scm
+index b92992f..4d38cc3 100644
+--- a/gdbm.scm
++++ b/gdbm.scm
+@@ -17,6 +17,9 @@
+ ;; You should have received a copy of the GNU General Public License
+ ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+ 
++;; Modified by Mark H Weaver <mhw@netris.org> in March 2018 to support
++;; gdbm-1.14 with its new 'gdbm_errno_location' interface.
++
+ (define-module (gdbm)
+   #:use-module (system foreign)
+   #:use-module (rnrs bytevectors)
+@@ -151,10 +154,21 @@
+ 
+ ;;; errors
+ 
+-(define %errno (dynamic-pointer "gdbm_errno" libgdbm))
++(define %list-int
++  (list int))
++
++(define (dereference-int ptr)
++  (apply (lambda (errno) errno)
++         (parse-c-struct ptr %list-int)))
++
++(define %errno-location
++  (or (false-if-exception
++       (let ((func (dynamic-func "gdbm_errno_location" libgdbm)))
++         (pointer->procedure '* func '())))
++      (const (dynamic-pointer "gdbm_errno" libgdbm))))
+ 
+ (define (gdbm-errno)
+-  (pointer-address (dereference-pointer %errno)))
++  (dereference-int (%errno-location)))
+ 
+ (define (gdbm-error)
+   (error (pointer->string (%gdbm-strerror (gdbm-errno)))))
+-- 
+2.16.2
+
-- 
2.16.2


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

* Re: guile-gdbm doesn't work with gdbm-1.14
  2018-03-18 13:50 ` Mark H Weaver
@ 2018-03-19 10:20   ` Ricardo Wurmus
  2018-03-19 16:17     ` Mark H Weaver
  2018-03-19 16:47   ` Ludovic Courtès
  1 sibling, 1 reply; 5+ messages in thread
From: Ricardo Wurmus @ 2018-03-19 10:20 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: guix-devel, guile-user


Mark H Weaver <mhw@netris.org> writes:

> iyzsong@member.fsf.org (宋文武) writes:
>
>> Hello, since version 1.14, gdbm doesn't export "gdbm_errno" anymore [1],
>> so the guile-gdbm ffi binding code [2] need updates now (I'm not
>> confident to do it myself...).
>>
>> [1] http://git.gnu.org.ua/cgit/gdbm.git/commit/?id=c175231e2781abd17eabf412cfb597654a076c7b
>> [2] https://github.com/ijp/guile-gdbm/blob/master/gdbm.scm#L156
>
> Here's a preliminary fix.

Thank you.

> * gnu/packages/patches/guile-gdbm-ffi-support-gdbm-1.14.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Add it.
> * gnu/packages/guile.scm (guile-gdbm-ffi)[native-inputs]: New field.
> [inputs]: Move above arguments.  Add the patch, and the 'patch' program.
> [propagated-inputs]: Move above arguments.
> [arguments]: In the builder, add code to apply the patch.

I don’t see the native-inputs field in the patch.  Shouldn’t the “patch”
and “patch-file” inputs be native-inputs?

-- 
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

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

* Re: guile-gdbm doesn't work with gdbm-1.14
  2018-03-19 10:20   ` Ricardo Wurmus
@ 2018-03-19 16:17     ` Mark H Weaver
  0 siblings, 0 replies; 5+ messages in thread
From: Mark H Weaver @ 2018-03-19 16:17 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel, guile-user

Ricardo Wurmus <rekado@elephly.net> writes:

> Mark H Weaver <mhw@netris.org> writes:
>
>> iyzsong@member.fsf.org (宋文武) writes:
>>
>>> Hello, since version 1.14, gdbm doesn't export "gdbm_errno" anymore [1],
>>> so the guile-gdbm ffi binding code [2] need updates now (I'm not
>>> confident to do it myself...).
>>>
>>> [1] http://git.gnu.org.ua/cgit/gdbm.git/commit/?id=c175231e2781abd17eabf412cfb597654a076c7b
>>> [2] https://github.com/ijp/guile-gdbm/blob/master/gdbm.scm#L156
>>
>> Here's a preliminary fix.
>
> Thank you.
>
>> * gnu/packages/patches/guile-gdbm-ffi-support-gdbm-1.14.patch: New file.
>> * gnu/local.mk (dist_patch_DATA): Add it.
>> * gnu/packages/guile.scm (guile-gdbm-ffi)[native-inputs]: New field.
>> [inputs]: Move above arguments.  Add the patch, and the 'patch' program.
>> [propagated-inputs]: Move above arguments.
>> [arguments]: In the builder, add code to apply the patch.
>
> I don’t see the native-inputs field in the patch.

Indeed, sorry for the mistake in the commit log.  Initially I made them
native inputs, but then I moved them to 'inputs'.

> Shouldn’t the “patch” and “patch-file” inputs be native-inputs?

Yes.  However, I noticed that the package already assumes a native
build, because it runs 'guile' from 'inputs' to compile the Scheme code.
Also, I wasn't sure off-hand how native-inputs are handled in the
trivial-build-system.

For purposes of this commit, I didn't want to take on the job of also
fixing this package for cross-building, which I was likely to get wrong
without testing.  Given that I no longer use substitutes, that would
have been a big job.

Does that make sense?

      Mark

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

* Re: guile-gdbm doesn't work with gdbm-1.14
  2018-03-18 13:50 ` Mark H Weaver
  2018-03-19 10:20   ` Ricardo Wurmus
@ 2018-03-19 16:47   ` Ludovic Courtès
  1 sibling, 0 replies; 5+ messages in thread
From: Ludovic Courtès @ 2018-03-19 16:47 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: guix-devel, guile-user, Ian Price

Hello,

Mark H Weaver <mhw@netris.org> skribis:

> iyzsong@member.fsf.org (宋文武) writes:
>
>> Hello, since version 1.14, gdbm doesn't export "gdbm_errno" anymore [1],
>> so the guile-gdbm ffi binding code [2] need updates now (I'm not
>> confident to do it myself...).

Thanks, Mark for the quick fix.

> --- /dev/null
> +++ b/gnu/packages/patches/guile-gdbm-ffi-support-gdbm-1.14.patch
> @@ -0,0 +1,53 @@
> +From 1da99396dc65993ba34ac0370ca5d6acda6a3322 Mon Sep 17 00:00:00 2001
> +From: Mark H Weaver <mhw@netris.org>
> +Date: Sun, 18 Mar 2018 07:02:37 -0400
> +Subject: [PATCH] Add support for gdbm-1.14.
> +
> +As of gdbm-1.14, 'gdbm_errno' no longer exists as a binary interface.
> +It has been replaced by 'gdbm_errno_location', a function that returns
> +int*.  We now use this new interface if it's available.

Ian, could you consider applying this patch upstream?

Thanks!

Ludo’.

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

end of thread, other threads:[~2018-03-19 16:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-18  8:39 guile-gdbm doesn't work with gdbm-1.14 宋文武
2018-03-18 13:50 ` Mark H Weaver
2018-03-19 10:20   ` Ricardo Wurmus
2018-03-19 16:17     ` Mark H Weaver
2018-03-19 16:47   ` Ludovic Courtès

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.