summaryrefslogtreecommitdiff
path: root/guix/build/gnu-build-system.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2012-12-15 16:35:26 +0100
committerLudovic Courtès <ludo@gnu.org>2012-12-15 16:35:26 +0100
commitd008415219df27f0b0ab000ceed12226183cd9b2 (patch)
tree83debd8ecf8b08bd89646d36c251b8755da1b2c6 /guix/build/gnu-build-system.scm
parentc1c94acf3206a086358e2ea39aa011c8299d29e5 (diff)
downloadguix-patches-d008415219df27f0b0ab000ceed12226183cd9b2.tar
guix-patches-d008415219df27f0b0ab000ceed12226183cd9b2.tar.gz
build-system/gnu: Patch shebangs in executable source files.
This allows many packages to build in a chroot that lacks /bin and thus /bin/sh. * guix/build/gnu-build-system.scm (patch-source-shebangs): New procedure. (%standard-phases): Add it. * guix/build/utils.scm (executable-file?): New procedure. * distro/packages/perl.scm (perl): Don't use /bin/sh to run `Configure'.
Diffstat (limited to 'guix/build/gnu-build-system.scm')
-rw-r--r--guix/build/gnu-build-system.scm21
1 files changed, 20 insertions, 1 deletions
diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index 3b139a99b8..b67918552c 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -82,6 +82,24 @@
(and (zero? (system* "tar" "xvf" source))
(chdir (first-subdirectory "."))))
+(define* (patch-source-shebangs #:key source #:allow-other-keys)
+ ;; Patch shebangs in executable source files. Most scripts honor
+ ;; $SHELL and $CONFIG_SHELL, but some don't, such as `mkinstalldirs'
+ ;; or Automake's `missing' script.
+ (for-each patch-shebang
+ (filter (lambda (file)
+ (and (executable-file? file)
+ (not (file-is-directory? file))))
+ (find-files "." ".*")))
+
+ ;; Gettext-generated po/Makefile.in.in does not honor $SHELL.
+ (let ((bash (search-path (search-path-as-string->list (getenv "PATH"))
+ "bash")))
+ (when (file-exists? "po/Makefile.in.in")
+ (substitute* "po/Makefile.in.in"
+ (("^SHELL[[:blank:]]*=.*$")
+ (string-append "SHELL = " bash))))))
+
(define* (patch #:key (patches '()) (patch-flags '("--batch" "-p1"))
#:allow-other-keys)
(every (lambda (p)
@@ -231,7 +249,8 @@
;; Standard build phases, as a list of symbol/procedure pairs.
(let-syntax ((phases (syntax-rules ()
((_ p ...) `((p . ,p) ...)))))
- (phases set-paths unpack patch configure build check install
+ (phases set-paths unpack patch-source-shebangs patch configure
+ build check install
patch-shebangs strip)))