unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#51853] [PATCH 0/2] gnu: sendgmail: Rename package; don't limit domain.
@ 2021-11-14 20:36 Philip McGrath
  2021-11-14 20:46 ` [bug#51853] [PATCH 1/2] gnu: sendgmail: Rename package to match command Philip McGrath
  0 siblings, 1 reply; 10+ messages in thread
From: Philip McGrath @ 2021-11-14 20:36 UTC (permalink / raw)
  To: 51853; +Cc: Philip McGrath

This patch series continues where the discussion
in <https://issues.guix.gnu.org/50420> left off.
For anyone who isn't aware of `sendgmail` at all,
one reason it's notable is that it's recommended
in <https://git-send-email.io/#step-2> (by the SourceHut developers).

The first commit renames the sendgmail package to match the name of the
command, rather than the (remarkably long) Go import path.

The second commit applies some patches to let the command also work for
non-`@gmail.com` email addresses, with an interface compatible with all known
forks. There's more detail on that below.

I am using the resulting package:

    /gnu/store/38bv07yrqzqwfgbdg8f1qswp1kpidw1l-sendgmail-0.0.0-1.e322915

to send these emails.

Philip McGrath (2):
  gnu: sendgmail: Rename package to match command.
  gnu: sendgmail: Don't limit domain name of sender.

 gnu/local.mk                                  |  2 +
 gnu/packages/golang.scm                       | 36 +---------------
 gnu/packages/mail.scm                         | 43 +++++++++++++++++++
 ...sendgmail-accept-ignored-gsuite-flag.patch | 39 +++++++++++++++++
 .../sendgmail-remove-domain-restriction.patch | 34 +++++++++++++++
 5 files changed, 119 insertions(+), 35 deletions(-)
 create mode 100644 gnu/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch
 create mode 100644 gnu/packages/patches/sendgmail-remove-domain-restriction.patch

-- 
2.32.0





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

* [bug#51853] [PATCH 1/2] gnu: sendgmail: Rename package to match command.
  2021-11-14 20:36 [bug#51853] [PATCH 0/2] gnu: sendgmail: Rename package; don't limit domain Philip McGrath
@ 2021-11-14 20:46 ` Philip McGrath
  2021-11-14 20:46   ` [bug#51853] [PATCH 2/2] gnu: sendgmail: Don't limit domain name of sender Philip McGrath
  2021-11-17 17:24   ` [bug#51853] [PATCH 1/2] gnu: sendgmail: Rename package to match command Liliana Marie Prikler
  0 siblings, 2 replies; 10+ messages in thread
From: Philip McGrath @ 2021-11-14 20:46 UTC (permalink / raw)
  To: 51853; +Cc: Philip McGrath

Suggested by Ludo’ in <https://issues.guix.gnu.org/50420#3>.

* gnu/packages/golang.scm
(go-github-com-google-gmail-oauth2-tools-go-sendgmail): Move to ...
* gnu/packages/mail.scm (sendgmail): ... this variable.
---
 gnu/packages/golang.scm | 36 +-----------------------------------
 gnu/packages/mail.scm   | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index cc2a4ebc16..aaf6194460 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -31,6 +31,7 @@
 ;;; Copyright © 2021 jgart <jgart@dismail.de>
 ;;; Copyright © 2021 Bonface Munyoki Kilyungi <me@bonfacemunyoki.com>
 ;;; Copyright © 2021 Chadwain Holness <chadwainholness@gmail.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -3036,41 +3037,6 @@ (define-public go-cloud-google-com-go-compute-metadata
 API service accounts for Go.")
     (license license:asl2.0)))
 
-(define-public go-github-com-google-gmail-oauth2-tools-go-sendgmail
-  (let ((commit "e3229155a4037267ce40f1a3a681f53221aa4d8d")
-        (revision "0"))
-    (package
-      (name "go-github-com-google-gmail-oauth2-tools-go-sendgmail")
-      (version (git-version "0.0.0" revision commit))
-      (source
-       (origin
-         (method git-fetch)
-         (uri (git-reference
-               (url "https://github.com/google/gmail-oauth2-tools")
-               (commit commit)))
-         (file-name (git-file-name name version))
-         (sha256
-          (base32
-           "1cxpkiaajhq1gjsg47r2b5xgck0r63pvkyrkm7af8c8dw7fyn64f"))))
-      (propagated-inputs
-       `(("go-golang-org-x-oauth2" ,go-golang-org-x-oauth2)
-         ("go-cloud-google-com-go-compute-metadata"
-          ,go-cloud-google-com-go-compute-metadata)))
-      (build-system go-build-system)
-      (arguments
-       '(#:unpack-path "github.com/google/gmail-oauth2-tools"
-         #:import-path "github.com/google/gmail-oauth2-tools/go/sendgmail"))
-      (home-page
-       "https://github.com/google/gmail-oauth2-tools/tree/master/go/sendgmail")
-      (synopsis
-       "Sendmail-compatible tool for using Gmail with @code{git send-email}")
-      (description
-       "The @command{sendgmail} command provides a minimal sendmail-compatible
-front-end that connects to Gmail using OAuth2.  It is specifically designed
-for use with @code{git send-email}.  The command needs a Gmail API key to
-function.")
-      (license license:asl2.0))))
-
 (define-public go-github-com-google-cadvisor
   (let ((commit "2ed7198f77395ee9a172878a0a7ab92ab59a2cfd")
         (revision "0"))
diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
index f00e8ac7b3..4ee878d4c6 100644
--- a/gnu/packages/mail.scm
+++ b/gnu/packages/mail.scm
@@ -43,6 +43,7 @@
 ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
 ;;; Copyright © 2021 Benoit Joly <benoit@benoitj.ca>
 ;;; Copyright © 2021 Morgan Smith <Morgan.J.Smith@outlook.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -4603,3 +4604,38 @@ (define-public rss2email
     ;; GPL version 2 or 3.  NOT 2+.
     (license (list license:gpl2
                    license:gpl3))))
+
+(define-public sendgmail
+  (let ((commit "e3229155a4037267ce40f1a3a681f53221aa4d8d")
+        (revision "0"))
+    (package
+      (name "sendgmail")
+      (version (git-version "0.0.0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/google/gmail-oauth2-tools")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "1cxpkiaajhq1gjsg47r2b5xgck0r63pvkyrkm7af8c8dw7fyn64f"))))
+      (propagated-inputs
+       `(("go-golang-org-x-oauth2" ,go-golang-org-x-oauth2)
+         ("go-cloud-google-com-go-compute-metadata"
+          ,go-cloud-google-com-go-compute-metadata)))
+      (build-system go-build-system)
+      (arguments
+       '(#:unpack-path "github.com/google/gmail-oauth2-tools"
+         #:import-path "github.com/google/gmail-oauth2-tools/go/sendgmail"))
+      (home-page
+       "https://github.com/google/gmail-oauth2-tools/tree/master/go/sendgmail")
+      (synopsis
+       "Sendmail-compatible tool for using Gmail with @code{git send-email}")
+      (description
+       "The @command{sendgmail} command provides a minimal sendmail-compatible
+front-end that connects to Gmail using OAuth2.  It is specifically designed
+for use with @code{git send-email}.  The command needs a Gmail API key to
+function.")
+      (license license:asl2.0))))
-- 
2.32.0





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

* [bug#51853] [PATCH 2/2] gnu: sendgmail: Don't limit domain name of sender.
  2021-11-14 20:46 ` [bug#51853] [PATCH 1/2] gnu: sendgmail: Rename package to match command Philip McGrath
@ 2021-11-14 20:46   ` Philip McGrath
  2021-11-17 17:24   ` [bug#51853] [PATCH 1/2] gnu: sendgmail: Rename package to match command Liliana Marie Prikler
  1 sibling, 0 replies; 10+ messages in thread
From: Philip McGrath @ 2021-11-14 20:46 UTC (permalink / raw)
  To: 51853; +Cc: Philip McGrath

There are three open pull requests adding this functionality:

  - https://github.com/google/gmail-oauth2-tools/pull/17 (October 2019)
  - https://github.com/google/gmail-oauth2-tools/pull/26 (May 2020)
  - https://github.com/google/gmail-oauth2-tools/pull/37 (May 2021)
    (The patch here is identical to #26, so I just closed this one.)

Meanwhile, the most recent commit to the upstream repository was in
May 2019: that was the commit that first added `sendgmail`.

This commit adjusts Guix's `sendgmail`, following Postel's advice,
to make the command "liberal in its receiving behavior" (RFC 760):
it always accepts email addresses with any domain name, as in #26,
and it accepts (and ignores) the `-gsuite` flag used in #17.

* gnu/packages/patches/sendgmail-remove-domain-restriction.patch:
New file. This is the patch from #26.
* gnu/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch:
New file, based on #17.
* gnu/local.mk (dist_patch_DATA): Add the new patches.
* gnu/packages/mail.scm (sendgmail)[source]: Apply the new patches.
Increment the "revision" argument to `git-version` from 0 to 1.
---

In case you are asking, "What does it mean for send*G*mail to support
non-`@gmail.com` email addresses?", here's some more context. As part of the
product variously known as Google Apps for Your Domain, GSuite, and, most
recently, Google Workspace, Google offers email hosting for arbitrary domains
(e.g. for work or schol, or from the "legacy free [gratis] edition"). The
Gmail API works for all of these domains, but the upstream version of the
`sendgmail` command checks that the email address passed as `-sender=` ends
with "@gmail.com".

The first fork to remove this limitation seems to have
been <https://github.com/google/gmail-oauth2-tools/pull/17>
by Flameeyes (Diego Elio Pettenò), which added an optional `-gsuite` flag to
disable the check, and thereby enable alternate domains. This approach has a
number of nice features. (I tried it for a while, and I've sent patches to
Guix with this fork.) In particular, by making alternative domains opt-in, it
preserves the nice error message for people who have merely made a typo.

The main disadvantage is that, in the time since the pull request was opened,
the product has been renamed, so it seems unlikely that the `-gsuite` flag
will be merged upstream. The history of this product's name also suggests that
a `-googleworkspace` flag might suffer the same fate eventually.

A second approach was taken by Tamas K Lengyel
in <https://github.com/google/gmail-oauth2-tools/pull/26>, which simply removes
the "@gmail.com" check altogether. On the other hand, this fork's `sendgmail`
fails with a usage note if it is passed a `-gsuite` flag.
(Later, I came up with exactly the same patch; I only realized after I
opened <https://github.com/google/gmail-oauth2-tools/pull/37> that of course I
wasn't the first to want this feature.)

Usually I want to err on the side of validation, but I've come to think that
being permissive is the right trade-off in this case. The usual way of using
`sendgmail` is as a backend to `git send-email`, and, in that case, you aren't
supplying `-sender=` interactively: you'll set it up once with `git config`
when you get your API token, and then you'll forget about it until you set up
a new machine (or accidently remove the root that was protecting your command
from `guix gc` ...). Ultimately, the standard for whether a `-sender=` is
valid is whether the server you're talking to will accept it. If the server's
error message does turn out to be slightly less good, people who are using
`git send-email` seem likely to be able to cope.

In that spirit, this commit applies Tamas's patch, but also adds another patch
to gracefully accept and ignore the `-gsuite` flag from Flameeyes's fork. If
your configuration or script worked with any of these `sendgmail` forks, it
should also work with the revised Guix package.

P.S. I've put the two patches to `sendgmail` in a Git repository at

    https://github.com/LiberalArtist/gmail-oauth2-tools/tree/guix-issue-51853

to make it easier to see the changes in context.

~Philip


 gnu/local.mk                                  |  2 +
 gnu/packages/mail.scm                         | 11 +++++-
 ...sendgmail-accept-ignored-gsuite-flag.patch | 39 +++++++++++++++++++
 .../sendgmail-remove-domain-restriction.patch | 34 ++++++++++++++++
 4 files changed, 84 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch
 create mode 100644 gnu/packages/patches/sendgmail-remove-domain-restriction.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 208875754b..37ad7bf7d7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1772,6 +1772,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/screen-hurd-path-max.patch		\
   %D%/packages/patches/sdl-libx11-1.6.patch			\
   %D%/packages/patches/seed-webkit.patch			\
+  %D%/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch	\
+  %D%/packages/patches/sendgmail-remove-domain-restriction.patch	\
   %D%/packages/patches/seq24-rename-mutex.patch			\
   %D%/packages/patches/serf-python3.patch			\
   %D%/packages/patches/shakespeare-spl-fix-grammar.patch		\
diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
index 4ee878d4c6..f29044608f 100644
--- a/gnu/packages/mail.scm
+++ b/gnu/packages/mail.scm
@@ -4607,7 +4607,7 @@ (define-public rss2email
 
 (define-public sendgmail
   (let ((commit "e3229155a4037267ce40f1a3a681f53221aa4d8d")
-        (revision "0"))
+        (revision "1"))
     (package
       (name "sendgmail")
       (version (git-version "0.0.0" revision commit))
@@ -4618,6 +4618,9 @@ (define-public sendgmail
                (url "https://github.com/google/gmail-oauth2-tools")
                (commit commit)))
          (file-name (git-file-name name version))
+         (patches (search-patches
+                   "sendgmail-remove-domain-restriction.patch"
+                   "sendgmail-accept-ignored-gsuite-flag.patch"))
          (sha256
           (base32
            "1cxpkiaajhq1gjsg47r2b5xgck0r63pvkyrkm7af8c8dw7fyn64f"))))
@@ -4637,5 +4640,9 @@ (define-public sendgmail
        "The @command{sendgmail} command provides a minimal sendmail-compatible
 front-end that connects to Gmail using OAuth2.  It is specifically designed
 for use with @code{git send-email}.  The command needs a Gmail API key to
-function.")
+function.
+
+Guix's version of @command{sendgmail} has been patched for compatibility with
+all known forks, including support for non-@code{@@gmail.com} email
+addresses.")
       (license license:asl2.0))))
diff --git a/gnu/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch b/gnu/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch
new file mode 100644
index 0000000000..8405ff4e42
--- /dev/null
+++ b/gnu/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch
@@ -0,0 +1,39 @@
+From 854490dc4a8a6a661b4750730c3ff749519f6e36 Mon Sep 17 00:00:00 2001
+From: Philip McGrath <philip@philipmcgrath.com>
+Date: Sun, 14 Nov 2021 10:14:24 -0500
+Subject: [PATCH] sendgmail: accept and ignore a "-gsuite" flag
+
+Accepting a "-gsuite" flag provides compatability with
+https://github.com/Flameeyes/gmail-oauth2-tools/commit/eabb456
+so users do not have to change their scripts or config files.
+
+Full hash of original: eabb45608ff4ce04045ff4ea92d05450e789ac81
+
+Related to https://github.com/google/gmail-oauth2-tools/pull/17
+---
+ go/sendgmail/main.go | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/go/sendgmail/main.go b/go/sendgmail/main.go
+index 405aa1b..5cfd0c1 100644
+--- a/go/sendgmail/main.go
++++ b/go/sendgmail/main.go
+@@ -40,6 +40,7 @@ var (
+ 	setUp  bool
+ 	dummyF string
+ 	dummyI bool
++	gsuite bool
+ )
+ 
+ func init() {
+@@ -47,6 +48,7 @@ func init() {
+ 	flag.BoolVar(&setUp, "setup", false, "If true, sendgmail sets up the sender's OAuth2 token and then exits.")
+ 	flag.StringVar(&dummyF, "f", "", "Dummy flag for compatibility with sendmail.")
+ 	flag.BoolVar(&dummyI, "i", true, "Dummy flag for compatibility with sendmail.")
++	flag.BoolVar(&gsuite, "gsuite", true, "Dummy flag for compatibility with other forks of sendgmail.")
+ }
+ 
+ func main() {
+-- 
+2.32.0
+
diff --git a/gnu/packages/patches/sendgmail-remove-domain-restriction.patch b/gnu/packages/patches/sendgmail-remove-domain-restriction.patch
new file mode 100644
index 0000000000..d23af33375
--- /dev/null
+++ b/gnu/packages/patches/sendgmail-remove-domain-restriction.patch
@@ -0,0 +1,34 @@
+From a5ecd1b2302d0def2f6f8349747022a615a9f017 Mon Sep 17 00:00:00 2001
+From: Tamas K Lengyel <tamas@tklengyel.com>
+Date: Tue, 26 May 2020 13:27:50 -0600
+Subject: [PATCH] Don't limit to email with @gmail.com
+
+---
+ go/sendgmail/main.go | 4 ----
+ 1 file changed, 4 deletions(-)
+
+diff --git a/go/sendgmail/main.go b/go/sendgmail/main.go
+index b35ef23..405aa1b 100644
+--- a/go/sendgmail/main.go
++++ b/go/sendgmail/main.go
+@@ -30,7 +30,6 @@ import (
+ 	"log"
+ 	"net/smtp"
+ 	"os"
+-	"strings"
+ 
+ 	"golang.org/x/oauth2"
+ 	googleOAuth2 "golang.org/x/oauth2/google"
+@@ -52,9 +51,6 @@ func init() {
+ 
+ func main() {
+ 	flag.Parse()
+-	if atDomain := "@gmail.com"; !strings.HasSuffix(sender, atDomain) {
+-		log.Fatalf("-sender must specify an %v email address.", atDomain)
+-	}
+ 	config := getConfig()
+ 	tokenPath := fmt.Sprintf("%v/.sendgmail.%v.json", os.Getenv("HOME"), sender)
+ 	if setUp {
+-- 
+2.32.0
+
-- 
2.32.0





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

* [bug#51853] [PATCH 1/2] gnu: sendgmail: Rename package to match command.
  2021-11-14 20:46 ` [bug#51853] [PATCH 1/2] gnu: sendgmail: Rename package to match command Philip McGrath
  2021-11-14 20:46   ` [bug#51853] [PATCH 2/2] gnu: sendgmail: Don't limit domain name of sender Philip McGrath
@ 2021-11-17 17:24   ` Liliana Marie Prikler
  2021-11-20  5:43     ` [bug#51853] [PATCH v2 0/2] gnu: sendgmail: Rename package; don't limit domain Philip McGrath
  1 sibling, 1 reply; 10+ messages in thread
From: Liliana Marie Prikler @ 2021-11-17 17:24 UTC (permalink / raw)
  To: Philip McGrath, 51853

Hi,

Am Sonntag, den 14.11.2021, 15:46 -0500 schrieb Philip McGrath:
> Suggested by Ludo’ in <https://issues.guix.gnu.org/50420#3>;.
> 
> * gnu/packages/golang.scm
> (go-github-com-google-gmail-oauth2-tools-go-sendgmail): Move to ...
> * gnu/packages/mail.scm (sendgmail): ... this variable.
> [...]
> -      (propagated-inputs
> -       `(("go-golang-org-x-oauth2" ,go-golang-org-x-oauth2)
> -         ("go-cloud-google-com-go-compute-metadata"
> -          ,go-cloud-google-com-go-compute-metadata)))
> [...]
> +      (propagated-inputs
> +       `(("go-golang-org-x-oauth2" ,go-golang-org-x-oauth2)
> +         ("go-cloud-google-com-go-compute-metadata"
> +          ,go-cloud-google-com-go-compute-metadata)))
Don't forget to depropagate the inputs if you want sendgmail to be a
command line tool rather than a library :)





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

* [bug#51853] [PATCH v2 0/2] gnu: sendgmail: Rename package; don't limit domain.
  2021-11-17 17:24   ` [bug#51853] [PATCH 1/2] gnu: sendgmail: Rename package to match command Liliana Marie Prikler
@ 2021-11-20  5:43     ` Philip McGrath
  2021-11-20  5:43       ` [bug#51853] [PATCH v2 1/2] gnu: sendgmail: Rename package to match command Philip McGrath
  2021-11-20  5:43       ` [bug#51853] [PATCH v2 2/2] gnu: sendgmail: Don't limit domain name of sender Philip McGrath
  0 siblings, 2 replies; 10+ messages in thread
From: Philip McGrath @ 2021-11-20  5:43 UTC (permalink / raw)
  To: 51853; +Cc: Liliana Marie Prikler

On 11/17/21 12:24, Liliana Marie Prikler wrote:
> Am Sonntag, den 14.11.2021, 15:46 -0500 schrieb Philip McGrath:
>> +      (propagated-inputs
>> +       `(("go-golang-org-x-oauth2" ,go-golang-org-x-oauth2)
>> +         ("go-cloud-google-com-go-compute-metadata"
>> +          ,go-cloud-google-com-go-compute-metadata)))
> Don't forget to depropagate the inputs if you want sendgmail to be a
> command line tool rather than a library :)

Ah, thanks! Here's a revised version.

Philip McGrath (2):
  gnu: sendgmail: Rename package to match command.
  gnu: sendgmail: Don't limit domain name of sender.

 gnu/local.mk                                  |  2 +
 gnu/packages/golang.scm                       | 36 +---------------
 gnu/packages/mail.scm                         | 43 +++++++++++++++++++
 ...sendgmail-accept-ignored-gsuite-flag.patch | 39 +++++++++++++++++
 .../sendgmail-remove-domain-restriction.patch | 34 +++++++++++++++
 5 files changed, 119 insertions(+), 35 deletions(-)
 create mode 100644 gnu/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch
 create mode 100644 gnu/packages/patches/sendgmail-remove-domain-restriction.patch

-- 
2.32.0





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

* [bug#51853] [PATCH v2 1/2] gnu: sendgmail: Rename package to match command.
  2021-11-20  5:43     ` [bug#51853] [PATCH v2 0/2] gnu: sendgmail: Rename package; don't limit domain Philip McGrath
@ 2021-11-20  5:43       ` Philip McGrath
  2021-12-10 14:12         ` bug#51853: [PATCH 0/2] gnu: sendgmail: Rename package; don't limit domain Ludovic Courtès
  2021-11-20  5:43       ` [bug#51853] [PATCH v2 2/2] gnu: sendgmail: Don't limit domain name of sender Philip McGrath
  1 sibling, 1 reply; 10+ messages in thread
From: Philip McGrath @ 2021-11-20  5:43 UTC (permalink / raw)
  To: 51853; +Cc: Liliana Marie Prikler

Suggested by Ludo’ in <https://issues.guix.gnu.org/50420#3>.

* gnu/packages/golang.scm
(go-github-com-google-gmail-oauth2-tools-go-sendgmail): Move to ...
* gnu/packages/mail.scm (sendgmail): ... this variable.
Change `propagated-inputs` to `inputs`.
---
 gnu/packages/golang.scm | 36 +-----------------------------------
 gnu/packages/mail.scm   | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index cc2a4ebc16..aaf6194460 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -31,6 +31,7 @@
 ;;; Copyright © 2021 jgart <jgart@dismail.de>
 ;;; Copyright © 2021 Bonface Munyoki Kilyungi <me@bonfacemunyoki.com>
 ;;; Copyright © 2021 Chadwain Holness <chadwainholness@gmail.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -3036,41 +3037,6 @@ (define-public go-cloud-google-com-go-compute-metadata
 API service accounts for Go.")
     (license license:asl2.0)))
 
-(define-public go-github-com-google-gmail-oauth2-tools-go-sendgmail
-  (let ((commit "e3229155a4037267ce40f1a3a681f53221aa4d8d")
-        (revision "0"))
-    (package
-      (name "go-github-com-google-gmail-oauth2-tools-go-sendgmail")
-      (version (git-version "0.0.0" revision commit))
-      (source
-       (origin
-         (method git-fetch)
-         (uri (git-reference
-               (url "https://github.com/google/gmail-oauth2-tools")
-               (commit commit)))
-         (file-name (git-file-name name version))
-         (sha256
-          (base32
-           "1cxpkiaajhq1gjsg47r2b5xgck0r63pvkyrkm7af8c8dw7fyn64f"))))
-      (propagated-inputs
-       `(("go-golang-org-x-oauth2" ,go-golang-org-x-oauth2)
-         ("go-cloud-google-com-go-compute-metadata"
-          ,go-cloud-google-com-go-compute-metadata)))
-      (build-system go-build-system)
-      (arguments
-       '(#:unpack-path "github.com/google/gmail-oauth2-tools"
-         #:import-path "github.com/google/gmail-oauth2-tools/go/sendgmail"))
-      (home-page
-       "https://github.com/google/gmail-oauth2-tools/tree/master/go/sendgmail")
-      (synopsis
-       "Sendmail-compatible tool for using Gmail with @code{git send-email}")
-      (description
-       "The @command{sendgmail} command provides a minimal sendmail-compatible
-front-end that connects to Gmail using OAuth2.  It is specifically designed
-for use with @code{git send-email}.  The command needs a Gmail API key to
-function.")
-      (license license:asl2.0))))
-
 (define-public go-github-com-google-cadvisor
   (let ((commit "2ed7198f77395ee9a172878a0a7ab92ab59a2cfd")
         (revision "0"))
diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
index 0e7134eaf3..891a163f0f 100644
--- a/gnu/packages/mail.scm
+++ b/gnu/packages/mail.scm
@@ -43,6 +43,7 @@
 ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
 ;;; Copyright © 2021 Benoit Joly <benoit@benoitj.ca>
 ;;; Copyright © 2021 Morgan Smith <Morgan.J.Smith@outlook.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -4642,3 +4643,38 @@ (define-public rss2email
     ;; GPL version 2 or 3.  NOT 2+.
     (license (list license:gpl2
                    license:gpl3))))
+
+(define-public sendgmail
+  (let ((commit "e3229155a4037267ce40f1a3a681f53221aa4d8d")
+        (revision "0"))
+    (package
+      (name "sendgmail")
+      (version (git-version "0.0.0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/google/gmail-oauth2-tools")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "1cxpkiaajhq1gjsg47r2b5xgck0r63pvkyrkm7af8c8dw7fyn64f"))))
+      (inputs
+       `(("go-golang-org-x-oauth2" ,go-golang-org-x-oauth2)
+         ("go-cloud-google-com-go-compute-metadata"
+          ,go-cloud-google-com-go-compute-metadata)))
+      (build-system go-build-system)
+      (arguments
+       '(#:unpack-path "github.com/google/gmail-oauth2-tools"
+         #:import-path "github.com/google/gmail-oauth2-tools/go/sendgmail"))
+      (home-page
+       "https://github.com/google/gmail-oauth2-tools/tree/master/go/sendgmail")
+      (synopsis
+       "Sendmail-compatible tool for using Gmail with @code{git send-email}")
+      (description
+       "The @command{sendgmail} command provides a minimal sendmail-compatible
+front-end that connects to Gmail using OAuth2.  It is specifically designed
+for use with @code{git send-email}.  The command needs a Gmail API key to
+function.")
+      (license license:asl2.0))))
-- 
2.32.0





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

* [bug#51853] [PATCH v2 2/2] gnu: sendgmail: Don't limit domain name of sender.
  2021-11-20  5:43     ` [bug#51853] [PATCH v2 0/2] gnu: sendgmail: Rename package; don't limit domain Philip McGrath
  2021-11-20  5:43       ` [bug#51853] [PATCH v2 1/2] gnu: sendgmail: Rename package to match command Philip McGrath
@ 2021-11-20  5:43       ` Philip McGrath
  2021-11-20  6:54         ` Liliana Marie Prikler
  1 sibling, 1 reply; 10+ messages in thread
From: Philip McGrath @ 2021-11-20  5:43 UTC (permalink / raw)
  To: 51853; +Cc: Liliana Marie Prikler

There are three open pull requests adding this functionality:

  - https://github.com/google/gmail-oauth2-tools/pull/17 (October 2019)
  - https://github.com/google/gmail-oauth2-tools/pull/26 (May 2020)
  - https://github.com/google/gmail-oauth2-tools/pull/37 (May 2021)
    (The patch here is identical to #26, so I just closed this one.)

Meanwhile, the most recent commit to the upstream repository was in
May 2019: that was the commit that first added `sendgmail`.

This commit adjusts Guix's `sendgmail`, following Postel's advice,
to make the command "liberal in its receiving behavior" (RFC 760):
it always accepts email addresses with any domain name, as in #26,
and it accepts (and ignores) the `-gsuite` flag used in #17.

* gnu/packages/patches/sendgmail-remove-domain-restriction.patch:
New file. This is the patch from #26.
* gnu/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch:
New file, based on #17.
* gnu/local.mk (dist_patch_DATA): Add the new patches.
* gnu/packages/mail.scm (sendgmail)[source]: Apply the new patches.
Increment the "revision" argument to `git-version` from 0 to 1.
---
 gnu/local.mk                                  |  2 +
 gnu/packages/mail.scm                         | 11 +++++-
 ...sendgmail-accept-ignored-gsuite-flag.patch | 39 +++++++++++++++++++
 .../sendgmail-remove-domain-restriction.patch | 34 ++++++++++++++++
 4 files changed, 84 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch
 create mode 100644 gnu/packages/patches/sendgmail-remove-domain-restriction.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 7cc06c8212..9f57e3004e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1757,6 +1757,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/screen-hurd-path-max.patch		\
   %D%/packages/patches/sdl-libx11-1.6.patch			\
   %D%/packages/patches/seed-webkit.patch			\
+  %D%/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch	\
+  %D%/packages/patches/sendgmail-remove-domain-restriction.patch	\
   %D%/packages/patches/seq24-rename-mutex.patch			\
   %D%/packages/patches/serf-python3.patch			\
   %D%/packages/patches/shakespeare-spl-fix-grammar.patch		\
diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
index 891a163f0f..579c4b9328 100644
--- a/gnu/packages/mail.scm
+++ b/gnu/packages/mail.scm
@@ -4646,7 +4646,7 @@ (define-public rss2email
 
 (define-public sendgmail
   (let ((commit "e3229155a4037267ce40f1a3a681f53221aa4d8d")
-        (revision "0"))
+        (revision "1"))
     (package
       (name "sendgmail")
       (version (git-version "0.0.0" revision commit))
@@ -4657,6 +4657,9 @@ (define-public sendgmail
                (url "https://github.com/google/gmail-oauth2-tools")
                (commit commit)))
          (file-name (git-file-name name version))
+         (patches (search-patches
+                   "sendgmail-remove-domain-restriction.patch"
+                   "sendgmail-accept-ignored-gsuite-flag.patch"))
          (sha256
           (base32
            "1cxpkiaajhq1gjsg47r2b5xgck0r63pvkyrkm7af8c8dw7fyn64f"))))
@@ -4676,5 +4679,9 @@ (define-public sendgmail
        "The @command{sendgmail} command provides a minimal sendmail-compatible
 front-end that connects to Gmail using OAuth2.  It is specifically designed
 for use with @code{git send-email}.  The command needs a Gmail API key to
-function.")
+function.
+
+Guix's version of @command{sendgmail} has been patched for compatibility with
+all known forks, including support for non-@code{@@gmail.com} email
+addresses.")
       (license license:asl2.0))))
diff --git a/gnu/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch b/gnu/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch
new file mode 100644
index 0000000000..8405ff4e42
--- /dev/null
+++ b/gnu/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch
@@ -0,0 +1,39 @@
+From 854490dc4a8a6a661b4750730c3ff749519f6e36 Mon Sep 17 00:00:00 2001
+From: Philip McGrath <philip@philipmcgrath.com>
+Date: Sun, 14 Nov 2021 10:14:24 -0500
+Subject: [PATCH] sendgmail: accept and ignore a "-gsuite" flag
+
+Accepting a "-gsuite" flag provides compatability with
+https://github.com/Flameeyes/gmail-oauth2-tools/commit/eabb456
+so users do not have to change their scripts or config files.
+
+Full hash of original: eabb45608ff4ce04045ff4ea92d05450e789ac81
+
+Related to https://github.com/google/gmail-oauth2-tools/pull/17
+---
+ go/sendgmail/main.go | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/go/sendgmail/main.go b/go/sendgmail/main.go
+index 405aa1b..5cfd0c1 100644
+--- a/go/sendgmail/main.go
++++ b/go/sendgmail/main.go
+@@ -40,6 +40,7 @@ var (
+ 	setUp  bool
+ 	dummyF string
+ 	dummyI bool
++	gsuite bool
+ )
+ 
+ func init() {
+@@ -47,6 +48,7 @@ func init() {
+ 	flag.BoolVar(&setUp, "setup", false, "If true, sendgmail sets up the sender's OAuth2 token and then exits.")
+ 	flag.StringVar(&dummyF, "f", "", "Dummy flag for compatibility with sendmail.")
+ 	flag.BoolVar(&dummyI, "i", true, "Dummy flag for compatibility with sendmail.")
++	flag.BoolVar(&gsuite, "gsuite", true, "Dummy flag for compatibility with other forks of sendgmail.")
+ }
+ 
+ func main() {
+-- 
+2.32.0
+
diff --git a/gnu/packages/patches/sendgmail-remove-domain-restriction.patch b/gnu/packages/patches/sendgmail-remove-domain-restriction.patch
new file mode 100644
index 0000000000..d23af33375
--- /dev/null
+++ b/gnu/packages/patches/sendgmail-remove-domain-restriction.patch
@@ -0,0 +1,34 @@
+From a5ecd1b2302d0def2f6f8349747022a615a9f017 Mon Sep 17 00:00:00 2001
+From: Tamas K Lengyel <tamas@tklengyel.com>
+Date: Tue, 26 May 2020 13:27:50 -0600
+Subject: [PATCH] Don't limit to email with @gmail.com
+
+---
+ go/sendgmail/main.go | 4 ----
+ 1 file changed, 4 deletions(-)
+
+diff --git a/go/sendgmail/main.go b/go/sendgmail/main.go
+index b35ef23..405aa1b 100644
+--- a/go/sendgmail/main.go
++++ b/go/sendgmail/main.go
+@@ -30,7 +30,6 @@ import (
+ 	"log"
+ 	"net/smtp"
+ 	"os"
+-	"strings"
+ 
+ 	"golang.org/x/oauth2"
+ 	googleOAuth2 "golang.org/x/oauth2/google"
+@@ -52,9 +51,6 @@ func init() {
+ 
+ func main() {
+ 	flag.Parse()
+-	if atDomain := "@gmail.com"; !strings.HasSuffix(sender, atDomain) {
+-		log.Fatalf("-sender must specify an %v email address.", atDomain)
+-	}
+ 	config := getConfig()
+ 	tokenPath := fmt.Sprintf("%v/.sendgmail.%v.json", os.Getenv("HOME"), sender)
+ 	if setUp {
+-- 
+2.32.0
+
-- 
2.32.0





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

* [bug#51853] [PATCH v2 2/2] gnu: sendgmail: Don't limit domain name of sender.
  2021-11-20  5:43       ` [bug#51853] [PATCH v2 2/2] gnu: sendgmail: Don't limit domain name of sender Philip McGrath
@ 2021-11-20  6:54         ` Liliana Marie Prikler
  2021-12-10 14:15           ` [bug#51853] [PATCH 0/2] gnu: sendgmail: Rename package; don't limit domain Ludovic Courtès
  0 siblings, 1 reply; 10+ messages in thread
From: Liliana Marie Prikler @ 2021-11-20  6:54 UTC (permalink / raw)
  To: Philip McGrath, 51853

Hi,

Am Samstag, den 20.11.2021, 00:43 -0500 schrieb Philip McGrath:
>  (define-public sendgmail
>    (let ((commit "e3229155a4037267ce40f1a3a681f53221aa4d8d")
> -        (revision "0"))
> +        (revision "1"))
IIRC you only need to bump revision when commit changes.  When the
recipe itself changes, e.g. due to an added patch, I'm pretty sure the
package would be rebuilt either way.  Can you check whether you really
need to bump it?

>      (package
>        (name "sendgmail")
>        (version (git-version "0.0.0" revision commit))
> @@ -4657,6 +4657,9 @@ (define-public sendgmail
>                 (url "https://github.com/google/gmail-oauth2-tools")
>                 (commit commit)))
>           (file-name (git-file-name name version))
> +         (patches (search-patches
> +                   "sendgmail-remove-domain-restriction.patch"
> +                   "sendgmail-accept-ignored-gsuite-flag.patch"))
>           (sha256
>            (base32
>             "1cxpkiaajhq1gjsg47r2b5xgck0r63pvkyrkm7af8c8dw7fyn64f")))
> )
> @@ -4676,5 +4679,9 @@ (define-public sendgmail
>         "The @command{sendgmail} command provides a minimal sendmail-
> compatible
>  front-end that connects to Gmail using OAuth2.  It is specifically
> designed
>  for use with @code{git send-email}.  The command needs a Gmail API
> key to
> -function.")
> +function.
> +
> +Guix's version of @command{sendgmail} has been patched for
> compatibility with
> +all known forks, including support for non-@code{@@gmail.com} email
> +addresses.")
Funnily enough non-@code is highlighted as a mail address for me.  It's
not high priority, but you might want to rewrite that sentence to
convey the same information in a way that @code is not preceded by
anything.

Cheers





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

* bug#51853: [PATCH 0/2] gnu: sendgmail: Rename package; don't limit domain.
  2021-11-20  5:43       ` [bug#51853] [PATCH v2 1/2] gnu: sendgmail: Rename package to match command Philip McGrath
@ 2021-12-10 14:12         ` Ludovic Courtès
  0 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2021-12-10 14:12 UTC (permalink / raw)
  To: Philip McGrath; +Cc: Liliana Marie Prikler, 51853-done

Hi,

Philip McGrath <philip@philipmcgrath.com> skribis:

> Suggested by Ludo’ in <https://issues.guix.gnu.org/50420#3>.
>
> * gnu/packages/golang.scm
> (go-github-com-google-gmail-oauth2-tools-go-sendgmail): Move to ...
> * gnu/packages/mail.scm (sendgmail): ... this variable.
> Change `propagated-inputs` to `inputs`.

[...]

> There are three open pull requests adding this functionality:
>
>   - https://github.com/google/gmail-oauth2-tools/pull/17 (October 2019)
>   - https://github.com/google/gmail-oauth2-tools/pull/26 (May 2020)
>   - https://github.com/google/gmail-oauth2-tools/pull/37 (May 2021)
>     (The patch here is identical to #26, so I just closed this one.)
>
> Meanwhile, the most recent commit to the upstream repository was in
> May 2019: that was the commit that first added `sendgmail`.
>
> This commit adjusts Guix's `sendgmail`, following Postel's advice,
> to make the command "liberal in its receiving behavior" (RFC 760):
> it always accepts email addresses with any domain name, as in #26,
> and it accepts (and ignores) the `-gsuite` flag used in #17.
>
> * gnu/packages/patches/sendgmail-remove-domain-restriction.patch:
> New file. This is the patch from #26.
> * gnu/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch:
> New file, based on #17.
> * gnu/local.mk (dist_patch_DATA): Add the new patches.
> * gnu/packages/mail.scm (sendgmail)[source]: Apply the new patches.
> Increment the "revision" argument to `git-version` from 0 to 1.

Applied both, thanks!

Ludo’.




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

* [bug#51853] [PATCH 0/2] gnu: sendgmail: Rename package; don't limit domain.
  2021-11-20  6:54         ` Liliana Marie Prikler
@ 2021-12-10 14:15           ` Ludovic Courtès
  0 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2021-12-10 14:15 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: Philip McGrath, 51853

Hi Liliana,

Liliana Marie Prikler <liliana.prikler@gmail.com> skribis:

> Am Samstag, den 20.11.2021, 00:43 -0500 schrieb Philip McGrath:
>>  (define-public sendgmail
>>    (let ((commit "e3229155a4037267ce40f1a3a681f53221aa4d8d")
>> -        (revision "0"))
>> +        (revision "1"))
> IIRC you only need to bump revision when commit changes.  When the
> recipe itself changes, e.g. due to an added patch, I'm pretty sure the
> package would be rebuilt either way.  Can you check whether you really
> need to bump it?

I think it’s fine since functionality changed a bit; and overall, I
think it’s no reason to block the patch.

Keep in mind that the goal of patch review is to help get things in
shape so we can eventually apply them (the sooner the better).  Don’t
hesitate to apply patches that are ready or ready minus details that you
can fix yourself.

Thanks for reviewing!

Ludo’.




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

end of thread, other threads:[~2021-12-10 14:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-14 20:36 [bug#51853] [PATCH 0/2] gnu: sendgmail: Rename package; don't limit domain Philip McGrath
2021-11-14 20:46 ` [bug#51853] [PATCH 1/2] gnu: sendgmail: Rename package to match command Philip McGrath
2021-11-14 20:46   ` [bug#51853] [PATCH 2/2] gnu: sendgmail: Don't limit domain name of sender Philip McGrath
2021-11-17 17:24   ` [bug#51853] [PATCH 1/2] gnu: sendgmail: Rename package to match command Liliana Marie Prikler
2021-11-20  5:43     ` [bug#51853] [PATCH v2 0/2] gnu: sendgmail: Rename package; don't limit domain Philip McGrath
2021-11-20  5:43       ` [bug#51853] [PATCH v2 1/2] gnu: sendgmail: Rename package to match command Philip McGrath
2021-12-10 14:12         ` bug#51853: [PATCH 0/2] gnu: sendgmail: Rename package; don't limit domain Ludovic Courtès
2021-11-20  5:43       ` [bug#51853] [PATCH v2 2/2] gnu: sendgmail: Don't limit domain name of sender Philip McGrath
2021-11-20  6:54         ` Liliana Marie Prikler
2021-12-10 14:15           ` [bug#51853] [PATCH 0/2] gnu: sendgmail: Rename package; don't limit domain Ludovic Courtès

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).