c66ea5a18767844e749fbbca9a6fc9d18f06be56
[jackhill/guix/guix.git] / gnu / packages / base.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2019 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
5 ;;; Copyright © 2014, 2015, 2016, 2018 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, 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
9 ;;; Copyright © 2016, 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
10 ;;; Copyright © 2016, 2018 Alex Vong <alexvong1995@gmail.com>
11 ;;; Copyright © 2017 Rene Saavedra <rennes@openmailbox.org>
12 ;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
13 ;;; Copyright © 2017, 2018, 2020 Marius Bakke <mbakke@fastmail.com>
14 ;;; Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
15 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
16 ;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
17 ;;; Copyright © 2020 Vitaliy Shatrov <D0dyBo0D0dyBo0@protonmail.com>
18 ;;;
19 ;;; This file is part of GNU Guix.
20 ;;;
21 ;;; GNU Guix is free software; you can redistribute it and/or modify it
22 ;;; under the terms of the GNU General Public License as published by
23 ;;; the Free Software Foundation; either version 3 of the License, or (at
24 ;;; your option) any later version.
25 ;;;
26 ;;; GNU Guix is distributed in the hope that it will be useful, but
27 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
28 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 ;;; GNU General Public License for more details.
30 ;;;
31 ;;; You should have received a copy of the GNU General Public License
32 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
33
34 (define-module (gnu packages base)
35 #:use-module ((guix licenses)
36 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
37 #:use-module (gnu packages)
38 #:use-module (gnu packages acl)
39 #:use-module (gnu packages algebra)
40 #:use-module (gnu packages bash)
41 #:use-module (gnu packages bison)
42 #:use-module (gnu packages ed)
43 #:use-module (gnu packages gcc)
44 #:use-module (gnu packages guile)
45 #:use-module (gnu packages multiprecision)
46 #:use-module (gnu packages compression)
47 #:use-module (gnu packages perl)
48 #:use-module (gnu packages linux)
49 #:use-module (gnu packages pcre)
50 #:use-module (gnu packages texinfo)
51 #:use-module (gnu packages hurd)
52 #:use-module (gnu packages pkg-config)
53 #:use-module (gnu packages python)
54 #:use-module (gnu packages gettext)
55 #:use-module (guix utils)
56 #:use-module (guix packages)
57 #:use-module (guix download)
58 #:use-module (guix git-download)
59 #:use-module (guix build-system gnu)
60 #:use-module (guix build-system trivial)
61 #:use-module (ice-9 match)
62 #:use-module (srfi srfi-1)
63 #:use-module (srfi srfi-26)
64 #:export (glibc
65 libiconv-if-needed))
66
67 ;;; Commentary:
68 ;;;
69 ;;; Base packages of the Guix-based GNU user-land software distribution.
70 ;;;
71 ;;; Code:
72
73 (define-public hello
74 (package
75 (name "hello")
76 (version "2.10")
77 (source (origin
78 (method url-fetch)
79 (uri (string-append "mirror://gnu/hello/hello-" version
80 ".tar.gz"))
81 (sha256
82 (base32
83 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
84 (build-system gnu-build-system)
85 (synopsis "Hello, GNU world: An example GNU package")
86 (description
87 "GNU Hello prints the message \"Hello, world!\" and then exits. It
88 serves as an example of standard GNU coding practices. As such, it supports
89 command-line arguments, multiple languages, and so on.")
90 (home-page "https://www.gnu.org/software/hello/")
91 (license gpl3+)))
92
93 (define-public grep
94 (package
95 (name "grep")
96 (version "3.4")
97 (source (origin
98 (method url-fetch)
99 (uri (string-append "mirror://gnu/grep/grep-"
100 version ".tar.xz"))
101 (sha256
102 (base32
103 "1yy33kiwrxrwj2nxa4fg15bvmwyghqbs8qwkdvy5phm784f7brjq"))
104 (patches (search-patches "grep-timing-sensitive-test.patch"))))
105 (build-system gnu-build-system)
106 (native-inputs `(("perl" ,perl))) ;some of the tests require it
107 (inputs `(("pcre" ,pcre)))
108 (arguments
109 `(#:phases
110 (modify-phases %standard-phases
111 (add-after 'install 'fix-egrep-and-fgrep
112 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
113 ;; absolute file name instead of searching for it in $PATH.
114 (lambda* (#:key outputs #:allow-other-keys)
115 (let* ((out (assoc-ref outputs "out"))
116 (bin (string-append out "/bin")))
117 (substitute* (list (string-append bin "/egrep")
118 (string-append bin "/fgrep"))
119 (("^exec grep")
120 (string-append "exec " bin "/grep")))
121 #t))))))
122 (synopsis "Print lines matching a pattern")
123 (description
124 "grep is a tool for finding text inside files. Text is found by
125 matching a pattern provided by the user in one or many files. The pattern
126 may be provided as a basic or extended regular expression, or as fixed
127 strings. By default, the matching text is simply printed to the screen,
128 however the output can be greatly customized to include, for example, line
129 numbers. GNU grep offers many extensions over the standard utility,
130 including, for example, recursive directory searching.")
131 (license gpl3+)
132 (home-page "https://www.gnu.org/software/grep/")))
133
134 (define-public sed
135 (package
136 (name "sed")
137 (version "4.8")
138 (source (origin
139 (method url-fetch)
140 (uri (string-append "mirror://gnu/sed/sed-" version
141 ".tar.gz"))
142 (sha256
143 (base32
144 "0alqagh0nliymz23kfjg6g9w3cr086k0sfni56gi8fhzqwa3xksk"))))
145 (build-system gnu-build-system)
146 (synopsis "Stream editor")
147 (native-inputs
148 `(("perl" ,perl))) ;for tests
149 (description
150 "Sed is a non-interactive, text stream editor. It receives a text
151 input from a file or from standard input and it then applies a series of text
152 editing commands to the stream and prints its output to standard output. It
153 is often used for substituting text patterns in a stream. The GNU
154 implementation offers several extensions over the standard utility.")
155 (license gpl3+)
156 (home-page "https://www.gnu.org/software/sed/")))
157
158 (define-public tar
159 (package
160 (name "tar")
161 (version "1.32")
162 (source (origin
163 (method url-fetch)
164 (uri (string-append "mirror://gnu/tar/tar-"
165 version ".tar.xz"))
166 (sha256
167 (base32
168 "1n7xy657ii0sa42zx6944v2m4v9qrh6sqgmw17l3nch3y43sxlyh"))
169 (patches (search-patches "tar-skip-unreliable-tests.patch"
170 "tar-remove-wholesparse-check.patch"))))
171 (build-system gnu-build-system)
172 ;; Note: test suite requires ~1GiB of disk space.
173 (arguments
174 `(,@(if (hurd-target?)
175 '(#:make-flags
176 (list (string-append
177 "TESTSUITEFLAGS= -k '"
178 "!sparse"
179 ",!renamed dirs in incrementals"
180 ",!--exclude-tag option in incremental pass"
181 ",!incremental dumps with -C"
182 ",!incremental dumps of nested directories"
183 ",!incremental restores with -C"
184 ",!concatenated incremental archives (renames)"
185 ",!renamed directory containing subdirectories"
186 ",!renamed subdirectories"
187 "'")))
188 '())
189 #:phases (modify-phases %standard-phases
190 (add-before 'build 'set-shell-file-name
191 (lambda* (#:key inputs #:allow-other-keys)
192 ;; Do not use "/bin/sh" to run programs.
193 (let ((bash (assoc-ref inputs "bash")))
194 (substitute* "src/system.c"
195 (("/bin/sh")
196 (string-append bash "/bin/sh")))
197 #t))))))
198
199 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
200 ;; to refer to the target Bash.
201 (inputs (if (%current-target-system)
202 `(("bash" ,bash))
203 '()))
204
205 (synopsis "Managing tar archives")
206 (description
207 "Tar provides the ability to create tar archives, as well as the
208 ability to extract, update or list files in an existing archive. It is
209 useful for combining many files into one larger file, while maintaining
210 directory structure and file information such as permissions and
211 creation/modification dates. GNU tar offers many extensions over the
212 standard utility.")
213 (license gpl3+)
214 (home-page "https://www.gnu.org/software/tar/")))
215
216 (define-public patch
217 (package
218 (name "patch")
219 (version "2.7.6")
220 (source (origin
221 (method url-fetch)
222 (uri (string-append "mirror://gnu/patch/patch-"
223 version ".tar.xz"))
224 (sha256
225 (base32
226 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
227 (patches (search-patches "patch-hurd-path-max.patch"))))
228 (build-system gnu-build-system)
229 (arguments
230 ;; Work around a cross-compilation bug whereby libpatch.a would provide
231 ;; '__mktime_internal', which conflicts with the one in libc.a.
232 (if (%current-target-system)
233 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
234 '()))
235 (native-inputs `(("ed" ,ed)))
236 (synopsis "Apply differences to originals, with optional backups")
237 (description
238 "Patch is a program that applies changes to files based on differences
239 laid out as by the program \"diff\". The changes may be applied to one or more
240 files depending on the contents of the diff file. It accepts several
241 different diff formats. It may also be used to revert previously applied
242 differences.")
243 (license gpl3+)
244 (home-page "https://savannah.gnu.org/projects/patch/")))
245
246 (define-public diffutils
247 (package
248 (name "diffutils")
249 (version "3.7")
250 (source (origin
251 (method url-fetch)
252 (uri (string-append "mirror://gnu/diffutils/diffutils-"
253 version ".tar.xz"))
254 (sha256
255 (base32
256 "09isrg0isjinv8c535nxsi1s86wfdfzml80dbw41dj9x3hiad9xk"))))
257 (build-system gnu-build-system)
258 (native-inputs `(("perl" ,perl)))
259 (synopsis "Comparing and merging files")
260 (description
261 "GNU Diffutils is a package containing tools for finding the
262 differences between files. The \"diff\" command is used to show how two files
263 differ, while \"cmp\" shows the offsets and line numbers where they differ.
264 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
265 interactive means to merge two files.")
266 (license gpl3+)
267 (home-page "https://www.gnu.org/software/diffutils/")))
268
269 (define-public findutils
270 (package
271 (name "findutils")
272 (version "4.7.0")
273 (source (origin
274 (method url-fetch)
275 (uri (string-append "mirror://gnu/findutils/findutils-"
276 version ".tar.xz"))
277 (sha256
278 (base32
279 "16kqz9yz98dasmj70jwf5py7jk558w96w0vgp3zf9xsqk3gzpzn5"))
280 (patches (search-patches "findutils-localstatedir.patch"
281 "findutils-test-rwlock-threads.patch"))))
282 (build-system gnu-build-system)
283 (arguments
284 `(#:configure-flags (list
285 ;; Tell 'updatedb' to write to /var.
286 "--localstatedir=/var")
287 #:phases (modify-phases %standard-phases
288 (add-before 'check 'adjust-test-shebangs
289 (lambda _
290 (substitute* '("tests/xargs/verbose-quote.sh"
291 "tests/find/exec-plus-last-file.sh")
292 (("#!/bin/sh")
293 (string-append "#!" (which "sh"))))
294 #t)))))
295 (synopsis "Operating on files matching given criteria")
296 (description
297 "Findutils supplies the basic file directory searching utilities of the
298 GNU system. It consists of two primary searching utilities: \"find\"
299 recursively searches for files in a directory according to given criteria and
300 \"locate\" lists files in a database that match a query. Two auxiliary tools
301 are included: \"updatedb\" updates the file name database and \"xargs\" may be
302 used to apply commands with arbitrarily long arguments.")
303 (license gpl3+)
304 (home-page "https://www.gnu.org/software/findutils/")))
305
306 (define-public coreutils
307 (package
308 (name "coreutils")
309 (version "8.32")
310 (source (origin
311 (method url-fetch)
312 (uri (string-append "mirror://gnu/coreutils/coreutils-"
313 version ".tar.xz"))
314 (sha256
315 (base32
316 "1yjcrh5hw70c0yn8zw55pd6j51dj90anpq8mmg649ps9g3gdhn24"))
317 (patches (search-patches "coreutils-ls.patch"))))
318 (build-system gnu-build-system)
319 (inputs `(("acl" ,acl) ; TODO: add SELinux
320 ("gmp" ,gmp) ;bignums in 'expr', yay!
321
322 ;; Do not use libcap when cross-compiling since it's not quite
323 ;; cross-compilable; and use it only for supported systems.
324 ,@(if (and (not (%current-target-system))
325 (member (%current-system)
326 (package-supported-systems libcap)))
327 `(("libcap" ,libcap)) ;capability support in 'ls', etc.
328 '())))
329 (native-inputs
330 ;; Perl is needed to run tests in native builds, and to run the bundled
331 ;; copy of help2man. However, don't pass it when cross-compiling since
332 ;; that would lead it to try to run programs to get their '--help' output
333 ;; for help2man.
334 (if (%current-target-system)
335 '()
336 `(("perl" ,perl))))
337 (outputs '("out" "debug"))
338 (arguments
339 `(#:parallel-build? #f ; help2man may be called too early
340 ,@(if (hurd-target?)
341 '(#:make-flags ; these tests fail deterministically
342 (list (string-append "XFAIL_TESTS=tests/misc/env-S.pl"
343 " tests/misc/kill.sh"
344 " tests/misc/nice.sh"
345 " tests/misc/shred-passes.sh"
346 " tests/split/fail.sh"
347 " tests/split/l-chunk.sh"
348 " tests/dd/stats.sh"
349 " test-fdutimensat"
350 " test-futimens"
351 " test-linkat"
352 " test-renameat"
353 " test-renameatu"
354 " test-tls"
355 " test-utimensat")))
356 '())
357 #:phases (modify-phases %standard-phases
358 (add-before 'build 'patch-shell-references
359 (lambda _
360 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
361 ;; that tests pass, since /bin/sh isn't in the chroot.
362 (setenv "SHELL" (which "sh"))
363
364 (substitute* (find-files "gnulib-tests" "\\.c$")
365 (("/bin/sh") (which "sh")))
366 (substitute* (find-files "tests" "\\.sh$")
367 (("#!/bin/sh") (string-append "#!" (which "sh"))))
368 #t)))))
369 (synopsis "Core GNU utilities (file, text, shell)")
370 (description
371 "GNU Coreutils package includes all of the basic command-line tools that
372 are expected in a POSIX system, excluding shell. This package is the union of
373 the GNU fileutils, sh-utils, and textutils packages. Most of these tools
374 offer extended functionality beyond that which is outlined in the POSIX
375 standard.")
376 (license gpl3+)
377 (home-page "https://www.gnu.org/software/coreutils/")))
378
379 (define-public coreutils-minimal
380 ;; Coreutils without its optional dependencies.
381 (package
382 (inherit coreutils)
383 (name "coreutils-minimal")
384 (outputs '("out"))
385 (inputs '())))
386
387 (define-public coreutils-8.30
388 ;; XXX: This version is kept just so we can run PRoot tests.
389 (hidden-package
390 (package
391 (inherit coreutils-minimal)
392 (version "8.30")
393 (source (origin
394 (method url-fetch)
395 (uri (string-append "mirror://gnu/coreutils/coreutils-"
396 version ".tar.xz"))
397 (sha256
398 (base32
399 "0mxhw43d4wpqmvg0l4znk1vm10fy92biyh90lzdnqjcic2lb6cg8"))))
400 (arguments
401 (substitute-keyword-arguments (package-arguments coreutils-minimal)
402 ((#:phases phases '%standard-phases)
403 `(modify-phases ,phases
404 (add-before 'check 'disable-broken-test
405 (lambda _
406 ;; This test hits the 127 character shebang limit in the build
407 ;; environment due to the way "env -S" splits arguments into
408 ;; shebangs. Note that "env-S-script.sh" works around this
409 ;; specific issue, but "env-S.pl" is not adjusted for build
410 ;; environments with long prefixes (/tmp/guix-build-...).
411 (substitute* "Makefile"
412 (("^.*tests/misc/env-S.pl.*$") ""))
413 #t)))))))))
414
415 (define-public gnu-make
416 (package
417 (name "make")
418 (version "4.3")
419 (source (origin
420 (method url-fetch)
421 (uri (string-append "mirror://gnu/make/make-" version
422 ".tar.gz"))
423 (sha256
424 (base32
425 "06cfqzpqsvdnsxbysl5p2fgdgxgl9y4p7scpnrfa8z2zgkjdspz0"))
426 (patches (search-patches "make-impure-dirs.patch"))))
427 (build-system gnu-build-system)
428 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
429 (inputs `(("guile" ,guile-3.0)))
430 (outputs '("out" "debug"))
431 (arguments
432 `(,@(if (hurd-target?)
433 '(#:configure-flags '("CFLAGS=-D__alloca=alloca"
434 "ac_cv_func_posix_spawn=no"))
435 '())
436 #:phases
437 (modify-phases %standard-phases
438 (add-before 'build 'set-default-shell
439 (lambda* (#:key inputs #:allow-other-keys)
440 ;; Change the default shell from /bin/sh.
441 (let ((bash (assoc-ref inputs "bash")))
442 (substitute* "src/job.c"
443 (("default_shell =.*$")
444 (format #f "default_shell = \"~a/bin/sh\";\n"
445 bash)))
446 #t))))))
447 (synopsis "Remake files automatically")
448 (description
449 "Make is a program that is used to control the production of
450 executables or other files from their source files. The process is
451 controlled from a Makefile, in which the developer specifies how each file is
452 generated from its source. It has powerful dependency resolution and the
453 ability to determine when files have to be regenerated after their sources
454 change. GNU make offers many powerful extensions over the standard utility.")
455 (license gpl3+)
456 (home-page "https://www.gnu.org/software/make/")))
457
458 (define-public gnu-make-4.2
459 (package
460 (inherit gnu-make)
461 (version "4.2.1")
462 (source (origin
463 (method url-fetch)
464 (uri (string-append "mirror://gnu/make/make-" version
465 ".tar.bz2"))
466 (sha256
467 (base32
468 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))))
469 (arguments
470 `(#:configure-flags '("CFLAGS=-D__alloca=alloca")
471 #:phases
472 (modify-phases %standard-phases
473 (add-before 'build 'set-default-shell
474 (lambda* (#:key inputs #:allow-other-keys)
475 ;; Change the default shell from /bin/sh.
476 (let ((bash (assoc-ref inputs "bash")))
477 (substitute* "job.c"
478 (("default_shell =.*$")
479 (format #f "default_shell = \"~a/bin/sh\";\n"
480 bash)))
481 #t))))))))
482
483 (define-public binutils
484 (package
485 (name "binutils")
486 (version "2.34")
487 (source (origin
488 (method url-fetch)
489 (uri (string-append "mirror://gnu/binutils/binutils-"
490 version ".tar.bz2"))
491 (sha256
492 (base32
493 "1rin1f5c7wm4n3piky6xilcrpf2s0n3dd5vqq8irrxkcic3i1w49"))
494 (patches (search-patches "binutils-loongson-workaround.patch"))))
495 (build-system gnu-build-system)
496
497 ;; TODO: Add dependency on zlib + those for Gold.
498 (arguments
499 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
500 ;; on GCC when bootstrapping.
501 "LDFLAGS=-static-libgcc"
502
503 ;; Turn on --enable-new-dtags by default to make the
504 ;; linker set RUNPATH instead of RPATH on binaries.
505 ;; This is important because RUNPATH can be overriden
506 ;; using LD_LIBRARY_PATH at runtime.
507 "--enable-new-dtags"
508
509 ;; Don't search under /usr/lib & co.
510 "--with-lib-path=/no-ld-lib-path"
511
512 ;; Install BFD. It ends up in a hidden directory,
513 ;; but it's here.
514 "--enable-install-libbfd"
515
516 ;; Make sure 'ar' and 'ranlib' produce archives in a
517 ;; deterministic fashion.
518 "--enable-deterministic-archives")
519
520 ;; XXX: binutils 2.34 was mistakenly released without generated manuals:
521 ;; <https://sourceware.org/bugzilla/show_bug.cgi?id=25491>. To avoid a
522 ;; circular dependency on texinfo, prevent the build system from creating
523 ;; the manuals by calling "true" instead of "makeinfo"...
524 #:make-flags '("MAKEINFO=true")))
525
526 ;; ...and "hide" this package so that users who install binutils get the
527 ;; version with documentation defined below.
528 (properties '((hidden? . #t)))
529
530 (synopsis "Binary utilities: bfd gas gprof ld")
531 (description
532 "GNU Binutils is a collection of tools for working with binary files.
533 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
534 Other tools include programs to display binary profiling information, list
535 the strings in a binary file, and utilities for working with archives. The
536 \"bfd\" library for working with executable and object formats is also
537 included.")
538 (license gpl3+)
539 (home-page "https://www.gnu.org/software/binutils/")))
540
541 ;; Work around a problem with binutils 2.34 whereby manuals are missing from
542 ;; the release tarball. Remove this and the related code above when updating.
543 (define-public binutils+documentation
544 (package/inherit
545 binutils
546 (native-inputs
547 `(("texinfo" ,texinfo)))
548 (arguments
549 (substitute-keyword-arguments (package-arguments binutils)
550 ((#:make-flags _ ''()) ''())))
551 (properties '())))
552
553 ;; FIXME: ath9k-firmware-htc-binutils.patch do not apply on 2.34 because of a
554 ;; big refactoring of xtensa-modules.c (commit 567607c11fbf7105 upstream).
555 ;; Keep this version around until the patch is updated.
556 (define-public binutils-2.33
557 (package/inherit
558 binutils
559 (version "2.33.1")
560 (source (origin
561 (inherit (package-source binutils))
562 (uri (string-append "mirror://gnu/binutils/binutils-"
563 version ".tar.bz2"))
564 (sha256
565 (base32
566 "1cmd0riv37bqy9mwbg6n3523qgr8b3bbm5kwj19sjrasl4yq9d0c"))))
567 (arguments
568 (substitute-keyword-arguments (package-arguments binutils)
569 ((#:make-flags _ ''()) ''())))
570 (properties '())))
571
572 (define-public binutils-gold
573 (package
574 (inherit binutils)
575 (name "binutils-gold")
576 (arguments
577 `(#:phases
578 (modify-phases %standard-phases
579 (add-after 'patch-source-shebangs 'patch-more-shebangs
580 (lambda _
581 (substitute* "gold/Makefile.in"
582 (("/bin/sh") (which "sh")))
583 #t)))
584 ,@(substitute-keyword-arguments (package-arguments binutils)
585 ; Upstream is aware of unrelocatable test failures on arm*.
586 ((#:tests? _ #f)
587 (if (any (cute string-prefix? <> (or (%current-target-system)
588 (%current-system)))
589 '("i686" "x86_64"))
590 '#t '#f))
591 ((#:configure-flags flags)
592 `(cons* "--enable-gold=default"
593 (delete "LDFLAGS=-static-libgcc" ,flags))))))
594 (native-inputs
595 `(("bc" ,bc)))
596 (inputs
597 `(("gcc:lib" ,gcc "lib")))))
598
599 (define* (make-ld-wrapper name #:key
600 (target (const #f))
601 binutils
602 (guile (canonical-package guile-3.0))
603 (bash (canonical-package bash))
604 (guile-for-build guile))
605 "Return a package called NAME that contains a wrapper for the 'ld' program
606 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
607 wrapper uses GUILE and BASH.
608
609 TARGET must be a one-argument procedure that, given a system type, returns a
610 cross-compilation target triplet or #f. When the result is not #f, make a
611 wrapper for the cross-linker for that target, called 'TARGET-ld'."
612 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
613 ;; its result can be delayed until the 'arguments' field is evaluated, thus
614 ;; in a context where '%current-system' is accurate.
615 (package
616 (name name)
617 (version "0")
618 (source #f)
619 (build-system trivial-build-system)
620 (inputs `(("binutils" ,binutils)
621 ("guile" ,guile)
622 ("bash" ,bash)
623 ("wrapper" ,(search-path %load-path
624 "gnu/packages/ld-wrapper.in"))))
625 (arguments
626 (let ((target (target (%current-system))))
627 `(#:guile ,guile-for-build
628 #:modules ((guix build utils))
629 #:builder (begin
630 (use-modules (guix build utils)
631 (system base compile))
632
633 (let* ((out (assoc-ref %outputs "out"))
634 (bin (string-append out "/bin"))
635 (ld ,(if target
636 `(string-append bin "/" ,target "-ld")
637 '(string-append bin "/ld")))
638 (go (string-append ld ".go")))
639
640 (setvbuf (current-output-port)
641 (cond-expand (guile-2.0 _IOLBF)
642 (else 'line)))
643 (format #t "building ~s/bin/ld wrapper in ~s~%"
644 (assoc-ref %build-inputs "binutils")
645 out)
646
647 (mkdir-p bin)
648 (copy-file (assoc-ref %build-inputs "wrapper") ld)
649 (substitute* ld
650 (("@SELF@")
651 ld)
652 (("@GUILE@")
653 (string-append (assoc-ref %build-inputs "guile")
654 "/bin/guile"))
655 (("@BASH@")
656 (string-append (assoc-ref %build-inputs "bash")
657 "/bin/bash"))
658 (("@LD@")
659 (string-append (assoc-ref %build-inputs "binutils")
660 ,(if target
661 (string-append "/bin/"
662 target "-ld")
663 "/bin/ld"))))
664 (chmod ld #o555)
665 (compile-file ld #:output-file go)
666 #t)))))
667 (synopsis "The linker wrapper")
668 (description
669 "The linker wrapper (or @code{ld-wrapper}) wraps the linker to add any
670 missing @code{-rpath} flags, and to detect any misuse of libraries outside of
671 the store.")
672 (home-page "https://www.gnu.org/software/guix//")
673 (license gpl3+)))
674
675 (export make-ld-wrapper)
676
677 (define-public glibc
678 ;; This is the GNU C Library, used on GNU/Linux and GNU/Hurd. Prior to
679 ;; version 2.28, GNU/Hurd used a different glibc branch.
680 (package
681 (name "glibc")
682 (version "2.31")
683 (source (origin
684 (method url-fetch)
685 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
686 (sha256
687 (base32
688 "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
689 (snippet
690 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
691 ;; required on LFS distros to avoid loading the distro's libc.so
692 ;; instead of ours.
693 '(begin
694 (substitute* "sysdeps/unix/sysv/linux/configure"
695 (("use_ldconfig=yes")
696 "use_ldconfig=no"))
697 #t))
698 (modules '((guix build utils)))
699 (patches (search-patches "glibc-ldd-x86_64.patch"
700 "glibc-hidden-visibility-ldconfig.patch"
701 "glibc-versioned-locpath.patch"
702 "glibc-allow-kernel-2.6.32.patch"
703 "glibc-reinstate-prlimit64-fallback.patch"
704 "glibc-supported-locales.patch"
705 "glibc-hurd-clock_t_centiseconds.patch"
706 "glibc-hurd-clock_gettime_monotonic.patch"
707 "glibc-hurd-signal-sa-siginfo.patch"))))
708 (build-system gnu-build-system)
709
710 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
711 ;; users should automatically pull Linux headers as well. On GNU/Hurd,
712 ;; libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
713 ;; so both should be propagated.
714 (propagated-inputs
715 (if (hurd-target?)
716 `(("hurd-core-headers" ,hurd-core-headers))
717 `(("kernel-headers" ,linux-libre-headers))))
718
719 (outputs '("out" "debug"
720 "static")) ;9 MiB of .a files
721
722 (arguments
723 `(#:out-of-source? #t
724
725 ;; The libraries have an empty RUNPATH, but some, such as the versioned
726 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
727 ;; these libraries are always going to be found anyway, just skip
728 ;; RUNPATH checks.
729 #:validate-runpath? #f
730
731 #:modules ((ice-9 ftw)
732 (srfi srfi-26)
733 (guix build utils)
734 (guix build gnu-build-system))
735
736 #:configure-flags
737 (list "--sysconfdir=/etc"
738
739 ;; Installing a locale archive with all the locales is to
740 ;; expensive (~100 MiB), so we rely on users to install the
741 ;; locales they really want.
742 ;;
743 ;; Set the default locale path. In practice, $LOCPATH may be
744 ;; defined to point whatever locales users want. However, setuid
745 ;; binaries don't honor $LOCPATH, so they'll instead look into
746 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
747 ;; with the idea that it is going to be populated by the sysadmin.
748 ;; The "X.Y" sub-directory is because locale data formats are
749 ;; incompatible across libc versions; see
750 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
751 ;;
752 ;; `--localedir' is not honored, so work around it.
753 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
754 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
755 ,(version-major+minor version))
756
757 (string-append "--with-headers="
758 (assoc-ref ,(if (%current-target-system)
759 '%build-target-inputs
760 '%build-inputs)
761 "kernel-headers")
762 "/include")
763
764 ;; This is the default for most architectures as of GNU libc 2.26,
765 ;; but we specify it explicitly for clarity and consistency. See
766 ;; "kernel-features.h" in the GNU libc for details.
767 "--enable-kernel=3.2.0"
768
769 ;; Use our Bash instead of /bin/sh.
770 (string-append "BASH_SHELL="
771 (assoc-ref %build-inputs "bash")
772 "/bin/bash")
773
774 ;; On GNU/Hurd we get discarded-qualifiers warnings for
775 ;; 'device_write_inband' among other things. Ignore them.
776 ,@(if (hurd-target?)
777 '("--disable-werror")
778 '()))
779
780 #:tests? #f ; XXX
781 #:phases (modify-phases %standard-phases
782 (add-before
783 'configure 'pre-configure
784 (lambda* (#:key inputs native-inputs outputs
785 #:allow-other-keys)
786 (let* ((out (assoc-ref outputs "out"))
787 (bin (string-append out "/bin"))
788 ;; FIXME: Normally we would look it up only in INPUTS
789 ;; but cross-base uses it as a native input.
790 (bash (or (assoc-ref inputs "static-bash")
791 (assoc-ref native-inputs "static-bash"))))
792 ;; Install the rpc data base file under `$out/etc/rpc'.
793 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
794 (substitute* "sunrpc/Makefile"
795 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
796 (string-append out "/etc/rpc" suffix "\n"))
797 (("^install-others =.*$")
798 (string-append "install-others = " out "/etc/rpc\n")))
799
800 (substitute* "Makeconfig"
801 ;; According to
802 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
803 ;; linking against libgcc_s is not needed with GCC
804 ;; 4.7.1.
805 ((" -lgcc_s") ""))
806
807 ;; Have `system' use that Bash.
808 (substitute* "sysdeps/posix/system.c"
809 (("#define[[:blank:]]+SHELL_PATH.*$")
810 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
811 bash)))
812
813 ;; Same for `popen'.
814 (substitute* "libio/iopopen.c"
815 (("/bin/sh")
816 (string-append bash "/bin/sh")))
817
818 ;; Same for the shell used by the 'exec' functions for
819 ;; scripts that lack a shebang.
820 (substitute* (find-files "." "^paths\\.h$")
821 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
822 (string-append "#define _PATH_BSHELL \""
823 bash "/bin/sh\"\n")))
824
825 ;; Nscd uses __DATE__ and __TIME__ to create a string to
826 ;; make sure the client and server come from the same
827 ;; libc. Use something deterministic instead.
828 (substitute* "nscd/nscd_stat.c"
829 (("static const char compilation\\[21\\] =.*$")
830 (string-append
831 "static const char compilation[21] = \""
832 (string-take (basename out) 20) "\";\n")))
833
834 ;; Make sure we don't retain a reference to the
835 ;; bootstrap Perl.
836 (substitute* "malloc/mtrace.pl"
837 (("^#!.*")
838 ;; The shebang can be omitted, because there's the
839 ;; "bilingual" eval/exec magic at the top of the file.
840 "")
841 (("exec @PERL@")
842 "exec perl"))
843
844 #t)))
845
846 (add-after 'install 'move-static-libs
847 (lambda* (#:key outputs #:allow-other-keys)
848 ;; Move static libraries to the "static" output.
849 (define (static-library? file)
850 ;; Return true if FILE is a static library. The
851 ;; "_nonshared.a" files are referred to by libc.so,
852 ;; libpthread.so, etc., which are in fact linker
853 ;; scripts.
854 (and (string-suffix? ".a" file)
855 (not (string-contains file "_nonshared"))))
856
857 (define (linker-script? file)
858 ;; Guess whether FILE, a ".a" file, is actually a
859 ;; linker script.
860 (and (not (ar-file? file))
861 (not (elf-file? file))))
862
863 (let* ((out (assoc-ref outputs "out"))
864 (lib (string-append out "/lib"))
865 (files (scandir lib static-library?))
866 (static (assoc-ref outputs "static"))
867 (slib (string-append static "/lib")))
868 (mkdir-p slib)
869 (for-each (lambda (base)
870 (rename-file (string-append lib "/" base)
871 (string-append slib "/" base)))
872 files)
873
874 ;; Usually libm.a is a linker script so we need to
875 ;; change the file names in there to refer to STATIC
876 ;; instead of OUT.
877 (for-each (lambda (ld-script)
878 (substitute* ld-script
879 ((out) static)))
880 (filter linker-script?
881 (map (cut string-append slib "/" <>)
882 files)))
883 #t)))
884
885 ,@(if (hurd-target?)
886 '((add-after 'install 'augment-libc.so
887 (lambda* (#:key outputs #:allow-other-keys)
888 (let* ((out (assoc-ref outputs "out")))
889 (substitute* (string-append out "/lib/libc.so")
890 (("/[^ ]+/lib/libc.so.0.3")
891 (string-append out "/lib/libc.so.0.3"
892 " libmachuser.so libhurduser.so"))))
893 #t)))
894 '()))))
895
896 (inputs `(("static-bash" ,static-bash)))
897
898 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
899 ;; install the message catalogs, with 'msgfmt'.
900 (native-inputs `(("texinfo" ,texinfo)
901 ("perl" ,perl)
902 ("bison" ,bison)
903 ("gettext" ,gettext-minimal)
904 ("python" ,python-minimal)
905
906 ,@(if (hurd-target?)
907 `(("mig" ,mig)
908 ("perl" ,perl))
909 '())))
910
911 (native-search-paths
912 ;; Search path for packages that provide locale data. This is useful
913 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
914 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
915 ;; distros.
916 (list (search-path-specification
917 (variable "GUIX_LOCPATH")
918 (files '("lib/locale")))))
919
920 (synopsis "The GNU C Library")
921 (description
922 "Any Unix-like operating system needs a C library: the library which
923 defines the \"system calls\" and other basic facilities such as open, malloc,
924 printf, exit...
925
926 The GNU C library is used as the C library in the GNU system and most systems
927 with the Linux kernel.")
928 (license lgpl2.0+)
929 (home-page "https://www.gnu.org/software/libc/")))
930
931 ;; Below are old libc versions, which we use mostly to build locale data in
932 ;; the old format (which the new libc cannot cope with.)
933
934 (define-public glibc-2.30
935 (package
936 (inherit glibc)
937 (version "2.30")
938 (source (origin
939 (inherit (package-source glibc))
940 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
941 (sha256
942 (base32
943 "1bxqpg91d02qnaz837a5kamm0f43pr1il4r9pknygywsar713i72"))
944 (patches (search-patches "glibc-ldd-x86_64.patch"
945 "glibc-CVE-2019-19126.patch"
946 "glibc-hidden-visibility-ldconfig.patch"
947 "glibc-versioned-locpath.patch"
948 "glibc-allow-kernel-2.6.32.patch"
949 "glibc-reinstate-prlimit64-fallback.patch"
950 "glibc-2.29-supported-locales.patch"))))))
951
952 (define-public glibc-2.29
953 (package
954 (inherit glibc)
955 (version "2.29")
956 (source (origin
957 (inherit (package-source glibc))
958 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
959 (sha256
960 (base32
961 "0jzh58728flfh939a8k9pi1zdyalfzlxmwra7k0rzji5gvavivpk"))
962 (patches (search-patches "glibc-ldd-x86_64.patch"
963 "glibc-CVE-2019-7309.patch"
964 "glibc-CVE-2019-9169.patch"
965 "glibc-2.29-git-updates.patch"
966 "glibc-hidden-visibility-ldconfig.patch"
967 "glibc-versioned-locpath.patch"
968 "glibc-allow-kernel-2.6.32.patch"
969 "glibc-reinstate-prlimit64-fallback.patch"
970 "glibc-2.29-supported-locales.patch"))))))
971
972 (define-public glibc-2.28
973 (package
974 (inherit glibc)
975 (version "2.28")
976 (source (origin
977 (inherit (package-source glibc))
978 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
979 (sha256
980 (base32
981 "10iha5ynvdj5m62vgpgqbq4cwvc2yhyl2w9yyyjgfxmdmx8h145i"))
982 (patches (search-patches "glibc-ldd-x86_64.patch"
983 "glibc-2.28-git-fixes.patch"
984 "glibc-hidden-visibility-ldconfig.patch"
985 "glibc-versioned-locpath.patch"
986 "glibc-allow-kernel-2.6.32.patch"
987 "glibc-reinstate-prlimit64-fallback.patch"
988 "glibc-hurd-magic-pid.patch"
989 "glibc-2.28-supported-locales.patch"))))))
990
991 (define-public glibc-2.27
992 (package
993 (inherit glibc)
994 (version "2.27")
995 (source (origin
996 (inherit (package-source glibc))
997 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
998 (sha256
999 (base32
1000 "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"))
1001 (patches (search-patches "glibc-ldd-x86_64.patch"
1002 "glibc-2.27-git-fixes.patch"
1003 "glibc-hidden-visibility-ldconfig.patch"
1004 "glibc-versioned-locpath.patch"
1005 "glibc-allow-kernel-2.6.32.patch"
1006 "glibc-reinstate-prlimit64-fallback.patch"
1007 "glibc-2.27-supported-locales.patch"
1008 "glibc-CVE-2018-11236.patch"
1009 "glibc-CVE-2018-11237.patch"))))
1010 (properties `((lint-hidden-cve . ("CVE-2017-18269")))))) ; glibc-2.27-git-fixes
1011
1012 (define-public glibc-2.26
1013 (package
1014 (inherit glibc)
1015 ;; This version number corresponds to the output of `git describe` and the
1016 ;; archive can be generated by checking out the commit ID and running:
1017 ;; git archive --prefix=$(git describe)/ HEAD | xz > $(git describe).tar.xz
1018 ;; See <https://bugs.gnu.org/29406> for why this was necessary.
1019 (version "2.26.105-g0890d5379c")
1020 (source (origin
1021 (inherit (package-source glibc))
1022 (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/"
1023 "glibc-" (version-major+minor version) "-"
1024 (caddr (string-split version #\.)) ".tar.xz"))
1025 (sha256
1026 (base32
1027 "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
1028 (patches (search-patches "glibc-ldd-x86_64.patch"
1029 "glibc-versioned-locpath.patch"
1030 "glibc-allow-kernel-2.6.32.patch"))))))
1031
1032 (define-public glibc-2.25
1033 (package
1034 (inherit glibc)
1035 (version "2.25")
1036 (source (origin
1037 (inherit (package-source glibc))
1038 (uri (string-append "mirror://gnu/glibc/glibc-"
1039 version ".tar.xz"))
1040 (sha256
1041 (base32
1042 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
1043 (patches (search-patches "glibc-ldd-x86_64.patch"
1044 "glibc-versioned-locpath.patch"
1045 "glibc-vectorized-strcspn-guards.patch"
1046 "glibc-CVE-2017-1000366-pt1.patch"
1047 "glibc-CVE-2017-1000366-pt2.patch"
1048 "glibc-CVE-2017-1000366-pt3.patch"))))))
1049
1050 (define-public glibc-2.24
1051 (package
1052 (inherit glibc)
1053 (version "2.24")
1054 (source (origin
1055 (inherit (package-source glibc))
1056 (uri (string-append "mirror://gnu/glibc/glibc-"
1057 version ".tar.xz"))
1058 (sha256
1059 (base32
1060 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
1061 (patches (search-patches "glibc-ldd-x86_64.patch"
1062 "glibc-versioned-locpath.patch"
1063 "glibc-vectorized-strcspn-guards.patch"
1064 "glibc-CVE-2015-5180.patch"
1065 "glibc-CVE-2017-1000366-pt1.patch"
1066 "glibc-CVE-2017-1000366-pt2.patch"
1067 "glibc-CVE-2017-1000366-pt3.patch"))))))
1068
1069 (define-public glibc-2.23
1070 (package
1071 (inherit glibc)
1072 (version "2.23")
1073 (source (origin
1074 (inherit (package-source glibc))
1075 (uri (string-append "mirror://gnu/glibc/glibc-"
1076 version ".tar.xz"))
1077 (sha256
1078 (base32
1079 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
1080 (patches (search-patches "glibc-ldd-x86_64.patch"
1081 "glibc-versioned-locpath.patch"
1082 "glibc-vectorized-strcspn-guards.patch"
1083 "glibc-CVE-2015-5180.patch"
1084 "glibc-CVE-2016-3075.patch"
1085 "glibc-CVE-2016-3706.patch"
1086 "glibc-CVE-2016-4429.patch"
1087 "glibc-CVE-2017-1000366-pt1.patch"
1088 "glibc-CVE-2017-1000366-pt2.patch"
1089 "glibc-CVE-2017-1000366-pt3.patch"))))))
1090
1091 (define-public glibc-2.22
1092 (package
1093 (inherit glibc)
1094 (version "2.22")
1095 (source (origin
1096 (inherit (package-source glibc))
1097 (uri (string-append "mirror://gnu/glibc/glibc-"
1098 version ".tar.xz"))
1099 (sha256
1100 (base32
1101 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
1102 (patches (search-patches "glibc-ldd-x86_64.patch"
1103 "glibc-o-largefile.patch"
1104 "glibc-vectorized-strcspn-guards.patch"
1105 "glibc-CVE-2015-5180.patch"
1106 "glibc-CVE-2015-7547.patch"
1107 "glibc-CVE-2016-3075.patch"
1108 "glibc-CVE-2016-3706.patch"
1109 "glibc-CVE-2016-4429.patch"
1110 "glibc-CVE-2017-1000366-pt1.patch"
1111 "glibc-CVE-2017-1000366-pt2.patch"
1112 "glibc-CVE-2017-1000366-pt3.patch"))))
1113 (arguments
1114 (substitute-keyword-arguments (package-arguments glibc)
1115 ((#:phases phases)
1116 `(modify-phases ,phases
1117 (add-before 'configure 'fix-pwd
1118 (lambda _
1119 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
1120 (substitute* "configure"
1121 (("/bin/pwd") "pwd"))
1122 #t))))))))
1123
1124 (define-public (make-gcc-libc base-gcc libc)
1125 "Return a GCC that targets LIBC."
1126 (package (inherit base-gcc)
1127 (name (string-append (package-name base-gcc) "-"
1128 (package-name libc) "-"
1129 (package-version libc)))
1130 (arguments
1131 (ensure-keyword-arguments (package-arguments base-gcc)
1132 '(#:implicit-inputs? #f)))
1133 (native-inputs
1134 `(,@(package-native-inputs base-gcc)
1135 ,@(append (fold alist-delete (%final-inputs) '("libc" "libc:static")))
1136 ("libc" ,libc)
1137 ("libc:static" ,libc "static")))))
1138
1139 (define-public (make-glibc-locales glibc)
1140 (package
1141 (inherit glibc)
1142 (name "glibc-locales")
1143 (source (origin (inherit (package-source glibc))
1144 ;; The patch for glibc 2.28 and earlier replaces the same
1145 ;; content, but the context in the patch is different
1146 ;; enough to fail to merge.
1147 (patches (cons (search-patch
1148 (if (version>=? (package-version glibc)
1149 "2.29")
1150 "glibc-locales.patch"
1151 "glibc-locales-2.28.patch"))
1152 (origin-patches (package-source glibc))))))
1153 (synopsis "All the locales supported by the GNU C Library")
1154 (description
1155 "This package provides all the locales supported by the GNU C Library,
1156 more than 400 in total. To use them set the @code{LOCPATH} environment variable
1157 to the @code{share/locale} sub-directory of this package.")
1158 (outputs '("out")) ;110+ MiB
1159 (native-search-paths '())
1160 (arguments
1161 (let ((args `(#:tests? #f #:strip-binaries? #f
1162 ,@(package-arguments glibc))))
1163 (substitute-keyword-arguments args
1164 ((#:modules modules '((guix build utils)
1165 (guix build gnu-build-system)))
1166 `((srfi srfi-11)
1167 (gnu build locale)
1168 ,@modules))
1169 ((#:imported-modules modules '())
1170 `((gnu build locale)
1171 ,@%gnu-build-system-modules))
1172 ((#:phases phases)
1173 `(modify-phases ,phases
1174 (replace 'build
1175 (lambda _
1176 (invoke "make" "localedata/install-locales"
1177 "-j" (number->string (parallel-job-count)))))
1178 (add-after 'build 'symlink-normalized-codesets
1179 (lambda* (#:key outputs #:allow-other-keys)
1180 ;; The above phase does not install locales with names using
1181 ;; the "normalized codeset." Thus, create symlinks like:
1182 ;; en_US.utf8 -> en_US.UTF-8
1183 (define (locale-directory? file stat)
1184 (and (file-is-directory? file)
1185 (string-index (basename file) #\_)
1186 (string-rindex (basename file) #\.)))
1187
1188 (let* ((out (assoc-ref outputs "out"))
1189 (locales (find-files out locale-directory?
1190 #:directories? #t)))
1191 (for-each (lambda (directory)
1192 (let*-values (((base)
1193 (basename directory))
1194 ((name codeset)
1195 (locale->name+codeset base))
1196 ((normalized)
1197 (normalize-codeset codeset)))
1198 (unless (string=? codeset normalized)
1199 (symlink base
1200 (string-append (dirname directory)
1201 "/" name "."
1202 normalized)))))
1203 locales)
1204 #t)))
1205 (delete 'install)
1206 (delete 'move-static-libs)))
1207 ((#:configure-flags flags)
1208 `(append ,flags
1209 ;; Use $(libdir)/locale/X.Y as is the case by default.
1210 (list (string-append "libc_cv_complocaledir="
1211 (assoc-ref %outputs "out")
1212 "/lib/locale/"
1213 ,(version-major+minor
1214 (package-version glibc)))))))))))
1215
1216 (define-public (make-glibc-utf8-locales glibc)
1217 (package
1218 (name "glibc-utf8-locales")
1219 (version (package-version glibc))
1220 (source #f)
1221 (build-system trivial-build-system)
1222 (arguments
1223 `(#:modules ((guix build utils))
1224 #:builder (begin
1225 (use-modules (guix build utils))
1226
1227 (let* ((libc (assoc-ref %build-inputs "glibc"))
1228 (gzip (assoc-ref %build-inputs "gzip"))
1229 (out (assoc-ref %outputs "out"))
1230 (localedir (string-append out "/lib/locale/"
1231 ,(version-major+minor version))))
1232 ;; 'localedef' needs 'gzip'.
1233 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1234
1235 (mkdir-p localedir)
1236 (for-each (lambda (locale)
1237 (define file
1238 ;; Use the "normalized codeset" by
1239 ;; default--e.g., "en_US.utf8".
1240 (string-append localedir "/" locale ".utf8"))
1241
1242 (invoke "localedef" "--no-archive"
1243 "--prefix" localedir
1244 "-i" locale
1245 "-f" "UTF-8" file)
1246
1247 ;; For backward compatibility with Guix
1248 ;; <= 0.8.3, add "xx_YY.UTF-8".
1249 (symlink (string-append locale ".utf8")
1250 (string-append localedir "/"
1251 locale ".UTF-8")))
1252
1253 ;; These are the locales commonly used for
1254 ;; tests---e.g., in Guile's i18n tests.
1255 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
1256 #t))))
1257 (native-inputs `(("glibc" ,glibc)
1258 ("gzip" ,gzip)))
1259 (synopsis "Small sample of UTF-8 locales")
1260 (description
1261 "This package provides a small sample of UTF-8 locales mostly useful in
1262 test environments.")
1263 (home-page (package-home-page glibc))
1264 (license (package-license glibc))))
1265
1266 (define-public glibc-locales
1267 (make-glibc-locales glibc))
1268 (define-public glibc-utf8-locales
1269 (make-glibc-utf8-locales glibc))
1270
1271 ;; Packages provided to ease use of binaries linked against the previous libc.
1272 (define-public glibc-locales-2.29
1273 (package (inherit (make-glibc-locales glibc-2.29))
1274 (name "glibc-locales-2.29")))
1275 (define-public glibc-utf8-locales-2.29
1276 (package (inherit (make-glibc-utf8-locales glibc-2.29))
1277 (name "glibc-utf8-locales-2.29")))
1278
1279 (define-public which
1280 (package
1281 (name "which")
1282 (version "2.21")
1283 (source (origin
1284 (method url-fetch)
1285 (uri (string-append "mirror://gnu/which/which-"
1286 version ".tar.gz"))
1287 (sha256
1288 (base32
1289 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1290 (build-system gnu-build-system)
1291 (home-page "https://gnu.org/software/which/")
1292 (synopsis "Find full path of shell commands")
1293 (description
1294 "The which program finds the location of executables in PATH, with a
1295 variety of options. It is an alternative to the shell \"type\" built-in
1296 command.")
1297 (license gpl3+))) ; some files are under GPLv2+
1298
1299 (define-public glibc/hurd-headers
1300 (package (inherit glibc)
1301 (name "glibc-hurd-headers")
1302 (outputs '("out"))
1303 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1304 ("hurd-headers" ,hurd-headers)))
1305 (native-inputs
1306 `(("mig" ,(if (%current-target-system)
1307 ;; XXX: When targeting i586-pc-gnu, we need a 32-bit MiG,
1308 ;; hence this hack.
1309 (package
1310 (inherit mig)
1311 (arguments `(#:system "i686-linux")))
1312 mig))
1313 ,@(package-native-inputs glibc)))
1314 (arguments
1315 (substitute-keyword-arguments (package-arguments glibc)
1316 ;; We just pass the flags really needed to build the headers.
1317 ((#:configure-flags _)
1318 `(list "--enable-add-ons"
1319 "--host=i586-pc-gnu"))
1320 ((#:phases _)
1321 '(modify-phases %standard-phases
1322 (replace 'install
1323 (lambda* (#:key outputs #:allow-other-keys)
1324 (invoke "make" "install-headers")
1325
1326 ;; Make an empty stubs.h to work around not being able to
1327 ;; produce a valid stubs.h and causing the build to fail. See
1328 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1329 (let ((out (assoc-ref outputs "out")))
1330 (close-port
1331 (open-output-file
1332 (string-append out "/include/gnu/stubs.h"))))
1333 #t))
1334 (delete 'build))))))) ; nothing to build
1335
1336 (define-public tzdata
1337 (package
1338 (name "tzdata")
1339 (version "2020a")
1340 (source (origin
1341 (method url-fetch)
1342 (uri (string-append
1343 "https://data.iana.org/time-zones/releases/tzdata"
1344 version ".tar.gz"))
1345 (sha256
1346 (base32
1347 "18lrp0zh8m931jjlrv8lvjas4ka5dfkzdbwnbw5lwd2dlbn62wal"))))
1348 (build-system gnu-build-system)
1349 (arguments
1350 '(#:tests? #f
1351 #:make-flags (let ((out (assoc-ref %outputs "out"))
1352 (tmp (getenv "TMPDIR")))
1353 (list (string-append "TOPDIR=" out)
1354 (string-append "TZDIR=" out "/share/zoneinfo")
1355 (string-append "TZDEFAULT=" out
1356 "/share/zoneinfo/localtime")
1357
1358 ;; Likewise for the C library routines.
1359 (string-append "LIBDIR=" tmp "/lib")
1360 (string-append "MANDIR=" tmp "/man")
1361
1362 "AWK=awk"
1363 "CC=gcc"))
1364 #:modules ((guix build utils)
1365 (guix build gnu-build-system)
1366 (srfi srfi-1))
1367 #:phases
1368 (modify-phases %standard-phases
1369 (replace 'unpack
1370 (lambda* (#:key source inputs #:allow-other-keys)
1371 (invoke "tar" "xvf" source)
1372 (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
1373 (add-after 'install 'post-install
1374 (lambda* (#:key outputs #:allow-other-keys)
1375 ;; Move data in the right place.
1376 (let ((out (assoc-ref outputs "out")))
1377 ;; Discard zic, dump, and tzselect, already
1378 ;; provided by glibc.
1379 (delete-file-recursively (string-append out "/usr"))
1380 (symlink (string-append out "/share/zoneinfo")
1381 (string-append out "/share/zoneinfo/posix"))
1382 (delete-file-recursively
1383 (string-append out "/share/zoneinfo-posix"))
1384 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1385 (string-append out "/share/zoneinfo/right"))
1386 (delete-file-recursively
1387 (string-append out "/share/zoneinfo-leaps"))
1388 #t)))
1389 (delete 'configure))))
1390 (inputs `(("tzcode" ,(origin
1391 (method url-fetch)
1392 (uri (string-append
1393 "https://data.iana.org/time-zones/releases/tzcode"
1394 version ".tar.gz"))
1395 (sha256
1396 (base32
1397 "0sfnlqw1p93r7klny69rwr94fh22mz632h52phgzfgg01q9gfakx"))))))
1398 (home-page "https://www.iana.org/time-zones")
1399 (synopsis "Database of current and historical time zones")
1400 (description "The Time Zone Database (often called tz or zoneinfo)
1401 contains code and data that represent the history of local time for many
1402 representative locations around the globe. It is updated periodically to
1403 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1404 and daylight-saving rules.")
1405 (license public-domain)))
1406
1407 ;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1408 ;;; and a few other places. We can update this whenever we are able to rebuild
1409 ;;; thousands of packages (for example, in a core-updates rebuild). This package
1410 ;;; will typically be obsolete and should never be referred to by a built
1411 ;;; package.
1412 (define-public tzdata-for-tests
1413 (hidden-package
1414 (package
1415 (inherit tzdata)
1416 (version "2019c")
1417 (source (origin
1418 (method url-fetch)
1419 (uri (string-append
1420 "https://data.iana.org/time-zones/releases/tzdata"
1421 version ".tar.gz"))
1422 (sha256
1423 (base32
1424 "0z7w1yv37cfk8yhix2cillam091vgp1j4g8fv84261q9mdnq1ivr"))))
1425 (inputs
1426 `(("tzcode" ,(origin
1427 (method url-fetch)
1428 (uri (string-append
1429 "https://data.iana.org/time-zones/releases/tzcode"
1430 version ".tar.gz"))
1431 (sha256
1432 (base32
1433 "1m3y2rnf1nggxxhxplab5zdd5whvar3ijyrv7lifvm82irkd7szn")))))))))
1434
1435 (define-public libiconv
1436 (package
1437 (name "libiconv")
1438 (version "1.15")
1439 (source (origin
1440 (method url-fetch)
1441 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1442 version ".tar.gz"))
1443 (sha256
1444 (base32
1445 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1446 (modules '((guix build utils)))
1447 (snippet
1448 ;; Work around "declared gets" error on glibc systems (fixed by
1449 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1450 '(begin
1451 (substitute* "srclib/stdio.in.h"
1452 (("^#undef gets") "")
1453 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1454 #t))))
1455 (build-system gnu-build-system)
1456 (synopsis "Character set conversion library")
1457 (description
1458 "libiconv provides an implementation of the iconv function for systems
1459 that lack it. iconv is used to convert between character encodings in a
1460 program. It supports a wide variety of different encodings.")
1461 (home-page "https://www.gnu.org/software/libiconv/")
1462 (license lgpl3+)))
1463
1464 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1465 "Return either a libiconv package specification to include in a dependency
1466 list for platforms that have an incomplete libc, or the empty list. If a
1467 package needs iconv ,@(libiconv-if-needed) should be added."
1468 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1469 ;; without iconv, such as MinGW, must return the then clause.
1470 (if (target-mingw? target)
1471 `(("libiconv" ,libiconv))
1472 '()))
1473
1474 (define-public (canonical-package package)
1475 ;; Avoid circular dependency by lazily resolving 'commencement'.
1476 (let* ((iface (resolve-interface '(gnu packages commencement)))
1477 (proc (module-ref iface 'canonical-package)))
1478 (proc package)))
1479
1480 (define-public (%final-inputs)
1481 "Return the list of \"final inputs\"."
1482 ;; Avoid circular dependency by lazily resolving 'commencement'.
1483 (let ((iface (resolve-interface '(gnu packages commencement))))
1484 (module-ref iface '%final-inputs)))
1485
1486 ;;; base.scm ends here