gnu: coreutils: Update to 8.28.
[jackhill/guix/guix.git] / gnu / packages / base.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
5 ;;; Copyright © 2014, 2015, 2016 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
7 ;;; Copyright © 2014, 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
8 ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
9 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
10 ;;; Copyright © 2017 Rene Saavedra <rennes@openmailbox.org>
11 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
12 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
13 ;;;
14 ;;; This file is part of GNU Guix.
15 ;;;
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
20 ;;;
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
25 ;;;
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29 (define-module (gnu packages base)
30 #:use-module ((guix licenses)
31 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
32 #:use-module (gnu packages)
33 #:use-module (gnu packages acl)
34 #:use-module (gnu packages bash)
35 #:use-module (gnu packages ed)
36 #:use-module (gnu packages guile)
37 #:use-module (gnu packages multiprecision)
38 #:use-module (gnu packages compression)
39 #:use-module (gnu packages perl)
40 #:use-module (gnu packages linux)
41 #:use-module (gnu packages texinfo)
42 #:use-module (gnu packages hurd)
43 #:use-module (gnu packages pkg-config)
44 #:use-module (gnu packages gettext)
45 #:use-module (guix utils)
46 #:use-module (guix packages)
47 #:use-module (guix download)
48 #:use-module (guix git-download)
49 #:use-module (guix build-system gnu)
50 #:use-module (guix build-system trivial)
51 #:use-module (ice-9 match)
52 #:export (glibc
53 libiconv-if-needed))
54
55 ;;; Commentary:
56 ;;;
57 ;;; Base packages of the Guix-based GNU user-land software distribution.
58 ;;;
59 ;;; Code:
60
61 (define-public hello
62 (package
63 (name "hello")
64 (version "2.10")
65 (source (origin
66 (method url-fetch)
67 (uri (string-append "mirror://gnu/hello/hello-" version
68 ".tar.gz"))
69 (sha256
70 (base32
71 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
72 (build-system gnu-build-system)
73 (synopsis "Hello, GNU world: An example GNU package")
74 (description
75 "GNU Hello prints the message \"Hello, world!\" and then exits. It
76 serves as an example of standard GNU coding practices. As such, it supports
77 command-line arguments, multiple languages, and so on.")
78 (home-page "https://www.gnu.org/software/hello/")
79 (license gpl3+)))
80
81 (define-public grep
82 (package
83 (name "grep")
84 (version "3.1")
85 (source (origin
86 (method url-fetch)
87 (uri (string-append "mirror://gnu/grep/grep-"
88 version ".tar.xz"))
89 (sha256
90 (base32
91 "0zm0ywmyz9g8vn1plw14mn8kj74yipx5qsljndbyfgmvndx5qqnv"))
92 (patches (search-patches "grep-timing-sensitive-test.patch"))))
93 (build-system gnu-build-system)
94 (native-inputs `(("perl" ,perl))) ;some of the tests require it
95 (arguments
96 `(#:phases
97 (modify-phases %standard-phases
98 (add-after 'install 'fix-egrep-and-fgrep
99 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
100 ;; absolute file name instead of searching for it in $PATH.
101 (lambda* (#:key outputs #:allow-other-keys)
102 (let* ((out (assoc-ref outputs "out"))
103 (bin (string-append out "/bin")))
104 (substitute* (list (string-append bin "/egrep")
105 (string-append bin "/fgrep"))
106 (("^exec grep")
107 (string-append "exec " bin "/grep")))
108 #t))))))
109 (synopsis "Print lines matching a pattern")
110 (description
111 "grep is a tool for finding text inside files. Text is found by
112 matching a pattern provided by the user in one or many files. The pattern
113 may be provided as a basic or extended regular expression, or as fixed
114 strings. By default, the matching text is simply printed to the screen,
115 however the output can be greatly customized to include, for example, line
116 numbers. GNU grep offers many extensions over the standard utility,
117 including, for example, recursive directory searching.")
118 (license gpl3+)
119 (home-page "https://www.gnu.org/software/grep/")))
120
121 (define-public sed
122 (package
123 (name "sed")
124 (version "4.4")
125 (source (origin
126 (method url-fetch)
127 (uri (string-append "mirror://gnu/sed/sed-" version
128 ".tar.xz"))
129 (sha256
130 (base32
131 "0fv88bcnraixc8jvpacvxshi30p5x9m7yb8ns1hfv07hmb2ypmnb"))))
132 (build-system gnu-build-system)
133 (synopsis "Stream editor")
134 (arguments
135 `(#:phases
136 (modify-phases %standard-phases
137 (add-after 'unpack 'dont-rebuild-sed.1
138 (lambda _
139 ;; Make sure we do not attempt to rebuild 'doc/sed.1', which does
140 ;; not work when cross-compiling because we cannot run 'sed'.
141 ;; This is fixed upstream as commit a0a25e3.
142 (substitute* "Makefile.in"
143 (("^doc/sed\\.1:.*")
144 "doc/sed.1:\n"))
145 #t))
146 (add-before 'patch-source-shebangs 'patch-test-suite
147 (lambda* (#:key inputs #:allow-other-keys)
148 (patch-makefile-SHELL "testsuite/Makefile.tests")
149 (substitute* '("testsuite/bsd.sh"
150 "testsuite/bug-regex9.c")
151 (("/bin/sh")
152 (which "sh")))
153 #t)))))
154 (description
155 "Sed is a non-interactive, text stream editor. It receives a text
156 input from a file or from standard input and it then applies a series of text
157 editing commands to the stream and prints its output to standard output. It
158 is often used for substituting text patterns in a stream. The GNU
159 implementation offers several extensions over the standard utility.")
160 (license gpl3+)
161 (home-page "https://www.gnu.org/software/sed/")))
162
163 (define-public tar
164 (package
165 (name "tar")
166 (version "1.29")
167 (source (origin
168 (method url-fetch)
169 (uri (string-append "mirror://gnu/tar/tar-"
170 version ".tar.xz"))
171 (sha256
172 (base32
173 "097hx7sbzp8qirl4m930lw84kn0wmxhmq7v1qpra3mrg0b8cyba0"))
174 (patches (search-patches "tar-CVE-2016-6321.patch"
175 "tar-skip-unreliable-tests.patch"))))
176 (build-system gnu-build-system)
177 ;; Note: test suite requires ~1GiB of disk space.
178 (arguments
179 '(#:phases (modify-phases %standard-phases
180 (add-before 'build 'set-shell-file-name
181 (lambda* (#:key inputs #:allow-other-keys)
182 ;; Do not use "/bin/sh" to run programs.
183 (let ((bash (assoc-ref inputs "bash")))
184 (substitute* "src/system.c"
185 (("/bin/sh")
186 (string-append bash "/bin/sh")))
187 #t))))))
188
189 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
190 ;; to refer to the target Bash.
191 (inputs (if (%current-target-system)
192 `(("bash" ,bash))
193 '()))
194
195 (synopsis "Managing tar archives")
196 (description
197 "Tar provides the ability to create tar archives, as well as the
198 ability to extract, update or list files in an existing archive. It is
199 useful for combining many files into one larger file, while maintaining
200 directory structure and file information such as permissions and
201 creation/modification dates. GNU tar offers many extensions over the
202 standard utility.")
203 (license gpl3+)
204 (home-page "https://www.gnu.org/software/tar/")))
205
206 (define-public patch
207 (package
208 (name "patch")
209 (version "2.7.5")
210 (source (origin
211 (method url-fetch)
212 (uri (string-append "mirror://gnu/patch/patch-"
213 version ".tar.xz"))
214 (sha256
215 (base32
216 "16d2r9kpivaak948mxzc0bai45mqfw73m113wrkmbffnalv1b5gx"))
217 (patches (search-patches "patch-hurd-path-max.patch"))))
218 (build-system gnu-build-system)
219 (native-inputs `(("ed" ,ed)))
220 (synopsis "Apply differences to originals, with optional backups")
221 (description
222 "Patch is a program that applies changes to files based on differences
223 laid out as by the program \"diff\". The changes may be applied to one or more
224 files depending on the contents of the diff file. It accepts several
225 different diff formats. It may also be used to revert previously applied
226 differences.")
227 (license gpl3+)
228 (home-page "https://savannah.gnu.org/projects/patch/")))
229
230 (define-public diffutils
231 (package
232 (name "diffutils")
233 (version "3.6")
234 (source (origin
235 (method url-fetch)
236 (uri (string-append "mirror://gnu/diffutils/diffutils-"
237 version ".tar.xz"))
238 (sha256
239 (base32
240 "1mivg0fy3a6fcn535ln8nkgfj6vxh5hsxxs5h6692wxmsjyyh8fn"))))
241 (build-system gnu-build-system)
242 (synopsis "Comparing and merging files")
243 (description
244 "GNU Diffutils is a package containing tools for finding the
245 differences between files. The \"diff\" command is used to show how two files
246 differ, while \"cmp\" shows the offsets and line numbers where they differ.
247 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
248 interactive means to merge two files.")
249 (license gpl3+)
250 (home-page "https://www.gnu.org/software/diffutils/")))
251
252 (define-public findutils
253 (package
254 (name "findutils")
255 (version "4.6.0")
256 (source (origin
257 (method url-fetch)
258 (uri (string-append "mirror://gnu/findutils/findutils-"
259 version ".tar.gz"))
260 (sha256
261 (base32
262 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
263 (patches (search-patches
264 "findutils-localstatedir.patch"
265 "findutils-test-xargs.patch"
266 ;; test-lock has performance issues on multi-core
267 ;; machines, it hangs or takes a long time to complete.
268 ;; This is a commit from gnulib to fix this issue.
269 "findutils-gnulib-multi-core.patch"))))
270 (build-system gnu-build-system)
271 (arguments
272 `(#:configure-flags (list
273 ;; Tell 'updatedb' to write to /var.
274 "--localstatedir=/var"
275
276 ;; Work around cross-compilation failure. See
277 ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
278 ,@(if (%current-target-system)
279 '("gl_cv_func_wcwidth_works=yes")
280 '()))))
281 (synopsis "Operating on files matching given criteria")
282 (description
283 "Findutils supplies the basic file directory searching utilities of the
284 GNU system. It consists of two primary searching utilities: \"find\"
285 recursively searches for files in a directory according to given criteria and
286 \"locate\" lists files in a database that match a query. Two auxiliary tools
287 are included: \"updatedb\" updates the file name database and \"xargs\" may be
288 used to apply commands with arbitrarily long arguments.")
289 (license gpl3+)
290 (home-page "https://www.gnu.org/software/findutils/")))
291
292 (define-public coreutils
293 (package
294 (name "coreutils")
295 (version "8.28")
296 (source (origin
297 (method url-fetch)
298 (uri (string-append "mirror://gnu/coreutils/coreutils-"
299 version ".tar.xz"))
300 (sha256
301 (base32
302 "0r8c1bgm68kl70j1lgd0rv12iykw6143k4m9a56xip9rc2hv25qi"))))
303 (build-system gnu-build-system)
304 (inputs `(("acl" ,acl) ; TODO: add SELinux
305 ("gmp" ,gmp) ;bignums in 'expr', yay!
306
307 ;; Drop the dependency on libcap when cross-compiling since it's
308 ;; not quite cross-compilable.
309 ,@(if (%current-target-system)
310 '()
311 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
312 (native-inputs
313 ;; Perl is needed to run tests in native builds, and to run the bundled
314 ;; copy of help2man. However, don't pass it when cross-compiling since
315 ;; that would lead it to try to run programs to get their '--help' output
316 ;; for help2man.
317 (if (%current-target-system)
318 '()
319 `(("perl" ,perl))))
320 (outputs '("out" "debug"))
321 (arguments
322 `(#:parallel-build? #f ; help2man may be called too early
323 #:phases (alist-cons-before
324 'build 'patch-shell-references
325 (lambda* (#:key inputs #:allow-other-keys)
326 (let ((bash (assoc-ref inputs "bash")))
327 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
328 ;; that tests pass, since /bin/sh isn't in the chroot.
329 (setenv "SHELL" (which "sh"))
330
331 (substitute* (find-files "gnulib-tests" "\\.c$")
332 (("/bin/sh")
333 (format #f "~a/bin/sh" bash)))
334 (substitute* (find-files "tests" "\\.sh$")
335 (("#!/bin/sh")
336 (format #f "#!~a/bin/sh" bash)))))
337 %standard-phases)))
338 (synopsis "Core GNU utilities (file, text, shell)")
339 (description
340 "GNU Coreutils includes all of the basic command-line tools that are
341 expected in a POSIX system. These provide the basic file, shell and text
342 manipulation functions of the GNU system. Most of these tools offer extended
343 functionality beyond that which is outlined in the POSIX standard.")
344 (license gpl3+)
345 (home-page "https://www.gnu.org/software/coreutils/")))
346
347 (define-public coreutils-minimal
348 ;; Coreutils without its optional dependencies.
349 (package
350 (inherit coreutils)
351 (name "coreutils-minimal")
352 (outputs '("out"))
353 (inputs '())))
354
355 (define-public gnu-make
356 (package
357 (name "make")
358 (version "4.2.1")
359 (source (origin
360 (method url-fetch)
361 (uri (string-append "mirror://gnu/make/make-" version
362 ".tar.bz2"))
363 (sha256
364 (base32
365 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
366 (patches (search-patches "make-impure-dirs.patch"))))
367 (build-system gnu-build-system)
368 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
369 (inputs `(("guile" ,guile-2.0)))
370 (outputs '("out" "debug"))
371 (arguments
372 '(#:phases
373 (modify-phases %standard-phases
374 (add-before 'build 'set-default-shell
375 (lambda* (#:key inputs #:allow-other-keys)
376 ;; Change the default shell from /bin/sh.
377 (let ((bash (assoc-ref inputs "bash")))
378 (substitute* "job.c"
379 (("default_shell =.*$")
380 (format #f "default_shell = \"~a/bin/sh\";\n"
381 bash)))))))))
382 (synopsis "Remake files automatically")
383 (description
384 "Make is a program that is used to control the production of
385 executables or other files from their source files. The process is
386 controlled from a Makefile, in which the developer specifies how each file is
387 generated from its source. It has powerful dependency resolution and the
388 ability to determine when files have to be regenerated after their sources
389 change. GNU make offers many powerful extensions over the standard utility.")
390 (license gpl3+)
391 (home-page "https://www.gnu.org/software/make/")))
392
393 (define-public binutils
394 (package
395 (name "binutils")
396 (version "2.28")
397 (source (origin
398 (method url-fetch)
399 (uri (string-append "mirror://gnu/binutils/binutils-"
400 version ".tar.bz2"))
401 (sha256
402 (base32
403 "0wiasgns7i8km8nrxas265sh2dfpsw93b3qw195ipc90w4z475v2"))
404 (patches (search-patches "binutils-ld-new-dtags.patch"
405 "binutils-loongson-workaround.patch"))))
406 (build-system gnu-build-system)
407
408 ;; TODO: Add dependency on zlib + those for Gold.
409 (arguments
410 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
411 ;; on GCC when bootstrapping.
412 "LDFLAGS=-static-libgcc"
413
414 ;; Don't search under /usr/lib & co.
415 "--with-lib-path=/no-ld-lib-path"
416
417 ;; Install BFD. It ends up in a hidden directory,
418 ;; but it's here.
419 "--enable-install-libbfd"
420
421 ;; Make sure 'ar' and 'ranlib' produce archives in a
422 ;; deterministic fashion.
423 "--enable-deterministic-archives")))
424
425 (synopsis "Binary utilities: bfd gas gprof ld")
426 (description
427 "GNU Binutils is a collection of tools for working with binary files.
428 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
429 Other tools include programs to display binary profiling information, list
430 the strings in a binary file, and utilities for working with archives. The
431 \"bfd\" library for working with executable and object formats is also
432 included.")
433 (license gpl3+)
434 (home-page "https://www.gnu.org/software/binutils/")))
435
436 (define* (make-ld-wrapper name #:key
437 (target (const #f))
438 binutils
439 (guile (canonical-package guile-2.2))
440 (bash (canonical-package bash))
441 (guile-for-build guile))
442 "Return a package called NAME that contains a wrapper for the 'ld' program
443 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
444 wrapper uses GUILE and BASH.
445
446 TARGET must be a one-argument procedure that, given a system type, returns a
447 cross-compilation target triplet or #f. When the result is not #f, make a
448 wrapper for the cross-linker for that target, called 'TARGET-ld'."
449 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
450 ;; its result can be delayed until the 'arguments' field is evaluated, thus
451 ;; in a context where '%current-system' is accurate.
452 (package
453 (name name)
454 (version "0")
455 (source #f)
456 (build-system trivial-build-system)
457 (inputs `(("binutils" ,binutils)
458 ("guile" ,guile)
459 ("bash" ,bash)
460 ("wrapper" ,(search-path %load-path
461 "gnu/packages/ld-wrapper.in"))))
462 (arguments
463 (let ((target (target (%current-system))))
464 `(#:guile ,guile-for-build
465 #:modules ((guix build utils))
466 #:builder (begin
467 (use-modules (guix build utils)
468 (system base compile))
469
470 (let* ((out (assoc-ref %outputs "out"))
471 (bin (string-append out "/bin"))
472 (ld ,(if target
473 `(string-append bin "/" ,target "-ld")
474 '(string-append bin "/ld")))
475 (go (string-append ld ".go")))
476
477 (setvbuf (current-output-port) _IOLBF)
478 (format #t "building ~s/bin/ld wrapper in ~s~%"
479 (assoc-ref %build-inputs "binutils")
480 out)
481
482 (mkdir-p bin)
483 (copy-file (assoc-ref %build-inputs "wrapper") ld)
484 (substitute* ld
485 (("@SELF@")
486 ld)
487 (("@GUILE@")
488 (string-append (assoc-ref %build-inputs "guile")
489 "/bin/guile"))
490 (("@BASH@")
491 (string-append (assoc-ref %build-inputs "bash")
492 "/bin/bash"))
493 (("@LD@")
494 (string-append (assoc-ref %build-inputs "binutils")
495 ,(if target
496 (string-append "/bin/"
497 target "-ld")
498 "/bin/ld"))))
499 (chmod ld #o555)
500 (compile-file ld #:output-file go))))))
501 (synopsis "The linker wrapper")
502 (description
503 "The linker wrapper (or 'ld-wrapper') wraps the linker to add any
504 missing '-rpath' flags, and to detect any misuse of libraries outside of the
505 store.")
506 (home-page "https://www.gnu.org/software/guix//")
507 (license gpl3+)))
508
509 (export make-ld-wrapper)
510
511 (define-public glibc/linux
512 (package
513 (name "glibc")
514 (version "2.25")
515 (source (origin
516 (method url-fetch)
517 (uri (string-append "mirror://gnu/glibc/glibc-"
518 version ".tar.xz"))
519 (sha256
520 (base32
521 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
522 (snippet
523 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
524 ;; required on LFS distros to avoid loading the distro's libc.so
525 ;; instead of ours.
526 '(substitute* "sysdeps/unix/sysv/linux/configure"
527 (("use_ldconfig=yes")
528 "use_ldconfig=no")))
529 (modules '((guix build utils)))
530 (patches (search-patches "glibc-ldd-x86_64.patch"
531 "glibc-versioned-locpath.patch"
532 "glibc-o-largefile.patch"
533 "glibc-memchr-overflow-i686.patch"
534 "glibc-vectorized-strcspn-guards.patch"
535 "glibc-CVE-2017-1000366-pt1.patch"
536 "glibc-CVE-2017-1000366-pt2.patch"
537 "glibc-CVE-2017-1000366-pt3.patch"))))
538 (build-system gnu-build-system)
539
540 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
541 ;; users should automatically pull Linux headers as well.
542 (propagated-inputs `(("kernel-headers" ,linux-libre-headers)))
543
544 (outputs '("out" "debug"
545 "static")) ;9 MiB of .a files
546
547 (arguments
548 `(#:out-of-source? #t
549
550 ;; The libraries have an empty RUNPATH, but some, such as the versioned
551 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
552 ;; these libraries are always going to be found anyway, just skip
553 ;; RUNPATH checks.
554 #:validate-runpath? #f
555
556 #:modules ((ice-9 ftw)
557 (srfi srfi-26)
558 (guix build utils)
559 (guix build gnu-build-system))
560
561 #:configure-flags
562 (list "--enable-add-ons"
563 "--sysconfdir=/etc"
564
565 ;; Installing a locale archive with all the locales is to
566 ;; expensive (~100 MiB), so we rely on users to install the
567 ;; locales they really want.
568 ;;
569 ;; Set the default locale path. In practice, $LOCPATH may be
570 ;; defined to point whatever locales users want. However, setuid
571 ;; binaries don't honor $LOCPATH, so they'll instead look into
572 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
573 ;; with the idea that it is going to be populated by the sysadmin.
574 ;; The "X.Y" sub-directory is because locale data formats are
575 ;; incompatible across libc versions; see
576 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
577 ;;
578 ;; `--localedir' is not honored, so work around it.
579 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
580 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
581 ,version)
582
583 (string-append "--with-headers="
584 (assoc-ref ,(if (%current-target-system)
585 '%build-target-inputs
586 '%build-inputs)
587 "kernel-headers")
588 "/include")
589
590 ;; This is the default for most architectures as of GNU libc 2.21,
591 ;; but we specify it explicitly for clarity and consistency. See
592 ;; "kernel-features.h" in the GNU libc for details.
593 "--enable-kernel=2.6.32"
594
595 ;; Use our Bash instead of /bin/sh.
596 (string-append "BASH_SHELL="
597 (assoc-ref %build-inputs "bash")
598 "/bin/bash")
599
600 ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
601 "libc_cv_ssp=no" "libc_cv_ssp_strong=no")
602
603 #:tests? #f ; XXX
604 #:phases (modify-phases %standard-phases
605 (add-before
606 'configure 'pre-configure
607 (lambda* (#:key inputs native-inputs outputs
608 #:allow-other-keys)
609 (let* ((out (assoc-ref outputs "out"))
610 (bin (string-append out "/bin"))
611 ;; FIXME: Normally we would look it up only in INPUTS
612 ;; but cross-base uses it as a native input.
613 (bash (or (assoc-ref inputs "static-bash")
614 (assoc-ref native-inputs "static-bash"))))
615 ;; Install the rpc data base file under `$out/etc/rpc'.
616 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
617 (substitute* "sunrpc/Makefile"
618 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
619 (string-append out "/etc/rpc" suffix "\n"))
620 (("^install-others =.*$")
621 (string-append "install-others = " out "/etc/rpc\n")))
622
623 (substitute* "Makeconfig"
624 ;; According to
625 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
626 ;; linking against libgcc_s is not needed with GCC
627 ;; 4.7.1.
628 ((" -lgcc_s") ""))
629
630 ;; Have `system' use that Bash.
631 (substitute* "sysdeps/posix/system.c"
632 (("#define[[:blank:]]+SHELL_PATH.*$")
633 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
634 bash)))
635
636 ;; Same for `popen'.
637 (substitute* "libio/iopopen.c"
638 (("/bin/sh")
639 (string-append bash "/bin/sh")))
640
641 ;; Same for the shell used by the 'exec' functions for
642 ;; scripts that lack a shebang.
643 (substitute* (find-files "." "^paths\\.h$")
644 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
645 (string-append "#define _PATH_BSHELL \""
646 bash "/bin/sh\"\n")))
647
648 ;; Nscd uses __DATE__ and __TIME__ to create a string to
649 ;; make sure the client and server come from the same
650 ;; libc. Use something deterministic instead.
651 (substitute* "nscd/nscd_stat.c"
652 (("static const char compilation\\[21\\] =.*$")
653 (string-append
654 "static const char compilation[21] = \""
655 (string-take (basename out) 20) "\";\n")))
656
657 ;; Make sure we don't retain a reference to the
658 ;; bootstrap Perl.
659 (substitute* "malloc/mtrace.pl"
660 (("^#!.*")
661 ;; The shebang can be omitted, because there's the
662 ;; "bilingual" eval/exec magic at the top of the file.
663 "")
664 (("exec @PERL@")
665 "exec perl")))))
666
667 (add-after 'install 'move-static-libs
668 (lambda* (#:key outputs #:allow-other-keys)
669 ;; Move static libraries to the "static" output.
670 (define (static-library? file)
671 ;; Return true if FILE is a static library. The
672 ;; "_nonshared.a" files are referred to by libc.so,
673 ;; libpthread.so, etc., which are in fact linker
674 ;; scripts.
675 (and (string-suffix? ".a" file)
676 (not (string-contains file "_nonshared"))))
677
678 (define (linker-script? file)
679 ;; Guess whether FILE, a ".a" file, is actually a
680 ;; linker script.
681 (and (not (ar-file? file))
682 (not (elf-file? file))))
683
684 (let* ((out (assoc-ref outputs "out"))
685 (lib (string-append out "/lib"))
686 (files (scandir lib static-library?))
687 (static (assoc-ref outputs "static"))
688 (slib (string-append static "/lib")))
689 (mkdir-p slib)
690 (for-each (lambda (base)
691 (rename-file (string-append lib "/" base)
692 (string-append slib "/" base)))
693 files)
694
695 ;; Usually libm.a is a linker script so we need to
696 ;; change the file names in there to refer to STATIC
697 ;; instead of OUT.
698 (for-each (lambda (ld-script)
699 (substitute* ld-script
700 ((out) static)))
701 (filter linker-script?
702 (map (cut string-append slib "/" <>)
703 files)))
704 #t))))))
705
706 (inputs `(("static-bash" ,static-bash)))
707
708 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
709 ;; install the message catalogs, with 'msgfmt'.
710 (native-inputs `(("texinfo" ,texinfo)
711 ("perl" ,perl)
712 ("gettext" ,gettext-minimal)))
713
714 (native-search-paths
715 ;; Search path for packages that provide locale data. This is useful
716 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
717 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
718 ;; distros.
719 (list (search-path-specification
720 (variable "GUIX_LOCPATH")
721 (files '("lib/locale")))))
722
723 (synopsis "The GNU C Library")
724 (description
725 "Any Unix-like operating system needs a C library: the library which
726 defines the \"system calls\" and other basic facilities such as open, malloc,
727 printf, exit...
728
729 The GNU C library is used as the C library in the GNU system and most systems
730 with the Linux kernel.")
731 (license lgpl2.0+)
732 (home-page "https://www.gnu.org/software/libc/")))
733
734 (define-public glibc/hurd
735 ;; The Hurd's libc variant.
736 (package (inherit glibc/linux)
737 (name "glibc-hurd")
738 (version "2.23")
739 (source (origin
740 (method url-fetch)
741 (uri (string-append "http://alpha.gnu.org/gnu/hurd/glibc-"
742 version "-hurd+libpthread-20161218" ".tar.gz"))
743 (sha256
744 (base32
745 "0vpdv05j6j3ria5bw8gp468i64gij94cslxkxj9xkfgi6p615b8p"))))
746
747 ;; Libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
748 ;; so both should be propagated.
749 (propagated-inputs `(("hurd-core-headers" ,hurd-core-headers)))
750 (native-inputs
751 `(,@(package-native-inputs glibc/linux)
752 ("mig" ,mig)
753 ("perl" ,perl)))
754
755 (arguments
756 (substitute-keyword-arguments (package-arguments glibc/linux)
757 ((#:phases original-phases)
758 ;; Add libmachuser.so and libhurduser.so to libc.so's search path.
759 ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-07/msg00051.html>.
760 `(modify-phases ,original-phases
761 (add-after 'install 'augment-libc.so
762 (lambda* (#:key outputs #:allow-other-keys)
763 (let* ((out (assoc-ref outputs "out")))
764 (substitute* (string-append out "/lib/libc.so")
765 (("/[^ ]+/lib/libc.so.0.3")
766 (string-append out "/lib/libc.so.0.3" " libmachuser.so" " libhurduser.so"))))
767 #t))
768 (add-after 'pre-configure 'pre-configure-set-pwd
769 (lambda _
770 ;; Use the right 'pwd'.
771 (substitute* "configure"
772 (("/bin/pwd") "pwd"))
773 #t))
774 (replace 'build
775 (lambda _
776 ;; Force mach/hurd/libpthread subdirs to build first in order to avoid
777 ;; linking errors.
778 ;; See <https://lists.gnu.org/archive/html/bug-hurd/2016-11/msg00045.html>
779 (let ((-j (list "-j" (number->string (parallel-job-count)))))
780 (let-syntax ((make (syntax-rules ()
781 ((_ target)
782 (zero? (apply system* "make" target -j))))))
783 (and (make "mach/subdir_lib")
784 (make "hurd/subdir_lib")
785 (make "libpthread/subdir_lib")
786 (zero? (apply system* "make" -j)))))))))
787 ((#:configure-flags original-configure-flags)
788 `(append (list "--host=i586-pc-gnu"
789
790 ;; We need this to get a working openpty() function.
791 "--enable-pt_chown"
792
793 ;; <https://lists.gnu.org/archive/html/bug-hurd/2016-10/msg00033.html>
794 "--disable-werror"
795
796 ;; nscd fails to build for GNU/Hurd:
797 ;; <https://lists.gnu.org/archive/html/bug-hurd/2014-07/msg00006.html>.
798 ;; Disable it.
799 "--disable-nscd")
800 (filter (lambda (flag)
801 (not (string-prefix? "--enable-kernel=" flag)))
802 ,original-configure-flags)))))
803 (synopsis "The GNU C Library (GNU Hurd variant)")
804 (supported-systems %hurd-systems)))
805
806 (define* (glibc-for-target #:optional
807 (target (or (%current-target-system)
808 (%current-system))))
809 "Return the glibc for TARGET, GLIBC/LINUX for a Linux host or
810 GLIBC/HURD for a Hurd host"
811 (match target
812 ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
813 (_ glibc/linux)))
814
815 (define-syntax glibc
816 (identifier-syntax (glibc-for-target)))
817
818 ;; Below are old libc versions, which we use mostly to build locale data in
819 ;; the old format (which the new libc cannot cope with.)
820
821 (define-public glibc-2.24
822 (package
823 (inherit glibc)
824 (version "2.24")
825 (source (origin
826 (inherit (package-source glibc))
827 (uri (string-append "mirror://gnu/glibc/glibc-"
828 version ".tar.xz"))
829 (sha256
830 (base32
831 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
832 (patches (search-patches "glibc-ldd-x86_64.patch"
833 "glibc-versioned-locpath.patch"
834 "glibc-o-largefile.patch"
835 "glibc-vectorized-strcspn-guards.patch"
836 "glibc-CVE-2015-5180.patch"
837 "glibc-CVE-2017-1000366-pt1.patch"
838 "glibc-CVE-2017-1000366-pt2.patch"
839 "glibc-CVE-2017-1000366-pt3.patch"))))))
840
841 (define-public glibc-2.23
842 (package
843 (inherit glibc)
844 (version "2.23")
845 (source (origin
846 (inherit (package-source glibc))
847 (uri (string-append "mirror://gnu/glibc/glibc-"
848 version ".tar.xz"))
849 (sha256
850 (base32
851 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
852 (patches (search-patches "glibc-ldd-x86_64.patch"
853 "glibc-versioned-locpath.patch"
854 "glibc-o-largefile.patch"
855 "glibc-vectorized-strcspn-guards.patch"
856 "glibc-CVE-2015-5180.patch"
857 "glibc-CVE-2016-3075.patch"
858 "glibc-CVE-2016-3706.patch"
859 "glibc-CVE-2016-4429.patch"
860 "glibc-CVE-2017-1000366-pt1.patch"
861 "glibc-CVE-2017-1000366-pt2.patch"
862 "glibc-CVE-2017-1000366-pt3.patch"))))))
863
864 (define-public glibc-2.22
865 (package
866 (inherit glibc)
867 (version "2.22")
868 (source (origin
869 (inherit (package-source glibc))
870 (uri (string-append "mirror://gnu/glibc/glibc-"
871 version ".tar.xz"))
872 (sha256
873 (base32
874 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
875 (patches (search-patches "glibc-ldd-x86_64.patch"
876 "glibc-vectorized-strcspn-guards.patch"
877 "glibc-CVE-2015-5180.patch"
878 "glibc-CVE-2015-7547.patch"
879 "glibc-CVE-2016-3075.patch"
880 "glibc-CVE-2016-3706.patch"
881 "glibc-CVE-2016-4429.patch"
882 "glibc-CVE-2017-1000366-pt1.patch"
883 "glibc-CVE-2017-1000366-pt2.patch"
884 "glibc-CVE-2017-1000366-pt3.patch"))))
885 (arguments
886 (substitute-keyword-arguments (package-arguments glibc)
887 ((#:phases phases)
888 `(modify-phases ,phases
889 (add-before 'configure 'fix-pwd
890 (lambda _
891 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
892 (substitute* "configure"
893 (("/bin/pwd") "pwd"))
894 #t))))))))
895
896 (define-public glibc-locales
897 (package
898 (inherit glibc)
899 (name "glibc-locales")
900 (source (origin (inherit (package-source glibc))
901 (patches (cons (search-patch "glibc-locales.patch")
902 (origin-patches (package-source glibc))))))
903 (synopsis "All the locales supported by the GNU C Library")
904 (description
905 "This package provides all the locales supported by the GNU C Library,
906 more than 400 in total. To use them set the 'LOCPATH' environment variable to
907 the 'share/locale' sub-directory of this package.")
908 (outputs '("out")) ;110+ MiB
909 (native-search-paths '())
910 (arguments
911 (let ((args `(#:tests? #f #:strip-binaries? #f
912 ,@(package-arguments glibc))))
913 (substitute-keyword-arguments args
914 ((#:phases phases)
915 `(alist-replace
916 'build
917 (lambda* (#:key outputs #:allow-other-keys)
918 (zero? (system* "make" "localedata/install-locales"
919 "-j" (number->string (parallel-job-count)))))
920 (alist-delete 'install ,phases)))
921 ((#:configure-flags flags)
922 `(append ,flags
923 ;; Use $(libdir)/locale/X.Y as is the case by default.
924 (list (string-append "libc_cv_complocaledir="
925 (assoc-ref %outputs "out")
926 "/lib/locale/"
927 ,(package-version glibc))))))))))
928
929 (define-public glibc-utf8-locales
930 (package
931 (name "glibc-utf8-locales")
932 (version (package-version glibc))
933 (source #f)
934 (build-system trivial-build-system)
935 (arguments
936 `(#:modules ((guix build utils))
937 #:builder (begin
938 (use-modules (srfi srfi-1)
939 (guix build utils))
940
941 (let* ((libc (assoc-ref %build-inputs "glibc"))
942 (gzip (assoc-ref %build-inputs "gzip"))
943 (out (assoc-ref %outputs "out"))
944 (localedir (string-append out "/lib/locale/"
945 ,version)))
946 ;; 'localedef' needs 'gzip'.
947 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
948
949 (mkdir-p localedir)
950 (every (lambda (locale)
951 (define file
952 ;; Use the "normalized codeset" by
953 ;; default--e.g., "en_US.utf8".
954 (string-append localedir "/" locale ".utf8"))
955
956 (and (zero? (system* "localedef" "--no-archive"
957 "--prefix" localedir
958 "-i" locale
959 "-f" "UTF-8" file))
960 (begin
961 ;; For backward compatibility with Guix
962 ;; <= 0.8.3, add "xx_YY.UTF-8".
963 (symlink (string-append locale ".utf8")
964 (string-append localedir "/"
965 locale ".UTF-8"))
966 #t)))
967
968 ;; These are the locales commonly used for
969 ;; tests---e.g., in Guile's i18n tests.
970 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))))))
971 (inputs `(("glibc" ,glibc)
972 ("gzip" ,gzip)))
973 (synopsis "Small sample of UTF-8 locales")
974 (description
975 "This package provides a small sample of UTF-8 locales mostly useful in
976 test environments.")
977 (home-page (package-home-page glibc))
978 (license (package-license glibc))))
979
980 (define-public which
981 (package
982 (name "which")
983 (version "2.21")
984 (source (origin
985 (method url-fetch)
986 (uri (string-append "mirror://gnu/which/which-"
987 version ".tar.gz"))
988 (sha256
989 (base32
990 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
991 (build-system gnu-build-system)
992 (home-page "https://gnu.org/software/which/")
993 (synopsis "Find full path of shell commands")
994 (description
995 "The which program finds the location of executables in PATH, with a
996 variety of options. It is an alternative to the shell \"type\" built-in
997 command.")
998 (license gpl3+))) ; some files are under GPLv2+
999
1000 (define-public glibc/hurd-headers
1001 (package (inherit glibc/hurd)
1002 (name "glibc-hurd-headers")
1003 (outputs '("out"))
1004 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1005 ("hurd-headers" ,hurd-headers)))
1006 (arguments
1007 (substitute-keyword-arguments (package-arguments glibc/hurd)
1008 ;; We just pass the flags really needed to build the headers.
1009 ((#:configure-flags _)
1010 `(list "--enable-add-ons"
1011 "--host=i586-pc-gnu"
1012 "--enable-obsolete-rpc"))
1013 ((#:phases _)
1014 '(alist-replace
1015 'install
1016 (lambda* (#:key outputs #:allow-other-keys)
1017 (and (zero? (system* "make" "install-headers"))
1018
1019 ;; Make an empty stubs.h to work around not being able to
1020 ;; produce a valid stubs.h and causing the build to fail. See
1021 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1022 (let ((out (assoc-ref outputs "out")))
1023 (close-port
1024 (open-output-file
1025 (string-append out "/include/gnu/stubs.h"))))))
1026
1027 ;; Nothing to build.
1028 (alist-delete
1029 'build
1030
1031 (alist-cons-before
1032 'configure 'pre-configure
1033 (lambda _
1034 ;; Use the right 'pwd'.
1035 (substitute* "configure"
1036 (("/bin/pwd") "pwd")))
1037 %standard-phases))))))))
1038
1039 (define-public tzdata
1040 (package
1041 (name "tzdata")
1042 (version "2017b")
1043 (source (origin
1044 (method url-fetch)
1045 (uri (string-append
1046 "https://www.iana.org/time-zones/repository/releases/tzdata"
1047 version ".tar.gz"))
1048 (sha256
1049 (base32
1050 "11l0s43vx33dcs78p80122i8s5s9l1sjwkzzwh66njd35r92l97q"))))
1051 (build-system gnu-build-system)
1052 (arguments
1053 '(#:tests? #f
1054 #:make-flags (let ((out (assoc-ref %outputs "out"))
1055 (tmp (getenv "TMPDIR")))
1056 (list (string-append "TOPDIR=" out)
1057 (string-append "TZDIR=" out "/share/zoneinfo")
1058
1059 ;; Discard zic, dump, and tzselect, already
1060 ;; provided by glibc.
1061 (string-append "ETCDIR=" tmp "/etc")
1062
1063 ;; Likewise for the C library routines.
1064 (string-append "LIBDIR=" tmp "/lib")
1065 (string-append "MANDIR=" tmp "/man")
1066
1067 "AWK=awk"
1068 "CC=gcc"))
1069 #:modules ((guix build utils)
1070 (guix build gnu-build-system)
1071 (srfi srfi-1))
1072 #:phases
1073 (modify-phases %standard-phases
1074 (replace 'unpack
1075 (lambda* (#:key source inputs #:allow-other-keys)
1076 (and (zero? (system* "tar" "xvf" source))
1077 (zero? (system* "tar" "xvf" (assoc-ref inputs "tzcode"))))))
1078 (add-after 'install 'post-install
1079 (lambda* (#:key outputs #:allow-other-keys)
1080 ;; Move data in the right place.
1081 (let ((out (assoc-ref outputs "out")))
1082 (symlink (string-append out "/share/zoneinfo")
1083 (string-append out "/share/zoneinfo/posix"))
1084 (delete-file-recursively
1085 (string-append out "/share/zoneinfo-posix"))
1086 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1087 (string-append out "/share/zoneinfo/right"))
1088 (delete-file-recursively
1089 (string-append out "/share/zoneinfo-leaps")))))
1090 (delete 'configure))))
1091 (inputs `(("tzcode" ,(origin
1092 (method url-fetch)
1093 (uri (string-append
1094 "http://www.iana.org/time-zones/repository/releases/tzcode"
1095 version ".tar.gz"))
1096 (sha256
1097 (base32
1098 "0h1d567gn8l3iqgyadcswwdy2yh07nhz3lfl8ds8saz2ajxka5sd"))))))
1099 (home-page "https://www.iana.org/time-zones")
1100 (synopsis "Database of current and historical time zones")
1101 (description "The Time Zone Database (often called tz or zoneinfo)
1102 contains code and data that represent the history of local time for many
1103 representative locations around the globe. It is updated periodically to
1104 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1105 and daylight-saving rules.")
1106 (license public-domain)))
1107
1108 ;;; A "fixed" version of tzdata, which is used in the test suites of
1109 ;;; glib and R. We can update this whenever we are able to rebuild
1110 ;;; thousands of packages (for example, in a core-updates rebuild).
1111 (define-public tzdata-2017a
1112 (package
1113 (inherit tzdata)
1114 (version "2017a")
1115 (source
1116 (origin
1117 (method url-fetch)
1118 (uri (string-append "https://www.iana.org/time-zones/repository"
1119 "/releases/tzdata" version ".tar.gz"))
1120 (sha256
1121 (base32
1122 "1mmv4rvcs12lrvgghw4fidczvb69yv69cmzknghcvw1c196mqfnz"))))
1123 (inputs `(("tzcode" ,(origin
1124 (method url-fetch)
1125 (uri (string-append
1126 "http://www.iana.org/time-zones/repository/releases/tzcode"
1127 version ".tar.gz"))
1128 (sha256
1129 (base32
1130 "1b1q7gnlsh5hjgs5065pvajd37rmbc3k9b8cgzad1vcrifswdwh2"))))))))
1131
1132
1133 (define-public libiconv
1134 (package
1135 (name "libiconv")
1136 (version "1.15")
1137 (source (origin
1138 (method url-fetch)
1139 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1140 version ".tar.gz"))
1141 (sha256
1142 (base32
1143 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1144 (modules '((guix build utils)))
1145 (snippet
1146 ;; Work around "declared gets" error on glibc systems (fixed by
1147 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1148 '(substitute* "srclib/stdio.in.h"
1149 (("^#undef gets") "")
1150 (("^_GL_WARN_ON_USE \\(gets.*") "")))))
1151 (build-system gnu-build-system)
1152 (synopsis "Character set conversion library")
1153 (description
1154 "libiconv provides an implementation of the iconv function for systems
1155 that lack it. iconv is used to convert between character encodings in a
1156 program. It supports a wide variety of different encodings.")
1157 (home-page "https://www.gnu.org/software/libiconv/")
1158 (license lgpl3+)))
1159
1160 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1161 "Return either a libiconv package specification to include in a dependency
1162 list for platforms that have an incomplete libc, or the empty list. If a
1163 package needs iconv ,@(libiconv-if-needed) should be added."
1164 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1165 ;; without iconv, such as MinGW, must return the then clause.
1166 (if (target-mingw? target)
1167 `(("libiconv" ,libiconv))
1168 '()))
1169
1170 (define-public (canonical-package package)
1171 ;; Avoid circular dependency by lazily resolving 'commencement'.
1172 (let* ((iface (resolve-interface '(gnu packages commencement)))
1173 (proc (module-ref iface 'canonical-package)))
1174 (proc package)))
1175
1176 (define-public (%final-inputs)
1177 "Return the list of \"final inputs\"."
1178 ;; Avoid circular dependency by lazily resolving 'commencement'.
1179 (let ((iface (resolve-interface '(gnu packages commencement))))
1180 (module-ref iface '%final-inputs)))
1181
1182 ;;; base.scm ends here