git: 3c8fd2ac242a - main - devel/gitlab-shell: fix build as non-root user in poudriere

From: Matthias Fechner <mfechner_at_FreeBSD.org>
Date: Fri, 17 May 2024 06:43:38 UTC
The branch main has been updated by mfechner:

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

commit 3c8fd2ac242ab03120b5d7eb4a02f84d346a0475
Author:     Yasuhito FUTATSUKI <freebsd-bug-report-yf@yf.bsdclub.org>
AuthorDate: 2024-05-16 11:19:29 +0000
Commit:     Matthias Fechner <mfechner@FreeBSD.org>
CommitDate: 2024-05-17 06:42:56 +0000

    devel/gitlab-shell: fix build as non-root user in poudriere
    
    PR:             278710
---
 devel/gitlab-shell/Makefile | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/devel/gitlab-shell/Makefile b/devel/gitlab-shell/Makefile
index 7936f330b809..e58abc4d9107 100644
--- a/devel/gitlab-shell/Makefile
+++ b/devel/gitlab-shell/Makefile
@@ -39,14 +39,17 @@ DIST_SUBDIR=	go/${PKGORIGIN:S,/,_,g}/${DISTNAME}
 EXTRACT_ONLY+=	${DISTFILES:N*.mod\:*:N*.mod:C/:.*//}
 _USES_fetch+=	800:go-post-fetch
 go-post-fetch:
-	@${ECHO_MSG} "Copy go.mod as go mod download will modify it, which breaks checksum check"
-	@(cd ${DISTDIR}/${DIST_SUBDIR}; ${CP} go.mod go.mod.orig)
-	@${ECHO_MSG} "===> Fetching ${GO_MODNAME} dependencies";
-	@(cd ${DISTDIR}/${DIST_SUBDIR}; \
-		[ -e go.mod ] || ${RLN} ${GO_MODFILE} go.mod; \
-		${SETENV} ${GO_ENV} GOPROXY=${GO_GOPROXY} ${GO_CMD} mod download -x all)
-	@${ECHO_MSG} "Restore previous go.mod"
-	@(cd ${DISTDIR}/${DIST_SUBDIR}; ${MV} go.mod.orig go.mod)
+	@if [ ! -e ${DISTDIR}/${DIST_SUBDIR}/.go-post-fetch-done ]; then\
+		${ECHO_MSG} "Copy go.mod as go mod download will modify it, which breaks checksum check" ;\
+		(cd ${DISTDIR}/${DIST_SUBDIR}; ${CP} go.mod go.mod.orig) ;\
+		${ECHO_MSG} "===> Fetching ${GO_MODNAME} dependencies";\
+		(cd ${DISTDIR}/${DIST_SUBDIR}; \
+			[ -e go.mod ] || ${RLN} ${GO_MODFILE} go.mod; \
+			${SETENV} ${GO_ENV} GOPROXY=${GO_GOPROXY} ${GO_CMD} mod download -x all) ;\
+		${ECHO_MSG} "Restore previous go.mod" ;\
+		(cd ${DISTDIR}/${DIST_SUBDIR}; ${MV} go.mod.orig go.mod) ;\
+		${TOUCH} ${DISTDIR}/${DIST_SUBDIR}/.go-post-fetch-done;\
+	fi;
 # ---------------------------
 
 VARLOGDIR=	/var/log/gitlab-shell
@@ -82,4 +85,11 @@ post-install:
 		${SED} -E -e '/sample$$/ s#^#@sample #; \
 		s#${DATADIR_REL}/bin#@(,,555) ${DATADIR_REL}/bin#; ' >> ${TMPPLIST}
 
-.include <bsd.port.mk>
+go-pre-delete-distfiles:
+	@if [ -e ${DISTDIR}/${DIST_SUBDIR}/.go-post-fetch-done ]; then\
+		${RM} ${DISTDIR}/${DIST_SUBDIR}/.go-post-fetch-done || ${TRUE};\
+	fi
+
+.include <bsd.port.pre.mk>
+delete-distfiles: go-pre-delete-distfiles
+.include <bsd.port.post.mk>