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