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