build-system/gnu: Use executables from the target inputs in 'patch-shebangs'.

Fixes <http://bugs.gnu.org/18895>.

* guix/build/gnu-build-system.scm (patch-shebangs): Add #:inputs
  parameter.  Remove 'bindirs'.  Add 'bin-directories',
  'output-bindirs', and 'input-bindirs'.  Use them instead of (getenv
  "PATH") to as the argument to 'patch-shebang'.
This commit is contained in:
Ludovic Courtès 2015-01-04 18:16:16 +01:00
parent cf81a23639
commit ac70048be2
1 changed files with 17 additions and 11 deletions

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -265,7 +265,7 @@ makefiles."
(define* (install #:key (make-flags '()) #:allow-other-keys) (define* (install #:key (make-flags '()) #:allow-other-keys)
(zero? (apply system* "make" "install" make-flags))) (zero? (apply system* "make" "install" make-flags)))
(define* (patch-shebangs #:key outputs (patch-shebangs? #t) (define* (patch-shebangs #:key inputs outputs (patch-shebangs? #t)
#:allow-other-keys) #:allow-other-keys)
(define (list-of-files dir) (define (list-of-files dir)
(map (cut string-append dir "/" <>) (map (cut string-append dir "/" <>)
@ -274,20 +274,26 @@ makefiles."
(eq? 'regular (stat:type s))))) (eq? 'regular (stat:type s)))))
'()))) '())))
(define bindirs (define bin-directories
(append-map (match-lambda (match-lambda
((_ . dir) ((_ . dir)
(list (string-append dir "/bin") (list (string-append dir "/bin")
(string-append dir "/sbin")))) (string-append dir "/sbin")))))
outputs))
(define output-bindirs
(append-map bin-directories outputs))
(define input-bindirs
;; Shebangs should refer to binaries of the target system---i.e., from
;; "inputs", not from "native-inputs".
(append-map bin-directories inputs))
(when patch-shebangs? (when patch-shebangs?
(let ((path (append bindirs (let ((path (append output-bindirs input-bindirs)))
(search-path-as-string->list (getenv "PATH")))))
(for-each (lambda (dir) (for-each (lambda (dir)
(let ((files (list-of-files dir))) (let ((files (list-of-files dir)))
(for-each (cut patch-shebang <> path) files))) (for-each (cut patch-shebang <> path) files)))
bindirs))) output-bindirs)))
#t) #t)
(define* (strip #:key target outputs (strip-binaries? #t) (define* (strip #:key target outputs (strip-binaries? #t)