Some refactoring and new functionality.
* Rename util/run to util/process. * Rename `run` to `capture` to better reflect functionality. * Implement `with-env`. * Rename util/tmpdir to util/filesystem. * Implement `delete-file-recursively`. * Implement `call-with-temporary-directory`. * Flesh out creation of tarball for transfer to remote system.
This commit is contained in:
parent
b29156d557
commit
4ebd83491c
5 changed files with 97 additions and 50 deletions
23
bin/play.scm
23
bin/play.scm
|
@ -3,13 +3,11 @@
|
|||
(use-modules (srfi srfi-11)
|
||||
(ice-9 getopt-long)
|
||||
(ice-9 format)
|
||||
(ordo util tmpdir))
|
||||
(ordo util filesystem))
|
||||
|
||||
(define (collect-files tarball dir . files)
|
||||
(let* ((mode (if (file-exists? tarball) "--append" "--create"))
|
||||
(rc (apply system* "tar" mode "--gzip" "--directory" dir "--file" tarball files)))
|
||||
(unless (zero? rc)
|
||||
(error (string-append "Error collecting files")))))
|
||||
(define (tar . args)
|
||||
(unless (zero? (apply system* "tar" args))
|
||||
(error (format #f "Non-zero exit from tar ~a" args))))
|
||||
|
||||
(define* (usage #:optional errmsg)
|
||||
(with-output-to-port (current-error-port)
|
||||
|
@ -31,12 +29,15 @@
|
|||
(help-wanted (usage))
|
||||
((not (= 1 (length args)))
|
||||
(usage "Expected exactly one playbook")))
|
||||
(values (car args) target)))
|
||||
(values (canonicalize-path (car args)) target)))
|
||||
|
||||
(define (main args)
|
||||
(let-values (((playbook-path target) (process-options args)))
|
||||
(define playbook (load (canonicalize-path playbook-path)))
|
||||
(define playbook (load playbook-path))
|
||||
(define top-dir (dirname (dirname (current-filename))))
|
||||
(define tmp-dir (create-temporary-directory))
|
||||
(define tarball (string-append tmp-dir "/payload.tar.gz"))
|
||||
(collect-files tarball top-dir "modules" "bin")))
|
||||
(call-with-temporary-directory
|
||||
(lambda (tmp-dir)
|
||||
(define tarball (string-append tmp-dir "/payload.tar"))
|
||||
(tar "--create" "--file" tarball "--directory" top-dir "modules" "bin")
|
||||
(tar "--append" "--file" tarball "--transform" "s/.*/playbook.scm/" playbook-path)
|
||||
(tar "tf" tarball)))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue