* bug#32514: mailutils Guile bindings are broken
@ 2018-08-23 20:13 Ricardo Wurmus
2018-08-24 10:39 ` Ludovic Courtès
2018-08-24 10:39 ` Ludovic Courtès
0 siblings, 2 replies; 4+ messages in thread
From: Ricardo Wurmus @ 2018-08-23 20:13 UTC (permalink / raw)
To: 32514
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#32514: mailutils Guile bindings are broken
2018-08-23 20:13 bug#32514: mailutils Guile bindings are broken Ricardo Wurmus
@ 2018-08-24 10:39 ` Ludovic Courtès
2018-08-24 18:05 ` Ricardo Wurmus
2018-08-24 10:39 ` Ludovic Courtès
1 sibling, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2018-08-24 10:39 UTC (permalink / raw)
To: Ricardo Wurmus; +Cc: 32514
[-- Attachment #1: Type: text/plain, Size: 3273 bytes --]
Hi!
Ricardo Wurmus <rekado@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’.
[-- Attachment #2: the email module --]
[-- Type: text/plain, Size: 3114 bytes --]
;;; 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@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@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))
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#32514: mailutils Guile bindings are broken
2018-08-23 20:13 bug#32514: mailutils Guile bindings are broken Ricardo Wurmus
2018-08-24 10:39 ` Ludovic Courtès
@ 2018-08-24 10:39 ` Ludovic Courtès
1 sibling, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2018-08-24 10:39 UTC (permalink / raw)
To: Ricardo Wurmus; +Cc: 32514
[-- Attachment #1: Type: text/plain, Size: 3273 bytes --]
Hi!
Ricardo Wurmus <rekado@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’.
[-- Attachment #2: the email module --]
[-- Type: text/plain, Size: 3114 bytes --]
;;; 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@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@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))
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#32514: mailutils Guile bindings are broken
2018-08-24 10:39 ` Ludovic Courtès
@ 2018-08-24 18:05 ` Ricardo Wurmus
0 siblings, 0 replies; 4+ messages in thread
From: Ricardo Wurmus @ 2018-08-24 18:05 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 32514-done
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-08-24 18:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-23 20:13 bug#32514: mailutils Guile bindings are broken Ricardo Wurmus
2018-08-24 10:39 ` Ludovic Courtès
2018-08-24 18:05 ` Ricardo Wurmus
2018-08-24 10:39 ` 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.