summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-12-25 19:04:23 +0000
committerArun Isaac2022-12-25 23:33:05 +0000
commita1368a0f1c38f8606902e4ce27459aeb0e6a6eca (patch)
tree71c8cd91559a9781b98c72f0db3b1749b0daaa40
parentef213c41ace0c60eeb96ae9fa4d6db4f234926c3 (diff)
downloadtissue-a1368a0f1c38f8606902e4ce27459aeb0e6a6eca.tar.gz
tissue-a1368a0f1c38f8606902e4ce27459aeb0e6a6eca.tar.lz
tissue-a1368a0f1c38f8606902e4ce27459aeb0e6a6eca.zip
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.
-rw-r--r--tissue/web/static.scm33
1 files changed, 19 insertions, 14 deletions
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 <file> 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 <file> 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))))