summary refs log tree commit diff
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2021-02-04 16:15:21 -0500
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2021-02-04 16:42:46 -0500
commit39e67ed697951db0c75b0ba76269ca54108d9506 (patch)
tree9280857af12c7e90fa3837e981141b0be0616686
parent3299530c4387fc897877f8a302ec1d0b84ed31a6 (diff)
downloadguix-39e67ed697951db0c75b0ba76269ca54108d9506.tar.gz
build/gnu: Only make source checkout files writable.
This is a followup commit to 6129ebddbd.

It was suggested by Ludovic in #guix that it's probably safer to leave files
extracted from a tarball alone.  While at it, guard against possible
exceptions that can happen in the presence of dangling symbolic links, for
example.

* guix/build/gnu-build-system.scm (unpack): Wrap the make-file-writable call
in a false-if-exception handler.  Move the for-each loop under the
file-is-directory? cond branch.
-rw-r--r--guix/build/gnu-build-system.scm9
1 files changed, 6 insertions, 3 deletions
diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index fca77f474c..af64b3b61f 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -156,7 +156,11 @@ working directory."
         ;; Preserve timestamps (set to the Epoch) on the copied tree so that
         ;; things work deterministically.
         (copy-recursively source "."
-                          #:keep-mtime? #t))
+                          #:keep-mtime? #t)
+        ;; Make the source checkout files writable, for convenience.
+        (for-each (lambda (f)
+                    (false-if-exception (make-file-writable f)))
+                  (find-files ".")))
       (begin
         (cond
          ((string-suffix? ".zip" source)
@@ -170,8 +174,7 @@ working directory."
             (when command
               (invoke command "--decompress" name)))))
         ;; Attempt to change into child directory.
-        (and=> (first-subdirectory ".") chdir)))
-  (for-each make-file-writable (find-files ".")))
+        (and=> (first-subdirectory ".") chdir))))
 
 (define* (bootstrap #:key bootstrap-scripts
                     #:allow-other-keys)