[gimp] plug-ins: sendmail is also a runtime dependency.



commit 0d8d5a0cfe4dbff4e81ffbf030d6db1e1ab4c6f5
Author: Jehan <jehan girinstud io>
Date:   Sat May 28 00:51:24 2016 +0200

    plug-ins: sendmail is also a runtime dependency.
    
    Such as `xdg-email`, if --with-sendmail is set, sendmail presence should
    actually be checked at runtime and not be a blocker during build.

 configure.ac           |    9 ++++-----
 plug-ins/common/mail.c |   39 +++++++++++++++------------------------
 2 files changed, 19 insertions(+), 29 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f6ef129..86cbf3d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1834,7 +1834,7 @@ have_email="no (xdg-email not found)"
 AC_ARG_WITH(sendmail,[  --with-sendmail[=DIR]   use sendmail instead of xdg-email])
 
 have_sendmail=no
-# Sendmail must be explicitely enabled.
+# Sendmail must be explicitely enabled to replace xdg-email implementation.
 if test "x$with_sendmail" != "x" && test "x$with_sendmail" != "xno"; then
   if test "x$with_sendmail" = "xyes"; then
       sendmail_path=$PATH:/usr/sbin:/usr/lib
@@ -1845,14 +1845,13 @@ if test "x$with_sendmail" != "x" && test "x$with_sendmail" != "xno"; then
   AC_PATH_PROG(SENDMAIL, sendmail, , $sendmail_path)
   if test "x$SENDMAIL" != "x"; then
     have_email="yes (sendmail)"
-    have_sendmail=yes
     AC_DEFINE_UNQUOTED(SENDMAIL, "$SENDMAIL",
                        [The MTA used by the mail plug-in.])
   else
-    AC_MSG_ERROR([
-*** Check for sendmail failed, though it was explicitly enabled with --with-sendmail.
-*** If you know where it is installed, you may configure --with-sendmail=/path/to/bin/.])
+    # Not having sendmail at runtime is not a blocker.
+    have_email="needs runtime dependency: sendmail"
   fi
+  have_sendmail=yes
 fi
 
 if test "x$have_sendmail" = xno; then
diff --git a/plug-ins/common/mail.c b/plug-ins/common/mail.c
index accca7c..4127b80 100644
--- a/plug-ins/common/mail.c
+++ b/plug-ins/common/mail.c
@@ -111,6 +111,8 @@ MAIN ()
 static void
 query (void)
 {
+  gchar *email_bin;
+
   static const GimpParamDef args[] =
   {
     { GIMP_PDB_INT32,    "run-mode",      "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
@@ -124,32 +126,17 @@ query (void)
     { GIMP_PDB_INT32,    "encapsulation", "ignored" }
   };
 
-#ifndef SENDMAIL /* xdg-email */
-  /* check if xdg-email is installed
+  /* check if xdg-email or sendmail is installed
    * TODO: allow setting the location of the executable in preferences
    */
-  gchar    *argv[]         = { "xdg-email", "--version", NULL };
-  gboolean  have_xdg_email = FALSE;
-
-  if (g_spawn_sync (NULL,
-                    argv,
-                    NULL,
-                    G_SPAWN_STDERR_TO_DEV_NULL |
-                    G_SPAWN_STDOUT_TO_DEV_NULL |
-                    G_SPAWN_SEARCH_PATH,
-                    NULL,
-                    NULL,
-                    NULL,
-                    NULL,
-                    NULL,
-                    NULL))
-    {
-      have_xdg_email = TRUE;
-    }
+#ifdef SENDMAIL
+  email_bin = g_find_program_in_path ("sendmail");
+#else
+  email_bin = g_find_program_in_path ("xdg-email");
+#endif
 
-  if (! have_xdg_email)
+  if (email_bin == NULL)
     return;
-#endif
 
   gimp_install_procedure (PLUG_IN_PROC,
                           N_("Send the image by email"),
@@ -171,6 +158,8 @@ query (void)
   gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/File/Send");
   gimp_plugin_icon_register (PLUG_IN_PROC, GIMP_ICON_TYPE_ICON_NAME,
                              (const guint8 *) GTK_STOCK_EDIT);
+
+  g_free (email_bin);
 }
 
 static void
@@ -400,7 +389,7 @@ send_image (const gchar *filename,
 
 #else /* SENDMAIL */
   /* construct the "sendmail user location" line */
-  mailcmd[0] = SENDMAIL;
+  mailcmd[0] = "sendmail";
   mailcmd[1] = mail_info.receipt;
   mailcmd[2] = NULL;
 
@@ -806,7 +795,9 @@ sendmail_pipe (gchar **cmd,
   gint    fd;
   GError *err = NULL;
 
-  if (! g_spawn_async_with_pipes (NULL, cmd, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
+  if (! g_spawn_async_with_pipes (NULL, cmd, NULL,
+                                  G_SPAWN_DO_NOT_REAP_CHILD |
+                                  G_SPAWN_SEARCH_PATH,
                                   NULL, NULL, pid, &fd, NULL, NULL, &err))
     {
       g_message (_("Could not start sendmail (%s)"), err->message);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]