From 0276dd6e97404c73fa5e9479f70419b7574d0b7d Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 11 Sep 2024 23:13:26 +0100 Subject: command-line-tool: Support File type staging entries. * ravanan/command-line-tool.scm (build-command-line-tool-script): Support File type staging entries. --- ravanan/command-line-tool.scm | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm index cfca932..0c8c292 100644 --- a/ravanan/command-line-tool.scm +++ b/ravanan/command-line-tool.scm @@ -683,9 +683,17 @@ named @var{name} with @var{inputs} using tools from Guix manifest (assoc-ref* env-var-requirement "envDef")))) (define (files-to-stage initial-work-dir-requirement) - (vector-map->list (lambda (dirent) - #~(list #$(coerce-expression (assoc-ref dirent "entryname")) - #$(coerce-expression (assoc-ref dirent "entry")))) + (vector-map->list (lambda (listing-entry) + (if (string? listing-entry) + ;; File + #~(let ((entry #$(coerce-expression listing-entry))) + (list (assoc-ref entry "basename") + entry)) + ;; Dirent + #~(list #$(coerce-expression + (assoc-ref listing-entry "entryname")) + #$(coerce-expression + (assoc-ref listing-entry "entry"))))) (assoc-ref initial-work-dir-requirement "listing"))) @@ -917,12 +925,20 @@ named @var{name} with @var{inputs} using tools from Guix manifest (call-with-current-directory outputs-directory (lambda () ;; Stage files. - ;; We currently support Dirent only. TODO: Support - ;; others. + ;; We currently support File and Dirent only. TODO: + ;; Support others. (map (match-lambda ((entry-name entry) - (call-with-output-file entry-name - (cut put-string <> entry)))) + (cond + ;; Stuff string literal into a file. + ((string? entry) + (call-with-input-file entry-name + (cut put-string <> entry))) + ;; Symlink to the file. + ((eq? (object-type entry) + 'File) + (symlink (assoc-ref entry "path") + entry-name))))) (list #$@(from-maybe (maybe-bind (find-requirement requirements -- cgit v1.2.3