git: 4c7443125c2e - main - security/vaultwarden: Make package rootdir friendly

From: Emmanuel Vadot <manu_at_FreeBSD.org>
Date: Mon, 11 Sep 2023 09:47:44 UTC
The branch main has been updated by manu:

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

commit 4c7443125c2e90ede58b0f8739a0197214034572
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2023-08-26 08:37:03 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2023-09-11 09:46:50 +0000

    security/vaultwarden: Make package rootdir friendly
    
    - Use @dir with ownership instead of executing chown in postexec
      We should never chown -R the data directory at install (because it's empty)
      or when we upgrade (not needed)
    - Fix the shipped configuration file, do not install it in etc/rc.conf.d, install
      it where vaultwarden will actually load it and use @sample
    
    Differential Revision:  https://reviews.freebsd.org/D41602
---
 security/vaultwarden/Makefile             | 11 +++++------
 security/vaultwarden/files/pkg-message.in | 14 --------------
 security/vaultwarden/pkg-plist            |  5 ++---
 3 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/security/vaultwarden/Makefile b/security/vaultwarden/Makefile
index d081103d869c..2a5fc35b4ca0 100644
--- a/security/vaultwarden/Makefile
+++ b/security/vaultwarden/Makefile
@@ -22,6 +22,10 @@ USE_GITHUB=	yes
 GH_ACCOUNT=	dani-garcia
 USE_RC_SUBR=	${PORTNAME}
 
+USERS=		${WWWOWN}
+GROUPS=		${WWWGRP}
+PLIST_SUB=	WWWOWN=${WWWOWN} WWWGRP=${WWWGRP}
+
 OPTIONS_DEFINE=	WEBVAULT
 OPTIONS_DEFAULT=WEBVAULT
 
@@ -36,7 +40,6 @@ CARGO_FEATURES=	mysql postgresql sqlite #vendored_openssl
 
 INSTALL_TARGET=	install-strip
 
-SUB_FILES=	pkg-message
 SUB_LIST=	WWWGRP=${WWWGRP} \
 		WWWOWN=${WWWOWN}
 
@@ -45,11 +48,7 @@ SUB_LIST=	WWWGRP=${WWWGRP} \
 #		${WRKSRC}/Cargo.toml
 
 post-install:
-	${MKDIR} ${STAGEDIR}/${ETCDIR}/rc.conf.d
-	${INSTALL} -m0600 ${FILESDIR}/${PORTNAME}_conf.in ${STAGEDIR}/${LOCALBASE}/etc/rc.conf.d/${PORTNAME}.sample
 	${MKDIR} ${STAGEDIR}/${WWWDIR}/data
-	${ECHO_CMD} \
-		'@postexec chown -R ${WWWOWN}:${WWWGRP} %D/${WWWDIR_REL}/data' \
-		>> ${TMPPLIST}
+	${INSTALL} -m0600 ${FILESDIR}/${PORTNAME}_conf.in ${STAGEDIR}/${WWWDIR}/data/config.json.sample
 
 .include <bsd.port.mk>
diff --git a/security/vaultwarden/files/pkg-message.in b/security/vaultwarden/files/pkg-message.in
deleted file mode 100644
index 7f2614605175..000000000000
--- a/security/vaultwarden/files/pkg-message.in
+++ /dev/null
@@ -1,14 +0,0 @@
-[
-{ type: install
-  message: <<EOM
-
-Setup vaultwarden environment:
-
-Copy %%PREFIX%%/etc/rc.conf.d/vaultwarden.sample to  %%PREFIX%%/etc/rc.conf.d/vaultwarden
-
-Adapt %%PREFIX%%/etc/rc.conf.d/vaultwarden to your needs.
-
-Enable and start vaultwarden service
-EOM
-}
-]
diff --git a/security/vaultwarden/pkg-plist b/security/vaultwarden/pkg-plist
index a70f701414d3..a3b7fa646df8 100644
--- a/security/vaultwarden/pkg-plist
+++ b/security/vaultwarden/pkg-plist
@@ -1,4 +1,3 @@
 bin/vaultwarden
-etc/rc.conf.d/vaultwarden.sample
-@dir %%ETCDIR%%/rc.conf.d
-@dir %%WWWDIR%%/data
+@dir(%%WWWOWN%%,%%WWWGRP%%,0755) %%WWWDIR%%/data
+@sample %%WWWDIR%%/data/config.json.sample