summary refs log tree commit diff
path: root/distro
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-01-11 16:01:49 +0100
committerLudovic Courtès <ludo@gnu.org>2013-01-11 16:01:49 +0100
commit01e354eb83299d00ddd6ba4beb73bac8130beeae (patch)
tree03368edd8462d818334bec458cd04dc1de4750a1 /distro
parentbfe384cc4c7e56ac1eceff8b5d92e916507436eb (diff)
parent28e55604212c01884a77a4f5eb66294c4957c48a (diff)
downloadguix-01e354eb83299d00ddd6ba4beb73bac8130beeae.tar.gz
Merge branch 'core-updates'
Conflicts:
	guix/build/union.scm
Diffstat (limited to 'distro')
-rw-r--r--distro/packages/acl.scm20
-rw-r--r--distro/packages/attr.scm40
-rw-r--r--distro/packages/autotools.scm34
-rw-r--r--distro/packages/base.scm285
-rw-r--r--distro/packages/bash.scm41
-rw-r--r--distro/packages/bdb.scm4
-rw-r--r--distro/packages/bootstrap.scm33
-rw-r--r--distro/packages/compression.scm1
-rw-r--r--distro/packages/gawk.scm31
-rw-r--r--distro/packages/gettext.scm15
-rw-r--r--distro/packages/guile.scm20
-rw-r--r--distro/packages/ld-wrapper.scm18
-rw-r--r--distro/packages/libsigsegv.scm3
-rw-r--r--distro/packages/linux.scm11
-rw-r--r--distro/packages/lsh.scm5
-rw-r--r--distro/packages/m4.scm14
-rw-r--r--distro/packages/make-bootstrap.scm308
-rw-r--r--distro/packages/multiprecision.scm29
-rw-r--r--distro/packages/ncurses.scm39
-rw-r--r--distro/packages/openssl.scm68
-rw-r--r--distro/packages/patches/gawk-shell.patch34
-rw-r--r--distro/packages/patches/glibc-bootstrap-system.patch28
-rw-r--r--distro/packages/perl.scm12
-rw-r--r--distro/packages/readline.scm80
-rw-r--r--distro/packages/time.scm18
25 files changed, 820 insertions, 371 deletions
diff --git a/distro/packages/acl.scm b/distro/packages/acl.scm
index 4f425be253..068789b562 100644
--- a/distro/packages/acl.scm
+++ b/distro/packages/acl.scm
@@ -41,15 +41,19 @@
     (build-system gnu-build-system)
     (arguments
      `(#:phases
-       (alist-replace 'check
-                      (lambda _
-                        (patch-shebang "test/run")
-                        (system* "make" "tests" "-C" "test")
+       (alist-cons-after
+        'configure 'patch-makefile-SHELL
+        (lambda _
+          (patch-makefile-SHELL "include/buildmacros"))
+        (alist-replace
+         'check
+         (lambda _
+           (system* "make" "tests" "-C" "test")
 
-                        ;; XXX: Ignore the test result since this is
-                        ;; dependent on the underlying file system.
-                        #t)
-                      %standard-phases)))
+           ;; XXX: Ignore the test result since this is
+           ;; dependent on the underlying file system.
+           #t)
+         %standard-phases))))
     (inputs `(("attr" ,attr)
               ("gettext" ,guix:gettext)
               ("perl" ,perl)))
diff --git a/distro/packages/attr.scm b/distro/packages/attr.scm
index 8326754261..ae0d257dbe 100644
--- a/distro/packages/attr.scm
+++ b/distro/packages/attr.scm
@@ -41,23 +41,31 @@
     (build-system gnu-build-system)
     (arguments
      `(#:phases
-       (alist-replace 'install
-                      (lambda _
-                        (zero? (system* "make"
-                                        "install"
-                                        "install-lib"
-                                        "install-dev")))
-                      (alist-replace 'check
-                                     (lambda _
-                                       (for-each patch-shebang
-                                                 (find-files "test" ".*"))
-                                       (system* "make" "tests" "-C" "test")
+       (alist-cons-after
+        'configure 'patch-makefile-SHELL
+        (lambda _
+          (patch-makefile-SHELL "include/buildmacros"))
+        (alist-replace
+         'install
+         (lambda _
+           (zero? (system* "make"
+                           "install"
+                           "install-lib"
+                           "install-dev")))
+         (alist-replace
+          'check
+          (lambda _
+            ;; Use the right shell.
+            (substitute* "test/run"
+              (("/bin/sh")
+               (which "bash")))
 
-                                       ;; XXX: Ignore the test result since
-                                       ;; this is dependent on the underlying
-                                       ;; file system.
-                                       #t)
-                                     %standard-phases))))
+            (system* "make" "tests" "-C" "test")
+
+            ;; XXX: Ignore the test result since this is dependent on the
+            ;; underlying file system.
+            #t)
+          %standard-phases)))))
     (inputs `(("perl" ,perl)
               ("gettext" ,guix:gettext)))
     (home-page
diff --git a/distro/packages/autotools.scm b/distro/packages/autotools.scm
index a472ce13dd..06568b2224 100644
--- a/distro/packages/autotools.scm
+++ b/distro/packages/autotools.scm
@@ -1,6 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
-;;; Copyright © 2012 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -99,9 +99,37 @@ Standards.  Automake requires the use of Autoconf.")
     (build-system gnu-build-system)
     (native-inputs `(("m4" ,m4)
                      ("perl" ,perl)))
+
+    ;; Separate binaries from the rest.  During bootstrap, only ltdl is
+    ;; used; not depending on the binaries allows us to avoid retaining
+    ;; a reference to the bootstrap bash.
+    (outputs '("bin"                         ; libtoolize, libtool, etc.
+               "out"))                       ; libltdl.so, ltdl.h, etc.
+
     (arguments
-     ;; TODO: Use `TESTSUITEFLAGS=-jN' for tests.
-     `(#:patches (list (assoc-ref %build-inputs "patch/skip-tests"))))
+     `(#:patches (list (assoc-ref %build-inputs "patch/skip-tests"))
+       #:phases (alist-cons-before
+                 'check 'pre-check
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   ;; Run the test suite in parallel, if possible.
+                   (let ((ncores
+                          (cond
+                           ((getenv "NIX_BUILD_CORES")
+                            =>
+                            (lambda (n)
+                              (if (zero? (string->number n))
+                                  (number->string (current-processor-count))
+                                  n)))
+                           (else "1"))))
+                    (setenv "TESTSUITEFLAGS"
+                            (string-append "-j" ncores)))
+
+                   ;; Path references to /bin/sh.
+                   (let ((bash (assoc-ref inputs "bash")))
+                     (substitute* "tests/testsuite"
+                       (("/bin/sh")
+                        (string-append bash "/bin/bash")))))
+                 %standard-phases)))
     (inputs `(("patch/skip-tests"
                ,(search-patch "libtool-skip-tests.patch"))))
     (synopsis "GNU Libtool, a generic library support script")
diff --git a/distro/packages/base.scm b/distro/packages/base.scm
index 0f60e983bc..bc705f16e7 100644
--- a/distro/packages/base.scm
+++ b/distro/packages/base.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -20,6 +20,7 @@
 (define-module (distro packages base)
   #:use-module (guix licenses)
   #:use-module (distro)
+  #:use-module (distro packages acl)
   #:use-module (distro packages bash)
   #:use-module (distro packages bootstrap)
   #:use-module (distro packages compression)
@@ -97,6 +98,17 @@ lines.")
               "13wlsb4sf5d5a82xjhxqmdvrrn36rmw5f0pl9qyb9zkvldnb7hra"))))
    (build-system gnu-build-system)
    (synopsis "GNU sed, a batch stream editor")
+   (arguments
+    `(#:phases (alist-cons-before
+                'patch-source-shebangs 'patch-test-suite
+                (lambda* (#:key inputs #:allow-other-keys)
+                  (let ((bash (assoc-ref inputs "bash")))
+                    (patch-makefile-SHELL "testsuite/Makefile.tests")
+                    (substitute* '("testsuite/bsd.sh"
+                                   "testsuite/bug-regex9.c")
+                      (("/bin/sh")
+                       (string-append bash "/bin/bash")))))
+                %standard-phases)))
    (description
     "Sed (stream editor) isn't really a true text editor or text processor.
 Instead, it is used to filter text, i.e., it takes text input and performs
@@ -252,19 +264,33 @@ The tools supplied with this package are:
 (define-public coreutils
   (package
    (name "coreutils")
-   (version "8.19")
+   (version "8.20")
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://gnu/coreutils/coreutils-"
                                 version ".tar.xz"))
             (sha256
              (base32
-              "1rx9x3fp848w4nny7irdkcpkan9fcx24d99v5dkwgkyq7wc76f5d"))))
+              "1cly97xdy3v4nbbx631k43smqw0nnpn651kkprs0yyl2cj3pkjyv"))))
    (build-system gnu-build-system)
-   (inputs `())                      ; TODO: optional deps: SELinux, ACL, GMP
+   (inputs `(("acl"  ,acl)
+             ("gmp"  ,gmp)
+             ("perl" ,perl)))                     ; TODO: add SELinux
    (arguments
-    '(;; Perl is missing, and some tests are failing.
-      #:tests? #f))
+    `(#:parallel-build? #f            ; help2man may be called too early
+      #:phases (alist-cons-before
+                'build 'patch-shell-references
+                (lambda* (#:key inputs #:allow-other-keys)
+                  (let ((bash (assoc-ref inputs "bash")))
+                    (substitute* (cons "src/split.c"
+                                       (find-files "gnulib-tests"
+                                                   "\\.c$"))
+                      (("/bin/sh")
+                       (format #f "~a/bin/sh" bash)))
+                    (substitute* (find-files "tests" "\\.sh$")
+                      (("#!/bin/sh")
+                       (format #f "#!~a/bin/bash" bash)))))
+                %standard-phases)))
    (synopsis
     "The basic file, shell and text manipulation utilities of the GNU
 operating system")
@@ -289,8 +315,18 @@ are expected to exist on every operating system.")
    (build-system gnu-build-system)
    (native-inputs
     `(("patch/impure-dirs" ,(search-patch "make-impure-dirs.patch"))))
-   (arguments `(#:patches (list (assoc-ref %build-inputs
-                                           "patch/impure-dirs"))))
+   (arguments
+    '(#:patches (list (assoc-ref %build-inputs "patch/impure-dirs"))
+      #:phases (alist-cons-before
+                'build 'set-default-shell
+                (lambda* (#:key inputs #:allow-other-keys)
+                  ;; Change the default shell from /bin/sh.
+                  (let ((bash (assoc-ref inputs "bash")))
+                    (substitute* "job.c"
+                      (("default_shell\\[\\] =.*$")
+                       (format #f "default_shell[] = \"~a/bin/bash\";\n"
+                               bash)))))
+                %standard-phases)))
    (synopsis "GNU Make, a program controlling the generation of non-source
 files from sources")
    (description
@@ -317,6 +353,11 @@ that it is possible to use Make to build and install the program.")
               "1a9w66v5dwvbnawshjwqcgz7km6kw6ihkzp6sswv9ycc3knzhykc"))))
    (build-system gnu-build-system)
 
+   ;; Split Binutils in several outputs, mostly to avoid collisions in
+   ;; user profiles with GCC---e.g., libiberty.a.
+   (outputs '("out"                        ; ar, ld, binutils.info, etc.
+              "lib"))                      ; libbfd.a, bfd.h, etc.
+
    ;; TODO: Add dependency on zlib + those for Gold.
    (native-inputs
     `(("patch/new-dtags" ,(search-patch "binutils-ld-new-dtags.patch"))))
@@ -455,14 +496,14 @@ used in the GNU system including the GNU/Linux variant.")
 (define-public glibc
   (package
    (name "glibc")
-   (version "2.16.0")
+   (version "2.17")
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://gnu/glibc/glibc-"
                                 version ".tar.xz"))
             (sha256
              (base32
-              "092rdm49zh6l1pqkxbcpcaawgsgzxhpf1s7wf5wi5dvc5am3dp0y"))))
+              "0gmjnn4kma9vgizccw1jv979xw55a8n1nkk94gg0l3hy80vy6539"))))
    (build-system gnu-build-system)
 
    ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
@@ -485,13 +526,20 @@ used in the GNU system including the GNU/Linux variant.")
             ;; GNU libc for details.
             "--enable-kernel=2.6.30"
 
+            ;; Use our Bash instead of /bin/sh.
+            (string-append "BASH_SHELL="
+                           (assoc-ref %build-inputs "bash")
+                           "/bin/bash")
+
             ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
             "libc_cv_ssp=no")
+
       #: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"))
@@ -509,10 +557,35 @@ used in the GNU system including the GNU/Linux variant.")
                       ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
                       ;; linking against libgcc_s is not needed with GCC
                       ;; 4.7.1.
-                      ((" -lgcc_s") ""))))
+                      ((" -lgcc_s") ""))
+
+                    ;; Copy a statically-linked Bash in the output, with
+                    ;; no references to other store paths.
+                    (mkdir-p bin)
+                    (copy-file (string-append (assoc-ref inputs "static-bash")
+                                              "/bin/bash")
+                               (string-append bin "/bash"))
+                    (remove-store-references (string-append bin "/bash"))
+                    (chmod (string-append bin "/bash") #o555)
+
+                    ;; Keep a symlink, for `patch-shebang' resolution.
+                    (with-directory-excursion bin
+                      (symlink "bash" "sh"))
+
+                    ;; 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" ,(static-package bash-light))))
    (synopsis "The GNU C Library")
    (description
     "Any Unix-like operating system needs a C library: the library which
@@ -534,21 +607,23 @@ with the Linux kernel.")
    (package (inherit gnu-make)
      (name "make-boot0")
      (location (source-properties->location (current-source-location)))
-     (arguments `(#:guile ,%bootstrap-guile
-                  #:implicit-inputs? #f
-                  #:tests? #f                  ; cannot run "make check"
-                  #:phases
-                  (alist-replace
-                   'build (lambda _
-                            (zero? (system* "./build.sh")))
-                   (alist-replace
-                    'install (lambda* (#:key outputs #:allow-other-keys)
-                               (let* ((out (assoc-ref outputs "out"))
-                                      (bin (string-append out "/bin")))
-                                 (mkdir-p bin)
-                                 (copy-file "make"
-                                            (string-append bin "/make"))))
-                    %standard-phases))))
+     (arguments
+      `(#:guile ,%bootstrap-guile
+        #:implicit-inputs? #f
+        #:tests? #f                  ; cannot run "make check"
+        ,@(substitute-keyword-arguments (package-arguments gnu-make)
+            ((#:phases phases)
+             `(alist-replace
+               'build (lambda _
+                        (zero? (system* "./build.sh")))
+               (alist-replace
+                'install (lambda* (#:key outputs #:allow-other-keys)
+                           (let* ((out (assoc-ref outputs "out"))
+                                  (bin (string-append out "/bin")))
+                             (mkdir-p bin)
+                             (copy-file "make"
+                                        (string-append bin "/make"))))
+                ,phases))))))
      (inputs %bootstrap-inputs))))
 
 (define diffutils-boot0
@@ -728,82 +803,125 @@ identifier SYSTEM."
     ;; cross-`as'.
     ,@%boot0-inputs))
 
-(define-public glibc-final
+(define glibc-final-with-bootstrap-bash
   ;; The final libc, "cross-built".  If everything went well, the resulting
-  ;; store path has no dependencies.
+  ;; store path has no dependencies.  Actually, the really-final libc is
+  ;; built just below; the only difference is that this one uses the
+  ;; bootstrap Bash.
   (package-with-bootstrap-guile
    (package (inherit glibc)
+     (name "glibc-intermediate")
      (arguments
       (lambda (system)
         `(#:guile ,%bootstrap-guile
           #:implicit-inputs? #f
 
-          ;; Leave /bin/sh as the interpreter for `ldd', `sotruss', etc. to
-          ;; avoid keeping a reference to the bootstrap Bash.
-          #:patch-shebangs? #f
           ,@(substitute-keyword-arguments (package-arguments glibc)
               ((#:configure-flags flags)
                `(append (list ,(string-append "--host=" (boot-triplet system))
                               ,(string-append "--build="
                                               (nix-system->gnu-triplet system))
-                              "BASH_SHELL=/bin/sh"
 
                               ;; Build Sun/ONC RPC support.  In particular,
                               ;; install rpc/*.h.
                               "--enable-obsolete-rpc")
                         ,flags))))))
      (propagated-inputs `(("linux-headers" ,linux-libre-headers-boot0)))
-     (inputs `( ;; A native GCC is needed to build `cross-rpcgen'.
-               ("native-gcc" ,@(assoc-ref %boot0-inputs "gcc"))
-               ,@%boot1-inputs
-               ,@(package-inputs glibc))))))      ; patches
+     (inputs
+      `( ;; A native GCC is needed to build `cross-rpcgen'.
+        ("native-gcc" ,@(assoc-ref %boot0-inputs "gcc"))
 
-(define gcc-boot0-wrapped
-  ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
-  ;; non-cross names.
+        ;; Here, we use the bootstrap Bash, which is not satisfactory
+        ;; because we don't want to depend on bootstrap tools.
+        ("static-bash" ,@(assoc-ref %boot0-inputs "bash"))
+
+        ,@%boot1-inputs
+        ,@(alist-delete "static-bash"
+                        (package-inputs glibc))))))) ; patches
+
+(define (cross-gcc-wrapper gcc binutils glibc bash)
+  "Return a wrapper for the pseudo-cross toolchain GCC/BINUTILS/GLIBC
+that makes it available under the native tool names."
   (package (inherit gcc-4.7)
-    (name (string-append (package-name gcc-boot0) "-wrapped"))
+    (name (string-append (package-name gcc) "-wrapped"))
     (source #f)
     (build-system trivial-build-system)
     (arguments
      (lambda (system)
-      `(#:guile ,%bootstrap-guile
-        #:modules ((guix build utils))
-        #:builder (begin
-                    (use-modules (guix build utils))
-
-                    (let* ((binutils (assoc-ref %build-inputs "binutils"))
-                           (gcc      (assoc-ref %build-inputs "gcc"))
-                           (libc     (assoc-ref %build-inputs "libc"))
-                           (out      (assoc-ref %outputs "out"))
-                           (bindir   (string-append out "/bin"))
-                           (triplet  ,(boot-triplet system)))
-                      (mkdir-p bindir)
-                      (with-directory-excursion bindir
-                        (for-each (lambda (tool)
-                                    (symlink (string-append binutils "/bin/"
-                                                            triplet "-" tool)
-                                             tool))
-                                  '("ar" "ranlib"))
-
-                        ;; GCC-BOOT0 is a libc-less cross-compiler, so it
-                        ;; needs to be told where to find the crt files and
-                        ;; the dynamic linker.
-                        (call-with-output-file "gcc"
-                          (lambda (p)
-                            (format p "#!/bin/sh
+       `(#:guile ,%bootstrap-guile
+         #:modules ((guix build utils))
+         #:builder (begin
+                     (use-modules (guix build utils))
+
+                     (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)))
+                       (mkdir-p bindir)
+                       (with-directory-excursion bindir
+                         (for-each (lambda (tool)
+                                     (symlink (string-append binutils "/bin/"
+                                                             triplet "-" tool)
+                                              tool))
+                                   '("ar" "ranlib"))
+
+                         ;; GCC-BOOT0 is a libc-less cross-compiler, so it
+                         ;; needs to be told where to find the crt files and
+                         ;; the dynamic linker.
+                         (call-with-output-file "gcc"
+                           (lambda (p)
+                             (format p "#!~a/bin/bash
 exec ~a/bin/~a-gcc -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
-                                    gcc triplet
-                                    libc libc
-                                    ,(glibc-dynamic-linker system))))
+                                     bash
+                                     gcc triplet
+                                     libc libc
+                                     ,(glibc-dynamic-linker system))))
 
-                        (chmod "gcc" #o555)))))))
+                         (chmod "gcc" #o555)))))))
     (native-inputs
-     `(("binutils" ,binutils-boot0)
-       ("gcc" ,gcc-boot0)
-       ("libc" ,glibc-final)))
+     `(("binutils" ,binutils)
+       ("gcc" ,gcc)
+       ("libc" ,glibc)
+       ("bash" ,bash)))
     (inputs '())))
 
+(define static-bash-for-glibc
+  ;; A statically-linked Bash to be embedded in GLIBC-FINAL, for use by
+  ;; system(3) & co.
+  (let* ((gcc  (cross-gcc-wrapper gcc-boot0 binutils-boot0
+                                  glibc-final-with-bootstrap-bash
+                                  (car (assoc-ref %boot1-inputs "bash"))))
+         (bash (package (inherit bash-light)
+                 (arguments
+                  (lambda (system)
+                    `(#:guile ,%bootstrap-guile
+                      ,@(package-arguments bash-light)))))))
+    (package-with-bootstrap-guile
+     (package-with-explicit-inputs (static-package bash)
+                                   `(("gcc" ,gcc)
+                                     ("libc" ,glibc-final-with-bootstrap-bash)
+                                     ,@(fold alist-delete %boot1-inputs
+                                             '("gcc" "libc")))
+                                   (current-source-location)))))
+
+(define-public glibc-final
+  ;; The final glibc, which embeds the statically-linked Bash built above.
+  (package (inherit glibc-final-with-bootstrap-bash)
+    (name "glibc")
+    (inputs `(("static-bash" ,static-bash-for-glibc)
+              ,@(alist-delete
+                 "static-bash"
+                 (package-inputs glibc-final-with-bootstrap-bash))))))
+
+(define gcc-boot0-wrapped
+  ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
+  ;; non-cross names.
+  (cross-gcc-wrapper gcc-boot0 binutils-boot0 glibc-final
+                     (car (assoc-ref %boot1-inputs "bash"))))
+
 (define %boot2-inputs
   ;; 3rd stage inputs.
   `(("libc" ,glibc-final)
@@ -857,9 +975,10 @@ exec ~a/bin/~a-gcc -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
     (source #f)
     (build-system trivial-build-system)
     (inputs `(("binutils" ,binutils-final)
-              ("guile"   ,%bootstrap-guile)
-              ("wrapper" ,(search-path %load-path
-                                       "distro/packages/ld-wrapper.scm"))))
+              ("guile"    ,%bootstrap-guile)
+              ("bash"     ,@(assoc-ref %boot2-inputs "bash"))
+              ("wrapper"  ,(search-path %load-path
+                                        "distro/packages/ld-wrapper.scm"))))
     (arguments
      `(#:guile ,%bootstrap-guile
        #:modules ((guix build utils))
@@ -883,6 +1002,9 @@ exec ~a/bin/~a-gcc -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
                        (("@GUILE@")
                         (string-append (assoc-ref %build-inputs "guile")
                                        "/bin/guile"))
+                       (("@BASH@")
+                        (string-append (assoc-ref %build-inputs "bash")
+                                       "/bin/bash"))
                        (("@LD@")
                         (string-append (assoc-ref %build-inputs "binutils")
                                        "/bin/ld")))
@@ -917,9 +1039,6 @@ store.")
     ,@(alist-delete "bash" %boot3-inputs)))
 
 (define-public guile-final
-  ;; FIXME: The Libtool used here, specifically its `bin/libtool' script,
-  ;; holds a dependency on the bootstrap Binutils.  Use multiple outputs for
-  ;; Libtool, so that that dependency is isolated in the "bin" output.
   (package-with-bootstrap-guile
    (package-with-explicit-inputs guile-2.0/fixed
                                  %boot4-inputs
@@ -931,7 +1050,9 @@ store.")
   (package (inherit ld-wrapper-boot3)
     (name "ld-wrapper")
     (inputs `(("guile" ,guile-final)
-              ,@(alist-delete "guile" (package-inputs ld-wrapper-boot3))))))
+              ("bash"  ,bash-final)
+              ,@(fold alist-delete (package-inputs ld-wrapper-boot3)
+                      '("guile" "bash"))))))
 
 (define-public %final-inputs
   ;; Final derivations used as implicit inputs by `gnu-build-system'.
diff --git a/distro/packages/bash.scm b/distro/packages/bash.scm
index 32a72d2347..0306c7197e 100644
--- a/distro/packages/bash.scm
+++ b/distro/packages/bash.scm
@@ -32,7 +32,13 @@
                                  "-DSTANDARD_UTILS_PATH='\"/no-such-path\"'"
                                  "-DNON_INTERACTIVE_LOGIN_SHELLS"
                                  "-DSSH_SOURCE_BASHRC")
-                               " ")))
+                               " "))
+        (post-install-phase
+         '(lambda* (#:key outputs #:allow-other-keys)
+            ;; Add a `bash' -> `sh' link.
+            (let ((out (assoc-ref outputs "out")))
+              (with-directory-excursion (string-append out "/bin")
+                (symlink "bash" "sh"))))))
     (package
      (name "bash")
      (version "4.2")
@@ -67,15 +73,9 @@
         ;; for now.
         #:tests? #f
 
-        #:phases
-        (alist-cons-after 'install 'post-install
-                          (lambda* (#:key outputs #:allow-other-keys)
-                            ;; Add a `bash' -> `sh' link.
-                            (let ((out (assoc-ref outputs "out")))
-                              (with-directory-excursion
-                                  (string-append out "/bin")
-                                (symlink "bash" "sh"))))
-                          %standard-phases)))
+        #:phases (alist-cons-after 'install 'post-install
+                                   ,post-install-phase
+                                   %standard-phases)))
      (synopsis "GNU Bourne-Again Shell")
      (description
       "Bash is the shell, or command language interpreter, that will appear in
@@ -87,3 +87,24 @@ use.  In addition, most sh scripts can be run by Bash without
 modification.")
      (license gpl3+)
      (home-page "http://www.gnu.org/software/bash/"))))
+
+(define-public bash-light
+  ;; A stripped-down Bash for non-interactive use.
+  (package (inherit bash)
+    (name "bash-light")
+    (inputs '())                                ; no readline, no curses
+    (arguments
+     (let ((args `(#:modules ((guix build gnu-build-system)
+                              (guix build utils)
+                              (srfi srfi-1)
+                              (srfi srfi-26))
+                             ,@(package-arguments bash))))
+       (substitute-keyword-arguments args
+         ((#:configure-flags flags)
+          `(list "--without-bash-malloc"
+                 "--disable-readline"
+                 "--disable-history"
+                 "--disable-help-builtin"
+                 "--disable-progcomp"
+                 "--disable-net-redirections"
+                 "--disable-nls")))))))
diff --git a/distro/packages/bdb.scm b/distro/packages/bdb.scm
index 6d6adc000c..93bf290231 100644
--- a/distro/packages/bdb.scm
+++ b/distro/packages/bdb.scm
@@ -44,7 +44,9 @@
            (let ((out (assoc-ref outputs "out")))
              (zero?
               (system* "./dist/configure"
-                       (string-append "--prefix=" out)))))
+                       (string-append "--prefix=" out)
+                       (string-append "CONFIG_SHELL=" (which "bash"))
+                       (string-append "SHELL=" (which "bash"))))))
          %standard-phases))))
    (synopsis "db, the Berkeley database")
    (description
diff --git a/distro/packages/bootstrap.scm b/distro/packages/bootstrap.scm
index 8d1d1e989d..9bf815b2d7 100644
--- a/distro/packages/bootstrap.scm
+++ b/distro/packages/bootstrap.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -167,7 +167,7 @@ check whether everything is alright."
                               (xz    (->store "xz"))
                               (mkdir (->store "mkdir"))
                               (bash  (->store "bash"))
-                              (guile (->store "guile-bootstrap-2.0.6.tar.xz"))
+                              (guile (->store "guile-2.0.7.tar.xz"))
                               (builder
                                (add-text-to-store store
                                                   "build-bootstrap-guile.sh"
@@ -205,15 +205,15 @@ $out/bin/guile --version~%"
                            (method url-fetch)
                            (uri (string-append
                                  %bootstrap-base-url "/"
-                                 system "/20121115/static-binaries.tar.xz"))
+                                 system "/20130105/static-binaries.tar.xz"))
                            (sha256
                             (match system
                               ("x86_64-linux"
                                (base32
-                                "0azisn8l2b3cvgni9k0ahzsxs5cxrj0hmf38zgpq3k6pggk3zbfm"))
+                                "0md23alzy6nc5f16pric7mkagczdzr8xbh074sb3rjzrls06j1ls"))
                               ("i686-linux"
                                (base32
-                                "16v60frbh0naccanwxcxz0z3444dd8salbg8p7cp7vwz8245nhfk"))))))
+                                "0nzj1lmm9b94g7k737cr4w1dv282w5nmhb53238ikax9r6pkc0yb"))))))
                         "true"                    ; the program to test
                         "Bootstrap binaries of Coreutils, Awk, etc."))
 
@@ -224,15 +224,15 @@ $out/bin/guile --version~%"
                            (method url-fetch)
                            (uri (string-append
                                  %bootstrap-base-url "/"
-                                 system "/20121115/binutils-2.22.tar.xz"))
+                                 system "/20130105/binutils-2.22.tar.xz"))
                            (sha256
                             (match system
                               ("x86_64-linux"
                                (base32
-                                "0ms6i035v40n7mhi91n4b8ivwv2qni3mcd5dj9sj9qmvgqb50r84"))
+                                "1ffmk2yy2pxvkqgzrkzp3s4jpn4qaaksyk3b5nsc5cjwfm7qkgzh"))
                               ("i686-linux"
                                (base32
-                                "193x62ach4l4x16rbzglrqa1d0a825z2as6czdiv9xjiizmcr0ad"))))))
+                                "1rafk6aq4sayvv3r3d2khn93nkyzf002xzh0xadlyci4mznr6b0a"))))))
                         "ld"                      ; the program to test
                         "Bootstrap binaries of the GNU Binutils"))
 
@@ -277,15 +277,15 @@ $out/bin/guile --version~%"
                       (origin
                        (method url-fetch)
                        (uri (string-append %bootstrap-base-url "/" system
-                                           "/20121115/glibc-2.16.0.tar.xz"))
+                                           "/20130105/glibc-2.17.tar.xz"))
                        (sha256
                         (match system
                           ("x86_64-linux"
                            (base32
-                            "1cz587p3scrrx0zgqnmp4nnfj0vvf01zdqdgkz445dnbfh64nl0v"))
+                            "18kv1z9d8dr1j3hm9w7663kchqw9p6rsx11n1m143jgba2jz6jy3"))
                           ("i686-linux"
                            (base32
-                            "0vzybz1577vflm0p0zg1slqj32carj5102b45k7iskkj46viy14z"))))))))))
+                            "08hv8i0axwnihrcgbz19x0a7s6zyv3yx38x8r29liwl8h82x9g88"))))))))))
     (synopsis "Bootstrap binaries and headers of the GNU C Library")
     (description #f)
     (home-page #f)))
@@ -348,15 +348,15 @@ exec ~a/bin/.gcc-wrapped -B~a/lib \
                       (origin
                        (method url-fetch)
                        (uri (string-append %bootstrap-base-url "/" system
-                                           "/20121115/gcc-4.7.2.tar.xz"))
+                                           "/20130105/gcc-4.7.2.tar.xz"))
                        (sha256
                         (match system
                           ("x86_64-linux"
                            (base32
-                            "0fg65i2qcym8ls5ig3g1cc9ida5cxwwsd6zi95xi1d8dnfrja4zz"))
+                            "1x1p7han5crnbw906iwdifykr6grzm0w27dy9gz75j0q1b32i4px"))
                           ("i686-linux"
                            (base32
-                            "01hlz98qmc8yhqrxqajpg5kbkhpvqq6wjnbfvplys32n895avzxg"))))))))))
+                            "06wqs0xxnpw3hn0xjb4c9cs0899p1xwkcysa2rvzhvpra0c5vsg2"))))))))))
     (synopsis "Bootstrap binaries of the GNU Compiler Collection")
     (description #f)
     (home-page #f)))
@@ -367,6 +367,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
diff --git a/distro/packages/compression.scm b/distro/packages/compression.scm
index 06bb4ffe86..51a2d70e2d 100644
--- a/distro/packages/compression.scm
+++ b/distro/packages/compression.scm
@@ -98,6 +98,7 @@ superior compression ratio of gzip is just a bonus.")
         (build-shared-lib
          ;; Build a shared library.
          '(lambda* (#:key inputs #:allow-other-keys)
+            (patch-makefile-SHELL "Makefile-libbz2_so")
             (zero? (system* "make" "-f" "Makefile-libbz2_so"))))
         (install-shared-lib
          '(lambda* (#:key outputs #:allow-other-keys)
diff --git a/distro/packages/gawk.scm b/distro/packages/gawk.scm
index 3bc4a8d8f1..6fed7f8b70 100644
--- a/distro/packages/gawk.scm
+++ b/distro/packages/gawk.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -35,15 +35,26 @@
             (sha256
              (base32 "0sss7rhpvizi2a88h6giv0i7w5h07s2fxkw3s6n1hqvcnhrfgbb0"))))
    (build-system gnu-build-system)
-   (arguments (case-lambda
-                ((system)
-                 (if (string=? system "i686-cygwin")
-                     '(#:tests? #f)      ; work around test failure on Cygwin
-                     '(#:parallel-tests? #f))) ; test suite fails in parallel
-                ((system cross-system)
-                 '(#:parallel-tests? #f))))
-   (inputs `(("libsigsegv" ,libsigsegv)             ; headers
-             ("libsigsegv/lib" ,libsigsegv "lib"))) ; library
+   (arguments
+    (case-lambda
+      ((system)
+       `(#:parallel-tests? #f             ; test suite fails in parallel
+
+         ;; Work around test failure on Cygwin.
+         #:tests? ,(not (string=? system "i686-cygwin"))
+
+         #:phases (alist-cons-before
+                   'configure 'set-shell-file-name
+                   (lambda* (#:key inputs #:allow-other-keys)
+                     ;; Refer to the right shell.
+                     (let ((bash (assoc-ref inputs "bash")))
+                       (substitute* "io.c"
+                         (("/bin/sh")
+                          (string-append bash "/bin/bash")))))
+                   %standard-phases)))
+      ((system cross-system)
+       '(#:parallel-tests? #f))))
+   (inputs `(("libsigsegv" ,libsigsegv)))
    (home-page "http://www.gnu.org/software/gawk/")
    (synopsis "GNU implementation of the Awk programming language")
    (description
diff --git a/distro/packages/gettext.scm b/distro/packages/gettext.scm
index dfc3a13066..e4d4acc615 100644
--- a/distro/packages/gettext.scm
+++ b/distro/packages/gettext.scm
@@ -37,7 +37,20 @@
         "1sa3ch12qxa4h3ya6hkz119yclcccmincl9j20dhrdx5mykp3b4k"))))
     (build-system gnu-build-system)
     (arguments
-     `(#:patches (list (assoc-ref %build-inputs "patch/gets"))))
+     `(#:patches (list (assoc-ref %build-inputs "patch/gets"))
+       #:phases (alist-cons-before
+                 'check 'patch-tests
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (let ((bash (assoc-ref inputs "bash")))
+                     (substitute* (find-files "gettext-tools/tests"
+                                              "^msgexec-[0-9]")
+                       (("#![[:blank:]]/bin/sh")
+                        (format #f "#!~a/bin/sh" bash)))
+                     (substitute* (find-files "gettext-tools/gnulib-tests"
+                                              "posix_spawn")
+                       (("/bin/sh")
+                        (format #f "~a/bin/bash" bash)))))
+                 %standard-phases)))
     (inputs
      `(("patch/gets"
         ,(search-patch "gettext-gets-undeclared.patch"))))
diff --git a/distro/packages/guile.scm b/distro/packages/guile.scm
index 84ba80841e..9964f9d9f0 100644
--- a/distro/packages/guile.scm
+++ b/distro/packages/guile.scm
@@ -120,6 +120,16 @@ extensible.  It supports many SRFIs.")
 
    (self-native-input? #t)
 
+   (arguments
+    '(#:phases (alist-cons-before
+                'configure 'pre-configure
+                (lambda* (#:key inputs #:allow-other-keys)
+                  (let ((bash (assoc-ref inputs "bash")))
+                    (substitute* "module/ice-9/popen.scm"
+                      (("/bin/sh")
+                       (string-append bash "/bin/bash")))))
+                %standard-phases)))
+
    (synopsis "GNU Guile 2.0, an embeddable Scheme implementation")
    (description
 "GNU Guile is an implementation of the Scheme programming language, with
@@ -134,15 +144,7 @@ call interface, and powerful string processing.")
 (define-public guile-2.0/fixed
   ;; A package of Guile 2.0 that's rarely changed.  It is the one used
   ;; in the `base' module, and thus changing it entails a full rebuild.
-  (package (inherit guile-2.0)
-    (version "2.0.6")
-    (source (origin
-             (method url-fetch)
-             (uri (string-append "mirror://gnu/guile/guile-" version
-                                 ".tar.xz"))
-             (sha256
-              (base32
-               "000ng5qsq3cl1k35jvzvhwxj92wx4q87745n2fppkd4irh58vv5l"))))))
+  guile-2.0)
 
 
 ;;;
diff --git a/distro/packages/ld-wrapper.scm b/distro/packages/ld-wrapper.scm
index 9b8a09f067..fd5a4cbd0c 100644
--- a/distro/packages/ld-wrapper.scm
+++ b/distro/packages/ld-wrapper.scm
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!@BASH@
 # -*- mode: scheme; coding: utf-8; -*-
 
 # XXX: We have to go through Bash because there's no command-line switch to
@@ -7,28 +7,28 @@
 # Use `load-compiled' because `load' (and `-l') doesn't otherwise load our
 # .go file (see <http://bugs.gnu.org/12519>).
 
-main="(@ (distro packages ld-wrapper) ld-wrapper)"
+main="(@ (gnu build-support ld-wrapper) ld-wrapper)"
 exec @GUILE@ -c "(load-compiled \"$0.go\") (apply $main (cdr (command-line)))" "$@"
 !#
-;;; Guix --- Nix package management from Guile.         -*- coding: utf-8 -*-
-;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2012 Ludovic Courtès <ludo@gnu.org>
 ;;;
-;;; This file is part of Guix.
+;;; This file is part of GNU Guix.
 ;;;
-;;; Guix is free software; you can redistribute it and/or modify it
+;;; GNU Guix is free software; you can redistribute it and/or modify it
 ;;; under the terms of the GNU General Public License as published by
 ;;; the Free Software Foundation; either version 3 of the License, or (at
 ;;; your option) any later version.
 ;;;
-;;; Guix is distributed in the hope that it will be useful, but
+;;; GNU Guix is distributed in the hope that it will be useful, but
 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;;; GNU General Public License for more details.
 ;;;
 ;;; You should have received a copy of the GNU General Public License
-;;; along with Guix.  If not, see <http://www.gnu.org/licenses/>.
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
-(define-module (distro packages ld-wrapper)
+(define-module (gnu build-support ld-wrapper)
   #:use-module (srfi srfi-1)
   #:export (ld-wrapper))
 
diff --git a/distro/packages/libsigsegv.scm b/distro/packages/libsigsegv.scm
index 07185186a5..a21e2064c7 100644
--- a/distro/packages/libsigsegv.scm
+++ b/distro/packages/libsigsegv.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -35,7 +35,6 @@
             (sha256
              (base32 "16hrs8k3nmc7a8jam5j1fpspd6sdpkamskvsdpcw6m29vnis8q44"))))
    (build-system gnu-build-system)
-   (outputs '("out" "lib"))                   ; separate libdir from the rest
    (home-page "http://www.gnu.org/software/libsigsegv/")
    (synopsis "GNU libsigsegv, a library to handle page faults in user mode")
    (description
diff --git a/distro/packages/linux.scm b/distro/packages/linux.scm
index 62bdefb1da..a40cc27c3e 100644
--- a/distro/packages/linux.scm
+++ b/distro/packages/linux.scm
@@ -33,8 +33,13 @@
 (define-public linux-libre-headers
   (let* ((version* "3.3.8")
          (build-phase
-          '(lambda* (#:key outputs #:allow-other-keys)
-             (setenv "ARCH" "x86_64")       ; XXX
+          '(lambda* (#:key system #:allow-other-keys)
+             (let ((arch (car (string-split system #\-))))
+               (setenv "ARCH"
+                       (cond ((string=? arch "i686") "i386")
+                             (else arch)))
+               (format #t "`ARCH' set to `~a'~%" (getenv "ARCH")))
+
              (and (zero? (system* "make" "defconfig"))
                   (zero? (system* "make" "mrproper" "headers_check")))))
          (install-phase
@@ -193,4 +198,4 @@ providing the system administrator with some help in common tasks.")
      "Tools for working with USB devices, such as lsusb")
     (description
      "Tools for working with USB devices, such as lsusb.")
-    (license gpl2+)))
\ No newline at end of file
+    (license gpl2+)))
diff --git a/distro/packages/lsh.scm b/distro/packages/lsh.scm
index fa19d3e1c5..d2c2d9082d 100644
--- a/distro/packages/lsh.scm
+++ b/distro/packages/lsh.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -114,8 +114,7 @@
           (substitute* "src/testsuite/login-auth-test"
             (("/bin/cat")
              ;; Use the right path to `cat'.
-             (search-path (search-path-as-string->list (getenv "PATH"))
-                          "cat"))))
+             (which "cat"))))
         %standard-phases)))
     (home-page "http://www.lysator.liu.se/~nisse/lsh/")
     (synopsis
diff --git a/distro/packages/m4.scm b/distro/packages/m4.scm
index 6f52f962c6..7f2bed3ab7 100644
--- a/distro/packages/m4.scm
+++ b/distro/packages/m4.scm
@@ -46,7 +46,19 @@
                    #:patches (list (assoc-ref %build-inputs "patch/s_isdir")
                                    (assoc-ref %build-inputs
                                               "patch/readlink-EINVAL")
-                                   (assoc-ref %build-inputs "patch/gets"))))
+                                   (assoc-ref %build-inputs "patch/gets"))
+                   #:phases (alist-cons-before
+                             'check 'pre-check
+                             (lambda* (#:key inputs #:allow-other-keys)
+                               ;; Fix references to /bin/sh.
+                               (let ((bash (assoc-ref inputs "bash")))
+                                 (for-each patch-shebang
+                                           (find-files "tests" "\\.sh$"))
+                                 (substitute* (find-files "tests"
+                                                          "posix_spawn")
+                                   (("/bin/sh")
+                                    (format #f "~a/bin/bash" bash)))))
+                             %standard-phases)))
                 ((system cross-system)
                  `(#:patches (list (assoc-ref %build-inputs "patch/s_isdir")
                                    (assoc-ref %build-inputs
diff --git a/distro/packages/make-bootstrap.scm b/distro/packages/make-bootstrap.scm
index 09b8c69dec..b1d74ec5d6 100644
--- a/distro/packages/make-bootstrap.scm
+++ b/distro/packages/make-bootstrap.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,7 +19,9 @@
 (define-module (distro packages make-bootstrap)
   #:use-module (guix utils)
   #:use-module (guix packages)
+  #:use-module (guix licenses)
   #:use-module (guix build-system trivial)
+  #:use-module (guix build-system gnu)
   #:use-module ((distro) #:select (search-patch))
   #:use-module (distro packages base)
   #:use-module (distro packages bash)
@@ -29,11 +31,13 @@
   #:use-module (distro packages linux)
   #:use-module (distro packages multiprecision)
   #:use-module (ice-9 match)
+  #:use-module (srfi srfi-1)
   #:export (%bootstrap-binaries-tarball
             %binutils-bootstrap-tarball
             %glibc-bootstrap-tarball
             %gcc-bootstrap-tarball
-            %guile-bootstrap-tarball))
+            %guile-bootstrap-tarball
+            %bootstrap-tarballs))
 
 ;;; Commentary:
 ;;;
@@ -43,48 +47,38 @@
 ;;;
 ;;; Code:
 
-(define* (static-package p #:optional (loc (current-source-location)))
-  "Return a statically-linked version of package P."
-  ;; TODO: Move to (guix build-system gnu).
-  (let ((args (package-arguments p)))
-    (package (inherit p)
-      (location (source-properties->location loc))
-      (arguments
-       (let ((augment (lambda (args)
-                        (let ((a (default-keyword-arguments args
-                                   '(#:configure-flags '()
-                                     #:strip-flags #f))))
-                          (substitute-keyword-arguments a
-                            ((#:configure-flags flags)
-                             `(cons* "--disable-shared"
-                                     "LDFLAGS=-static"
-                                     ,flags))
-                            ((#:strip-flags _)
-                             ''("--strip-all")))))))
-         (if (procedure? args)
-             (lambda x
-               (augment (apply args x)))
-             (augment args)))))))
+(define %glibc-for-bootstrap
+  ;; A libc whose `system' and `popen' functions looks for `sh' in $PATH,
+  ;; without nscd, and with static NSS modules.
+  (package (inherit glibc-final)
+    (arguments
+     (lambda (system)
+       (substitute-keyword-arguments ((package-arguments glibc-final) system)
+         ((#:patches patches)
+          `(cons (assoc-ref %build-inputs "patch/system")
+                 ,patches))
+         ((#:configure-flags flags)
+          ;; Arrange so that getaddrinfo & co. do not contact the nscd,
+          ;; and can use statically-linked NSS modules.
+          `(cons* "--disable-nscd" "--disable-build-nscd"
+                  "--enable-static-nss"
+                  ,flags)))))
+    (inputs
+     `(("patch/system" ,(search-patch "glibc-bootstrap-system.patch"))
+       ,@(package-inputs glibc-final)))))
+
+(define %standard-inputs-with-relocatable-glibc
+  ;; Standard inputs with the above libc and corresponding GCC.
+  `(("libc", %glibc-for-bootstrap)
+    ("gcc" ,(package-with-explicit-inputs
+             gcc-4.7
+             `(("libc",%glibc-for-bootstrap)
+               ,@(alist-delete "libc" %final-inputs))
+             (current-source-location)))
+    ,@(fold alist-delete %final-inputs '("libc" "gcc"))))
 
 (define %bash-static
-  (let ((bash-light (package (inherit bash-final)
-                      (inputs '())              ; no readline, no curses
-                      (arguments
-                       (let ((args `(#:modules ((guix build gnu-build-system)
-                                                (guix build utils)
-                                                (srfi srfi-1)
-                                                (srfi srfi-26))
-                                               ,@(package-arguments bash))))
-                         (substitute-keyword-arguments args
-                           ((#:configure-flags flags)
-                            `(list "--without-bash-malloc"
-                                   "--disable-readline"
-                                   "--disable-history"
-                                   "--disable-help-builtin"
-                                   "--disable-progcomp"
-                                   "--disable-net-redirections"
-                                   "--disable-nls"))))))))
-    (static-package bash-light)))
+  (static-package bash-light))
 
 (define %static-inputs
   ;; Packages that are to be used as %BOOTSTRAP-INPUTS.
@@ -94,8 +88,13 @@
                         '("--disable-nls"
                           "--disable-silent-rules"
                           "--enable-no-install-program=stdbuf,libstdbuf.so"
+                          "CFLAGS=-Os -g0"        ; smaller, please
                           "LDFLAGS=-static -pthread")
-                        ,@(package-arguments coreutils)))))
+                        #:tests? #f   ; signal-related Gnulib tests fail
+                        ,@(package-arguments coreutils)))
+
+                     ;; Remove optional dependencies such as GMP.
+                     (inputs `(,(assoc "perl" (package-inputs coreutils))))))
         (bzip2 (package (inherit bzip2)
                  (arguments
                   (substitute-keyword-arguments (package-arguments bzip2)
@@ -121,18 +120,27 @@
         (gawk (package (inherit gawk)
                 (arguments
                  (lambda (system)
-                   `(#:phases (alist-cons-before
-                               'build 'no-export-dynamic
-                               (lambda* (#:key outputs #:allow-other-keys)
-                                 ;; Since we use `-static', remove
-                                 ;; `-export-dynamic'.
-                                 (substitute* "configure"
-                                   (("-export-dynamic") "")))
-                               %standard-phases)
-                     ,@((package-arguments gawk) system)))))))
+                   `(#:patches (list (assoc-ref %build-inputs "patch/sh"))
+                     ,@(substitute-keyword-arguments
+                           ((package-arguments gawk) system)
+                         ((#:phases phases)
+                          `(alist-cons-before
+                            'configure 'no-export-dynamic
+                            (lambda _
+                              ;; Since we use `-static', remove
+                              ;; `-export-dynamic'.
+                              (substitute* "configure"
+                                (("-export-dynamic") "")))
+                            ,phases))))))
+                (inputs `(("patch/sh" ,(search-patch "gawk-shell.patch"))))))
+        (finalize (lambda (p)
+                    (static-package (package-with-explicit-inputs
+                                     p
+                                     %standard-inputs-with-relocatable-glibc)
+                                    (current-source-location)))))
     `(,@(map (match-lambda
               ((name package)
-               (list name (static-package package (current-source-location)))))
+               (list name (finalize package))))
              `(("tar" ,tar)
                ("gzip" ,gzip)
                ("bzip2" ,bzip2)
@@ -272,84 +280,87 @@
   ;; GNU libc's essential shared libraries, dynamic linker, and headers,
   ;; with all references to store directories stripped.  As a result,
   ;; libc.so is unusable and need to be patched for proper relocation.
-  (package (inherit glibc-final)
-    (name "glibc-stripped")
-    (build-system trivial-build-system)
-    (arguments
-     `(#:modules ((guix build utils))
-       #:builder
-       (begin
-         (use-modules (guix build utils))
-
-         (setvbuf (current-output-port) _IOLBF)
-         (let* ((out    (assoc-ref %outputs "out"))
-                (libdir (string-append out "/lib"))
-                (incdir (string-append out "/include"))
-                (libc   (assoc-ref %build-inputs "libc"))
-                (linux  (assoc-ref %build-inputs "linux-headers")))
-           (mkdir-p libdir)
-           (for-each (lambda (file)
-                       (let ((target (string-append libdir "/"
-                                                    (basename file))))
-                         (copy-file file target)
-                         (remove-store-references target)))
-                     (find-files (string-append libc "/lib")
-                                 "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|libc_nonshared\\.a)$"))
-
-           (copy-recursively (string-append libc "/include") incdir)
-
-           ;; Copy some of the Linux-Libre headers that glibc headers
-           ;; refer to.
-           (mkdir (string-append incdir "/linux"))
-           (for-each (lambda (file)
-                       (copy-file (string-append linux "/include/linux/" file)
-                                  (string-append incdir "/linux/"
-                                                 (basename file))))
-                     '("limits.h" "errno.h" "socket.h" "kernel.h"
-                       "sysctl.h" "param.h" "ioctl.h" "types.h"
-                       "posix_types.h" "stddef.h"))
-
-           (copy-recursively (string-append linux "/include/asm")
-                             (string-append incdir "/asm"))
-           (copy-recursively (string-append linux "/include/asm-generic")
-                             (string-append incdir "/asm-generic"))
-           #t))))
-    (inputs `(("libc" ,glibc-final)
-              ("linux-headers" ,linux-libre-headers)))))
+  (let ((glibc %glibc-for-bootstrap))
+    (package (inherit glibc)
+      (name "glibc-stripped")
+      (build-system trivial-build-system)
+      (arguments
+       `(#:modules ((guix build utils))
+         #:builder
+         (begin
+           (use-modules (guix build utils))
+
+           (setvbuf (current-output-port) _IOLBF)
+           (let* ((out    (assoc-ref %outputs "out"))
+                  (libdir (string-append out "/lib"))
+                  (incdir (string-append out "/include"))
+                  (libc   (assoc-ref %build-inputs "libc"))
+                  (linux  (assoc-ref %build-inputs "linux-headers")))
+             (mkdir-p libdir)
+             (for-each (lambda (file)
+                         (let ((target (string-append libdir "/"
+                                                      (basename file))))
+                           (copy-file file target)
+                           (remove-store-references target)))
+                       (find-files (string-append libc "/lib")
+                                   "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|libc_nonshared\\.a)$"))
+
+             (copy-recursively (string-append libc "/include") incdir)
+
+             ;; Copy some of the Linux-Libre headers that glibc headers
+             ;; refer to.
+             (mkdir (string-append incdir "/linux"))
+             (for-each (lambda (file)
+                         (copy-file (string-append linux "/include/linux/" file)
+                                    (string-append incdir "/linux/"
+                                                   (basename file))))
+                       '("limits.h" "errno.h" "socket.h" "kernel.h"
+                         "sysctl.h" "param.h" "ioctl.h" "types.h"
+                         "posix_types.h" "stddef.h"))
+
+             (copy-recursively (string-append linux "/include/asm")
+                               (string-append incdir "/asm"))
+             (copy-recursively (string-append linux "/include/asm-generic")
+                               (string-append incdir "/asm-generic"))
+             #t))))
+      (inputs `(("libc" ,glibc)
+                ("linux-headers" ,linux-libre-headers))))))
 
 (define %gcc-static
   ;; A statically-linked GCC, with stripped-down functionality.
-  (package (inherit gcc-final)
-    (name "gcc-static")
-    (arguments
-     (lambda (system)
-       `(#:modules ((guix build utils)
-                    (guix build gnu-build-system)
-                    (srfi srfi-1)
-                    (srfi srfi-26)
-                    (ice-9 regex))
-         ,@(substitute-keyword-arguments ((package-arguments gcc-final) system)
-             ((#:guile _) #f)
-             ((#:implicit-inputs? _) #t)
-             ((#:configure-flags flags)
-              `(append (list
-                        "--disable-shared"
-                        "--disable-plugin"
-                        "--enable-languages=c"
-                        "--disable-libmudflap"
-                        "--disable-libgomp"
-                        "--disable-libssp"
-                        "--disable-libquadmath"
-                        "--disable-decimal-float")
-                       (remove (cut string-match "--(.*plugin|enable-languages)" <>)
-                               ,flags)))
-             ((#:make-flags flags)
-              `(cons "BOOT_LDFLAGS=-static" ,flags))))))
-    (inputs `(("gmp-source" ,(package-source gmp))
-              ("mpfr-source" ,(package-source mpfr))
-              ("mpc-source" ,(package-source mpc))
-              ("binutils" ,binutils-final)
-              ,@(package-inputs gcc-4.7)))))
+  (package-with-explicit-inputs
+   (package (inherit gcc-final)
+     (name "gcc-static")
+     (arguments
+      (lambda (system)
+        `(#:modules ((guix build utils)
+                     (guix build gnu-build-system)
+                     (srfi srfi-1)
+                     (srfi srfi-26)
+                     (ice-9 regex))
+          ,@(substitute-keyword-arguments ((package-arguments gcc-final) system)
+              ((#:guile _) #f)
+              ((#:implicit-inputs? _) #t)
+              ((#:configure-flags flags)
+               `(append (list
+                         "--disable-shared"
+                         "--disable-plugin"
+                         "--enable-languages=c"
+                         "--disable-libmudflap"
+                         "--disable-libgomp"
+                         "--disable-libssp"
+                         "--disable-libquadmath"
+                         "--disable-decimal-float")
+                        (remove (cut string-match "--(.*plugin|enable-languages)" <>)
+                                ,flags)))
+              ((#:make-flags flags)
+               `(cons "BOOT_LDFLAGS=-static" ,flags))))))
+     (inputs `(("gmp-source" ,(package-source gmp))
+               ("mpfr-source" ,(package-source mpfr))
+               ("mpc-source" ,(package-source mpc))
+               ("binutils" ,binutils-final)
+               ,@(package-inputs gcc-4.7))))
+   %standard-inputs-with-relocatable-glibc))
 
 (define %gcc-stripped
   ;; The subset of GCC files needed for bootstrap.
@@ -429,7 +440,9 @@
                     ;; There are uses of `dynamic-link' in
                     ;; {foreign,coverage}.test that don't fly here.
                     #:tests? #f)))))
-    (static-package guile (current-source-location))))
+    (package-with-explicit-inputs (static-package guile)
+                                  %standard-inputs-with-relocatable-glibc
+                                  (current-source-location))))
 
 (define %guile-static-stripped
   ;; A stripped static Guile binary, for use during bootstrap.
@@ -509,4 +522,41 @@
   ;; A tarball with the statically-linked, relocatable Guile.
   (tarball-package %guile-static-stripped))
 
+(define %bootstrap-tarballs
+  ;; A single derivation containing all the bootstrap tarballs, for
+  ;; convenience.
+  (package
+    (name "bootstrap-tarballs")
+    (version "0")
+    (source #f)
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (let ((out (assoc-ref %outputs "out")))
+         (use-modules (guix build utils)
+                      (ice-9 match)
+                      (srfi srfi-26))
+
+         (setvbuf (current-output-port) _IOLBF)
+         (mkdir out)
+         (chdir out)
+         (for-each (match-lambda
+                    ((name . directory)
+                     (for-each (lambda (file)
+                                 (format #t "~a -> ~a~%" file out)
+                                 (symlink file (basename file)))
+                               (find-files directory "\\.tar\\."))))
+                   %build-inputs)
+         #t)))
+    (inputs `(("guile-tarball" ,%guile-bootstrap-tarball)
+              ("gcc-tarball" ,%gcc-bootstrap-tarball)
+              ("binutils-tarball" ,%binutils-bootstrap-tarball)
+              ("glibc-tarball" ,%glibc-bootstrap-tarball)
+              ("coreutils&co-tarball" ,%bootstrap-binaries-tarball)))
+    (synopsis #f)
+    (description #f)
+    (home-page #f)
+    (license gpl3+)))
+
 ;;; make-bootstrap.scm ends here
diff --git a/distro/packages/multiprecision.scm b/distro/packages/multiprecision.scm
index 453f756d87..444c6103eb 100644
--- a/distro/packages/multiprecision.scm
+++ b/distro/packages/multiprecision.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -28,14 +28,18 @@
 (define-public gmp
   (package
    (name "gmp")
-   (version "5.0.5")
+   (version "5.1.0")
    (source (origin
             (method url-fetch)
-            (uri (string-append "mirror://gnu/gmp/gmp-" version
-                                ".tar.bz2"))
+            (uri
+             ;; Note: this version is not available from GNU mirrors
+             ;; because it was made with an Automake affected by
+             ;; CVE-2012-3386.
+             (string-append "ftp://ftp.gmplib.org/pub/gmp-"
+                            version "/gmp-" version ".tar.bz2"))
             (sha256
              (base32
-              "1jfymbr90mpn0zw5sg001llqnvf2462y77vgjknrmfs1rjn8ln0z"))))
+              "15n7xxgasbxdch8ii8z9ic6fxc2ysk3q8iavf55abjp5iylspnfz"))))
    (build-system gnu-build-system)
    (native-inputs `(("m4" ,m4)))
    (arguments `(#:configure-flags
@@ -96,14 +100,13 @@ double-precision floating-point arithmetic (53-bit mantissa).")
 (define-public mpc
   (package
    (name "mpc")
-   (version "1.0")
+   (version "1.0.1")
    (source (origin
             (method url-fetch)
             (uri (string-append
-                  "http://www.multiprecision.org/mpc/download/mpc-"
-                  version ".tar.gz"))
+                  "mirror://gnu/mpc/mpc-" version ".tar.gz"))
             (sha256 (base32
-                     "00rxjmkpqnv6zzcyw9aa5w6rzaav32ys87km25zgfcv9i32km5cw"))))
+                     "1zq0fidp1jii2j5k5n9hmx55a6wwid33gjzhimvxq9d5zrf82npd"))))
    (build-system gnu-build-system)
    (inputs `(("gmp" ,gmp)
              ("mpfr" ,mpfr)))
@@ -111,7 +114,11 @@ double-precision floating-point arithmetic (53-bit mantissa).")
 with exact rounding")
    (description
     "GNU MPC is a C library for the arithmetic of complex numbers with
-arbitrarily high precision and correct rounding of the result.  It is built
-upon and follows the same principles as GNU MPFR.")
+arbitrarily high precision and correct rounding of the result. It extends
+the principles of the IEEE-754 standard for fixed precision real floating
+point numbers to complex numbers, providing well-defined semantics for
+every operation. At the same time, speed of operation at high precision
+is a major design goal. The library is built upon and follows the same
+principles as GNU MPFR.")
    (license lgpl3+)
    (home-page "http://mpc.multiprecision.org/")))
diff --git a/distro/packages/ncurses.scm b/distro/packages/ncurses.scm
index f8641c72f9..938d1dc2c4 100644
--- a/distro/packages/ncurses.scm
+++ b/distro/packages/ncurses.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -24,7 +24,26 @@
   #:use-module (guix build-system gnu))
 
 (define-public ncurses
-  (let ((post-install-phase
+  (let ((patch-makefile-phase
+         '(lambda _
+            (for-each patch-makefile-SHELL
+                      (find-files "." "Makefile.in"))))
+        (configure-phase
+         '(lambda* (#:key inputs outputs configure-flags
+                    #:allow-other-keys)
+            ;; The `ncursesw5-config' has a #!/bin/sh.  We want to patch
+            ;; it to point to libc's embedded Bash, to avoid retaining a
+            ;; reference to the bootstrap Bash.
+            (let* ((libc (assoc-ref inputs "libc"))
+                   (bash (string-append libc "/bin/bash"))
+                   (out  (assoc-ref outputs "out")))
+              (format #t "configure flags: ~s~%" configure-flags)
+              (zero? (apply system* bash "./configure"
+                            (string-append "SHELL=" bash)
+                            (string-append "CONFIG_SHELL=" bash)
+                            (string-append "--prefix=" out)
+                            configure-flags)))))
+        (post-install-phase
          '(lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out")))
               ;; When building a wide-character (Unicode) build, create backward
@@ -81,13 +100,15 @@
                     '("--without-cxx-binding")
                     '()))
            #:tests? #f                            ; no "check" target
-           #:phases (alist-cons-after 'install 'post-install
-                                      ,post-install-phase
-                                      %standard-phases)
-
-           ;; The `ncursesw5-config' has a #!/bin/sh that we don't want to
-           ;; patch, to avoid retaining a reference to the build-time Bash.
-           #:patch-shebangs? #f))
+           #:phases (alist-cons-after
+                     'install 'post-install ,post-install-phase
+                     (alist-cons-before
+                      'configure 'patch-makefile-SHELL
+                      ,patch-makefile-phase
+                      (alist-replace
+                       'configure
+                       ,configure-phase
+                       %standard-phases)))))
         ((system cross-system)
          (arguments cross-system))))
      (self-native-input? #t)
diff --git a/distro/packages/openssl.scm b/distro/packages/openssl.scm
new file mode 100644
index 0000000000..4018e46a49
--- /dev/null
+++ b/distro/packages/openssl.scm
@@ -0,0 +1,68 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (distro packages openssl)
+  #:use-module (distro)
+  #:use-module (distro packages perl)
+  #:use-module (guix licenses)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix build-system gnu))
+
+(define-public openssl
+  (package
+   (name "openssl")
+   (version "1.0.1c")
+   (source (origin
+            (method url-fetch)
+            (uri (string-append "ftp://ftp.openssl.org/source/openssl-" version
+                                ".tar.gz"))
+            (sha256 (base32
+                     "1gjy6a7d8nszi9wq8jdzx3cffn0nss23h3cw2ywlw4cb9v6v77ia"))))
+   (build-system gnu-build-system)
+   (inputs `(("perl" ,perl)))
+   (arguments
+    (lambda (system)
+      `(#:parallel-build? #f
+        #:parallel-tests? #f
+        #:test-target "test"
+        #:phases
+        (alist-replace
+         'configure
+         (lambda* (#:key outputs #:allow-other-keys)
+           (let ((out (assoc-ref outputs "out")))
+             (zero?
+              (system* "./config"
+                       "shared"                 ; build shared libraries
+                       "--libdir=lib"
+                       (string-append "--prefix=" out)))))
+         (alist-cons-before
+          'patch-source-shebangs 'patch-tests
+          (lambda* (#:key inputs #:allow-other-keys)
+            (let ((bash (assoc-ref inputs "bash")))
+             (substitute* (find-files "test" ".*")
+               (("/bin/sh")
+                (string-append bash "/bin/bash"))
+               (("/bin/rm")
+                "rm"))))
+          %standard-phases)))))
+   (synopsis "OpenSSL, an SSL/TLS implementation")
+   (description
+    "OpenSSL is an implementation of SSL/TLS")
+   (license openssl)
+   (home-page "http://www.openssl.org/")))
diff --git a/distro/packages/patches/gawk-shell.patch b/distro/packages/patches/gawk-shell.patch
new file mode 100644
index 0000000000..89b8540a8d
--- /dev/null
+++ b/distro/packages/patches/gawk-shell.patch
@@ -0,0 +1,34 @@
+As for libc's `system', change Awk to look for `sh' in $PATH.  This patch is
+only meant to be used during bootstrapping, where we don't know in advance the
+absolute file name of `sh'.
+
+--- gawk-4.0.0/io.c	2011-05-18 20:47:29.000000000 +0200
++++ gawk-4.0.0/io.c	2012-12-18 15:56:06.000000000 +0100
+@@ -1759,7 +1759,7 @@ two_way_open(const char *str, struct red
+ 
+ 			signal(SIGPIPE, SIG_DFL);
+ 
+-			execl("/bin/sh", "sh", "-c", str, NULL);
++			execlp("sh", "sh", "-c", str, NULL);
+ 			_exit(errno == ENOENT ? 127 : 126);
+ 
+ 		case -1:
+@@ -1924,7 +1924,7 @@ use_pipes:
+ 		    || close(ctop[0]) == -1 || close(ctop[1]) == -1)
+ 			fatal(_("close of pipe failed (%s)"), strerror(errno));
+ 		/* stderr does NOT get dup'ed onto child's stdout */
+-		execl("/bin/sh", "sh", "-c", str, NULL);
++		execlp("sh", "sh", "-c", str, NULL);
+ 		_exit(errno == ENOENT ? 127 : 126);
+ 	}
+ #endif /* NOT __EMX__ */
+@@ -2074,7 +2074,7 @@ gawk_popen(const char *cmd, struct redir
+ 			fatal(_("moving pipe to stdout in child failed (dup: %s)"), strerror(errno));
+ 		if (close(p[0]) == -1 || close(p[1]) == -1)
+ 			fatal(_("close of pipe failed (%s)"), strerror(errno));
+-		execl("/bin/sh", "sh", "-c", cmd, NULL);
++		execlp("sh", "sh", "-c", cmd, NULL);
+ 		_exit(errno == ENOENT ? 127 : 126);
+ 	}
+ #endif /* NOT __EMX__ */
+
diff --git a/distro/packages/patches/glibc-bootstrap-system.patch b/distro/packages/patches/glibc-bootstrap-system.patch
new file mode 100644
index 0000000000..7208cce3f4
--- /dev/null
+++ b/distro/packages/patches/glibc-bootstrap-system.patch
@@ -0,0 +1,28 @@
+We want to allow builds in chroots that lack /bin/sh.  Thus, system(3)
+and popen(3) need to be tweaked to use the right shell.  For the bootstrap
+glibc, we just use whatever `sh' can be found in $PATH.  The final glibc
+instead uses the hard-coded absolute file name of `bash'.
+
+--- a/sysdeps/posix/system.c
++++ b/sysdeps/posix/system.c
+@@ -134,7 +134,7 @@ do_system (const char *line)
+       INIT_LOCK ();
+ 
+       /* Exec the shell.  */
+-      (void) __execve (SHELL_PATH, (char *const *) new_argv, __environ);
++      (void) __execvpe (SHELL_NAME, (char *const *) new_argv, __environ);
+       _exit (127);
+     }
+   else if (pid < (pid_t) 0)
+
+--- b/libio/iopopen.c	2012-06-30 21:12:34.000000000 +0200
++++ b/libio/iopopen.c	2012-12-19 12:52:29.000000000 +0100
+@@ -226,7 +226,7 @@ _IO_new_proc_open (fp, command, mode)
+ 	    _IO_close (fd);
+ 	}
+ 
+-      _IO_execl ("/bin/sh", "sh", "-c", command, (char *) 0);
++      execlp ("sh", "sh", "-c", command, (char *) 0);
+       _IO__exit (127);
+     }
+   _IO_close (child_end);
diff --git a/distro/packages/perl.scm b/distro/packages/perl.scm
index 9f8de3d84f..b6357875b6 100644
--- a/distro/packages/perl.scm
+++ b/distro/packages/perl.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -46,16 +46,14 @@
           'configure
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let ((out  (assoc-ref outputs "out"))
-                  (libc (assoc-ref inputs "libc"))
-                  (pwd  (search-path (search-path-as-string->list
-                                      (getenv "PATH"))
-                                     "pwd")))
+                  (libc (assoc-ref inputs "libc")))
               ;; Use the right path for `pwd'.
               (substitute* "dist/Cwd/Cwd.pm"
-                (("/bin/pwd") pwd))
+                (("/bin/pwd")
+                 (which "pwd")))
 
               (zero?
-               (system* "/bin/sh" "./Configure"
+               (system* "./Configure"
                         (string-append "-Dprefix=" out)
                         (string-append "-Dman1dir=" out "/share/man/man1")
                         (string-append "-Dman3dir=" out "/share/man/man3")
diff --git a/distro/packages/readline.scm b/distro/packages/readline.scm
index 9b1b0d16b4..5498f15b52 100644
--- a/distro/packages/readline.scm
+++ b/distro/packages/readline.scm
@@ -26,44 +26,46 @@
   #:use-module (guix build-system gnu))
 
 (define-public readline
-  (package
-   (name "readline")
-   (version "6.2")
-   (source (origin
-            (method url-fetch)
-            (uri (string-append "mirror://gnu/readline/readline-"
-                                version ".tar.gz"))
-            (sha256
-             (base32
-              "10ckm2bd2rkxhvdmj7nmbsylmihw0abwcsnxf8y27305183rd9kr"))))
-   (build-system gnu-build-system)
-   (propagated-inputs `(("ncurses" ,ncurses)))
-   (inputs `(("patch/link-ncurses"
-              ,(search-patch "readline-link-ncurses.patch"))))
-   (arguments `(#:patches (list (assoc-ref %build-inputs
-                                           "patch/link-ncurses"))
-                #:patch-flags '("-p0")
-                #:configure-flags
-                (list (string-append "LDFLAGS=-Wl,-rpath -Wl,"
-                                     (assoc-ref %build-inputs "ncurses")
-                                     "/lib"))
+  (let ((post-install-phase
+         '(lambda* (#:key outputs #:allow-other-keys)
+            (let* ((out (assoc-ref outputs "out"))
+                   (lib (string-append out "/lib")))
+              ;; Make libraries writable so that `strip' can work.
+              ;; Failing to do that, it bails out with "Permission
+              ;; denied".
+              (for-each (lambda (f) (chmod f #o755))
+                        (find-files lib "\\.so"))
+              (for-each (lambda (f) (chmod f #o644))
+                        (find-files lib "\\.a"))))))
+    (package
+      (name "readline")
+      (version "6.2")
+      (source (origin
+               (method url-fetch)
+               (uri (string-append "mirror://gnu/readline/readline-"
+                                   version ".tar.gz"))
+               (sha256
+                (base32
+                 "10ckm2bd2rkxhvdmj7nmbsylmihw0abwcsnxf8y27305183rd9kr"))))
+      (build-system gnu-build-system)
+      (propagated-inputs `(("ncurses" ,ncurses)))
+      (inputs `(("patch/link-ncurses"
+                 ,(search-patch "readline-link-ncurses.patch"))))
+      (arguments `(#:patches (list (assoc-ref %build-inputs
+                                              "patch/link-ncurses"))
+                   #:patch-flags '("-p0")
+                   #:configure-flags
+                   (list (string-append "LDFLAGS=-Wl,-rpath -Wl,"
+                                        (assoc-ref %build-inputs "ncurses")
+                                        "/lib"))
 
-                #:phases (alist-cons-after
-                          'install 'post-install
-                          (lambda* (#:key outputs #:allow-other-keys)
-                            (let* ((out (assoc-ref outputs "out"))
-                                   (lib (string-append out "/lib")))
-                              ;; Make libraries writable so that `strip' can
-                              ;; work.  Failing to do that, it bails out with
-                              ;; "Permission denied".
-                              (for-each (lambda (f) (chmod f #o755))
-                                        (find-files lib "\\.so"))
-                              (for-each (lambda (f) (chmod f #o644))
-                                        (find-files lib "\\.a"))))
-                          %standard-phases)))
-   (synopsis "GNU Readline, a library for interactive line editing")
-   (description
-    "The GNU Readline library provides a set of functions for use by
+                   #:phases (alist-cons-after
+                             'install 'post-install
+                             ,post-install-phase
+                             %standard-phases)))
+      (synopsis "GNU Readline, a library for interactive line editing")
+      (description
+       "The GNU Readline library provides a set of functions for use by
 applications that allow users to edit command lines as they are typed in.
 Both Emacs and vi editing modes are available.  The Readline library includes
 additional functions to maintain a list of previously-entered command lines,
@@ -73,5 +75,5 @@ expansion on previous commands.
 The history facilites are also placed into a separate library, the History
 library, as part of the build process.  The History library may be used
 without Readline in applications which desire its capabilities.")
-   (license gpl3+)
-   (home-page "http://savannah.gnu.org/projects/readline/")))
+      (license gpl3+)
+      (home-page "http://savannah.gnu.org/projects/readline/"))))
diff --git a/distro/packages/time.scm b/distro/packages/time.scm
index b7eaec0c21..0b7bde9a1b 100644
--- a/distro/packages/time.scm
+++ b/distro/packages/time.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
+;;; Copyright © 2013 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -35,6 +36,18 @@
        (base32
         "0va9063fcn7xykv658v2s9gilj2fq4rcdxx2mn2mmy1v4ndafzp3"))))
     (build-system gnu-build-system)
+    (arguments
+     '(#:phases
+       (alist-replace 'configure
+                      (lambda* (#:key outputs #:allow-other-keys)
+                        ;; This old `configure' script doesn't support
+                        ;; variables passed as arguments.
+                        (let ((out (assoc-ref outputs "out")))
+                          (setenv "CONFIG_SHELL" (which "bash"))
+                          (zero?
+                           (system* "./configure"
+                                    (string-append "--prefix=" out)))))
+                      %standard-phases)))
     (home-page "http://www.gnu.org/software/time/")
     (synopsis
      "GNU Time, a tool that runs programs and summarizes the system
@@ -49,6 +62,5 @@ in a file instead of displaying it on the screen.
 The resources that 'time' can report on fall into the general categories
 of time, memory, and I/O and IPC calls.  Some systems do not provide
 much information about program resource use; 'time' reports unavailable
-information as zero values.
-")
-    (license gpl2+)))
\ No newline at end of file
+information as zero values.")
+    (license gpl2+)))