GNU bug report logs - #32514
mailutils Guile bindings are broken

Previous Next

Package: guix;

Reported by: Ricardo Wurmus <rekado <at> elephly.net>

Date: Thu, 23 Aug 2018 20:18:01 UTC

Severity: normal

Done: Ricardo Wurmus <rekado <at> elephly.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 32514 in the body.
You can then email your comments to 32514 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#32514; Package guix. (Thu, 23 Aug 2018 20:18:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ricardo Wurmus <rekado <at> elephly.net>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Thu, 23 Aug 2018 20:18:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ricardo Wurmus <rekado <at> elephly.net>
To: bug-guix <at> gnu.org
Subject: mailutils Guile bindings are broken
Date: Thu, 23 Aug 2018 22:13:25 +0200
There are at least three problems with the Guile bindings for mailutils:

1. the Guile source files are not compiled.

2. the Guile source files are installed to $out/share/guile/site/ and
are thus not found with “,use (mailutils mailutils)” in a Guile REPL.

3. the Guile session segfaults when loading the module:

--8<---------------cut here---------------start------------->8---
rekado in debbugs [env]: guile
GNU Guile 2.2.4
Copyright (C) 1995-2017 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (add-to-load-path "/gnu/store/50lg0i5rqw1g7nf0ar2afgs788mgdjmq-mailutils-3.4/share/guile/site/")
scheme@(guile-user)> ,use (mailutils mailutils)
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /gnu/store/50lg0i5rqw1g7nf0ar2afgs788mgdjmq-mailutils-3.4/share/guile/site/mailutils/mailutils.scm
;;; compiled /home/rekado/.cache/guile/ccache/2.2-LE-8-3.A/gnu/store/50lg0i5rqw1g7nf0ar2afgs788mgdjmq-mailutils-3.4/share/guile/site/mailutils/mailutils.scm.go
Segmentation fault
rekado in debbugs [env]:
--8<---------------cut here---------------end--------------->8---

Are the bindings not usable with Guile 2.2?

--
Ricardo





Information forwarded to bug-guix <at> gnu.org:
bug#32514; Package guix. (Fri, 24 Aug 2018 10:40:02 GMT) Full text and rfc822 format available.

Message #8 received at 32514 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Ricardo Wurmus <rekado <at> elephly.net>
Cc: 32514 <at> debbugs.gnu.org
Subject: Re: bug#32514: mailutils Guile bindings are broken
Date: Fri, 24 Aug 2018 12:39:24 +0200
[Message part 1 (text/plain, inline)]
Hi!

Ricardo Wurmus <rekado <at> elephly.net> skribis:

> Are the bindings not usable with Guile 2.2?

No, but I have good news: those in Mailutils master are usable.  Here’s
a recipe:

--8<---------------cut here---------------start------------->8---
(define-public mailutils-next
  ;; This version of Mailutils supports Guile 2.2, unlike version <= 3.4.
  (let ((commit "62666075e3c7276d308dffef42c7c50dc526925b")
        (revision "0"))
    (package
      (inherit mailutils)
      (version (string-append (package-version mailutils)
                              "-" revision "." (string-take commit 7)))
      (source (origin
                (method git-fetch)
                (uri (git-reference
                      (url "https://git.savannah.gnu.org/git/mailutils.git")
                      (commit commit)
                      (recursive? #t)))           ;for Gnulib & co.
                (sha256
                 (base32
                  "1m4cbjn02hklp6li14ajfzfg29ibbk38n0c3g8vyfx71iy0pxpnb"))
                (file-name (string-append "mailutils-" version "-checkout"))))
      (outputs '("out" "debug"))
      (inputs
       `(("guile" ,guile-2.2)
         ("gsasl" ,gsasl)                         ;for SMTP authentication
         ,@(alist-delete "guile" (package-inputs mailutils))))
      (native-inputs
       `(("autoconf" ,autoconf-wrapper)
         ("automake" ,automake)
         ("libtool" ,libtool)
         ("gettext" ,gnu-gettext)
         ,@(package-native-inputs mailutils)))
      (arguments
       (substitute-keyword-arguments (package-arguments mailutils)
         ((#:modules modules %gnu-build-system-modules)
          `((srfi srfi-1) ,@modules))
         ((#:configure-flags flags ''())
          `(cons* "--disable-radius"

                  ;; Add "/2.2" to the installation directory.
                  (string-append "--with-guile-site-dir="
                                 (assoc-ref %outputs "out")
                                 "/share/guile/site/2.2")
                  ,flags))
         ((#:phases phases)
          `(modify-phases ,phases
             (replace 'bootstrap
               (lambda* (#:key inputs #:allow-other-keys)
                 (for-each patch-shebang
                           '("bootstrap" "gnulib/gnulib-tool"))
                 (substitute* "bootstrap.conf"
                   (("git submodule" all)
                    (string-append "#" all)))
                 (for-each make-file-writable (find-files "gnulib"))
                 (substitute* "configure.ac"
                   (("AM_GNU_RADIUS") ""))
                 (invoke "./bootstrap" "--no-git" "--skip-po"
                         (string-append "--gnulib-srcdir=gnulib"))
                 #t))
             (delete 'prepare-test-suite)))
         ((#:parallel-build? _ #f)                ;due to parser.y
          #f)
         ((#:tests? _ #f)                         ;XXX
          #f))))))
--8<---------------cut here---------------end--------------->8---

Below is a simple example to get started.  The Mailutils API is not this
complicated but it took me a while to figure it out, so you might find
that module helpful.

Happy emailing!  :-)

Ludo’.

[email.scm (text/plain, inline)]
;;; This module is licensed under the same terms, those of the GNU GPL
;;; version 3 or (at your option) any later version.
;;;
;;; Copyright © 2018 Ludovic Courtès <ludo <at> gnu.org>

(define-module (email)
  #:use-module ((guix build utils) #:select (dump-port))
  #:use-module (guix base64)
  #:use-module (rnrs io ports)
  #:use-module (rnrs bytevectors)
  #:use-module (mailutils mailutils)
  #:export (compose-message
            send-message))

;; This variable is looked up by 'mu-message-send', uh!
(define-public mu-debug 0)

(define* (insert-newlines str #:optional (line-length 76))
  "Insert newlines in STR every LINE-LENGTH characters."
  (let loop ((result '())
             (str str))
    (if (string-null? str)
        (string-concatenate-reverse result)
        (let* ((length (min (string-length str) line-length))
               (prefix (string-take str length))
               (suffix (string-drop str length)))
          (loop (cons (string-append prefix "\n") result)
                suffix)))))

(define* (compose-message from to
                          #:key text subject file)
  "Compose a message, and return a message object."
  (let* ((mime    (mu-mime-create))
         (message (mu-message-create))
         (body    (mu-message-get-port message "w")))
    (mu-message-set-header message
                           "Content-Type"
                           "text/plain; charset=utf-8")

    (put-bytevector body (string->utf8 text))
    (close-port body)
    (mu-mime-add-part mime message)

    (when file
      (let* ((attach (mu-message-create))
             (port   (mu-message-get-port attach "w")))
        (display (insert-newlines
                  (base64-encode (call-with-input-file file
                                   get-bytevector-all)))
                 port)
        (close-port port)
        (mu-message-set-header attach
                               "Content-Transfer-Encoding"
                               "base64")
        (mu-message-set-header attach
                               "Content-Type" "image/jpeg")
        (mu-message-set-header attach
                               "Content-Disposition" "inline")
        (mu-mime-add-part mime attach)))

    (let ((result (mu-mime-get-message mime)))
      (mu-message-set-header result "From" from)
      (mu-message-set-header result "To" to)
      (when subject
        (mu-message-set-header result "Subject" subject))
      result)))

(define (display-body message)                    ;debug
  (let ((port (mu-message-get-port message "r")))
    (dump-port port (current-error-port))
    (close-port port)))

(define (send-message message)
  "Send MESSAGE, a message returned by 'compose-message', using the SMTP
parameters found in ~/.config/smtp."
  (define uri
    ;; Something like "smtp://USER:SECRET <at> SERVER:PORT" (info "(mailutils)
    ;; SMTP Mailboxes").
    (call-with-input-file (string-append (getenv "HOME") "/.config/smtp")
      read))

  (mu-register-format "smtp")
  (mu-message-send message uri))

Information forwarded to bug-guix <at> gnu.org:
bug#32514; Package guix. (Fri, 24 Aug 2018 10:40:03 GMT) Full text and rfc822 format available.

Message #11 received at 32514 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Ricardo Wurmus <rekado <at> elephly.net>
Cc: 32514 <at> debbugs.gnu.org
Subject: Re: bug#32514: mailutils Guile bindings are broken
Date: Fri, 24 Aug 2018 12:39:48 +0200
[Message part 1 (text/plain, inline)]
Hi!

Ricardo Wurmus <rekado <at> elephly.net> skribis:

> Are the bindings not usable with Guile 2.2?

No, but I have good news: those in Mailutils master are usable.  Here’s
a recipe:

--8<---------------cut here---------------start------------->8---
(define-public mailutils-next
  ;; This version of Mailutils supports Guile 2.2, unlike version <= 3.4.
  (let ((commit "62666075e3c7276d308dffef42c7c50dc526925b")
        (revision "0"))
    (package
      (inherit mailutils)
      (version (string-append (package-version mailutils)
                              "-" revision "." (string-take commit 7)))
      (source (origin
                (method git-fetch)
                (uri (git-reference
                      (url "https://git.savannah.gnu.org/git/mailutils.git")
                      (commit commit)
                      (recursive? #t)))           ;for Gnulib & co.
                (sha256
                 (base32
                  "1m4cbjn02hklp6li14ajfzfg29ibbk38n0c3g8vyfx71iy0pxpnb"))
                (file-name (string-append "mailutils-" version "-checkout"))))
      (outputs '("out" "debug"))
      (inputs
       `(("guile" ,guile-2.2)
         ("gsasl" ,gsasl)                         ;for SMTP authentication
         ,@(alist-delete "guile" (package-inputs mailutils))))
      (native-inputs
       `(("autoconf" ,autoconf-wrapper)
         ("automake" ,automake)
         ("libtool" ,libtool)
         ("gettext" ,gnu-gettext)
         ,@(package-native-inputs mailutils)))
      (arguments
       (substitute-keyword-arguments (package-arguments mailutils)
         ((#:modules modules %gnu-build-system-modules)
          `((srfi srfi-1) ,@modules))
         ((#:configure-flags flags ''())
          `(cons* "--disable-radius"

                  ;; Add "/2.2" to the installation directory.
                  (string-append "--with-guile-site-dir="
                                 (assoc-ref %outputs "out")
                                 "/share/guile/site/2.2")
                  ,flags))
         ((#:phases phases)
          `(modify-phases ,phases
             (replace 'bootstrap
               (lambda* (#:key inputs #:allow-other-keys)
                 (for-each patch-shebang
                           '("bootstrap" "gnulib/gnulib-tool"))
                 (substitute* "bootstrap.conf"
                   (("git submodule" all)
                    (string-append "#" all)))
                 (for-each make-file-writable (find-files "gnulib"))
                 (substitute* "configure.ac"
                   (("AM_GNU_RADIUS") ""))
                 (invoke "./bootstrap" "--no-git" "--skip-po"
                         (string-append "--gnulib-srcdir=gnulib"))
                 #t))
             (delete 'prepare-test-suite)))
         ((#:parallel-build? _ #f)                ;due to parser.y
          #f)
         ((#:tests? _ #f)                         ;XXX
          #f))))))
--8<---------------cut here---------------end--------------->8---

Below is a simple example to get started.  The Mailutils API is not this
complicated but it took me a while to figure it out, so you might find
that module helpful.

Happy emailing!  :-)

Ludo’.

[email.scm (text/plain, inline)]
;;; This module is licensed under the same terms, those of the GNU GPL
;;; version 3 or (at your option) any later version.
;;;
;;; Copyright © 2018 Ludovic Courtès <ludo <at> gnu.org>

(define-module (email)
  #:use-module ((guix build utils) #:select (dump-port))
  #:use-module (guix base64)
  #:use-module (rnrs io ports)
  #:use-module (rnrs bytevectors)
  #:use-module (mailutils mailutils)
  #:export (compose-message
            send-message))

;; This variable is looked up by 'mu-message-send', uh!
(define-public mu-debug 0)

(define* (insert-newlines str #:optional (line-length 76))
  "Insert newlines in STR every LINE-LENGTH characters."
  (let loop ((result '())
             (str str))
    (if (string-null? str)
        (string-concatenate-reverse result)
        (let* ((length (min (string-length str) line-length))
               (prefix (string-take str length))
               (suffix (string-drop str length)))
          (loop (cons (string-append prefix "\n") result)
                suffix)))))

(define* (compose-message from to
                          #:key text subject file)
  "Compose a message, and return a message object."
  (let* ((mime    (mu-mime-create))
         (message (mu-message-create))
         (body    (mu-message-get-port message "w")))
    (mu-message-set-header message
                           "Content-Type"
                           "text/plain; charset=utf-8")

    (put-bytevector body (string->utf8 text))
    (close-port body)
    (mu-mime-add-part mime message)

    (when file
      (let* ((attach (mu-message-create))
             (port   (mu-message-get-port attach "w")))
        (display (insert-newlines
                  (base64-encode (call-with-input-file file
                                   get-bytevector-all)))
                 port)
        (close-port port)
        (mu-message-set-header attach
                               "Content-Transfer-Encoding"
                               "base64")
        (mu-message-set-header attach
                               "Content-Type" "image/jpeg")
        (mu-message-set-header attach
                               "Content-Disposition" "inline")
        (mu-mime-add-part mime attach)))

    (let ((result (mu-mime-get-message mime)))
      (mu-message-set-header result "From" from)
      (mu-message-set-header result "To" to)
      (when subject
        (mu-message-set-header result "Subject" subject))
      result)))

(define (display-body message)                    ;debug
  (let ((port (mu-message-get-port message "r")))
    (dump-port port (current-error-port))
    (close-port port)))

(define (send-message message)
  "Send MESSAGE, a message returned by 'compose-message', using the SMTP
parameters found in ~/.config/smtp."
  (define uri
    ;; Something like "smtp://USER:SECRET <at> SERVER:PORT" (info "(mailutils)
    ;; SMTP Mailboxes").
    (call-with-input-file (string-append (getenv "HOME") "/.config/smtp")
      read))

  (mu-register-format "smtp")
  (mu-message-send message uri))

Reply sent to Ricardo Wurmus <rekado <at> elephly.net>:
You have taken responsibility. (Fri, 24 Aug 2018 18:21:02 GMT) Full text and rfc822 format available.

Notification sent to Ricardo Wurmus <rekado <at> elephly.net>:
bug acknowledged by developer. (Fri, 24 Aug 2018 18:21:02 GMT) Full text and rfc822 format available.

Message #16 received at 32514-done <at> debbugs.gnu.org (full text, mbox):

From: Ricardo Wurmus <rekado <at> elephly.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 32514-done <at> debbugs.gnu.org
Subject: Re: bug#32514: mailutils Guile bindings are broken
Date: Fri, 24 Aug 2018 20:05:26 +0200
Hi!

>> Are the bindings not usable with Guile 2.2?
>
> No, but I have good news: those in Mailutils master are usable.  Here’s
> a recipe: […]
> Below is a simple example to get started.  The Mailutils API is not this
> complicated but it took me a while to figure it out, so you might find
> that module helpful.

Thank you!

I was hoping to use some procedures from Mailutils to simplify parsing
Debbugs emails, so that I don’t have to implement, say, a parser for
Quoted Printable string encodings.  I’ll play with this for a while.

I’m closing this bug now, because I guess this will all be fine with the
next release.

--
Ricardo





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 22 Sep 2018 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 274 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.