From 6e32f6c019c35a8092f1285be67aaa7dd04c0f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 20 Dec 2012 00:49:06 +0100 Subject: [PATCH] distro: glibc: Add a statically-linked Bash to $out/bin. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * distro/packages/base.scm (glibc): Pass `ac_cv_path_BASH_SHELL' in the configure flags. During the `pre-configure' phase, copy the "static-bash" input to $out/bin, and change `system' and `popen' to use it instead of /bin/sh. Add the "static-bash" input. Suggested by Shea Levy and LluĂ­s Batlle i Rossell . --- distro/packages/base.scm | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/distro/packages/base.scm b/distro/packages/base.scm index 58c39ce7cd..7cb2dc116e 100644 --- a/distro/packages/base.scm +++ b/distro/packages/base.scm @@ -499,12 +499,19 @@ (define-public glibc "--enable-kernel=2.6.30" ;; XXX: Work around "undefined reference to `__stack_chk_guard'". - "libc_cv_ssp=no") + "libc_cv_ssp=no" + + ;; Use our Bash instead of /bin/sh. + (string-append "ac_cv_path_BASH_SHELL=" + (assoc-ref %build-inputs "bash") + "/bin/bash")) + #:tests? #f ; XXX #:phases (alist-cons-before 'configure 'pre-configure - (lambda* (#:key outputs #:allow-other-keys) - (let ((out (assoc-ref outputs "out"))) + (lambda* (#:key inputs outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (bin (string-append out "/bin"))) ;; Use `pwd', not `/bin/pwd'. (substitute* "configure" (("/bin/pwd") "pwd")) @@ -522,10 +529,28 @@ (define-public glibc ;; , ;; linking against libgcc_s is not needed with GCC ;; 4.7.1. - ((" -lgcc_s") "")))) + ((" -lgcc_s") "")) + + ;; Copy a statically-linked Bash in the output. + (mkdir-p bin) + (copy-file (assoc-ref inputs "static-bash") + (string-append bin "/bash")) + (chmod (string-append bin "/bash") #o555) + + ;; Have `system' use that Bash. + (substitute* "sysdeps/posix/system.c" + (("#define[[:blank:]]+SHELL_PATH.*$") + (format #f "#define SHELL_PATH \"~a/bin/bash\"\n" + out))) + + ;; Same for `popen'. + (substitute* "libio/iopopen.c" + (("/bin/sh") + (string-append out "/bin/bash"))))) %standard-phases))) (inputs `(("patch/ld.so.cache" - ,(search-patch "glibc-no-ld-so-cache.patch")))) + ,(search-patch "glibc-no-ld-so-cache.patch")) + ("static-bash" ,(cut search-bootstrap-binary "bash" <>)))) (synopsis "The GNU C Library") (description "Any Unix-like operating system needs a C library: the library which