gnu: stagit: Update to 0.5.
[jackhill/guix/guix.git] / gnu / packages / base.scm
index 3614361..c75e038 100644 (file)
@@ -1,9 +1,12 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
-;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2014, 2015, 2016 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
+;;; Copyright © 2014, 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
+;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -22,7 +25,7 @@
 
 (define-module (gnu packages base)
   #:use-module ((guix licenses)
-                #:select (gpl3+ lgpl2.0+ public-domain))
+                #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
   #:use-module (gnu packages)
   #:use-module (gnu packages acl)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages texinfo)
+  #:use-module (gnu packages hurd)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages gettext)
   #:use-module (guix utils)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix git-download)
   #:use-module (guix build-system gnu)
-  #:use-module (guix build-system trivial))
+  #:use-module (guix build-system trivial)
+  #:use-module (ice-9 match)
+  #:export (glibc
+            libiconv-if-needed))
 
 ;;; Commentary:
 ;;;
 
 (define-public hello
   (package
-   (name "hello")
-   (version "2.10")
-   (source (origin
-            (method url-fetch)
-            (uri (string-append "mirror://gnu/hello/hello-" version
-                                ".tar.gz"))
-            (sha256
-             (base32 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
-   (build-system gnu-build-system)
-   (synopsis "Hello, GNU world: An example GNU package")
-   (description
-    "GNU Hello prints the message \"Hello, world!\" and then exits.  It
+    (name "hello")
+    (version "2.10")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://gnu/hello/hello-" version
+                                  ".tar.gz"))
+              (sha256
+               (base32
+                "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
+    (build-system gnu-build-system)
+    (synopsis "Hello, GNU world: An example GNU package")
+    (description
+     "GNU Hello prints the message \"Hello, world!\" and then exits.  It
 serves as an example of standard GNU coding practices.  As such, it supports
 command-line arguments, multiple languages, and so on.")
-   (home-page "http://www.gnu.org/software/hello/")
-   (license gpl3+)))
+    (home-page "http://www.gnu.org/software/hello/")
+    (license gpl3+)))
 
 (define-public grep
   (package
    (name "grep")
-   (version "2.21")
+   (version "2.25")
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://gnu/grep/grep-"
                                 version ".tar.xz"))
             (sha256
              (base32
-              "1pp5n15qwxrw1pibwjhhgsibyv5cafhamf8lwzjygs6y00fa2i2j"))
-            (patches (list (search-patch "grep-CVE-2015-1345.patch")))))
+              "0c38b67cnwchwzv4wq2gpz6smkhdxrac2hhssv8f0l04qnx867p2"))
+            (patches (search-patches "grep-timing-sensitive-test.patch"))))
    (build-system gnu-build-system)
+   (native-inputs `(("perl" ,perl)))             ;some of the tests require it
+   (arguments
+    `(#:phases
+      (modify-phases %standard-phases
+        (add-after 'install 'fix-egrep-and-fgrep
+          ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
+          ;; absolute file name instead of searching for it in $PATH.
+          (lambda* (#:key outputs #:allow-other-keys)
+            (let* ((out (assoc-ref outputs "out"))
+                   (bin (string-append out "/bin")))
+              (substitute* (list (string-append bin "/egrep")
+                                 (string-append bin "/fgrep"))
+                (("^exec grep")
+                 (string-append "exec " bin "/grep")))
+              #t))))))
    (synopsis "Print lines matching a pattern")
    (description
      "grep is a tool for finding text inside files.  Text is found by
@@ -100,7 +125,8 @@ including, for example, recursive directory searching.")
                                 ".tar.bz2"))
             (sha256
              (base32
-              "1myvrmh99jsvk7v3d7crm0gcrq51hmmm1r2kjyyci152in1x2j7h"))))
+              "1myvrmh99jsvk7v3d7crm0gcrq51hmmm1r2kjyyci152in1x2j7h"))
+            (patches (search-patches "sed-hurd-path-max.patch"))))
    (build-system gnu-build-system)
    (synopsis "Stream editor")
    (arguments
@@ -128,15 +154,34 @@ implementation offers several extensions over the standard utility.")
 (define-public tar
   (package
    (name "tar")
-   (version "1.28")
+   (version "1.29")
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://gnu/tar/tar-"
                                 version ".tar.xz"))
             (sha256
              (base32
-              "1wi2zwm4c9r3h3b8y4w0nm0qq897kn8kyj9k22ba0iqvxj48vvk4"))))
+              "097hx7sbzp8qirl4m930lw84kn0wmxhmq7v1qpra3mrg0b8cyba0"))
+            (patches (search-patches "tar-skip-unreliable-tests.patch"))))
    (build-system gnu-build-system)
+   ;; Note: test suite requires ~1GiB of disk space.
+   (arguments
+    '(#:phases (modify-phases %standard-phases
+                 (add-before 'build 'set-shell-file-name
+                   (lambda* (#:key inputs #:allow-other-keys)
+                     ;; Do not use "/bin/sh" to run programs.
+                     (let ((bash (assoc-ref inputs "bash")))
+                       (substitute* "src/system.c"
+                         (("/bin/sh")
+                          (string-append bash "/bin/sh")))
+                       #t))))))
+
+   ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
+   ;; to refer to the target Bash.
+   (inputs (if (%current-target-system)
+               `(("bash" ,bash))
+               '()))
+
    (synopsis "Managing tar archives")
    (description
     "Tar provides the ability to create tar archives, as well as the
@@ -158,9 +203,10 @@ standard utility.")
                                   version ".tar.xz"))
               (sha256
                (base32
-                "16d2r9kpivaak948mxzc0bai45mqfw73m113wrkmbffnalv1b5gx"))))
+                "16d2r9kpivaak948mxzc0bai45mqfw73m113wrkmbffnalv1b5gx"))
+              (patches (search-patches "patch-hurd-path-max.patch"))))
    (build-system gnu-build-system)
-   (native-inputs `(("ed"ed)))
+   (native-inputs `(("ed" ,ed)))
    (synopsis "Apply differences to originals, with optional backups")
    (description
     "Patch is a program that applies changes to files based on differences
@@ -174,20 +220,20 @@ differences.")
 (define-public diffutils
   (package
    (name "diffutils")
-   (version "3.3")
+   (version "3.5")
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://gnu/diffutils/diffutils-"
                                 version ".tar.xz"))
             (sha256
              (base32
-              "1761vymxbp4wb5rzjvabhdkskk95pghnn67464byvzb5mfl8jpm2"))))
+              "0csmqfz8ks23kdjsq0v2ll1acqiz8lva06dj19mwmymrsp69ilys"))))
    (build-system gnu-build-system)
    (synopsis "Comparing and merging files")
    (description
     "GNU Diffutils is a package containing tools for finding the
 differences between files.  The \"diff\" command is used to show how two files
-differ, while \"cmp\" shows the offsets and line numbers where they differ. 
+differ, while \"cmp\" shows the offsets and line numbers where they differ.
 \"diff3\" allows you to compare three files.  Finally, \"sdiff\" offers an
 interactive means to merge two files.")
    (license gpl3+)
@@ -196,22 +242,27 @@ interactive means to merge two files.")
 (define-public findutils
   (package
    (name "findutils")
-   (version "4.4.2")
+   (version "4.6.0")
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://gnu/findutils/findutils-"
                                 version ".tar.gz"))
             (sha256
              (base32
-              "0amn0bbwqvsvvsh6drfwz20ydc2czk374lzw5kksbh6bf78k4ks3"))
-            (patches (list (search-patch "findutils-absolute-paths.patch")))))
+              "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
+            (patches (search-patches "findutils-localstatedir.patch"
+                                     "findutils-test-xargs.patch"))))
    (build-system gnu-build-system)
    (arguments
-    ;; Work around cross-compilation failure.
-    ;; See <http://savannah.gnu.org/bugs/?27299#comment1>.
-    (if (%current-target-system)
-        '(#:configure-flags '("gl_cv_func_wcwidth_works=yes"))
-        '()))
+    `(#:configure-flags (list
+                         ;; Tell 'updatedb' to write to /var.
+                         "--localstatedir=/var"
+
+                         ;; Work around cross-compilation failure.  See
+                         ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
+                         ,@(if (%current-target-system)
+                               '("gl_cv_func_wcwidth_works=yes")
+                               '()))))
    (synopsis "Operating on files matching given criteria")
    (description
     "Findutils supplies the basic file directory searching utilities of the
@@ -226,18 +277,23 @@ used to apply commands with arbitrarily long arguments.")
 (define-public coreutils
   (package
    (name "coreutils")
-   (version "8.23")
+   (version "8.25")
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://gnu/coreutils/coreutils-"
                                 version ".tar.xz"))
             (sha256
              (base32
-              "0bdq6yggyl7nkc2pbl6pxhhyx15nyqhz3ds6rfn448n6rxdwlhzc"))
-            (patches (list (search-patch "coreutils-dummy-man.patch")))))
+              "11yfrnb94xzmvi4lhclkcmkqsbhww64wf234ya1aacjvg82prrii"))))
    (build-system gnu-build-system)
    (inputs `(("acl"  ,acl)                        ; TODO: add SELinux
-             ("gmp"  ,gmp)))
+             ("gmp"  ,gmp)                        ;bignums in 'expr', yay!
+
+             ;; Drop the dependency on libcap when cross-compiling since it's
+             ;; not quite cross-compilable.
+             ,@(if (%current-target-system)
+                   '()
+                   `(("libcap" ,libcap)))))  ;capability support is 'ls', etc.
    (native-inputs
     ;; Perl is needed to run tests in native builds, and to run the bundled
     ;; copy of help2man.  However, don't pass it when cross-compiling since
@@ -273,33 +329,41 @@ functionality beyond that which is outlined in the POSIX standard.")
    (license gpl3+)
    (home-page "http://www.gnu.org/software/coreutils/")))
 
+(define-public coreutils-minimal
+  ;; Coreutils without its optional dependencies.
+  (package
+    (inherit coreutils)
+    (name "coreutils-minimal")
+    (outputs '("out"))
+    (inputs '())))
+
 (define-public gnu-make
   (package
    (name "make")
-   (version "4.1")
+   (version "4.2.1")
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://gnu/make/make-" version
                                 ".tar.bz2"))
             (sha256
              (base32
-              "19gwwhik3wdwn0r42b7xcihkbxvjl9r2bdal8nifc3k5i4rn3iqb"))
-            (patches (list (search-patch "make-impure-dirs.patch")))))
+              "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
+            (patches (search-patches "make-impure-dirs.patch"))))
    (build-system gnu-build-system)
-   (native-inputs `(("pkg-config"pkg-config)))  ; to detect Guile
+   (native-inputs `(("pkg-config" ,pkg-config)))  ; to detect Guile
    (inputs `(("guile" ,guile-2.0)))
    (outputs '("out" "debug"))
    (arguments
-    '(#: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)))
+    '(#:phases
+      (modify-phases %standard-phases
+        (add-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)))))))))
    (synopsis "Remake files automatically")
    (description
     "Make is a program that is used to control the production of
@@ -314,16 +378,17 @@ change.  GNU make offers many powerful extensions over the standard utility.")
 (define-public binutils
   (package
    (name "binutils")
-   (version "2.25")
+   (version "2.27")
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://gnu/binutils/binutils-"
                                 version ".tar.bz2"))
             (sha256
              (base32
-              "08r9i26b05zcwb9zxb6zllpfdiiicdfsgbpsjlrjmvx3rxjzrpi2"))
-            (patches (list (search-patch "binutils-ld-new-dtags.patch")
-                           (search-patch "binutils-loongson-workaround.patch")))))
+              "125clslv17xh1sab74343fg6v31msavpmaa1c1394zsqa773g5rn"))
+            (patches (search-patches "binutils-ld-new-dtags.patch"
+                                     "binutils-loongson-workaround.patch"
+                                     "binutils-mips-bash-bug.patch"))))
    (build-system gnu-build-system)
 
    ;; TODO: Add dependency on zlib + those for Gold.
@@ -358,14 +423,22 @@ included.")
    (license gpl3+)
    (home-page "http://www.gnu.org/software/binutils/")))
 
-(define* (make-ld-wrapper name #:key binutils
+(define* (make-ld-wrapper name #:key
+                          (target (const #f))
+                          binutils
                           (guile (canonical-package guile-2.0))
-                          (bash (canonical-package bash)) target
+                          (bash (canonical-package bash))
                           (guile-for-build guile))
   "Return a package called NAME that contains a wrapper for the 'ld' program
-of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line.  When
-TARGET is not #f, make a wrapper for the cross-linker for TARGET, called
-'TARGET-ld'.  The wrapper uses GUILE and BASH."
+of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line.  The
+wrapper uses GUILE and BASH.
+
+TARGET must be a one-argument procedure that, given a system type, returns a
+cross-compilation target triplet or #f.  When the result is not #f, make a
+wrapper for the cross-linker for that target, called 'TARGET-ld'."
+  ;; Note: #:system->target-triplet is a procedure so that the evaluation of
+  ;; its result can be delayed until the 'arguments' field is evaluated, thus
+  ;; in a context where '%current-system' is accurate.
   (package
     (name name)
     (version "0")
@@ -377,43 +450,44 @@ TARGET is not #f, make a wrapper for the cross-linker for TARGET, called
               ("wrapper"  ,(search-path %load-path
                                         "gnu/packages/ld-wrapper.in"))))
     (arguments
-     `(#:guile ,guile-for-build
-       #:modules ((guix build utils))
-       #:builder (begin
-                   (use-modules (guix build utils)
-                                (system base compile))
-
-                   (let* ((out (assoc-ref %outputs "out"))
-                          (bin (string-append out "/bin"))
-                          (ld  ,(if target
-                                    `(string-append bin "/" ,target "-ld")
-                                    '(string-append bin "/ld")))
-                          (go  (string-append ld ".go")))
-
-                     (setvbuf (current-output-port) _IOLBF)
-                     (format #t "building ~s/bin/ld wrapper in ~s~%"
-                             (assoc-ref %build-inputs "binutils")
-                             out)
-
-                     (mkdir-p bin)
-                     (copy-file (assoc-ref %build-inputs "wrapper") ld)
-                     (substitute* ld
-                       (("@SELF@")
-                        ld)
-                       (("@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")
-                                       ,(if target
-                                            (string-append "/bin/"
-                                                           target "-ld")
-                                            "/bin/ld"))))
-                     (chmod ld #o555)
-                     (compile-file ld #:output-file go)))))
+     (let ((target (target (%current-system))))
+       `(#:guile ,guile-for-build
+         #:modules ((guix build utils))
+         #:builder (begin
+                     (use-modules (guix build utils)
+                                  (system base compile))
+
+                     (let* ((out (assoc-ref %outputs "out"))
+                            (bin (string-append out "/bin"))
+                            (ld  ,(if target
+                                      `(string-append bin "/" ,target "-ld")
+                                      '(string-append bin "/ld")))
+                            (go  (string-append ld ".go")))
+
+                       (setvbuf (current-output-port) _IOLBF)
+                       (format #t "building ~s/bin/ld wrapper in ~s~%"
+                               (assoc-ref %build-inputs "binutils")
+                               out)
+
+                       (mkdir-p bin)
+                       (copy-file (assoc-ref %build-inputs "wrapper") ld)
+                       (substitute* ld
+                         (("@SELF@")
+                          ld)
+                         (("@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")
+                                         ,(if target
+                                              (string-append "/bin/"
+                                                             target "-ld")
+                                              "/bin/ld"))))
+                       (chmod ld #o555)
+                       (compile-file ld #:output-file go))))))
     (synopsis "The linker wrapper")
     (description
      "The linker wrapper (or 'ld-wrapper') wraps the linker to add any
@@ -424,17 +498,17 @@ store.")
 
 (export make-ld-wrapper)
 
-(define-public glibc
+(define-public glibc/linux
   (package
    (name "glibc")
-   (version "2.21")
+   (version "2.24")
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://gnu/glibc/glibc-"
                                 version ".tar.xz"))
             (sha256
              (base32
-              "1f135546j34s9bfkydmx2nhh9vwxlx60jldi80zmsnln6wj3dsxf"))
+              "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
             (snippet
              ;; Disable 'ldconfig' and /etc/ld.so.cache.  The latter is
              ;; required on LFS distros to avoid loading the distro's libc.so
@@ -443,12 +517,14 @@ store.")
                 (("use_ldconfig=yes")
                  "use_ldconfig=no")))
             (modules '((guix build utils)))
-            (patches (list (search-patch "glibc-ldd-x86_64.patch")))))
+            (patches (search-patches "glibc-ldd-x86_64.patch"
+                                     "glibc-versioned-locpath.patch"
+                                     "glibc-o-largefile.patch"))))
    (build-system gnu-build-system)
 
    ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
    ;; users should automatically pull Linux headers as well.
-   (propagated-inputs `(("linux-headers" ,linux-libre-headers)))
+   (propagated-inputs `(("kernel-headers" ,linux-libre-headers)))
 
    (outputs '("out" "debug"))
 
@@ -460,7 +536,7 @@ store.")
       #:parallel-build? #f
 
       ;; The libraries have an empty RUNPATH, but some, such as the versioned
-      ;; libraries (libdl-2.21.so, etc.) have ld.so marked as NEEDED.  Since
+      ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED.  Since
       ;; these libraries are always going to be found anyway, just skip
       ;; RUNPATH checks.
       #:validate-runpath? #f
@@ -476,15 +552,22 @@ store.")
             ;; Set the default locale path.  In practice, $LOCPATH may be
             ;; defined to point whatever locales users want.  However, setuid
             ;; binaries don't honor $LOCPATH, so they'll instead look into
-            ;; $libc_cv_localedir; we choose /run/current-system/locale, with
-            ;; the idea that it is going to be populated by the sysadmin.
+            ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
+            ;; with the idea that it is going to be populated by the sysadmin.
+            ;; The "X.Y" sub-directory is because locale data formats are
+            ;; incompatible across libc versions; see
+            ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
             ;;
             ;; `--localedir' is not honored, so work around it.
             ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
-            (string-append "libc_cv_localedir=/run/current-system/locale")
+            (string-append "libc_cv_complocaledir=/run/current-system/locale/"
+                           ,version)
 
             (string-append "--with-headers="
-                           (assoc-ref %build-inputs "linux-headers")
+                           (assoc-ref ,(if (%current-target-system)
+                                           '%build-target-inputs
+                                           '%build-inputs)
+                                      "kernel-headers")
                            "/include")
 
             ;; This is the default for most architectures as of GNU libc 2.21,
@@ -498,85 +581,87 @@ store.")
                            "/bin/bash")
 
             ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
-            "libc_cv_ssp=no")
+            "libc_cv_ssp=no" "libc_cv_ssp_strong=no")
 
       #:tests? #f                                 ; XXX
-      #:phases (alist-cons-before
-                'configure 'pre-configure
-                (lambda* (#:key inputs native-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"))
-
-                    ;; Install the rpc data base file under `$out/etc/rpc'.
-                    ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
-                    (substitute* "sunrpc/Makefile"
-                      (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
-                       (string-append out "/etc/rpc" suffix "\n"))
-                      (("^install-others =.*$")
-                       (string-append "install-others = " out "/etc/rpc\n")))
-
-                    (substitute* "Makeconfig"
-                      ;; According to
-                      ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
-                      ;; linking against libgcc_s is not needed with GCC
-                      ;; 4.7.1.
-                      ((" -lgcc_s") ""))
-
-                    ;; Copy a statically-linked Bash in the output, with
-                    ;; no references to other store paths.
-                    ;; FIXME: Normally we would look it up only in INPUTS but
-                    ;; cross-base uses it as a native input.
-                    (mkdir-p bin)
-                    (copy-file (string-append (or (assoc-ref inputs
-                                                             "static-bash")
-                                                  (assoc-ref native-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")))
-
-                    ;; Make sure we don't retain a reference to the
-                    ;; bootstrap Perl.
-                    (substitute* "malloc/mtrace.pl"
-                      (("^#!.*")
-                       ;; The shebang can be omitted, because there's the
-                       ;; "bilingual" eval/exec magic at the top of the file.
-                       "")
-                      (("exec @PERL@")
-                       "exec perl"))))
-                %standard-phases)))
+      #:phases (modify-phases %standard-phases
+                 (add-before
+                  'configure 'pre-configure
+                  (lambda* (#:key inputs native-inputs outputs
+                                  #:allow-other-keys)
+                    (let* ((out  (assoc-ref outputs "out"))
+                           (bin  (string-append out "/bin"))
+                           ;; FIXME: Normally we would look it up only in INPUTS
+                           ;; but cross-base uses it as a native input.
+                           (bash (or (assoc-ref inputs "static-bash")
+                                     (assoc-ref native-inputs "static-bash"))))
+                      ;; Install the rpc data base file under `$out/etc/rpc'.
+                      ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
+                      (substitute* "sunrpc/Makefile"
+                        (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
+                         (string-append out "/etc/rpc" suffix "\n"))
+                        (("^install-others =.*$")
+                         (string-append "install-others = " out "/etc/rpc\n")))
+
+                      (substitute* "Makeconfig"
+                        ;; According to
+                        ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
+                        ;; linking against libgcc_s is not needed with GCC
+                        ;; 4.7.1.
+                        ((" -lgcc_s") ""))
+
+                      ;; Have `system' use that Bash.
+                      (substitute* "sysdeps/posix/system.c"
+                        (("#define[[:blank:]]+SHELL_PATH.*$")
+                         (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
+                                 bash)))
 
-   (inputs `(("static-bash" ,(static-package bash-light))))
+                      ;; Same for `popen'.
+                      (substitute* "libio/iopopen.c"
+                        (("/bin/sh")
+                         (string-append bash "/bin/bash")))
 
-   ;; To build the manual, we need Texinfo and Perl.
+                      ;; Same for the shell used by the 'exec' functions for
+                      ;; scripts that lack a shebang.
+                      (substitute* (find-files "." "^paths\\.h$")
+                        (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
+                         (string-append "#define _PATH_BSHELL \""
+                                        bash "/bin/bash\"\n")))
+
+                      ;; Nscd uses __DATE__ and __TIME__ to create a string to
+                      ;; make sure the client and server come from the same
+                      ;; libc.  Use something deterministic instead.
+                      (substitute* "nscd/nscd_stat.c"
+                        (("static const char compilation\\[21\\] =.*$")
+                         (string-append
+                          "static const char compilation[21] = \""
+                          (string-take (basename out) 20) "\";\n")))
+
+                      ;; Make sure we don't retain a reference to the
+                      ;; bootstrap Perl.
+                      (substitute* "malloc/mtrace.pl"
+                        (("^#!.*")
+                         ;; The shebang can be omitted, because there's the
+                         ;; "bilingual" eval/exec magic at the top of the file.
+                         "")
+                        (("exec @PERL@")
+                         "exec perl"))))))))
+
+   (inputs `(("static-bash" ,static-bash)))
+
+   ;; To build the manual, we need Texinfo and Perl.  Gettext is needed to
+   ;; install the message catalogs, with 'msgfmt'.
    (native-inputs `(("texinfo" ,texinfo)
-                    ("perl" ,perl)))
+                    ("perl" ,perl)
+                    ("gettext" ,gettext-minimal)))
 
    (native-search-paths
     ;; Search path for packages that provide locale data.  This is useful
-    ;; primarily in build environments.
+    ;; primarily in build environments.  Use 'GUIX_LOCPATH' rather than
+    ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
+    ;; distros.
     (list (search-path-specification
-           (variable "LOCPATH")
+           (variable "GUIX_LOCPATH")
            (files '("lib/locale")))))
 
    (synopsis "The GNU C Library")
@@ -590,6 +675,128 @@ with the Linux kernel.")
    (license lgpl2.0+)
    (home-page "http://www.gnu.org/software/libc/")))
 
+(define-public glibc/hurd
+  ;; The Hurd's libc variant.
+  (package (inherit glibc/linux)
+    (name "glibc-hurd")
+    (version "2.23")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "http://alpha.gnu.org/gnu/hurd/glibc-"
+                                  version "-hurd+libpthread-20161218" ".tar.gz"))
+              (sha256
+               (base32
+                "0vpdv05j6j3ria5bw8gp468i64gij94cslxkxj9xkfgi6p615b8p"))))
+
+    ;; Libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
+    ;; so both should be propagated.
+    (propagated-inputs `(("hurd-core-headers" ,hurd-core-headers)))
+    (native-inputs
+     `(,@(package-native-inputs glibc/linux)
+       ("mig" ,mig)
+       ("perl" ,perl)))
+
+    (arguments
+     (substitute-keyword-arguments (package-arguments glibc/linux)
+       ((#:phases original-phases)
+        ;; Add libmachuser.so and libhurduser.so to libc.so's search path.
+        ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-07/msg00051.html>.
+        `(alist-cons-after
+          'install 'augment-libc.so
+          (lambda* (#:key outputs #:allow-other-keys)
+            (let* ((out (assoc-ref outputs "out")))
+              (substitute* (string-append out "/lib/libc.so")
+                (("/[^ ]+/lib/libc.so.0.3")
+                 (string-append out "/lib/libc.so.0.3" " libmachuser.so" " libhurduser.so"))))
+            #t)
+          (alist-cons-after
+           'pre-configure 'pre-configure-set-pwd
+           (lambda _
+             ;; Use the right 'pwd'.
+             (substitute* "configure"
+               (("/bin/pwd") "pwd")))
+          ,original-phases)))
+        ((#:configure-flags original-configure-flags)
+        `(append (list "--host=i586-pc-gnu"
+
+                       ;; We need this to get a working openpty() function.
+                       "--enable-pt_chown"
+
+                       ;; <https://lists.gnu.org/archive/html/bug-hurd/2016-10/msg00033.html>
+                       "--disable-werror"
+
+                       ;; nscd fails to build for GNU/Hurd:
+                       ;; <https://lists.gnu.org/archive/html/bug-hurd/2014-07/msg00006.html>.
+                       ;; Disable it.
+                       "--disable-nscd")
+                 (filter (lambda (flag)
+                           (not (string-prefix? "--enable-kernel=" flag)))
+                         ,original-configure-flags)))))
+    (synopsis "The GNU C Library (GNU Hurd variant)")
+    (supported-systems %hurd-systems)))
+
+(define* (glibc-for-target #:optional
+                           (target (or (%current-target-system)
+                                       (%current-system))))
+  "Return the glibc for TARGET, GLIBC/LINUX for a Linux host or
+GLIBC/HURD for a Hurd host"
+  (match target
+    ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
+    (_ glibc/linux)))
+
+(define-syntax glibc
+  (identifier-syntax (glibc-for-target)))
+
+;; Below are old libc versions, which we use mostly to build locale data in
+;; the old format (which the new libc cannot cope with.)
+
+(define-public glibc-2.23
+  (package
+    (inherit glibc)
+    (version "2.23")
+    (source (origin
+              (inherit (package-source glibc))
+              (uri (string-append "mirror://gnu/glibc/glibc-"
+                                  version ".tar.xz"))
+              (sha256
+               (base32
+                "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))))))
+
+(define-public glibc-2.22
+  (package
+    (inherit glibc)
+    (version "2.22")
+    (source (origin
+              (inherit (package-source glibc))
+              (uri (string-append "mirror://gnu/glibc/glibc-"
+                                  version ".tar.xz"))
+              (sha256
+               (base32
+                "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
+              (patches (search-patches "glibc-ldd-x86_64.patch"))))
+    (arguments
+      (substitute-keyword-arguments (package-arguments glibc)
+        ((#:phases phases)
+         `(modify-phases ,phases
+            (add-before 'configure 'fix-pwd
+              (lambda _
+                ;; Use `pwd' instead of `/bin/pwd' for glibc-2.21
+                (substitute* "configure"
+                  (("/bin/pwd") "pwd"))))))))))
+
+(define-public glibc-2.21
+  (package
+    (inherit glibc-2.22)
+    (version "2.21")
+    (source (origin
+              (inherit (package-source glibc))
+              (uri (string-append "mirror://gnu/glibc/glibc-"
+                                  version ".tar.xz"))
+              (sha256
+               (base32
+                "1f135546j34s9bfkydmx2nhh9vwxlx60jldi80zmsnln6wj3dsxf"))
+              (patches (search-patches "glibc-ldd-x86_64.patch"))))))
+
 (define-public glibc-locales
   (package
     (inherit glibc)
@@ -612,19 +819,16 @@ the 'share/locale' sub-directory of this package.")
           `(alist-replace
             'build
             (lambda* (#:key outputs #:allow-other-keys)
-              (let ((out (assoc-ref outputs "out")))
-                ;; Delete $out/bin, which contains 'bash'.
-                (delete-file-recursively (string-append out "/bin")))
-
               (zero? (system* "make" "localedata/install-locales"
                               "-j" (number->string (parallel-job-count)))))
             (alist-delete 'install ,phases)))
          ((#:configure-flags flags)
           `(append ,flags
-                   ;; Use $(libdir)/locale as is the case by default.
-                   (list (string-append "libc_cv_localedir="
+                   ;; Use $(libdir)/locale/X.Y as is the case by default.
+                   (list (string-append "libc_cv_complocaledir="
                                         (assoc-ref %outputs "out")
-                                        "/lib/locale")))))))))
+                                        "/lib/locale/"
+                                        ,(package-version glibc))))))))))
 
 (define-public glibc-utf8-locales
   (package
@@ -633,7 +837,7 @@ the 'share/locale' sub-directory of this package.")
     (source #f)
     (build-system trivial-build-system)
     (arguments
-     '(#:modules ((guix build utils))
+     `(#:modules ((guix build utils))
        #:builder (begin
                    (use-modules (srfi srfi-1)
                                 (guix build utils))
@@ -641,18 +845,29 @@ the 'share/locale' sub-directory of this package.")
                    (let* ((libc      (assoc-ref %build-inputs "glibc"))
                           (gzip      (assoc-ref %build-inputs "gzip"))
                           (out       (assoc-ref %outputs "out"))
-                          (localedir (string-append out "/lib/locale")))
+                          (localedir (string-append out "/lib/locale/"
+                                                    ,version)))
                      ;; 'localedef' needs 'gzip'.
                      (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
 
                      (mkdir-p localedir)
                      (every (lambda (locale)
-                              (zero? (system* "localedef" "--no-archive"
-                                              "--prefix" localedir "-i" locale
-                                              "-f" "UTF-8"
+                              (define file
+                                ;; Use the "normalized codeset" by
+                                ;; default--e.g., "en_US.utf8".
+                                (string-append localedir "/" locale ".utf8"))
+
+                              (and (zero? (system* "localedef" "--no-archive"
+                                                   "--prefix" localedir
+                                                   "-i" locale
+                                                   "-f" "UTF-8" file))
+                                   (begin
+                                     ;; For backward compatibility with Guix
+                                     ;; <= 0.8.3, add "xx_YY.UTF-8".
+                                     (symlink (string-append locale ".utf8")
                                               (string-append localedir "/"
-                                                             locale
-                                                             ".UTF-8"))))
+                                                             locale ".UTF-8"))
+                                     #t)))
 
                             ;; These are the locales commonly used for
                             ;; tests---e.g., in Guile's i18n tests.
@@ -669,14 +884,14 @@ test environments.")
 (define-public which
   (package
     (name "which")
-    (version "2.20")
+    (version "2.21")
     (source (origin
               (method url-fetch)
               (uri (string-append "mirror://gnu/which/which-"
                                   version ".tar.gz"))
               (sha256
                (base32
-                "1y2p50zadb36izzh2zw4dm5hvdiydqf3qa88l8kav20dcmfbc5yl"))))
+                "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
     (build-system gnu-build-system)
     (home-page "https://gnu.org/software/which/")
     (synopsis "Find full path of shell commands")
@@ -686,18 +901,57 @@ variety of options.  It is an alternative to the shell \"type\" built-in
 command.")
     (license gpl3+))) ; some files are under GPLv2+
 
+(define-public glibc/hurd-headers
+  (package (inherit glibc/hurd)
+    (name "glibc-hurd-headers")
+    (outputs '("out"))
+    (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
+                         ("hurd-headers" ,hurd-headers)))
+    (arguments
+     (substitute-keyword-arguments (package-arguments glibc/hurd)
+       ;; We just pass the flags really needed to build the headers.
+       ((#:configure-flags _)
+        `(list "--enable-add-ons"
+               "--host=i586-pc-gnu"
+               "--enable-obsolete-rpc"))
+       ((#:phases _)
+        '(alist-replace
+          'install
+          (lambda* (#:key outputs #:allow-other-keys)
+            (and (zero? (system* "make" "install-headers"))
+
+                 ;; Make an empty stubs.h to work around not being able to
+                 ;; produce a valid stubs.h and causing the build to fail. See
+                 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
+                 (let ((out (assoc-ref outputs "out")))
+                   (close-port
+                    (open-output-file
+                     (string-append out "/include/gnu/stubs.h"))))))
+
+          ;; Nothing to build.
+          (alist-delete
+           'build
+
+           (alist-cons-before
+            'configure 'pre-configure
+            (lambda _
+              ;; Use the right 'pwd'.
+              (substitute* "configure"
+                (("/bin/pwd") "pwd")))
+            %standard-phases))))))))
+
 (define-public tzdata
   (package
     (name "tzdata")
-    (version "2015b")
+    (version "2016j")
     (source (origin
              (method url-fetch)
              (uri (string-append
-                   "http://www.iana.org/time-zones/repository/releases/tzdata"
+                   "https://www.iana.org/time-zones/repository/releases/tzdata"
                    version ".tar.gz"))
              (sha256
               (base32
-               "0qmdr1yqqn94b5a54axwszfzimyxg27i6xsfmp0sswd3nfjw2sjm"))))
+               "1j4xycpwhs57qnkcxwh3np8wnf3km69n3cf4w6p2yv2z247lxvpm"))))
     (build-system gnu-build-system)
     (arguments
      '(#:tests? #f
@@ -720,23 +974,24 @@ command.")
                   (guix build gnu-build-system)
                   (srfi srfi-1))
        #:phases
-       (alist-replace
-        'unpack
-        (lambda* (#:key source inputs #:allow-other-keys)
-          (and (zero? (system* "tar" "xvf" source))
-               (zero? (system* "tar" "xvf" (assoc-ref inputs "tzcode")))))
-        (alist-cons-after
-         'install 'post-install
-         (lambda* (#:key outputs #:allow-other-keys)
-           ;; Move data in the right place.
-           (let ((out (assoc-ref outputs "out")))
-             (copy-recursively (string-append out "/share/zoneinfo-posix")
-                               (string-append out "/share/zoneinfo/posix"))
-             (copy-recursively (string-append out "/share/zoneinfo-leaps")
-                               (string-append out "/share/zoneinfo/right"))
-             (delete-file-recursively (string-append out "/share/zoneinfo-posix"))
-             (delete-file-recursively (string-append out "/share/zoneinfo-leaps"))))
-         (alist-delete 'configure %standard-phases)))))
+       (modify-phases %standard-phases
+         (replace 'unpack
+           (lambda* (#:key source inputs #:allow-other-keys)
+             (and (zero? (system* "tar" "xvf" source))
+                  (zero? (system* "tar" "xvf" (assoc-ref inputs "tzcode"))))))
+         (add-after 'install 'post-install
+           (lambda* (#:key outputs #:allow-other-keys)
+             ;; Move data in the right place.
+             (let ((out (assoc-ref outputs "out")))
+               (symlink (string-append out "/share/zoneinfo")
+                        (string-append out "/share/zoneinfo/posix"))
+               (delete-file-recursively
+                (string-append out "/share/zoneinfo-posix"))
+               (copy-recursively (string-append out "/share/zoneinfo-leaps")
+                                 (string-append out "/share/zoneinfo/right"))
+               (delete-file-recursively
+                (string-append out "/share/zoneinfo-leaps")))))
+         (delete 'configure))))
     (inputs `(("tzcode" ,(origin
                           (method url-fetch)
                           (uri (string-append
@@ -744,8 +999,8 @@ command.")
                                 version ".tar.gz"))
                           (sha256
                            (base32
-                            "0xjxlgzva13y8qi3vfbb3nq5pii8ax9wi4yc7vj9134rbciz2s76"))))))
-    (home-page "http://www.iana.org/time-zones")
+                            "1dxhrk4z0n2di8p0yd6q00pa6bwyz5xqbrfbasiz8785ni7zrvxr"))))))
+    (home-page "https://www.iana.org/time-zones")
     (synopsis "Database of current and historical time zones")
     (description "The Time Zone Database (often called tz or zoneinfo)
 contains code and data that represent the history of local time for many
@@ -754,10 +1009,53 @@ reflect changes made by political bodies to time zone boundaries, UTC offsets,
 and daylight-saving rules.")
     (license public-domain)))
 
+(define-public libiconv
+  (package
+    (name "libiconv")
+    (version "1.14")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://gnu/libiconv/libiconv-"
+                                  version ".tar.gz"))
+              (sha256
+               (base32
+                "04q6lgl3kglmmhw59igq1n7v3rp1rpkypl366cy1k1yn2znlvckj"))
+              (modules '((guix build utils)))
+              (snippet
+               ;; Work around "declared gets" error on glibc systems (fixed by
+               ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
+               '(substitute* "srclib/stdio.in.h"
+                  (("^#undef gets") "")
+                  (("^_GL_WARN_ON_USE \\(gets.*") "")))))
+    (build-system gnu-build-system)
+    (synopsis "Character set conversion library")
+    (description
+     "libiconv provides an implementation of the iconv function for systems
+that lack it.  iconv is used to convert between character encodings in a
+program.  It supports a wide variety of different encodings.")
+    (home-page "http://www.gnu.org/software/libiconv/")
+    (license lgpl3+)))
+
+(define* (libiconv-if-needed #:optional (target (%current-target-system)))
+  "Return either a libiconv package specification to include in a dependency
+list for platforms that have an incomplete libc, or the empty list.  If a
+package needs iconv ,@(libiconv-if-needed) should be added."
+  ;; POSIX C libraries provide iconv.  Platforms with an incomplete libc
+  ;; without iconv, such as MinGW, must return the then clause.
+  (if (target-mingw? target)
+      `(("libiconv" ,libiconv))
+      '()))
+
 (define-public (canonical-package package)
   ;; Avoid circular dependency by lazily resolving 'commencement'.
   (let* ((iface (resolve-interface '(gnu packages commencement)))
          (proc  (module-ref iface 'canonical-package)))
     (proc package)))
 
+(define-public (%final-inputs)
+  "Return the list of \"final inputs\"."
+  ;; Avoid circular dependency by lazily resolving 'commencement'.
+  (let ((iface (resolve-interface '(gnu packages commencement))))
+    (module-ref iface '%final-inputs)))
+
 ;;; base.scm ends here