git: f5bf335f3015 - main - devel/fossology-nomos-standalone: try to fix build on 14.x

From: Dmitry Marakasov <amdmi3_at_FreeBSD.org>
Date: Mon, 22 May 2023 18:27:48 UTC
The branch main has been updated by amdmi3:

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

commit f5bf335f30152e9a883e7cdb984cd5bcd3580b0a
Author:     Dmitry Marakasov <amdmi3@FreeBSD.org>
AuthorDate: 2023-05-22 14:24:19 +0000
Commit:     Dmitry Marakasov <amdmi3@FreeBSD.org>
CommitDate: 2023-05-22 18:27:09 +0000

    devel/fossology-nomos-standalone: try to fix build on 14.x
    
    Adjust code to XSI compliant strerror_r version FreeBSD has
    
    Reported by:    pkg-fallout
---
 .../files/patch-src_nomos_agent_nomos.c            | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/devel/fossology-nomos-standalone/files/patch-src_nomos_agent_nomos.c b/devel/fossology-nomos-standalone/files/patch-src_nomos_agent_nomos.c
new file mode 100644
index 000000000000..172d2a70930b
--- /dev/null
+++ b/devel/fossology-nomos-standalone/files/patch-src_nomos_agent_nomos.c
@@ -0,0 +1,38 @@
+There are two strerror_r impementations,
+
+int strerror_r(int errnum, char *buf, size_t buflen); /* XSI-compliant */
+char *strerror_r(int errnum, char *buf, size_t buflen); /* GNU-specific */
+
+FreeBSD only uses the former, while Linux may use either depending
+on compiler flags. I haven't figured out how to check for this
+correctly, so just use right version on FreeBSD for now.
+
+--- src/nomos/agent/nomos.c.orig	2022-11-15 10:13:05 UTC
++++ src/nomos/agent/nomos.c
+@@ -309,16 +309,26 @@ int main(int argc, char **argv)
+ 
+   if (putenv("LANG=C") < 0)
+   {
++#if defined(__FreeBSD__)
++    strerror_r(errno, sErrorBuf, sizeof(sErrorBuf));
++    LOG_FATAL("Cannot set LANG=C in environment.  Error: %s", sErrorBuf)
++#else
+     char * estr = strerror_r(errno, sErrorBuf, sizeof(sErrorBuf));
+     LOG_FATAL("Cannot set LANG=C in environment.  Error: %s", estr)
++#endif
+     Bail(-__LINE__);
+   }
+ 
+   /* Save the current directory */
+   if (getcwd(gl.initwd, sizeof(gl.initwd)) == NULL_STR)
+   {
++#if defined(__FreeBSD__)
++    strerror_r(errno, sErrorBuf, sizeof(sErrorBuf));
++    LOG_FATAL("Cannot obtain starting directory.  Error: %s", sErrorBuf)
++#else
+     char *estr = strerror_r(errno, sErrorBuf, sizeof(sErrorBuf));
+     LOG_FATAL("Cannot obtain starting directory.  Error: %s", estr)
++#endif
+     Bail(-__LINE__);
+   }
+