Merge branch 'master' 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, 2019 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.32")
160 (source (origin
161 (method url-fetch)
162 (uri (string-append "mirror://gnu/tar/tar-"
163 version ".tar.xz"))
164 (sha256
165 (base32
166 "1n7xy657ii0sa42zx6944v2m4v9qrh6sqgmw17l3nch3y43sxlyh"))
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 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
183 ;; to refer to the target Bash.
184 (inputs (if (%current-target-system)
185 `(("bash" ,bash))
186 '()))
187
188 (synopsis "Managing tar archives")
189 (description
190 "Tar provides the ability to create tar archives, as well as the
191 ability to extract, update or list files in an existing archive. It is
192 useful for combining many files into one larger file, while maintaining
193 directory structure and file information such as permissions and
194 creation/modification dates. GNU tar offers many extensions over the
195 standard utility.")
196 (license gpl3+)
197 (home-page "https://www.gnu.org/software/tar/")))
198
199 (define-public patch
200 (package
201 (name "patch")
202 (version "2.7.6")
203 (source (origin
204 (method url-fetch)
205 (uri (string-append "mirror://gnu/patch/patch-"
206 version ".tar.xz"))
207 (sha256
208 (base32
209 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
210 (patches (search-patches "patch-hurd-path-max.patch"))))
211 (build-system gnu-build-system)
212 (arguments
213 ;; Work around a cross-compilation bug whereby libpatch.a would provide
214 ;; '__mktime_internal', which conflicts with the one in libc.a.
215 (if (%current-target-system)
216 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
217 '()))
218 (native-inputs `(("ed" ,ed)))
219 (synopsis "Apply differences to originals, with optional backups")
220 (description
221 "Patch is a program that applies changes to files based on differences
222 laid out as by the program \"diff\". The changes may be applied to one or more
223 files depending on the contents of the diff file. It accepts several
224 different diff formats. It may also be used to revert previously applied
225 differences.")
226 (license gpl3+)
227 (home-page "https://savannah.gnu.org/projects/patch/")))
228
229 (define-public diffutils
230 (package
231 (name "diffutils")
232 (version "3.7")
233 (source (origin
234 (method url-fetch)
235 (uri (string-append "mirror://gnu/diffutils/diffutils-"
236 version ".tar.xz"))
237 (sha256
238 (base32
239 "09isrg0isjinv8c535nxsi1s86wfdfzml80dbw41dj9x3hiad9xk"))))
240 (build-system gnu-build-system)
241 (native-inputs `(("perl" ,perl)))
242 (synopsis "Comparing and merging files")
243 (description
244 "GNU Diffutils is a package containing tools for finding the
245 differences between files. The \"diff\" command is used to show how two files
246 differ, while \"cmp\" shows the offsets and line numbers where they differ.
247 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
248 interactive means to merge two files.")
249 (license gpl3+)
250 (home-page "https://www.gnu.org/software/diffutils/")))
251
252 (define-public findutils
253 (package
254 (name "findutils")
255 (version "4.6.0")
256 (source (origin
257 (method url-fetch)
258 (uri (string-append "mirror://gnu/findutils/findutils-"
259 version ".tar.gz"))
260 (sha256
261 (base32
262 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
263 (patches (search-patches
264 "findutils-gnulib-libio.patch"
265 "findutils-localstatedir.patch"
266 "findutils-makedev.patch"
267 "findutils-test-xargs.patch"))
268 (modules '((guix build utils)))
269 (snippet
270 '(begin
271 ;; The gnulib test-lock test is prone to writer starvation
272 ;; with our glibc@2.25, which prefers readers, so disable it.
273 ;; The gnulib commit b20e8afb0b2 should fix this once
274 ;; incorporated here.
275 (substitute* "tests/Makefile.in"
276 (("test-lock\\$\\(EXEEXT\\) ") ""))
277 #t))))
278 (build-system gnu-build-system)
279 (arguments
280 `(#:configure-flags (list
281 ;; Tell 'updatedb' to write to /var.
282 "--localstatedir=/var"
283
284 ;; Work around cross-compilation failure. See
285 ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
286 ,@(if (%current-target-system)
287 '("gl_cv_func_wcwidth_works=yes")
288 '()))))
289 (synopsis "Operating on files matching given criteria")
290 (description
291 "Findutils supplies the basic file directory searching utilities of the
292 GNU system. It consists of two primary searching utilities: \"find\"
293 recursively searches for files in a directory according to given criteria and
294 \"locate\" lists files in a database that match a query. Two auxiliary tools
295 are included: \"updatedb\" updates the file name database and \"xargs\" may be
296 used to apply commands with arbitrarily long arguments.")
297 (license gpl3+)
298 (home-page "https://www.gnu.org/software/findutils/")))
299
300 (define-public coreutils
301 (package
302 (name "coreutils")
303 (version "8.31")
304 (source (origin
305 (method url-fetch)
306 (uri (string-append "mirror://gnu/coreutils/coreutils-"
307 version ".tar.xz"))
308 (sha256
309 (base32
310 "1zg9m79x1i2nifj4kb0waf9x3i5h6ydkypkjnbsb9rnwis8rqypz"))))
311 (build-system gnu-build-system)
312 (inputs `(("acl" ,acl) ; TODO: add SELinux
313 ("gmp" ,gmp) ;bignums in 'expr', yay!
314
315 ;; Drop the dependency on libcap when cross-compiling since it's
316 ;; not quite cross-compilable.
317 ,@(if (%current-target-system)
318 '()
319 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
320 (native-inputs
321 ;; Perl is needed to run tests in native builds, and to run the bundled
322 ;; copy of help2man. However, don't pass it when cross-compiling since
323 ;; that would lead it to try to run programs to get their '--help' output
324 ;; for help2man.
325 (if (%current-target-system)
326 '()
327 `(("perl" ,perl))))
328 (outputs '("out" "debug"))
329 (arguments
330 `(#:parallel-build? #f ; help2man may be called too early
331 #:phases (modify-phases %standard-phases
332 (add-before 'build 'patch-shell-references
333 (lambda _
334 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
335 ;; that tests pass, since /bin/sh isn't in the chroot.
336 (setenv "SHELL" (which "sh"))
337
338 (substitute* (find-files "gnulib-tests" "\\.c$")
339 (("/bin/sh") (which "sh")))
340 (substitute* (find-files "tests" "\\.sh$")
341 (("#!/bin/sh") (string-append "#!" (which "sh"))))
342 #t))
343 (add-before 'check 'disable-broken-test
344 (lambda _
345 ;; This test hits the 127 character shebang limit in the build
346 ;; environment due to the way "env -S" splits arguments into
347 ;; shebangs. Note that "env-S-script.sh" works around this
348 ;; specific issue, but "env-S.pl" is not adjusted for build
349 ;; environments with long prefixes (/tmp/guix-build-...).
350 (substitute* "Makefile"
351 (("^.*tests/misc/env-S.pl.*$") ""))
352 #t)))))
353 (synopsis "Core GNU utilities (file, text, shell)")
354 (description
355 "GNU Coreutils includes all of the basic command-line tools that are
356 expected in a POSIX system. These provide the basic file, shell and text
357 manipulation functions of the GNU system. Most of these tools offer extended
358 functionality beyond that which is outlined in the POSIX standard.")
359 (license gpl3+)
360 (home-page "https://www.gnu.org/software/coreutils/")))
361
362 (define-public coreutils-minimal
363 ;; Coreutils without its optional dependencies.
364 (package
365 (inherit coreutils)
366 (name "coreutils-minimal")
367 (outputs '("out"))
368 (inputs '())))
369
370 (define-public gnu-make
371 (package
372 (name "make")
373 (version "4.2.1")
374 (source (origin
375 (method url-fetch)
376 (uri (string-append "mirror://gnu/make/make-" version
377 ".tar.bz2"))
378 (sha256
379 (base32
380 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
381 (patches (search-patches "make-impure-dirs.patch"
382 "make-glibc-compat.patch"))))
383 (build-system gnu-build-system)
384 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
385 (inputs `(("guile" ,guile-2.0)))
386 (outputs '("out" "debug"))
387 (arguments
388 '(;; Work around faulty glob detection with glibc 2.27. See
389 ;; <https://lists.nongnu.org/archive/html/bug-make/2017-11/msg00027.html>.
390 #:configure-flags '("make_cv_sys_gnu_glob=yes")
391 #:phases
392 (modify-phases %standard-phases
393 (add-before 'build 'set-default-shell
394 (lambda* (#:key inputs #:allow-other-keys)
395 ;; Change the default shell from /bin/sh.
396 (let ((bash (assoc-ref inputs "bash")))
397 (substitute* "job.c"
398 (("default_shell =.*$")
399 (format #f "default_shell = \"~a/bin/sh\";\n"
400 bash)))
401 #t))))))
402 (synopsis "Remake files automatically")
403 (description
404 "Make is a program that is used to control the production of
405 executables or other files from their source files. The process is
406 controlled from a Makefile, in which the developer specifies how each file is
407 generated from its source. It has powerful dependency resolution and the
408 ability to determine when files have to be regenerated after their sources
409 change. GNU make offers many powerful extensions over the standard utility.")
410 (license gpl3+)
411 (home-page "https://www.gnu.org/software/make/")))
412
413 (define-public binutils
414 (package
415 (name "binutils")
416 (version "2.32")
417 (source (origin
418 (method url-fetch)
419 (uri (string-append "mirror://gnu/binutils/binutils-"
420 version ".tar.bz2"))
421 (sha256
422 (base32
423 "0b8767nyal1bc4cyzg5h9iis8kpkln1i3wkamig75cifj1fb2f6y"))
424 (patches (search-patches "binutils-loongson-workaround.patch"))))
425 (build-system gnu-build-system)
426
427 ;; TODO: Add dependency on zlib + those for Gold.
428 (arguments
429 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
430 ;; on GCC when bootstrapping.
431 "LDFLAGS=-static-libgcc"
432
433 ;; Turn on --enable-new-dtags by default to make the
434 ;; linker set RUNPATH instead of RPATH on binaries.
435 ;; This is important because RUNPATH can be overriden
436 ;; using LD_LIBRARY_PATH at runtime.
437 "--enable-new-dtags"
438
439 ;; Don't search under /usr/lib & co.
440 "--with-lib-path=/no-ld-lib-path"
441
442 ;; Install BFD. It ends up in a hidden directory,
443 ;; but it's here.
444 "--enable-install-libbfd"
445
446 ;; Make sure 'ar' and 'ranlib' produce archives in a
447 ;; deterministic fashion.
448 "--enable-deterministic-archives")))
449
450 (synopsis "Binary utilities: bfd gas gprof ld")
451 (description
452 "GNU Binutils is a collection of tools for working with binary files.
453 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
454 Other tools include programs to display binary profiling information, list
455 the strings in a binary file, and utilities for working with archives. The
456 \"bfd\" library for working with executable and object formats is also
457 included.")
458 (license gpl3+)
459 (home-page "https://www.gnu.org/software/binutils/")))
460
461 (define-public binutils-gold
462 (package
463 (inherit binutils)
464 (name "binutils-gold")
465 (arguments
466 `(#:phases
467 (modify-phases %standard-phases
468 (add-after 'patch-source-shebangs 'patch-more-shebangs
469 (lambda _
470 (substitute* "gold/Makefile.in"
471 (("/bin/sh") (which "sh")))
472 #t)))
473 ,@(substitute-keyword-arguments (package-arguments binutils)
474 ; Upstream is aware of unrelocatable test failures on arm*.
475 ((#:tests? _ #f)
476 (if (any (cute string-prefix? <> (or (%current-target-system)
477 (%current-system)))
478 '("i686" "x86_64"))
479 '#t '#f))
480 ((#:configure-flags flags)
481 `(cons* "--enable-gold=default"
482 (delete "LDFLAGS=-static-libgcc" ,flags))))))
483 (native-inputs
484 `(("bc" ,bc)))
485 (inputs
486 `(("gcc:lib" ,gcc "lib")))))
487
488 (define* (make-ld-wrapper name #:key
489 (target (const #f))
490 binutils
491 (guile (canonical-package guile-2.2))
492 (bash (canonical-package bash))
493 (guile-for-build guile))
494 "Return a package called NAME that contains a wrapper for the 'ld' program
495 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
496 wrapper uses GUILE and BASH.
497
498 TARGET must be a one-argument procedure that, given a system type, returns a
499 cross-compilation target triplet or #f. When the result is not #f, make a
500 wrapper for the cross-linker for that target, called 'TARGET-ld'."
501 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
502 ;; its result can be delayed until the 'arguments' field is evaluated, thus
503 ;; in a context where '%current-system' is accurate.
504 (package
505 (name name)
506 (version "0")
507 (source #f)
508 (build-system trivial-build-system)
509 (inputs `(("binutils" ,binutils)
510 ("guile" ,guile)
511 ("bash" ,bash)
512 ("wrapper" ,(search-path %load-path
513 "gnu/packages/ld-wrapper.in"))))
514 (arguments
515 (let ((target (target (%current-system))))
516 `(#:guile ,guile-for-build
517 #:modules ((guix build utils))
518 #:builder (begin
519 (use-modules (guix build utils)
520 (system base compile))
521
522 (let* ((out (assoc-ref %outputs "out"))
523 (bin (string-append out "/bin"))
524 (ld ,(if target
525 `(string-append bin "/" ,target "-ld")
526 '(string-append bin "/ld")))
527 (go (string-append ld ".go")))
528
529 (setvbuf (current-output-port) _IOLBF)
530 (format #t "building ~s/bin/ld wrapper in ~s~%"
531 (assoc-ref %build-inputs "binutils")
532 out)
533
534 (mkdir-p bin)
535 (copy-file (assoc-ref %build-inputs "wrapper") ld)
536 (substitute* ld
537 (("@SELF@")
538 ld)
539 (("@GUILE@")
540 (string-append (assoc-ref %build-inputs "guile")
541 "/bin/guile"))
542 (("@BASH@")
543 (string-append (assoc-ref %build-inputs "bash")
544 "/bin/bash"))
545 (("@LD@")
546 (string-append (assoc-ref %build-inputs "binutils")
547 ,(if target
548 (string-append "/bin/"
549 target "-ld")
550 "/bin/ld"))))
551 (chmod ld #o555)
552 (compile-file ld #:output-file go)
553 #t)))))
554 (synopsis "The linker wrapper")
555 (description
556 "The linker wrapper (or @code{ld-wrapper}) wraps the linker to add any
557 missing @code{-rpath} flags, and to detect any misuse of libraries outside of
558 the store.")
559 (home-page "https://www.gnu.org/software/guix//")
560 (license gpl3+)))
561
562 (export make-ld-wrapper)
563
564 (define-public glibc
565 ;; This is the GNU C Library, used on GNU/Linux and GNU/Hurd. Prior to
566 ;; version 2.28, GNU/Hurd used a different glibc branch.
567 (package
568 (name "glibc")
569 ;; Note: Always use a dot after the minor version since various places rely
570 ;; on "version-major+minor" to determine where locales are found.
571 (version "2.28")
572 (source (origin
573 (method url-fetch)
574 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
575 (sha256
576 (base32
577 "10iha5ynvdj5m62vgpgqbq4cwvc2yhyl2w9yyyjgfxmdmx8h145i"))
578 (snippet
579 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
580 ;; required on LFS distros to avoid loading the distro's libc.so
581 ;; instead of ours.
582 '(begin
583 (substitute* "sysdeps/unix/sysv/linux/configure"
584 (("use_ldconfig=yes")
585 "use_ldconfig=no"))
586 #t))
587 (modules '((guix build utils)))
588 (patches (search-patches "glibc-ldd-x86_64.patch"
589 "glibc-2.28-git-fixes.patch"
590 "glibc-hidden-visibility-ldconfig.patch"
591 "glibc-versioned-locpath.patch"
592 "glibc-allow-kernel-2.6.32.patch"
593 "glibc-reinstate-prlimit64-fallback.patch"
594 "glibc-hurd-magic-pid.patch"
595 "glibc-supported-locales.patch"))))
596 (build-system gnu-build-system)
597
598 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
599 ;; users should automatically pull Linux headers as well. On GNU/Hurd,
600 ;; libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
601 ;; so both should be propagated.
602 (propagated-inputs
603 (if (hurd-target?)
604 `(("hurd-core-headers" ,hurd-core-headers))
605 `(("kernel-headers" ,linux-libre-headers))))
606
607 (outputs '("out" "debug"
608 "static")) ;9 MiB of .a files
609
610 (arguments
611 `(#:out-of-source? #t
612
613 ;; The libraries have an empty RUNPATH, but some, such as the versioned
614 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
615 ;; these libraries are always going to be found anyway, just skip
616 ;; RUNPATH checks.
617 #:validate-runpath? #f
618
619 #:modules ((ice-9 ftw)
620 (srfi srfi-26)
621 (guix build utils)
622 (guix build gnu-build-system))
623
624 #:configure-flags
625 (list "--sysconfdir=/etc"
626
627 ;; Installing a locale archive with all the locales is to
628 ;; expensive (~100 MiB), so we rely on users to install the
629 ;; locales they really want.
630 ;;
631 ;; Set the default locale path. In practice, $LOCPATH may be
632 ;; defined to point whatever locales users want. However, setuid
633 ;; binaries don't honor $LOCPATH, so they'll instead look into
634 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
635 ;; with the idea that it is going to be populated by the sysadmin.
636 ;; The "X.Y" sub-directory is because locale data formats are
637 ;; incompatible across libc versions; see
638 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
639 ;;
640 ;; `--localedir' is not honored, so work around it.
641 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
642 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
643 ,(version-major+minor version))
644
645 (string-append "--with-headers="
646 (assoc-ref ,(if (%current-target-system)
647 '%build-target-inputs
648 '%build-inputs)
649 "kernel-headers")
650 "/include")
651
652 ;; This is the default for most architectures as of GNU libc 2.26,
653 ;; but we specify it explicitly for clarity and consistency. See
654 ;; "kernel-features.h" in the GNU libc for details.
655 "--enable-kernel=3.2.0"
656
657 ;; Use our Bash instead of /bin/sh.
658 (string-append "BASH_SHELL="
659 (assoc-ref %build-inputs "bash")
660 "/bin/bash")
661
662 ;; On GNU/Hurd we get discarded-qualifiers warnings for
663 ;; 'device_write_inband' among other things. Ignore them.
664 ,@(if (hurd-target?)
665 '("--disable-werror")
666 '()))
667
668 #:tests? #f ; XXX
669 #:phases (modify-phases %standard-phases
670 (add-before
671 'configure 'pre-configure
672 (lambda* (#:key inputs native-inputs outputs
673 #:allow-other-keys)
674 (let* ((out (assoc-ref outputs "out"))
675 (bin (string-append out "/bin"))
676 ;; FIXME: Normally we would look it up only in INPUTS
677 ;; but cross-base uses it as a native input.
678 (bash (or (assoc-ref inputs "static-bash")
679 (assoc-ref native-inputs "static-bash"))))
680 ;; Install the rpc data base file under `$out/etc/rpc'.
681 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
682 (substitute* "sunrpc/Makefile"
683 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
684 (string-append out "/etc/rpc" suffix "\n"))
685 (("^install-others =.*$")
686 (string-append "install-others = " out "/etc/rpc\n")))
687
688 (substitute* "Makeconfig"
689 ;; According to
690 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
691 ;; linking against libgcc_s is not needed with GCC
692 ;; 4.7.1.
693 ((" -lgcc_s") ""))
694
695 ;; Have `system' use that Bash.
696 (substitute* "sysdeps/posix/system.c"
697 (("#define[[:blank:]]+SHELL_PATH.*$")
698 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
699 bash)))
700
701 ;; Same for `popen'.
702 (substitute* "libio/iopopen.c"
703 (("/bin/sh")
704 (string-append bash "/bin/sh")))
705
706 ;; Same for the shell used by the 'exec' functions for
707 ;; scripts that lack a shebang.
708 (substitute* (find-files "." "^paths\\.h$")
709 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
710 (string-append "#define _PATH_BSHELL \""
711 bash "/bin/sh\"\n")))
712
713 ;; Nscd uses __DATE__ and __TIME__ to create a string to
714 ;; make sure the client and server come from the same
715 ;; libc. Use something deterministic instead.
716 (substitute* "nscd/nscd_stat.c"
717 (("static const char compilation\\[21\\] =.*$")
718 (string-append
719 "static const char compilation[21] = \""
720 (string-take (basename out) 20) "\";\n")))
721
722 ;; Make sure we don't retain a reference to the
723 ;; bootstrap Perl.
724 (substitute* "malloc/mtrace.pl"
725 (("^#!.*")
726 ;; The shebang can be omitted, because there's the
727 ;; "bilingual" eval/exec magic at the top of the file.
728 "")
729 (("exec @PERL@")
730 "exec perl"))
731
732 #t)))
733
734 (add-after 'install 'move-static-libs
735 (lambda* (#:key outputs #:allow-other-keys)
736 ;; Move static libraries to the "static" output.
737 (define (static-library? file)
738 ;; Return true if FILE is a static library. The
739 ;; "_nonshared.a" files are referred to by libc.so,
740 ;; libpthread.so, etc., which are in fact linker
741 ;; scripts.
742 (and (string-suffix? ".a" file)
743 (not (string-contains file "_nonshared"))))
744
745 (define (linker-script? file)
746 ;; Guess whether FILE, a ".a" file, is actually a
747 ;; linker script.
748 (and (not (ar-file? file))
749 (not (elf-file? file))))
750
751 (let* ((out (assoc-ref outputs "out"))
752 (lib (string-append out "/lib"))
753 (files (scandir lib static-library?))
754 (static (assoc-ref outputs "static"))
755 (slib (string-append static "/lib")))
756 (mkdir-p slib)
757 (for-each (lambda (base)
758 (rename-file (string-append lib "/" base)
759 (string-append slib "/" base)))
760 files)
761
762 ;; Usually libm.a is a linker script so we need to
763 ;; change the file names in there to refer to STATIC
764 ;; instead of OUT.
765 (for-each (lambda (ld-script)
766 (substitute* ld-script
767 ((out) static)))
768 (filter linker-script?
769 (map (cut string-append slib "/" <>)
770 files)))
771 #t)))
772
773 ,@(if (hurd-target?)
774 '((add-after 'install 'augment-libc.so
775 (lambda* (#:key outputs #:allow-other-keys)
776 (let* ((out (assoc-ref outputs "out")))
777 (substitute* (string-append out "/lib/libc.so")
778 (("/[^ ]+/lib/libc.so.0.3")
779 (string-append out "/lib/libc.so.0.3"
780 " libmachuser.so libhurduser.so"))))
781 #t)))
782 '()))))
783
784 (inputs `(("static-bash" ,static-bash)))
785
786 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
787 ;; install the message catalogs, with 'msgfmt'.
788 (native-inputs `(("texinfo" ,texinfo)
789 ("perl" ,perl)
790 ("bison" ,bison)
791 ("gettext" ,gettext-minimal)
792
793 ,@(if (hurd-target?)
794 `(("mig" ,mig)
795 ("perl" ,perl))
796 '())))
797
798 (native-search-paths
799 ;; Search path for packages that provide locale data. This is useful
800 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
801 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
802 ;; distros.
803 (list (search-path-specification
804 (variable "GUIX_LOCPATH")
805 (files '("lib/locale")))))
806
807 (synopsis "The GNU C Library")
808 (description
809 "Any Unix-like operating system needs a C library: the library which
810 defines the \"system calls\" and other basic facilities such as open, malloc,
811 printf, exit...
812
813 The GNU C library is used as the C library in the GNU system and most systems
814 with the Linux kernel.")
815 (license lgpl2.0+)
816 (home-page "https://www.gnu.org/software/libc/")))
817
818 ;; Below are old libc versions, which we use mostly to build locale data in
819 ;; the old format (which the new libc cannot cope with.)
820
821 (define-public glibc-2.27
822 (package
823 (inherit glibc)
824 (version "2.27")
825 (source (origin
826 (inherit (package-source glibc))
827 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
828 (sha256
829 (base32
830 "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"))
831 (patches (search-patches "glibc-ldd-x86_64.patch"
832 "glibc-2.27-git-fixes.patch"
833 "glibc-hidden-visibility-ldconfig.patch"
834 "glibc-versioned-locpath.patch"
835 "glibc-allow-kernel-2.6.32.patch"
836 "glibc-reinstate-prlimit64-fallback.patch"
837 "glibc-supported-locales.patch"
838 "glibc-CVE-2018-11236.patch"
839 "glibc-CVE-2018-11237.patch"))))
840 (properties `((lint-hidden-cve . ("CVE-2017-18269")))))) ; glibc-2.27-git-fixes
841
842 (define-public glibc-2.26
843 (package
844 (inherit glibc)
845 ;; This version number corresponds to the output of `git describe` and the
846 ;; archive can be generated by checking out the commit ID and running:
847 ;; git archive --prefix=$(git describe)/ HEAD | xz > $(git describe).tar.xz
848 ;; See <https://bugs.gnu.org/29406> for why this was necessary.
849 (version "2.26.105-g0890d5379c")
850 (source (origin
851 (inherit (package-source glibc))
852 (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/"
853 "glibc-" (version-major+minor version) "-"
854 (caddr (string-split version #\.)) ".tar.xz"))
855 (sha256
856 (base32
857 "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
858 (patches (search-patches "glibc-ldd-x86_64.patch"
859 "glibc-versioned-locpath.patch"
860 "glibc-allow-kernel-2.6.32.patch"))))))
861
862 (define-public glibc-2.25
863 (package
864 (inherit glibc)
865 (version "2.25")
866 (source (origin
867 (inherit (package-source glibc))
868 (uri (string-append "mirror://gnu/glibc/glibc-"
869 version ".tar.xz"))
870 (sha256
871 (base32
872 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
873 (patches (search-patches "glibc-ldd-x86_64.patch"
874 "glibc-versioned-locpath.patch"
875 "glibc-vectorized-strcspn-guards.patch"
876 "glibc-CVE-2017-1000366-pt1.patch"
877 "glibc-CVE-2017-1000366-pt2.patch"
878 "glibc-CVE-2017-1000366-pt3.patch"))))))
879
880 (define-public glibc-2.24
881 (package
882 (inherit glibc)
883 (version "2.24")
884 (source (origin
885 (inherit (package-source glibc))
886 (uri (string-append "mirror://gnu/glibc/glibc-"
887 version ".tar.xz"))
888 (sha256
889 (base32
890 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
891 (patches (search-patches "glibc-ldd-x86_64.patch"
892 "glibc-versioned-locpath.patch"
893 "glibc-vectorized-strcspn-guards.patch"
894 "glibc-CVE-2015-5180.patch"
895 "glibc-CVE-2017-1000366-pt1.patch"
896 "glibc-CVE-2017-1000366-pt2.patch"
897 "glibc-CVE-2017-1000366-pt3.patch"))))))
898
899 (define-public glibc-2.23
900 (package
901 (inherit glibc)
902 (version "2.23")
903 (source (origin
904 (inherit (package-source glibc))
905 (uri (string-append "mirror://gnu/glibc/glibc-"
906 version ".tar.xz"))
907 (sha256
908 (base32
909 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
910 (patches (search-patches "glibc-ldd-x86_64.patch"
911 "glibc-versioned-locpath.patch"
912 "glibc-vectorized-strcspn-guards.patch"
913 "glibc-CVE-2015-5180.patch"
914 "glibc-CVE-2016-3075.patch"
915 "glibc-CVE-2016-3706.patch"
916 "glibc-CVE-2016-4429.patch"
917 "glibc-CVE-2017-1000366-pt1.patch"
918 "glibc-CVE-2017-1000366-pt2.patch"
919 "glibc-CVE-2017-1000366-pt3.patch"))))))
920
921 (define-public glibc-2.22
922 (package
923 (inherit glibc)
924 (version "2.22")
925 (source (origin
926 (inherit (package-source glibc))
927 (uri (string-append "mirror://gnu/glibc/glibc-"
928 version ".tar.xz"))
929 (sha256
930 (base32
931 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
932 (patches (search-patches "glibc-ldd-x86_64.patch"
933 "glibc-o-largefile.patch"
934 "glibc-vectorized-strcspn-guards.patch"
935 "glibc-CVE-2015-5180.patch"
936 "glibc-CVE-2015-7547.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 (arguments
944 (substitute-keyword-arguments (package-arguments glibc)
945 ((#:phases phases)
946 `(modify-phases ,phases
947 (add-before 'configure 'fix-pwd
948 (lambda _
949 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
950 (substitute* "configure"
951 (("/bin/pwd") "pwd"))
952 #t))))))))
953
954 (define (make-gcc-libc base-gcc libc)
955 "Return a GCC that targets LIBC."
956 (package (inherit base-gcc)
957 (name (string-append (package-name base-gcc) "-"
958 (package-name libc) "-"
959 (package-version libc)))
960 (arguments
961 (substitute-keyword-arguments
962 (ensure-keyword-arguments (package-arguments base-gcc)
963 '(#:implicit-inputs? #f))
964 ((#:make-flags flags)
965 `(let ((libc (assoc-ref %build-inputs "libc")))
966 ;; FLAGS_FOR_TARGET are needed for the target libraries to receive
967 ;; the -Bxxx for the startfiles.
968 (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib")
969 ,flags)))))
970 (native-inputs
971 `(("libc" ,libc)
972 ("libc:static" ,libc "static")
973 ,@(append (package-inputs base-gcc)
974 (fold alist-delete (%final-inputs) '("libc" "libc:static")))))
975 (inputs '())))
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 @code{LOCPATH} environment variable
988 to the @code{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 ((#:modules modules '((guix build utils)
996 (guix build gnu-build-system)))
997 `((srfi srfi-11)
998 (gnu build locale)
999 ,@modules))
1000 ((#:imported-modules modules '())
1001 `((gnu build locale)
1002 ,@%gnu-build-system-modules))
1003 ((#:phases phases)
1004 `(modify-phases ,phases
1005 (replace 'build
1006 (lambda _
1007 (invoke "make" "localedata/install-locales"
1008 "-j" (number->string (parallel-job-count)))))
1009 (add-after 'build 'symlink-normalized-codesets
1010 (lambda* (#:key outputs #:allow-other-keys)
1011 ;; The above phase does not install locales with names using
1012 ;; the "normalized codeset." Thus, create symlinks like:
1013 ;; en_US.utf8 -> en_US.UTF-8
1014 (define (locale-directory? file stat)
1015 (and (file-is-directory? file)
1016 (string-index (basename file) #\_)
1017 (string-rindex (basename file) #\.)))
1018
1019 (let* ((out (assoc-ref outputs "out"))
1020 (locales (find-files out locale-directory?
1021 #:directories? #t)))
1022 (for-each (lambda (directory)
1023 (let*-values (((base)
1024 (basename directory))
1025 ((name codeset)
1026 (locale->name+codeset base))
1027 ((normalized)
1028 (normalize-codeset codeset)))
1029 (unless (string=? codeset normalized)
1030 (symlink base
1031 (string-append (dirname directory)
1032 "/" name "."
1033 normalized)))))
1034 locales)
1035 #t)))
1036 (delete 'install)
1037 (delete 'move-static-libs)))
1038 ((#:configure-flags flags)
1039 `(append ,flags
1040 ;; Use $(libdir)/locale/X.Y as is the case by default.
1041 (list (string-append "libc_cv_complocaledir="
1042 (assoc-ref %outputs "out")
1043 "/lib/locale/"
1044 ,(version-major+minor
1045 (package-version glibc)))))))))))
1046
1047 (define-public (make-glibc-utf8-locales glibc)
1048 (package
1049 (name "glibc-utf8-locales")
1050 (version (package-version glibc))
1051 (source #f)
1052 (build-system trivial-build-system)
1053 (arguments
1054 `(#:modules ((guix build utils))
1055 #:builder (begin
1056 (use-modules (guix build utils))
1057
1058 (let* ((libc (assoc-ref %build-inputs "glibc"))
1059 (gzip (assoc-ref %build-inputs "gzip"))
1060 (out (assoc-ref %outputs "out"))
1061 (localedir (string-append out "/lib/locale/"
1062 ,(version-major+minor version))))
1063 ;; 'localedef' needs 'gzip'.
1064 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1065
1066 (mkdir-p localedir)
1067 (for-each (lambda (locale)
1068 (define file
1069 ;; Use the "normalized codeset" by
1070 ;; default--e.g., "en_US.utf8".
1071 (string-append localedir "/" locale ".utf8"))
1072
1073 (invoke "localedef" "--no-archive"
1074 "--prefix" localedir
1075 "-i" locale
1076 "-f" "UTF-8" file)
1077
1078 ;; For backward compatibility with Guix
1079 ;; <= 0.8.3, add "xx_YY.UTF-8".
1080 (symlink (string-append locale ".utf8")
1081 (string-append localedir "/"
1082 locale ".UTF-8")))
1083
1084 ;; These are the locales commonly used for
1085 ;; tests---e.g., in Guile's i18n tests.
1086 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
1087 #t))))
1088 (inputs `(("glibc" ,glibc)
1089 ("gzip" ,gzip)))
1090 (synopsis "Small sample of UTF-8 locales")
1091 (description
1092 "This package provides a small sample of UTF-8 locales mostly useful in
1093 test environments.")
1094 (home-page (package-home-page glibc))
1095 (license (package-license glibc))))
1096
1097 (define-public glibc-locales
1098 (make-glibc-locales glibc))
1099 (define-public glibc-utf8-locales
1100 (make-glibc-utf8-locales glibc))
1101
1102 (define-public glibc-locales-2.27
1103 (package (inherit (make-glibc-locales glibc-2.27))
1104 (name "glibc-locales-2.27")))
1105 (define-public glibc-utf8-locales-2.27
1106 (package (inherit (make-glibc-utf8-locales glibc-2.27))
1107 (name "glibc-utf8-locales-2.27")))
1108
1109 (define-public which
1110 (package
1111 (name "which")
1112 (version "2.21")
1113 (source (origin
1114 (method url-fetch)
1115 (uri (string-append "mirror://gnu/which/which-"
1116 version ".tar.gz"))
1117 (sha256
1118 (base32
1119 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1120 (build-system gnu-build-system)
1121 (home-page "https://gnu.org/software/which/")
1122 (synopsis "Find full path of shell commands")
1123 (description
1124 "The which program finds the location of executables in PATH, with a
1125 variety of options. It is an alternative to the shell \"type\" built-in
1126 command.")
1127 (license gpl3+))) ; some files are under GPLv2+
1128
1129 (define-public glibc/hurd-headers
1130 (package (inherit glibc)
1131 (name "glibc-hurd-headers")
1132 (outputs '("out"))
1133 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1134 ("hurd-headers" ,hurd-headers)))
1135 (arguments
1136 (substitute-keyword-arguments (package-arguments glibc)
1137 ;; We just pass the flags really needed to build the headers.
1138 ((#:configure-flags _)
1139 `(list "--enable-add-ons"
1140 "--host=i586-pc-gnu"))
1141 ((#:phases _)
1142 '(modify-phases %standard-phases
1143 (replace 'install
1144 (lambda* (#:key outputs #:allow-other-keys)
1145 (invoke "make" "install-headers")
1146
1147 ;; Make an empty stubs.h to work around not being able to
1148 ;; produce a valid stubs.h and causing the build to fail. See
1149 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1150 (let ((out (assoc-ref outputs "out")))
1151 (close-port
1152 (open-output-file
1153 (string-append out "/include/gnu/stubs.h"))))
1154 #t))
1155 (delete 'build))))))) ; nothing to build
1156
1157 (define-public tzdata
1158 (package
1159 (name "tzdata")
1160 (version "2019a")
1161 (source (origin
1162 (method url-fetch)
1163 (uri (string-append
1164 "https://www.iana.org/time-zones/repository/releases/tzdata"
1165 version ".tar.gz"))
1166 (sha256
1167 (base32
1168 "0wlpqm4asvi0waaz24xj20iq40gqfypmb4nldjhkfgm09bgnsdlh"))))
1169 (build-system gnu-build-system)
1170 (arguments
1171 '(#:tests? #f
1172 #:make-flags (let ((out (assoc-ref %outputs "out"))
1173 (tmp (getenv "TMPDIR")))
1174 (list (string-append "TOPDIR=" out)
1175 (string-append "TZDIR=" out "/share/zoneinfo")
1176 (string-append "TZDEFAULT=" out
1177 "/share/zoneinfo/localtime")
1178
1179 ;; Likewise for the C library routines.
1180 (string-append "LIBDIR=" tmp "/lib")
1181 (string-append "MANDIR=" tmp "/man")
1182
1183 "AWK=awk"
1184 "CC=gcc"))
1185 #:modules ((guix build utils)
1186 (guix build gnu-build-system)
1187 (srfi srfi-1))
1188 #:phases
1189 (modify-phases %standard-phases
1190 (replace 'unpack
1191 (lambda* (#:key source inputs #:allow-other-keys)
1192 (invoke "tar" "xvf" source)
1193 (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
1194 (add-after 'install 'post-install
1195 (lambda* (#:key outputs #:allow-other-keys)
1196 ;; Move data in the right place.
1197 (let ((out (assoc-ref outputs "out")))
1198 ;; Discard zic, dump, and tzselect, already
1199 ;; provided by glibc.
1200 (delete-file-recursively (string-append out "/usr"))
1201 (symlink (string-append out "/share/zoneinfo")
1202 (string-append out "/share/zoneinfo/posix"))
1203 (delete-file-recursively
1204 (string-append out "/share/zoneinfo-posix"))
1205 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1206 (string-append out "/share/zoneinfo/right"))
1207 (delete-file-recursively
1208 (string-append out "/share/zoneinfo-leaps"))
1209 #t)))
1210 (delete 'configure))))
1211 (inputs `(("tzcode" ,(origin
1212 (method url-fetch)
1213 (uri (string-append
1214 "http://www.iana.org/time-zones/repository/releases/tzcode"
1215 version ".tar.gz"))
1216 (sha256
1217 (base32
1218 "1x9z8fpgnhzlsnps0hamb54ymaskjab7ys9m4i4gpk9hpiig2fc7"))))))
1219 (home-page "https://www.iana.org/time-zones")
1220 (synopsis "Database of current and historical time zones")
1221 (description "The Time Zone Database (often called tz or zoneinfo)
1222 contains code and data that represent the history of local time for many
1223 representative locations around the globe. It is updated periodically to
1224 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1225 and daylight-saving rules.")
1226 (license public-domain)))
1227
1228 ;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1229 ;;; and a few other places. We can update this whenever we are able to rebuild
1230 ;;; thousands of packages (for example, in a core-updates rebuild). This package
1231 ;;; will typically be obsolete and should never be referred to by a built
1232 ;;; package.
1233 (define-public tzdata-for-tests
1234 (hidden-package
1235 (package
1236 (inherit tzdata)
1237 (version "2018g")
1238 (source (origin
1239 (method url-fetch)
1240 (uri (string-append
1241 "https://www.iana.org/time-zones/repository/releases/tzdata"
1242 version ".tar.gz"))
1243 (sha256
1244 (base32
1245 "05kayi3w9pvhj6ljx1hvwd0r8mxfzn436fjmwhx53xkj919xxpq2"))))
1246 (inputs
1247 `(("tzcode" ,(origin
1248 (method url-fetch)
1249 (uri (string-append
1250 "http://www.iana.org/time-zones/repository/releases/tzcode"
1251 version ".tar.gz"))
1252 (sha256
1253 (base32
1254 "09y44fzcdq3c06saa8iqqa0a59cyw6ni3p31ps0j1w3hcpxz8lxa")))))))))
1255
1256 (define-public libiconv
1257 (package
1258 (name "libiconv")
1259 (version "1.15")
1260 (source (origin
1261 (method url-fetch)
1262 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1263 version ".tar.gz"))
1264 (sha256
1265 (base32
1266 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1267 (modules '((guix build utils)))
1268 (snippet
1269 ;; Work around "declared gets" error on glibc systems (fixed by
1270 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1271 '(begin
1272 (substitute* "srclib/stdio.in.h"
1273 (("^#undef gets") "")
1274 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1275 #t))))
1276 (build-system gnu-build-system)
1277 (synopsis "Character set conversion library")
1278 (description
1279 "libiconv provides an implementation of the iconv function for systems
1280 that lack it. iconv is used to convert between character encodings in a
1281 program. It supports a wide variety of different encodings.")
1282 (home-page "https://www.gnu.org/software/libiconv/")
1283 (license lgpl3+)))
1284
1285 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1286 "Return either a libiconv package specification to include in a dependency
1287 list for platforms that have an incomplete libc, or the empty list. If a
1288 package needs iconv ,@(libiconv-if-needed) should be added."
1289 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1290 ;; without iconv, such as MinGW, must return the then clause.
1291 (if (target-mingw? target)
1292 `(("libiconv" ,libiconv))
1293 '()))
1294
1295 (define-public (canonical-package package)
1296 ;; Avoid circular dependency by lazily resolving 'commencement'.
1297 (let* ((iface (resolve-interface '(gnu packages commencement)))
1298 (proc (module-ref iface 'canonical-package)))
1299 (proc package)))
1300
1301 (define-public (%final-inputs)
1302 "Return the list of \"final inputs\"."
1303 ;; Avoid circular dependency by lazily resolving 'commencement'.
1304 (let ((iface (resolve-interface '(gnu packages commencement))))
1305 (module-ref iface '%final-inputs)))
1306
1307 ;;; base.scm ends here