[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/01: utils: 'elf-file?' and 'ar-file?' return #f for directories.

From: Ludovic Courtès
Subject: 01/01: utils: 'elf-file?' and 'ar-file?' return #f for directories.
Date: Sun, 23 Nov 2014 18:20:29 +0000

civodul pushed a commit to branch core-updates
in repository guix.

commit c23d17095db0611d8ee32357f17da441bcb0bc75
Author: Ludovic Courtès <address@hidden>
Date:   Sun Nov 23 19:15:21 2014 +0100

    utils: 'elf-file?' and 'ar-file?' return #f for directories.
    This avoids uncaught exceptions when the 'strip' phase would call these
    procedures on symlinks to directories, such as 'lib/terminfo' in
    ncurses (see <>.)
    * guix/build/utils.scm (file-header-match): Catch 'system-error', and
      return #f upon EISDIR.
 guix/build/utils.scm |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index a3050b9..c480dbf 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -122,7 +122,13 @@ with the bytes in HEADER, a bytevector."
           (get-bytevector-n port len))
         #:binary #t #:guess-encoding #f))
-    (equal? (get-header) header)))
+    (catch 'system-error
+      (lambda ()
+        (equal? (get-header) header))
+      (lambda args
+        (if (= EISDIR (system-error-errno args))
+            #f                                    ;FILE is a directory
+            (apply throw args))))))
 (define %elf-magic-bytes
   ;; Magic bytes of ELF files.  See <elf.h>.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]