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