summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnu/packages/autotools.scm35
1 files changed, 34 insertions, 1 deletions
diff --git a/gnu/packages/autotools.scm b/gnu/packages/autotools.scm
index bc4dddc01f..51aadbf0ec 100644
--- a/gnu/packages/autotools.scm
+++ b/gnu/packages/autotools.scm
@@ -151,6 +151,11 @@ exec ~a --no-auto-compile \"$0\" \"$@\"
,(search-patch "automake-skip-amhello-tests.patch"))))
(arguments
'(#:patches (list (assoc-ref %build-inputs "patch/skip-amhello"))
+ #:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-1)
+ (srfi srfi-26)
+ (rnrs io ports))
#:phases (alist-cons-before
'patch-source-shebangs 'patch-tests-shebangs
(lambda _
@@ -163,7 +168,35 @@ exec ~a --no-auto-compile \"$0\" \"$@\"
;; that occur during the test suite.
(setenv "SHELL" sh)
(setenv "CONFIG_SHELL" sh)))
- %standard-phases)))
+
+ ;; Files like `install-sh', `mdate.sh', etc. must use
+ ;; #!/bin/sh, otherwise users could leak erroneous shebangs
+ ;; in the wild. See <http://bugs.gnu.org/14201> for an
+ ;; example.
+ (alist-cons-after
+ 'install 'unpatch-shebangs
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (dir (string-append out "/share")))
+ (define (starts-with-shebang? file)
+ (equal? (call-with-input-file file
+ (lambda (p)
+ (list (get-u8 p) (get-u8 p))))
+ (map char->integer '(#\# #\!))))
+
+ (for-each (lambda (file)
+ (when (and (starts-with-shebang? file)
+ (executable-file? file))
+ (format #t "restoring shebang on `~a'~%"
+ file)
+ (substitute* file
+ (("^#!.*/bin/sh")
+ "#!/bin/sh")
+ (("^#!.*/bin/env(.*)$" _ args)
+ (string-append "#!/usr/bin/env"
+ args)))))
+ (find-files dir ".*"))))
+ %standard-phases))))
(home-page "http://www.gnu.org/software/automake/")
(synopsis
"GNU Automake, a GNU standard-compliant makefile generator")