git: 00180663d1e1 - main - devel/juce: Add better workaround for broken ENVIRON(7) in shared libraries

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Sun, 16 Oct 2022 22:14:47 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=00180663d1e163f50dfae6916e9eac4c4192338d

commit 00180663d1e163f50dfae6916e9eac4c4192338d
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2022-10-16 22:11:00 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2022-10-16 22:14:45 +0000

    devel/juce: Add better workaround for broken ENVIRON(7) in shared libraries
    
    New workaround exactly mimics the effect of ENVIRON(7).
---
 devel/juce/Makefile                                     |  2 +-
 ...tch-modules_juce__core_native_juce__linux__Files.cpp | 17 ++++++++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/devel/juce/Makefile b/devel/juce/Makefile
index 77cbb3a7987b..2ae237a153ac 100644
--- a/devel/juce/Makefile
+++ b/devel/juce/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	juce
 DISTVERSION=	7.0.2
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	devel
 
 PATCH_SITES=	https://github.com/${GH_ACCOUNT}/${GH_PROJECT}/commit/
diff --git a/devel/juce/files/patch-modules_juce__core_native_juce__linux__Files.cpp b/devel/juce/files/patch-modules_juce__core_native_juce__linux__Files.cpp
index 707d077e2b20..085a1b166a93 100644
--- a/devel/juce/files/patch-modules_juce__core_native_juce__linux__Files.cpp
+++ b/devel/juce/files/patch-modules_juce__core_native_juce__linux__Files.cpp
@@ -1,13 +1,24 @@
 - workaround for https://reviews.freebsd.org/D30842
 
---- modules/juce_core/native/juce_linux_Files.cpp.orig	2022-10-16 19:17:29 UTC
+--- modules/juce_core/native/juce_linux_Files.cpp.orig	2022-08-15 18:29:17 UTC
 +++ modules/juce_core/native/juce_linux_Files.cpp
-@@ -229,7 +229,7 @@ bool Process::openDocument (const String& fileName, co
+@@ -21,7 +21,9 @@
+ */
+ 
+ #if JUCE_BSD
+-extern char** environ;
++//extern char** environ; // this is broken on FreeBSD, see https://reviews.freebsd.org/D30842
++#include <dlfcn.h>
++static char*** environ_ptr = (char***)dlsym(RTLD_DEFAULT, "environ"); // workaround for the above
+ #endif
+ 
+ namespace juce
+@@ -229,7 +231,7 @@ bool Process::openDocument (const String& fileName, co
          setsid();
  
          // Child process
 -        execve (argv[0], (char**) argv, environ);
-+        execv (argv[0], (char**) argv);
++        execve (argv[0], (char**) argv, *environ_ptr);
          exit (0);
      }