git: 3ef68ca2451c - main - graphics/imv: Install imv_config as imv_config.sample

From: Nuno Teixeira <eduardo_at_FreeBSD.org>
Date: Sat, 06 Jan 2024 22:52:48 UTC
The branch main has been updated by eduardo:

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

commit 3ef68ca2451cad33eebe3619777fd7f96a709bad
Author:     embhd <embhd@posteo.de>
AuthorDate: 2024-01-06 22:46:50 +0000
Commit:     Nuno Teixeira <eduardo@FreeBSD.org>
CommitDate: 2024-01-06 22:52:07 +0000

    graphics/imv: Install imv_config as imv_config.sample
    
    - Use @sample macro on installed config .sample
    
    While I'm here:
    
    - Fix hardcoded paths in imv program and manual(1)
    
    PR:             276157
---
 graphics/imv/Makefile                  |  7 ++++++-
 graphics/imv/files/patch-doc_imv.1.txt | 15 +++++++++++++++
 graphics/imv/files/patch-meson.build   | 12 ++++++++++--
 graphics/imv/files/patch-src_imv.c     | 12 ++++++++++++
 graphics/imv/pkg-plist                 |  2 +-
 5 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/graphics/imv/Makefile b/graphics/imv/Makefile
index 9f0d913cd704..4a20c27439dd 100644
--- a/graphics/imv/Makefile
+++ b/graphics/imv/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	imv
 DISTVERSIONPREFIX=	v
 DISTVERSION=	4.4.0
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	graphics
 MASTER_SITES=	https://git.sr.ht/~exec64/${PORTNAME}/archive/${DISTVERSIONFULL}${EXTRACT_SUFX}?dummy=/
 
@@ -76,4 +76,9 @@ X11_USE=	GL=glu \
 		XORG=x11,xcb
 X11_MESON_ON=	-Dwindows=x11
 
+post-patch:
+	@${REINPLACE_CMD} -e 's|@PREFIX@|${PREFIX}|g' \
+		${WRKSRC}/src/imv.c \
+		${WRKSRC}/doc/imv.1.txt
+
 .include <bsd.port.mk>
diff --git a/graphics/imv/files/patch-doc_imv.1.txt b/graphics/imv/files/patch-doc_imv.1.txt
new file mode 100644
index 000000000000..448979dea168
--- /dev/null
+++ b/graphics/imv/files/patch-doc_imv.1.txt
@@ -0,0 +1,15 @@
+--- doc/imv.1.txt.orig	2023-01-18 22:20:52 UTC
++++ doc/imv.1.txt
+@@ -265,10 +265,9 @@ - $HOME/.imv/config
+ - $HOME/.config/imv/config
+ - $HOME/.imv_config
+ - $HOME/.imv/config
+-- /usr/local/etc/imv_config
+-- /etc/imv_config
++- @PREFIX@/etc/imv_config
+ 
+-A default config file is shipped with imv into /etc/imv_config
++A default config file is shipped with imv into @PREFIX@/etc/imv_config
+ 
+ For documentation on the config file format, see **imv**(5).
+ 
diff --git a/graphics/imv/files/patch-meson.build b/graphics/imv/files/patch-meson.build
index fb6f49490f59..ac1369ba632f 100644
--- a/graphics/imv/files/patch-meson.build
+++ b/graphics/imv/files/patch-meson.build
@@ -1,6 +1,6 @@
---- meson.build.orig	2021-03-15 09:06:48 UTC
+--- meson.build.orig	2023-01-18 22:20:52 UTC
 +++ meson.build
-@@ -101,7 +101,7 @@ files_msg = files('src/imv_msg.c', 'src/ipc_common.c')
+@@ -120,7 +120,7 @@ foreach backend : [
  
  enabled_backends = []
  foreach backend : [
@@ -9,3 +9,11 @@
    ['libtiff', 'dependency', 'libtiff-4', []],
    ['libpng', 'dependency', 'libpng', []],
    ['libjpeg', 'dependency', 'libturbojpeg', []],
+@@ -204,6 +204,7 @@ install_data(
+   files('files/imv_config'),
+   install_dir: get_option('sysconfdir'),
+   install_mode: 'rw-r--r--',
++  rename: 'imv_config.sample',
+ )
+ 
+ dep_cmocka = dependency('cmocka', required: get_option('test'))
diff --git a/graphics/imv/files/patch-src_imv.c b/graphics/imv/files/patch-src_imv.c
new file mode 100644
index 000000000000..5f30caad1c1a
--- /dev/null
+++ b/graphics/imv/files/patch-src_imv.c
@@ -0,0 +1,12 @@
+--- src/imv.c.orig	2024-01-06 21:47:38 UTC
++++ src/imv.c
+@@ -1425,8 +1425,7 @@ static char *get_config_path(void)
+     "$HOME/.config/imv/config",
+     "$HOME/.imv_config",
+     "$HOME/.imv/config",
+-    "/usr/local/etc/imv_config",
+-    "/etc/imv_config",
++    "@PREFIX@/etc/imv_config",
+   };
+ 
+   for (size_t i = 0; i < sizeof(config_paths) / sizeof(char*); ++i) {
diff --git a/graphics/imv/pkg-plist b/graphics/imv/pkg-plist
index 318d84a328f0..ab9113da7e0f 100644
--- a/graphics/imv/pkg-plist
+++ b/graphics/imv/pkg-plist
@@ -3,7 +3,7 @@ bin/imv-dir
 bin/imv-msg
 %%ALL%%bin/imv-wayland
 %%ALL%%bin/imv-x11
-etc/imv_config
+@sample etc/imv_config.sample
 man/man1/imv-dir.1.gz
 man/man1/imv-msg.1.gz
 man/man1/imv.1.gz