~ruther/guix-local

9d1d434cd07d8a0372b113c2c0efacd2eb6e258a — Ludovic Courtès 13 years ago cb1427d
build-system/gnu: Avoid using /bin/sh.

* guix/build/gnu-build-system.scm (configure): Add `inputs' keyword
  parameter.  Take Bash from there, falling back to /bin/sh.  Set
  `CONFIG_SHELL' and `SHELL' to that Bash.  Run "bash ./configure"
  instead of just "./configure".
* distro/packages/bootstrap.scm (%bootstrap-inputs): Add "bash".
* distro/packages/base.scm (gcc-boot0-wrapped): Use "bash" from
  %BOOT1-INPUTS instead of /bin/sh.
3 files changed, 22 insertions(+), 6 deletions(-)

M distro/packages/base.scm
M distro/packages/bootstrap.scm
M guix/build/gnu-build-system.scm
M distro/packages/base.scm => distro/packages/base.scm +5 -2
@@ 774,6 774,7 @@ identifier SYSTEM."
                    (let* ((binutils (assoc-ref %build-inputs "binutils"))
                           (gcc      (assoc-ref %build-inputs "gcc"))
                           (libc     (assoc-ref %build-inputs "libc"))
                           (bash     (assoc-ref %build-inputs "bash"))
                           (out      (assoc-ref %outputs "out"))
                           (bindir   (string-append out "/bin"))
                           (triplet  ,(boot-triplet system)))


@@ 790,8 791,9 @@ identifier SYSTEM."
                        ;; the dynamic linker.
                        (call-with-output-file "gcc"
                          (lambda (p)
                            (format p "#!/bin/sh
                            (format p "#!~a/bin/bash
exec ~a/bin/~a-gcc -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
                                    bash
                                    gcc triplet
                                    libc libc
                                    ,(glibc-dynamic-linker system))))


@@ 800,7 802,8 @@ exec ~a/bin/~a-gcc -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
    (native-inputs
     `(("binutils" ,binutils-boot0)
       ("gcc" ,gcc-boot0)
       ("libc" ,glibc-final)))
       ("libc" ,glibc-final)
       ("bash" ,(assoc-ref %boot1-inputs "bash"))))
    (inputs '())))

(define %boot2-inputs

M distro/packages/bootstrap.scm => distro/packages/bootstrap.scm +4 -1
@@ 366,6 366,9 @@ exec ~a/bin/.gcc-wrapped -B~a/lib \
  `(("libc" ,%bootstrap-glibc)
    ("gcc" ,%bootstrap-gcc)
    ("binutils" ,%bootstrap-binutils)
    ("coreutils&co" ,%bootstrap-coreutils&co)))
    ("coreutils&co" ,%bootstrap-coreutils&co)

    ;; In gnu-build-system.scm, we rely on the availability of Bash.
    ("bash" ,%bootstrap-coreutils&co)))

;;; bootstrap.scm ends here

M guix/build/gnu-build-system.scm => guix/build/gnu-build-system.scm +13 -3
@@ 90,12 90,17 @@
                         (append patch-flags (list "--input" p)))))
         patches))

(define* (configure #:key outputs (configure-flags '()) out-of-source?
(define* (configure #:key inputs outputs (configure-flags '()) out-of-source?
                    #:allow-other-keys)
  (let* ((prefix     (assoc-ref outputs "out"))
         (libdir     (assoc-ref outputs "lib"))
         (includedir (assoc-ref outputs "include"))
         (flags      `(,(string-append "--prefix=" prefix)
         (bash       (or (and=> (assoc-ref inputs "bash")
                                (cut string-append <> "/bin/bash"))
                         "/bin/sh"))
         (flags      `(,(string-append "CONFIG_SHELL=" bash)
                       ,(string-append "SHELL=" bash)
                       ,(string-append "--prefix=" prefix)
                       "--enable-fast-install"    ; when using Libtool

                       ;; Produce multiple outputs when specific output names


@@ 121,10 126,15 @@
    (format #t "build directory: ~s~%" (getcwd))
    (format #t "configure flags: ~s~%" flags)

    ;; Use BASH to reduce reliance on /bin/sh since it may not always be
    ;; reliable (see
    ;; <http://thread.gmane.org/gmane.linux.distributions.nixos/9748>
    ;; for a summary of the situation.)
    ;;
    ;; Call `configure' with a relative path.  Otherwise, GCC's build system
    ;; (for instance) records absolute source file names, which typically
    ;; contain the hash part of the `.drv' file, leading to a reference leak.
    (zero? (apply system*
    (zero? (apply system* bash
                  (string-append srcdir "/configure")
                  flags))))