git: eb07e6a19a9f - main - devel/coccinelle: fix wrong default path for COCCINELLE_HOME

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Mon, 06 May 2024 21:37:46 UTC
The branch main has been updated by bapt:

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

commit eb07e6a19a9f44e833bde9e4ecfe1f685359f606
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2024-05-06 21:37:12 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2024-05-06 21:37:12 +0000

    devel/coccinelle: fix wrong default path for COCCINELLE_HOME
    
    This resulted on spatch never able to lookup for standard.iso
---
 devel/coccinelle/Makefile                          |  5 +-
 ...63-wrong-default-path-for-COCCINELLE_HOME.patch | 66 ++++++++++++++++++++++
 2 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/devel/coccinelle/Makefile b/devel/coccinelle/Makefile
index 99533970bc10..488e3a5d6de2 100644
--- a/devel/coccinelle/Makefile
+++ b/devel/coccinelle/Makefile
@@ -1,12 +1,14 @@
 PORTNAME=	coccinelle
 PORTVERSION=	1.1.1
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	devel
 
 MAINTAINER=	ports@FreeBSD.org
 COMMENT=	Program matching and transformation engine
 WWW=		http://coccinelle.lip6.fr/
 
+EXTRA_PATCHES=	${FILESDIR}/0001-Fix-263-wrong-default-path-for-COCCINELLE_HOME.patch:-p1
+
 LICENSE=	GPLv2
 LICENSE_FILE=	${WRKSRC}/license.txt
 
@@ -23,7 +25,6 @@ BINARY_ALIAS=	make=${LOCALBASE}/bin/gmake
 SHEBANG_FILES=	tools/pycocci
 USE_PERL5=	build
 GNU_CONFIGURE=	yes
-GNU_CONFIGURE_MANPREFIX=${PREFIX}/share
 CONFIGURE_ENV=	PYTHON="${PYTHON_CMD}" PYVER="${PYTHON_VER}"
 MAKE_ARGS=	PYTHON_VERSION="${PYTHON_VER}"
 
diff --git a/devel/coccinelle/files/0001-Fix-263-wrong-default-path-for-COCCINELLE_HOME.patch b/devel/coccinelle/files/0001-Fix-263-wrong-default-path-for-COCCINELLE_HOME.patch
new file mode 100644
index 000000000000..098ac1583b51
--- /dev/null
+++ b/devel/coccinelle/files/0001-Fix-263-wrong-default-path-for-COCCINELLE_HOME.patch
@@ -0,0 +1,66 @@
+From 540888ff426e0b1f7907b63ce26e712d1fc172cc Mon Sep 17 00:00:00 2001
+Message-Id: <540888ff426e0b1f7907b63ce26e712d1fc172cc.1660153142.git.osandov@osandov.com>
+From: Thierry Martinez <Thierry.Martinez@inria.fr>
+Date: Mon, 7 Feb 2022 11:24:49 +0100
+Subject: [PATCH] Fix 263: wrong default path for COCCINELLE_HOME
+
+COCCINELLE_HOME is the directory where standard.iso is looked for.
+If COCCINELLE_HOME is not defined, we consider the directory $bindir
+where the current executable is. If $bindir/standard.iso exists,
+we use COCCINELLE_HOME=$bindir (this is a usual case during
+development, where we run spatch.opt from the working directory of the
+repository).
+
+Otherwise, we suppose that coccinelle has been installed (make
+install), and that standard.iso is installed in $libdir, where
+$libdir is $exec_prefix/lib.
+
+Before this commit, we considered wrongly that $exec_prefix was equal
+to $bindir, whereas the default value for $bindir is
+$exec_prefix/bin. Therefore, we should take for $exec_prefix the
+parent directory of $bindir.
+---
+ globals/config.ml.in | 22 ++++++++++++++++++----
+ 1 file changed, 18 insertions(+), 4 deletions(-)
+
+diff --git a/globals/config.ml.in b/globals/config.ml.in
+index da1e9da4..6505a911 100644
+--- a/globals/config.ml.in
++++ b/globals/config.ml.in
+@@ -26,15 +26,29 @@ let rec realpath path =
+     end
+ 
+ let path =
++  (* COCCINELLE_HOME is the directory where standard.iso is looked for. *)
+   try (Sys.getenv "COCCINELLE_HOME")
+   with Not_found->
++    (* If COCCINELLE_HOME is not defined, we consider the directory $bindir
++       where the current executable is. *)
+     let exec_realpath = realpath Sys.executable_name in
+-    let exec_dir = Filename.dirname exec_realpath in
+-    if Sys.file_exists (Filename.concat exec_dir "standard.iso") then
+-      exec_dir
++    let bin_dir = Filename.dirname exec_realpath in
++    if Sys.file_exists (Filename.concat bin_dir "standard.iso") then
++       (* If $bindir/standard.iso exists,
++          we use COCCINELLE_HOME=$bindir (this is a usual case during
++          development, where we run spatch.opt from the working directory
++          of the repository). *)
++      bin_dir
+     else
++      (* Otherwise, we suppose that coccinelle has been installed (make
++         install), and that standard.iso is installed in $libdir, where
++         $libdir is $exec_prefix/lib.
++         The default value for $bindir is $exec_prefix/bin.
++         Therefore, we should take for $exec_prefix the parent directory
++         of $bindir.*)
+       let libdir =
+-        Str.global_replace (Str.regexp "[$]{exec_prefix}") exec_dir "@libdir@"
++        Str.global_replace (Str.regexp "[$]{exec_prefix}")
++          (Filename.dirname bin_dir) "@libdir@"
+       in
+       Filename.concat libdir "coccinelle"
+ 
+-- 
+2.37.1
+