From b35b72a0c85b2b147067de563fde72fc50d1a3a4 Mon Sep 17 00:00:00 2001
From: Raghav Gururajan <raghavgururajan@disroot.org>
Date: Wed, 6 May 2020 09:04:52 -0400
Subject: [PATCH] gnu: claws-mail: Fix fhs directories.

* gnu/packages/mail.scm (claws-mail):
[build-system]: Change from gnu to glib-or-gtk; as the latter is
more appropriate for glib/gtk based applications.
[inputs]: Add bash, cairo, compface, dbus, fontconfig, gdk-pibuf,
glib, gobject-introspection, gumbo-parser, libgdata, librsvg,
libsoup, mailutils, nettle, openldap, poppler, python-wrapper,
python2-pygtk and webkitgtk; for additional functionalities.
[inputs]: Remove hicolor-icon-theme, libsm and libxml2; as they are
no longer required.
[arguments]: Remove all configure flags; as they are not required.
[arguments]: Remove phase 'patch-mime.
[arguments]: Add phase 'patch-fhs-dirs.
---
 gnu/packages/mail.scm | 74 ++++++++++++++++++++++++++++++-------------
 1 file changed, 52 insertions(+), 22 deletions(-)

diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
index 2a6286fb16..a5d06db8f6 100644
--- a/gnu/packages/mail.scm
+++ b/gnu/packages/mail.scm
@@ -72,6 +72,7 @@
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages emacs)
   #:use-module (gnu packages enchant)
+  #:use-module (gnu packages fontutils)
   #:use-module (gnu packages gdb)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages ghostscript)
@@ -97,10 +98,12 @@
   #:use-module (gnu packages m4)
   #:use-module (gnu packages man)
   #:use-module (gnu packages ncurses)
+  #:use-module (gnu packages nettle)
   #:use-module (gnu packages networking)
   #:use-module (gnu packages openldap)
   #:use-module (gnu packages onc-rpc)
   #:use-module (gnu packages pcre)
+  #:use-module (gnu packages pdf)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages perl-check)
   #:use-module (gnu packages perl-web)
@@ -138,6 +141,7 @@
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix utils)
+  #:use-module (guix build-system glib-or-gtk)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system guile)
   #:use-module (guix build-system perl)
@@ -1167,46 +1171,72 @@ compresses it.")
               (sha256
                (base32
                 "1gjrmdmhc7zzilrlss9yl86ybv9sra8v0qi7mkwv7d9azidx5kns"))))
-    (build-system gnu-build-system)
+    (build-system glib-or-gtk-build-system)
     (native-inputs `(("pkg-config" ,pkg-config)))
-    (inputs `(("bogofilter" ,bogofilter)
+    (inputs `(("bash" ,bash)
+              ("bogofilter" ,bogofilter)
+              ("cairo" ,cairo)
+              ("compface" ,compface)
               ("curl" ,curl)
               ("dbus-glib" ,dbus-glib)
+              ("dbus" ,dbus)
               ("enchant" ,enchant)
               ("expat" ,expat)
+              ("fontconfig" ,fontconfig)
+              ("gdk-pxbuf" ,gdk-pixbuf)
               ("ghostscript" ,ghostscript)
-              ("hicolor-icon-theme" ,hicolor-icon-theme)
+              ("glib" ,glib)
               ("gnupg" ,gnupg)
               ("gnutls" ,gnutls)
+              ("gobject-introspection" ,gobject-introspection)
               ("gpgme" ,gpgme)
               ("gtk" ,gtk+-2)
+              ("gumbo-parser" ,gumbo-parser)
               ("libarchive" ,libarchive)
               ("libcanberra" ,libcanberra)
               ("libetpan" ,libetpan)
+              ("libgdata" ,libgdata)
               ("libical" ,libical)
               ("libnotify" ,libnotify)
-              ("libsm" ,libsm)
-              ("libxml2" ,libxml2)
+              ("librsvg" ,librsvg)
+              ("libsoup" ,libsoup)
+              ("mailutils" ,mailutils)
+              ("nettle" ,nettle)
+              ("openldap" ,openldap)
               ("perl" ,perl)
+              ("poppler" ,poppler)
               ("python-2" ,python-2)
-              ("mime-info" ,shared-mime-info)
-              ("startup-notification" ,startup-notification)))
+              ("python-wrapper" ,python-wrapper)
+              ("python2-pygtk" ,python2-pygtk)
+              ("shared-mime-info" ,shared-mime-info)
+              ("startup-notification" ,startup-notification)
+              ("webkitgtk" ,webkitgtk)))
     (arguments
-      '(#:configure-flags
-        '("--enable-gnutls" "--enable-pgpmime-plugin" "--enable-enchant"
-          "--enable-ldap")
-        #:make-flags
-        ;; Disable updating icon cache since it's done by the profile hook.
-        ;; Conflict with other packages in the profile would be inevitable
-        ;; otherwise.
-        '("gtk_update_icon_cache=true")
-        #:phases (modify-phases %standard-phases
-                   (add-before 'build 'patch-mime
-                     (lambda* (#:key inputs #:allow-other-keys)
-                       (substitute* "src/procmime.c"
-                         (("/usr/share/mime/globs")
-                          (string-append (assoc-ref inputs "mime-info")
-                                         "/share/mime/globs"))))))))
+     '(#:make-flags
+       ;; Disable updating icon cache since it's done by the profile hook.
+       ;; Conflict with other packages in the profile would be inevitable
+       ;; otherwise.
+       '("gtk_update_icon_cache=true")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-fhs-dirs
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let*
+                 ((sh (string-append (assoc-ref inputs "bash")
+                                     "/bin/sh"))
+                  (inc (string-append (assoc-ref inputs "mailutils")
+                                      "/bin/mu-mh/inc"))
+                  (send (string-append (assoc-ref inputs "mailutils")
+                                       "/bin/mu-mh/send"))
+                  (globs (string-append (assoc-ref inputs "shared-mime-info")
+                                        "/share/mime/globs")))
+               (with-directory-excursion "src"
+                 (substitute* '("action.c" "common/defs.h" "etpan/imap-thread.c")
+                   (("/bin/sh") sh)
+                   (("/usr/bin/mh/inc") inc)
+                   (("/usr/sbin/sendmail") send)
+                   (("/usr/share/mime/globs") globs)))
+               #t))))))
     (synopsis "GTK-based Email client")
     (description
      "Claws-Mail is an email client (and news reader) based on GTK+.  The
-- 
2.26.2

