build: support Guix.

* guile/guix/make.scm (link-or-cp): New function.
  (assert-link, store): Use it.
This commit is contained in:
Jan Nieuwenhuizen 2017-07-20 08:16:54 +02:00
parent 2de207076b
commit d4294c0088

View file

@ -210,8 +210,13 @@
(string-append %store-dir "/" (if (string? o) o (string-append %store-dir "/" (if (string? o) o
(target-hash o)))) (target-hash o))))
(define (link-or-cp existing-file new-file)
(catch #t
(lambda _ (link existing-file new-file))
(lambda _ (copy-file existing-file new-file))))
(define (assert-link existing-file new-file) (define (assert-link existing-file new-file)
(if (not (file-exists? new-file)) (link existing-file new-file))) (if (not (file-exists? new-file)) (link-or-cp existing-file new-file)))
(define store (define store
(let ((*store* '())) (let ((*store* '()))
@ -244,7 +249,7 @@
(file-name (target-file-name get))) (file-name (target-file-name get)))
(and (file-exists? store-file) (and (file-exists? store-file)
(if (file-exists? file-name) (delete-file file-name)) (if (file-exists? file-name) (delete-file file-name))
(link store-file file-name) (link-or-cp store-file file-name)
(store #:add get #:key key))))) (store #:add get #:key key)))))
(get (assoc-ref *store* get)) (get (assoc-ref *store* get))
(delete (and (assoc-ref *store* delete) (delete (and (assoc-ref *store* delete)