From a1368a0f1c38f8606902e4ce27459aeb0e6a6eca Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 25 Dec 2022 19:04:23 +0000 Subject: web: static: Build website from within temporary clone of repo. The build process may run code that expects files to be on the filesystem. Not all of this file accessing code is within tissue's control. Think arbitrary code in skribilo documents. So, we cannot always work around this by pointing file accesses into a bare git repository. * tissue/web/static.scm: Import (git). (build-website): Move into temporary clone of git repository before building files. (exporter): Use call-with-input-file instead of call-with-file-in-git. --- tissue/web/static.scm | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'tissue') diff --git a/tissue/web/static.scm b/tissue/web/static.scm index fbef99e..795ccee 100644 --- a/tissue/web/static.scm +++ b/tissue/web/static.scm @@ -30,6 +30,7 @@ #:use-module (skribilo evaluator) #:use-module (skribilo reader) #:use-module (web uri) + #:use-module (git) #:use-module (tissue git) #:use-module (tissue issue) #:use-module (tissue utils) @@ -62,7 +63,7 @@ NEW-EXTENSION." @var{proc}. @var{proc} is passed two arguments---the input port to read from and the output port to write to." (lambda (out) - (call-with-file-in-git (current-git-repository) file + (call-with-input-file file (cut proc <> out)))) (define (copier file) @@ -132,16 +133,20 @@ the web output. Log to LOG-PORT. When LOG-PORT is #f, do not log." ;; Create output directory. (make-directories output-directory) - ;; Write each of the objects. - (for-each (lambda (file) - (let ((output-file - (string-append output-directory "/" (file-name file)))) - (when log-port - (display (file-name file) log-port) - (newline log-port)) - (make-directories (dirname output-file)) - (call-with-output-file output-file - (lambda (port) - (call-with-current-directory repository-top-level - (cut (file-writer file) port)))))) - files)) + ;; Move into a temporary clone of the git repository, and write each + ;; of the objects. + (call-with-temporary-directory + (lambda (temporary-repository-clone) + (clone repository-top-level temporary-repository-clone) + (for-each (lambda (file) + (let ((output-file + (string-append output-directory "/" (file-name file)))) + (when log-port + (display (file-name file) log-port) + (newline log-port)) + (make-directories (dirname output-file)) + (call-with-output-file output-file + (lambda (port) + (call-with-current-directory temporary-repository-clone + (cut (file-writer file) port)))))) + files)))) -- cgit v1.2.3