diff options
-rwxr-xr-x | install.scm | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/install.scm b/install.scm index 2b0e7cb..dfb85af 100755 --- a/install.scm +++ b/install.scm @@ -52,15 +52,22 @@ (string-append prefix (substring f user-end (string-length f))))) (else (string-append (getcwd) "/" f)))) +(define (symlink? path) + (false-if-exception + (eq? 'symlink (stat:type (lstat path))))) + (define (clean-file full-dest) - (when (file-exists? full-dest) + (when (false-if-exception (lstat full-dest)) (log-msg 'WARN (string-append "Deleting previous file: " full-dest)) - (delete-file full-dest)) - full-dest) + (delete-file full-dest))) (define (config-links title src target) - (symlink (expand-file src) (clean-file (expand-file target))) - (log-msg 'OK (string-append title " on " target))) + (let ((src-path (expand-file src)) + (target-path (expand-file target))) + (unless (and (symlink? target-path) (equal? (readlink target-path) src-path)) + (clean-file target-path) + (symlink src-path target-path) + (log-msg 'OK (string-append title " on " target))))) (define (git-config) (log-msg 'INFO "Configuring git") |