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.
This commit is contained in:
Ludovic Courtès 2014-11-23 19:15:21 +01:00
parent 1d1fa9327c
commit c23d17095d

View file

@ -122,7 +122,13 @@ (define (get-header)
(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>.