taler-deployment

Deployment scripts and configuration files
Log | Files | Refs | README

taler-helpers.scm (1147B)


      1 (define-module (taler-helpers)
      2   #:use-module (guix)
      3   #:use-module (guix utils)
      4   #:use-module (ice-9 textual-ports)
      5   #:export (concat-local-files))
      6 
      7 ;;;
      8 ;;; Helpers
      9 ;;;
     10 
     11 (define (absolute-file-name file directory)
     12   "Return the canonical absolute file name for FILE, which lives in the
     13 vicinity of DIRECTORY."
     14   (canonicalize-path
     15    (cond ((string-prefix? "/" file) file)
     16          ((not directory) file)
     17          ((string-prefix? "/" directory)
     18           (string-append directory "/" file))
     19          (else file))))
     20 
     21 (define (%%concat-local-files srcdir outname files)
     22   (define (slurp f)
     23     (call-with-input-file (absolute-file-name f srcdir) get-string-all))
     24   (define (file-concat files)
     25     (string-concatenate (map slurp files)))
     26   (plain-file outname (file-concat files)))
     27 
     28 
     29 (define-syntax concat-local-files
     30   (lambda (s)
     31     (syntax-case s ()
     32       ((_ outname files)
     33        #'(%%concat-local-files (current-source-directory) outname files))
     34       ((_)
     35        #'(syntax-error "missing arguments"))
     36       (id
     37        (identifier? #'id)
     38        #'(syntax-error
     39           "'concat-local-files' is a macro and cannot be used like this")))))