aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2014-08-21 11:30:08 -0400
committerMark H Weaver <mhw@netris.org>2014-08-23 20:48:18 -0400
commit8a0576f175a656a332c5a4ca65168e76c56af5c3 (patch)
tree970d3e091bf0ac0932eaae0a1c01d0719ae3d392
parent8f5708c1d8fbdc9065b8968d0112f7ee40d8dc97 (diff)
downloadgnu-guix-8a0576f175a656a332c5a4ca65168e76c56af5c3.tar
gnu-guix-8a0576f175a656a332c5a4ca65168e76c56af5c3.tar.gz
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.
-rw-r--r--guix/build/gnu-build-system.scm30
1 files changed, 30 insertions, 0 deletions
diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index 8636931ed9..17fa7afd8d 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -106,6 +106,35 @@ working directory."
(and (zero? (system* "tar" "xvf" source))
(chdir (first-subdirectory ".")))))
+;; See <http://bugs.gnu.org/17840>.
+(define* (patch-usr-bin-file #:key native-inputs inputs
+ (patch-/usr/bin/file? #t)
+ #:allow-other-keys)
+ "Patch occurrences of /usr/bin/file in configure, if present."
+ (when patch-/usr/bin/file?
+ (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 +382,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)))