git: ac411586cb - main - website: Fix build when public dir is already populated

From: Danilo G. Baio <dbaio_at_FreeBSD.org>
Date: Wed, 23 Mar 2022 23:14:18 UTC
The branch main has been updated by dbaio:

URL: https://cgit.FreeBSD.org/doc/commit/?id=ac411586cb2ed824242fcbb258d94330e617d103

commit ac411586cb2ed824242fcbb258d94330e617d103
Author:     Danilo G. Baio <dbaio@FreeBSD.org>
AuthorDate: 2022-03-23 00:18:32 +0000
Commit:     Danilo G. Baio <dbaio@FreeBSD.org>
CommitDate: 2022-03-23 23:13:38 +0000

    website: Fix build when public dir is already populated
    
    All CGI scripts are set with 555 permission mode in the post-build
    target, and this makes the following builds hang if not cleaned the
    public (temp) directory before or changed CGI permissions to 755.
    
    Error: Error building site: process: readAndProcessContent: open
    /doc/website/public/cgi/mailindex.cgi: permission denied
    
    PR:             256352
    Reviewed by:    lwhsu wosch
    Differential Revision: https://reviews.freebsd.org/D34641
---
 website/Makefile | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/website/Makefile b/website/Makefile
index c10ec92408..bda2590cde 100644
--- a/website/Makefile
+++ b/website/Makefile
@@ -63,8 +63,8 @@ SKIP_LANGS+=	${a}
 .ORDER: build post-build
 .ORDER: post-build end-message
 
-all: starting-message generate-releases build post-build end-message
-run: starting-message generate-releases run-local
+all: starting-message generate-releases cgi-pre-permissions build post-build end-message
+run: starting-message generate-releases cgi-pre-permissions run-local
 clean: hugo-clean releases-clean
 
 starting-message: .PHONY
@@ -93,6 +93,11 @@ build: .PHONY
 
 post-build: cgi-permissions
 
+cgi-pre-permissions:
+.if exists(./public/cgi)
+	@chmod 755 ./public/cgi/*.cgi
+.endif
+
 cgi-permissions:
 	@chmod 555 ./public/cgi/*.cgi