From 883f77d92f5b1e8af294f88abea0b09487fb901b Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Thu, 21 Aug 2014 11:30:08 -0400 Subject: [PATCH 2/3] gnu-build-system: Add 'patch-usr-bin-file' to %standard-phases. * guix/build/gnu-build-system.scm (patch-usr-bin-file): New procedure. (%standard-phases): Add it. --- guix/build/gnu-build-system.scm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm index 8636931..a1fe26e 100644 --- a/guix/build/gnu-build-system.scm +++ b/guix/build/gnu-build-system.scm @@ -106,6 +106,31 @@ working directory." (and (zero? (system* "tar" "xvf" source)) (chdir (first-subdirectory "."))))) +(define* (patch-usr-bin-file #:key native-inputs inputs #:allow-other-keys) + "Patch occurrences of /usr/bin/file in configure, if present." + (let ((file "configure") + (file-command (or (and=> (assoc-ref (or native-inputs inputs) "file") + (cut string-append <> "/bin/file")) + (which "file")))) + (cond ((not (file-exists? file)) + (format (current-error-port) + "patch-usr-bin-file: warning: `~a' not found~%" + file)) + ((not file-command) + (format (current-error-port) + "patch-usr-bin-file: warning: `file' not found in PATH~%")) + (else + (let ((st (stat file))) + (substitute* file + (("/usr/bin/file") + (begin + (format (current-error-port) + "patch-usr-bin-file: ~a: changing `~a' to `~a'~%" + file "/usr/bin/file" file-command) + file-command))) + (set-file-time file st)))) + #t)) + (define* (patch-source-shebangs #:key source #:allow-other-keys) "Patch shebangs in all source files; this includes non-executable files such as `.in' templates. Most scripts honor $SHELL and @@ -353,6 +378,7 @@ makefiles." (let-syntax ((phases (syntax-rules () ((_ p ...) `((p . ,p) ...))))) (phases set-paths unpack + patch-usr-bin-file patch-source-shebangs configure patch-generated-file-shebangs build check install patch-shebangs strip))) -- 1.8.4