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