git: 7b6ca19a8048 - main - sysutils/gnupg: Fix running without procfs

From: Adam Weinberger <adamw_at_FreeBSD.org>
Date: Tue, 02 Nov 2021 11:22:39 UTC
The branch main has been updated by adamw:

URL: https://cgit.FreeBSD.org/ports/commit/?id=7b6ca19a8048d71d57b04f2f01962a90f90f67c9

commit 7b6ca19a8048d71d57b04f2f01962a90f90f67c9
Author:     FiLiS <freebsdbugs@filis.org>
AuthorDate: 2021-11-02 11:22:07 +0000
Commit:     Adam Weinberger <adamw@FreeBSD.org>
CommitDate: 2021-11-02 11:22:07 +0000

    sysutils/gnupg: Fix running without procfs
---
 security/gnupg/Makefile                     |  1 +
 security/gnupg/files/patch-common_homedir.c | 30 +++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/security/gnupg/Makefile b/security/gnupg/Makefile
index 7e12050353b9..8dfab25275a4 100644
--- a/security/gnupg/Makefile
+++ b/security/gnupg/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	gnupg
 PORTVERSION=	2.3.3
+PORTREVISION=	1
 CATEGORIES=	security
 MASTER_SITES=	GNUPG
 
diff --git a/security/gnupg/files/patch-common_homedir.c b/security/gnupg/files/patch-common_homedir.c
new file mode 100644
index 000000000000..619818f4ab54
--- /dev/null
+++ b/security/gnupg/files/patch-common_homedir.c
@@ -0,0 +1,30 @@
+--- common/homedir.c.orig	2021-10-01 12:44:06.000000000 +0000
++++ common/homedir.c	2021-10-26 08:14:01.320259000 +0000
+@@ -68,7 +68,9 @@
+  * text was read.  */
+ #if __linux__
+ # define MYPROC_SELF_EXE "/proc/self/exe"
+-#else /* Assume *BSD*/
++#elif defined(__NetBSD__)
++# define MYPROC_SELF_EXE "/proc/curproc/exe"
++#else /* Assume other BSDs */
+ # define MYPROC_SELF_EXE "/proc/curproc/file"
+ #endif
+ 
+@@ -495,13 +497,13 @@
+           if (nread < 0)
+             {
+               err = gpg_error_from_syserror ();
+-              log_info ("error reading symlink '%s': %s\n",
+-                        MYPROC_SELF_EXE, gpg_strerror (err));
+               buffer[0] = 0;
+               if ((name = getenv ("GNUPG_BUILD_ROOT")) && *name == '/')
+                 {
+                   /* Try a fallback for systems w/o a supported /proc
+-                   * file system.  */
++                   * file system if we are running a regression test.  */
++                  log_info ("error reading symlink '%s': %s\n",
++                            MYPROC_SELF_EXE, gpg_strerror (err));
+                   xfree  (buffer);
+                   buffer = xstrconcat (name, "/bin/gpgconf", NULL);
+                   log_info ("trying fallback '%s'\n", buffer);