~ruther/guix-local

c23d17095db0611d8ee32357f17da441bcb0bc75 — Ludovic Courtès 11 years ago 1d1fa93
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 <http://hydra.gnu.org/build/167310/nixlog/1/tail-reload>.)

* guix/build/utils.scm (file-header-match): Catch 'system-error', and
  return #f upon EISDIR.
1 files changed, 7 insertions(+), 1 deletions(-)

M guix/build/utils.scm
M guix/build/utils.scm => guix/build/utils.scm +7 -1
@@ 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>.