git: 64cacbc56476 - main - security/bitwarden-cli: fix fetch and build

From: Hiroki Tagato <tagattie_at_FreeBSD.org>
Date: Mon, 06 Nov 2023 14:27:38 UTC
The branch main has been updated by tagattie:

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

commit 64cacbc564767d1a53e0a3390d28e1d6fb0aa320
Author:     Hiroki Tagato <tagattie@FreeBSD.org>
AuthorDate: 2023-11-06 14:23:38 +0000
Commit:     Hiroki Tagato <tagattie@FreeBSD.org>
CommitDate: 2023-11-06 14:27:11 +0000

    security/bitwarden-cli: fix fetch and build
    
    npm version 10 fails with the following error when prefetching node
    modules (this only happens with poudriere):
    
    npm ERR! code EEXIST
    npm ERR! syscall open
    npm ERR! path /wrkdirs/usr/ports/security/bitwarden-cli/work/.npm/_cacache/tmp/e61947a0
    npm ERR! errno -17
    npm ERR! EEXIST: file already exists, open '/wrkdirs/usr/ports/security/bitwarden-cli/work/.npm/_cacache/tmp/e61947a0'
    npm ERR! File exists: /wrkdirs/usr/ports/security/bitwarden-cli/work/.npm/_cacache/tmp/e61947a0
    npm ERR! Remove the existing file and try again, or run npm
    npm ERR! with --force to overwrite files recklessly.
    
    As a temporary workaround, install and use npm version 9 for
    prefetching node modules.
    
    Reported by:    Miroslav Lachman <000.fbsd@quip.cz> (via private mail)
    MFH:            2023Q4
---
 security/bitwarden-cli/Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/security/bitwarden-cli/Makefile b/security/bitwarden-cli/Makefile
index 27edd8ba370a..707187e26af5 100644
--- a/security/bitwarden-cli/Makefile
+++ b/security/bitwarden-cli/Makefile
@@ -37,6 +37,8 @@ USE_GITHUB=	yes
 GH_ACCOUNT=	bitwarden
 GH_PROJECT=	clients
 
+MAKE_ENV+=	PYTHONDONTWRITEBYTECODE=1
+
 BUILD_WRKSRC=	${WRKSRC}/apps/cli
 
 PLIST_FILES=	bin/bw \
@@ -65,7 +67,8 @@ pre-fetch:
 		${MKDIR} ${WRKDIR}/node-modules-cache; \
 		${CP} -R ${FILESDIR}/packagejsons/* ${WRKDIR}/node-modules-cache; \
 		cd ${WRKDIR}/node-modules-cache && \
-		${SETENV} HOME=${WRKDIR} npm ci --ignore-scripts --no-progress; \
+		${SETENV} HOME=${WRKDIR} npm install -g --prefix=${WRKDIR} npm@9.9.0 && \
+		${SETENV} HOME=${WRKDIR} PATH=${WRKDIR}/bin:${PATH} npm ci --ignore-scripts --no-progress; \
 		${FIND} ${WRKDIR}/node-modules-cache -depth 1 -print | \
 			${GREP} -v node_modules | ${XARGS} ${RM} -r; \
 		${FIND} ${WRKDIR}/node-modules-cache -type d -exec ${CHMOD} 755 {} ';'; \