Merge branch 'master' into staging
[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 python)
53 #:use-module (gnu packages gettext)
54 #:use-module (guix utils)
55 #:use-module (guix packages)
56 #:use-module (guix download)
57 #:use-module (guix git-download)
58 #:use-module (guix build-system gnu)
59 #:use-module (guix build-system trivial)
60 #:use-module (ice-9 match)
61 #:use-module (srfi srfi-1)
62 #:use-module (srfi srfi-26)
63 #:export (glibc
64 libiconv-if-needed))
65
66 ;;; Commentary:
67 ;;;
68 ;;; Base packages of the Guix-based GNU user-land software distribution.
69 ;;;
70 ;;; Code:
71
72 (define-public hello
73 (package
74 (name "hello")
75 (version "2.10")
76 (source (origin
77 (method url-fetch)
78 (uri (string-append "mirror://gnu/hello/hello-" version
79 ".tar.gz"))
80 (sha256
81 (base32
82 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
83 (build-system gnu-build-system)
84 (synopsis "Hello, GNU world: An example GNU package")
85 (description
86 "GNU Hello prints the message \"Hello, world!\" and then exits. It
87 serves as an example of standard GNU coding practices. As such, it supports
88 command-line arguments, multiple languages, and so on.")
89 (home-page "https://www.gnu.org/software/hello/")
90 (license gpl3+)))
91
92 (define-public grep
93 (package
94 (name "grep")
95 (version "3.3")
96 (source (origin
97 (method url-fetch)
98 (uri (string-append "mirror://gnu/grep/grep-"
99 version ".tar.xz"))
100 (sha256
101 (base32
102 "055mqp6vrd0brkygmygb2673qwz409a7kyp1mzbfy6cn94f58q5r"))
103 (patches (search-patches "grep-timing-sensitive-test.patch"))))
104 (build-system gnu-build-system)
105 (native-inputs `(("perl" ,perl))) ;some of the tests require it
106 (inputs `(("pcre" ,pcre)))
107 (arguments
108 `(#:phases
109 (modify-phases %standard-phases
110 (add-after 'install 'fix-egrep-and-fgrep
111 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
112 ;; absolute file name instead of searching for it in $PATH.
113 (lambda* (#:key outputs #:allow-other-keys)
114 (let* ((out (assoc-ref outputs "out"))
115 (bin (string-append out "/bin")))
116 (substitute* (list (string-append bin "/egrep")
117 (string-append bin "/fgrep"))
118 (("^exec grep")
119 (string-append "exec " bin "/grep")))
120 #t))))))
121 (synopsis "Print lines matching a pattern")
122 (description
123 "grep is a tool for finding text inside files. Text is found by
124 matching a pattern provided by the user in one or many files. The pattern
125 may be provided as a basic or extended regular expression, or as fixed
126 strings. By default, the matching text is simply printed to the screen,
127 however the output can be greatly customized to include, for example, line
128 numbers. GNU grep offers many extensions over the standard utility,
129 including, for example, recursive directory searching.")
130 (license gpl3+)
131 (home-page "https://www.gnu.org/software/grep/")))
132
133 (define-public sed
134 (package
135 (name "sed")
136 (version "4.7")
137 (source (origin
138 (method url-fetch)
139 (uri (string-append "mirror://gnu/sed/sed-" version
140 ".tar.xz"))
141 (sha256
142 (base32
143 "0smxcx66vx29djzb542nxcynl7qnzxqa5032ibazi7x2s267d198"))))
144 (build-system gnu-build-system)
145 (synopsis "Stream editor")
146 (native-inputs
147 `(("perl" ,perl))) ;for tests
148 (description
149 "Sed is a non-interactive, text stream editor. It receives a text
150 input from a file or from standard input and it then applies a series of text
151 editing commands to the stream and prints its output to standard output. It
152 is often used for substituting text patterns in a stream. The GNU
153 implementation offers several extensions over the standard utility.")
154 (license gpl3+)
155 (home-page "https://www.gnu.org/software/sed/")))
156
157 (define-public tar
158 (package
159 (name "tar")
160 (version "1.32")
161 (source (origin
162 (method url-fetch)
163 (uri (string-append "mirror://gnu/tar/tar-"
164 version ".tar.xz"))
165 (sha256
166 (base32
167 "1n7xy657ii0sa42zx6944v2m4v9qrh6sqgmw17l3nch3y43sxlyh"))
168 (patches (search-patches "tar-skip-unreliable-tests.patch"
169 "tar-remove-wholesparse-check.patch"))))
170 (build-system gnu-build-system)
171 ;; Note: test suite requires ~1GiB of disk space.
172 (arguments
173 `(#:phases (modify-phases %standard-phases
174 (add-before 'build 'set-shell-file-name
175 (lambda* (#:key inputs #:allow-other-keys)
176 ;; Do not use "/bin/sh" to run programs.
177 (let ((bash (assoc-ref inputs "bash")))
178 (substitute* "src/system.c"
179 (("/bin/sh")
180 (string-append bash "/bin/sh")))
181 #t))))))
182
183 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
184 ;; to refer to the target Bash.
185 (inputs (if (%current-target-system)
186 `(("bash" ,bash))
187 '()))
188
189 (synopsis "Managing tar archives")
190 (description
191 "Tar provides the ability to create tar archives, as well as the
192 ability to extract, update or list files in an existing archive. It is
193 useful for combining many files into one larger file, while maintaining
194 directory structure and file information such as permissions and
195 creation/modification dates. GNU tar offers many extensions over the
196 standard utility.")
197 (license gpl3+)
198 (home-page "https://www.gnu.org/software/tar/")))
199
200 (define-public patch
201 (package
202 (name "patch")
203 (version "2.7.6")
204 (source (origin
205 (method url-fetch)
206 (uri (string-append "mirror://gnu/patch/patch-"
207 version ".tar.xz"))
208 (sha256
209 (base32
210 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
211 (patches (search-patches "patch-hurd-path-max.patch"))))
212 (build-system gnu-build-system)
213 (arguments
214 ;; Work around a cross-compilation bug whereby libpatch.a would provide
215 ;; '__mktime_internal', which conflicts with the one in libc.a.
216 (if (%current-target-system)
217 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
218 '()))
219 (native-inputs `(("ed" ,ed)))
220 (synopsis "Apply differences to originals, with optional backups")
221 (description
222 "Patch is a program that applies changes to files based on differences
223 laid out as by the program \"diff\". The changes may be applied to one or more
224 files depending on the contents of the diff file. It accepts several
225 different diff formats. It may also be used to revert previously applied
226 differences.")
227 (license gpl3+)
228 (home-page "https://savannah.gnu.org/projects/patch/")))
229
230 (define-public diffutils
231 (package
232 (name "diffutils")
233 (version "3.7")
234 (source (origin
235 (method url-fetch)
236 (uri (string-append "mirror://gnu/diffutils/diffutils-"
237 version ".tar.xz"))
238 (sha256
239 (base32
240 "09isrg0isjinv8c535nxsi1s86wfdfzml80dbw41dj9x3hiad9xk"))))
241 (build-system gnu-build-system)
242 (native-inputs `(("perl" ,perl)))
243 (synopsis "Comparing and merging files")
244 (description
245 "GNU Diffutils is a package containing tools for finding the
246 differences between files. The \"diff\" command is used to show how two files
247 differ, while \"cmp\" shows the offsets and line numbers where they differ.
248 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
249 interactive means to merge two files.")
250 (license gpl3+)
251 (home-page "https://www.gnu.org/software/diffutils/")))
252
253 (define-public findutils
254 (package
255 (name "findutils")
256 (version "4.6.0")
257 (source (origin
258 (method url-fetch)
259 (uri (string-append "mirror://gnu/findutils/findutils-"
260 version ".tar.gz"))
261 (sha256
262 (base32
263 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
264 (patches (search-patches
265 "findutils-gnulib-libio.patch"
266 "findutils-localstatedir.patch"
267 "findutils-makedev.patch"
268 "findutils-test-xargs.patch"))
269 (modules '((guix build utils)))
270 (snippet
271 '(begin
272 ;; The gnulib test-lock test is prone to writer starvation
273 ;; with our glibc@2.25, which prefers readers, so disable it.
274 ;; The gnulib commit b20e8afb0b2 should fix this once
275 ;; incorporated here.
276 (substitute* "tests/Makefile.in"
277 (("test-lock\\$\\(EXEEXT\\) ") ""))
278 #t))))
279 (build-system gnu-build-system)
280 (arguments
281 `(#:configure-flags (list
282 ;; Tell 'updatedb' to write to /var.
283 "--localstatedir=/var"
284
285 ;; Work around cross-compilation failure. See
286 ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
287 ,@(if (%current-target-system)
288 '("gl_cv_func_wcwidth_works=yes")
289 '()))))
290 (synopsis "Operating on files matching given criteria")
291 (description
292 "Findutils supplies the basic file directory searching utilities of the
293 GNU system. It consists of two primary searching utilities: \"find\"
294 recursively searches for files in a directory according to given criteria and
295 \"locate\" lists files in a database that match a query. Two auxiliary tools
296 are included: \"updatedb\" updates the file name database and \"xargs\" may be
297 used to apply commands with arbitrarily long arguments.")
298 (license gpl3+)
299 (home-page "https://www.gnu.org/software/findutils/")))
300
301 (define-public coreutils
302 (package
303 (name "coreutils")
304 (version "8.31")
305 (source (origin
306 (method url-fetch)
307 (uri (string-append "mirror://gnu/coreutils/coreutils-"
308 version ".tar.xz"))
309 (sha256
310 (base32
311 "1zg9m79x1i2nifj4kb0waf9x3i5h6ydkypkjnbsb9rnwis8rqypz"))))
312 (build-system gnu-build-system)
313 (inputs `(("acl" ,acl) ; TODO: add SELinux
314 ("gmp" ,gmp) ;bignums in 'expr', yay!
315
316 ;; Drop the dependency on libcap when cross-compiling since it's
317 ;; not quite cross-compilable.
318 ,@(if (%current-target-system)
319 '()
320 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
321 (native-inputs
322 ;; Perl is needed to run tests in native builds, and to run the bundled
323 ;; copy of help2man. However, don't pass it when cross-compiling since
324 ;; that would lead it to try to run programs to get their '--help' output
325 ;; for help2man.
326 (if (%current-target-system)
327 '()
328 `(("perl" ,perl))))
329 (outputs '("out" "debug"))
330 (arguments
331 `(#:parallel-build? #f ; help2man may be called too early
332 #:phases (modify-phases %standard-phases
333 (add-before 'build 'patch-shell-references
334 (lambda _
335 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
336 ;; that tests pass, since /bin/sh isn't in the chroot.
337 (setenv "SHELL" (which "sh"))
338
339 (substitute* (find-files "gnulib-tests" "\\.c$")
340 (("/bin/sh") (which "sh")))
341 (substitute* (find-files "tests" "\\.sh$")
342 (("#!/bin/sh") (string-append "#!" (which "sh"))))
343 #t))
344 (add-before 'check 'disable-broken-test
345 (lambda _
346 ;; This test hits the 127 character shebang limit in the build
347 ;; environment due to the way "env -S" splits arguments into
348 ;; shebangs. Note that "env-S-script.sh" works around this
349 ;; specific issue, but "env-S.pl" is not adjusted for build
350 ;; environments with long prefixes (/tmp/guix-build-...).
351 (substitute* "Makefile"
352 (("^.*tests/misc/env-S.pl.*$") ""))
353 #t)))))
354 (synopsis "Core GNU utilities (file, text, shell)")
355 (description
356 "GNU Coreutils includes all of the basic command-line tools that are
357 expected in a POSIX system. These provide the basic file, shell and text
358 manipulation functions of the GNU system. Most of these tools offer extended
359 functionality beyond that which is outlined in the POSIX standard.")
360 (license gpl3+)
361 (home-page "https://www.gnu.org/software/coreutils/")))
362
363 (define-public coreutils-minimal
364 ;; Coreutils without its optional dependencies.
365 (package
366 (inherit coreutils)
367 (name "coreutils-minimal")
368 (outputs '("out"))
369 (inputs '())))
370
371 (define-public gnu-make
372 (package
373 (name "make")
374 (version "4.2.1")
375 (source (origin
376 (method url-fetch)
377 (uri (string-append "mirror://gnu/make/make-" version
378 ".tar.bz2"))
379 (sha256
380 (base32
381 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
382 (patches (search-patches "make-impure-dirs.patch"
383 "make-glibc-compat.patch"))))
384 (build-system gnu-build-system)
385 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
386 (inputs `(("guile" ,guile-2.0)))
387 (outputs '("out" "debug"))
388 (arguments
389 '(;; Work around faulty glob detection with glibc 2.27. See
390 ;; <https://lists.nongnu.org/archive/html/bug-make/2017-11/msg00027.html>.
391 #:configure-flags '("make_cv_sys_gnu_glob=yes")
392 #:phases
393 (modify-phases %standard-phases
394 (add-before 'build 'set-default-shell
395 (lambda* (#:key inputs #:allow-other-keys)
396 ;; Change the default shell from /bin/sh.
397 (let ((bash (assoc-ref inputs "bash")))
398 (substitute* "job.c"
399 (("default_shell =.*$")
400 (format #f "default_shell = \"~a/bin/sh\";\n"
401 bash)))
402 #t))))))
403 (synopsis "Remake files automatically")
404 (description
405 "Make is a program that is used to control the production of
406 executables or other files from their source files. The process is
407 controlled from a Makefile, in which the developer specifies how each file is
408 generated from its source. It has powerful dependency resolution and the
409 ability to determine when files have to be regenerated after their sources
410 change. GNU make offers many powerful extensions over the standard utility.")
411 (license gpl3+)
412 (home-page "https://www.gnu.org/software/make/")))
413
414 (define-public binutils
415 (package
416 (name "binutils")
417 (version "2.32")
418 (source (origin
419 (method url-fetch)
420 (uri (string-append "mirror://gnu/binutils/binutils-"
421 version ".tar.bz2"))
422 (sha256
423 (base32
424 "0b8767nyal1bc4cyzg5h9iis8kpkln1i3wkamig75cifj1fb2f6y"))
425 (patches (search-patches "binutils-loongson-workaround.patch"))))
426 (build-system gnu-build-system)
427
428 ;; TODO: Add dependency on zlib + those for Gold.
429 (arguments
430 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
431 ;; on GCC when bootstrapping.
432 "LDFLAGS=-static-libgcc"
433
434 ;; Turn on --enable-new-dtags by default to make the
435 ;; linker set RUNPATH instead of RPATH on binaries.
436 ;; This is important because RUNPATH can be overriden
437 ;; using LD_LIBRARY_PATH at runtime.
438 "--enable-new-dtags"
439
440 ;; Don't search under /usr/lib & co.
441 "--with-lib-path=/no-ld-lib-path"
442
443 ;; Install BFD. It ends up in a hidden directory,
444 ;; but it's here.
445 "--enable-install-libbfd"
446
447 ;; Make sure 'ar' and 'ranlib' produce archives in a
448 ;; deterministic fashion.
449 "--enable-deterministic-archives")))
450
451 (synopsis "Binary utilities: bfd gas gprof ld")
452 (description
453 "GNU Binutils is a collection of tools for working with binary files.
454 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
455 Other tools include programs to display binary profiling information, list
456 the strings in a binary file, and utilities for working with archives. The
457 \"bfd\" library for working with executable and object formats is also
458 included.")
459 (license gpl3+)
460 (home-page "https://www.gnu.org/software/binutils/")))
461
462 (define-public binutils-gold
463 (package
464 (inherit binutils)
465 (name "binutils-gold")
466 (arguments
467 `(#:phases
468 (modify-phases %standard-phases
469 (add-after 'patch-source-shebangs 'patch-more-shebangs
470 (lambda _
471 (substitute* "gold/Makefile.in"
472 (("/bin/sh") (which "sh")))
473 #t)))
474 ,@(substitute-keyword-arguments (package-arguments binutils)
475 ; Upstream is aware of unrelocatable test failures on arm*.
476 ((#:tests? _ #f)
477 (if (any (cute string-prefix? <> (or (%current-target-system)
478 (%current-system)))
479 '("i686" "x86_64"))
480 '#t '#f))
481 ((#:configure-flags flags)
482 `(cons* "--enable-gold=default"
483 (delete "LDFLAGS=-static-libgcc" ,flags))))))
484 (native-inputs
485 `(("bc" ,bc)))
486 (inputs
487 `(("gcc:lib" ,gcc "lib")))))
488
489 (define* (make-ld-wrapper name #:key
490 (target (const #f))
491 binutils
492 (guile (canonical-package guile-2.2))
493 (bash (canonical-package bash))
494 (guile-for-build guile))
495 "Return a package called NAME that contains a wrapper for the 'ld' program
496 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
497 wrapper uses GUILE and BASH.
498
499 TARGET must be a one-argument procedure that, given a system type, returns a
500 cross-compilation target triplet or #f. When the result is not #f, make a
501 wrapper for the cross-linker for that target, called 'TARGET-ld'."
502 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
503 ;; its result can be delayed until the 'arguments' field is evaluated, thus
504 ;; in a context where '%current-system' is accurate.
505 (package
506 (name name)
507 (version "0")
508 (source #f)
509 (build-system trivial-build-system)
510 (inputs `(("binutils" ,binutils)
511 ("guile" ,guile)
512 ("bash" ,bash)
513 ("wrapper" ,(search-path %load-path
514 "gnu/packages/ld-wrapper.in"))))
515 (arguments
516 (let ((target (target (%current-system))))
517 `(#:guile ,guile-for-build
518 #:modules ((guix build utils))
519 #:builder (begin
520 (use-modules (guix build utils)
521 (system base compile))
522
523 (let* ((out (assoc-ref %outputs "out"))
524 (bin (string-append out "/bin"))
525 (ld ,(if target
526 `(string-append bin "/" ,target "-ld")
527 '(string-append bin "/ld")))
528 (go (string-append ld ".go")))
529
530 (setvbuf (current-output-port) _IOLBF)
531 (format #t "building ~s/bin/ld wrapper in ~s~%"
532 (assoc-ref %build-inputs "binutils")
533 out)
534
535 (mkdir-p bin)
536 (copy-file (assoc-ref %build-inputs "wrapper") ld)
537 (substitute* ld
538 (("@SELF@")
539 ld)
540 (("@GUILE@")
541 (string-append (assoc-ref %build-inputs "guile")
542 "/bin/guile"))
543 (("@BASH@")
544 (string-append (assoc-ref %build-inputs "bash")
545 "/bin/bash"))
546 (("@LD@")
547 (string-append (assoc-ref %build-inputs "binutils")
548 ,(if target
549 (string-append "/bin/"
550 target "-ld")
551 "/bin/ld"))))
552 (chmod ld #o555)
553 (compile-file ld #:output-file go)
554 #t)))))
555 (synopsis "The linker wrapper")
556 (description
557 "The linker wrapper (or @code{ld-wrapper}) wraps the linker to add any
558 missing @code{-rpath} flags, and to detect any misuse of libraries outside of
559 the store.")
560 (home-page "https://www.gnu.org/software/guix//")
561 (license gpl3+)))
562
563 (export make-ld-wrapper)
564
565 (define-public glibc
566 ;; This is the GNU C Library, used on GNU/Linux and GNU/Hurd. Prior to
567 ;; version 2.28, GNU/Hurd used a different glibc branch.
568 (package
569 (name "glibc")
570 (version "2.29")
571 (source (origin
572 (method url-fetch)
573 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
574 (sha256
575 (base32
576 "0jzh58728flfh939a8k9pi1zdyalfzlxmwra7k0rzji5gvavivpk"))
577 (snippet
578 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
579 ;; required on LFS distros to avoid loading the distro's libc.so
580 ;; instead of ours.
581 '(begin
582 (substitute* "sysdeps/unix/sysv/linux/configure"
583 (("use_ldconfig=yes")
584 "use_ldconfig=no"))
585 #t))
586 (modules '((guix build utils)))
587 (patches (search-patches "glibc-ldd-x86_64.patch"
588 "glibc-CVE-2019-7309.patch"
589 "glibc-CVE-2019-9169.patch"
590 "glibc-2.29-git-updates.patch"
591 "glibc-hidden-visibility-ldconfig.patch"
592 "glibc-versioned-locpath.patch"
593 "glibc-allow-kernel-2.6.32.patch"
594 "glibc-reinstate-prlimit64-fallback.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 ("python" ,python-minimal)
793
794 ,@(if (hurd-target?)
795 `(("mig" ,mig)
796 ("perl" ,perl))
797 '())))
798
799 (native-search-paths
800 ;; Search path for packages that provide locale data. This is useful
801 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
802 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
803 ;; distros.
804 (list (search-path-specification
805 (variable "GUIX_LOCPATH")
806 (files '("lib/locale")))))
807
808 (synopsis "The GNU C Library")
809 (description
810 "Any Unix-like operating system needs a C library: the library which
811 defines the \"system calls\" and other basic facilities such as open, malloc,
812 printf, exit...
813
814 The GNU C library is used as the C library in the GNU system and most systems
815 with the Linux kernel.")
816 (license lgpl2.0+)
817 (home-page "https://www.gnu.org/software/libc/")))
818
819 ;; Below are old libc versions, which we use mostly to build locale data in
820 ;; the old format (which the new libc cannot cope with.)
821
822 (define-public glibc-2.28
823 (package
824 (inherit glibc)
825 (version "2.28")
826 (source (origin
827 (inherit (package-source glibc))
828 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
829 (sha256
830 (base32
831 "10iha5ynvdj5m62vgpgqbq4cwvc2yhyl2w9yyyjgfxmdmx8h145i"))
832 (patches (search-patches "glibc-ldd-x86_64.patch"
833 "glibc-2.28-git-fixes.patch"
834 "glibc-hidden-visibility-ldconfig.patch"
835 "glibc-versioned-locpath.patch"
836 "glibc-allow-kernel-2.6.32.patch"
837 "glibc-reinstate-prlimit64-fallback.patch"
838 "glibc-hurd-magic-pid.patch"
839 "glibc-2.28-supported-locales.patch"))))))
840
841 (define-public glibc-2.27
842 (package
843 (inherit glibc)
844 (version "2.27")
845 (source (origin
846 (inherit (package-source glibc))
847 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
848 (sha256
849 (base32
850 "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"))
851 (patches (search-patches "glibc-ldd-x86_64.patch"
852 "glibc-2.27-git-fixes.patch"
853 "glibc-hidden-visibility-ldconfig.patch"
854 "glibc-versioned-locpath.patch"
855 "glibc-allow-kernel-2.6.32.patch"
856 "glibc-reinstate-prlimit64-fallback.patch"
857 "glibc-2.27-supported-locales.patch"
858 "glibc-CVE-2018-11236.patch"
859 "glibc-CVE-2018-11237.patch"))))
860 (properties `((lint-hidden-cve . ("CVE-2017-18269")))))) ; glibc-2.27-git-fixes
861
862 (define-public glibc-2.26
863 (package
864 (inherit glibc)
865 ;; This version number corresponds to the output of `git describe` and the
866 ;; archive can be generated by checking out the commit ID and running:
867 ;; git archive --prefix=$(git describe)/ HEAD | xz > $(git describe).tar.xz
868 ;; See <https://bugs.gnu.org/29406> for why this was necessary.
869 (version "2.26.105-g0890d5379c")
870 (source (origin
871 (inherit (package-source glibc))
872 (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/"
873 "glibc-" (version-major+minor version) "-"
874 (caddr (string-split version #\.)) ".tar.xz"))
875 (sha256
876 (base32
877 "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
878 (patches (search-patches "glibc-ldd-x86_64.patch"
879 "glibc-versioned-locpath.patch"
880 "glibc-allow-kernel-2.6.32.patch"))))))
881
882 (define-public glibc-2.25
883 (package
884 (inherit glibc)
885 (version "2.25")
886 (source (origin
887 (inherit (package-source glibc))
888 (uri (string-append "mirror://gnu/glibc/glibc-"
889 version ".tar.xz"))
890 (sha256
891 (base32
892 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
893 (patches (search-patches "glibc-ldd-x86_64.patch"
894 "glibc-versioned-locpath.patch"
895 "glibc-vectorized-strcspn-guards.patch"
896 "glibc-CVE-2017-1000366-pt1.patch"
897 "glibc-CVE-2017-1000366-pt2.patch"
898 "glibc-CVE-2017-1000366-pt3.patch"))))))
899
900 (define-public glibc-2.24
901 (package
902 (inherit glibc)
903 (version "2.24")
904 (source (origin
905 (inherit (package-source glibc))
906 (uri (string-append "mirror://gnu/glibc/glibc-"
907 version ".tar.xz"))
908 (sha256
909 (base32
910 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
911 (patches (search-patches "glibc-ldd-x86_64.patch"
912 "glibc-versioned-locpath.patch"
913 "glibc-vectorized-strcspn-guards.patch"
914 "glibc-CVE-2015-5180.patch"
915 "glibc-CVE-2017-1000366-pt1.patch"
916 "glibc-CVE-2017-1000366-pt2.patch"
917 "glibc-CVE-2017-1000366-pt3.patch"))))))
918
919 (define-public glibc-2.23
920 (package
921 (inherit glibc)
922 (version "2.23")
923 (source (origin
924 (inherit (package-source glibc))
925 (uri (string-append "mirror://gnu/glibc/glibc-"
926 version ".tar.xz"))
927 (sha256
928 (base32
929 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
930 (patches (search-patches "glibc-ldd-x86_64.patch"
931 "glibc-versioned-locpath.patch"
932 "glibc-vectorized-strcspn-guards.patch"
933 "glibc-CVE-2015-5180.patch"
934 "glibc-CVE-2016-3075.patch"
935 "glibc-CVE-2016-3706.patch"
936 "glibc-CVE-2016-4429.patch"
937 "glibc-CVE-2017-1000366-pt1.patch"
938 "glibc-CVE-2017-1000366-pt2.patch"
939 "glibc-CVE-2017-1000366-pt3.patch"))))))
940
941 (define-public glibc-2.22
942 (package
943 (inherit glibc)
944 (version "2.22")
945 (source (origin
946 (inherit (package-source glibc))
947 (uri (string-append "mirror://gnu/glibc/glibc-"
948 version ".tar.xz"))
949 (sha256
950 (base32
951 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
952 (patches (search-patches "glibc-ldd-x86_64.patch"
953 "glibc-o-largefile.patch"
954 "glibc-vectorized-strcspn-guards.patch"
955 "glibc-CVE-2015-5180.patch"
956 "glibc-CVE-2015-7547.patch"
957 "glibc-CVE-2016-3075.patch"
958 "glibc-CVE-2016-3706.patch"
959 "glibc-CVE-2016-4429.patch"
960 "glibc-CVE-2017-1000366-pt1.patch"
961 "glibc-CVE-2017-1000366-pt2.patch"
962 "glibc-CVE-2017-1000366-pt3.patch"))))
963 (arguments
964 (substitute-keyword-arguments (package-arguments glibc)
965 ((#:phases phases)
966 `(modify-phases ,phases
967 (add-before 'configure 'fix-pwd
968 (lambda _
969 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
970 (substitute* "configure"
971 (("/bin/pwd") "pwd"))
972 #t))))))))
973
974 (define-public (make-gcc-libc base-gcc libc)
975 "Return a GCC that targets LIBC."
976 (package (inherit base-gcc)
977 (name (string-append (package-name base-gcc) "-"
978 (package-name libc) "-"
979 (package-version libc)))
980 (arguments
981 (substitute-keyword-arguments
982 (ensure-keyword-arguments (package-arguments base-gcc)
983 '(#:implicit-inputs? #f))
984 ((#:make-flags flags)
985 `(let ((libc (assoc-ref %build-inputs "libc")))
986 ;; FLAGS_FOR_TARGET are needed for the target libraries to receive
987 ;; the -Bxxx for the startfiles.
988 (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib")
989 ,flags)))))
990 (native-inputs
991 `(("libc" ,libc)
992 ("libc:static" ,libc "static")
993 ,@(append (package-inputs base-gcc)
994 (fold alist-delete (%final-inputs) '("libc" "libc:static")))))
995 (inputs '())))
996
997 (define-public (make-glibc-locales glibc)
998 (package
999 (inherit glibc)
1000 (name "glibc-locales")
1001 (source (origin (inherit (package-source glibc))
1002 ;; The patch for glibc 2.28 and earlier replaces the same
1003 ;; content, but the context in the patch is different
1004 ;; enough to fail to merge.
1005 (patches (cons (search-patch
1006 (if (version>=? (package-version glibc)
1007 "2.29")
1008 "glibc-locales.patch"
1009 "glibc-locales-2.28.patch"))
1010 (origin-patches (package-source glibc))))))
1011 (synopsis "All the locales supported by the GNU C Library")
1012 (description
1013 "This package provides all the locales supported by the GNU C Library,
1014 more than 400 in total. To use them set the @code{LOCPATH} environment variable
1015 to the @code{share/locale} sub-directory of this package.")
1016 (outputs '("out")) ;110+ MiB
1017 (native-search-paths '())
1018 (arguments
1019 (let ((args `(#:tests? #f #:strip-binaries? #f
1020 ,@(package-arguments glibc))))
1021 (substitute-keyword-arguments args
1022 ((#:modules modules '((guix build utils)
1023 (guix build gnu-build-system)))
1024 `((srfi srfi-11)
1025 (gnu build locale)
1026 ,@modules))
1027 ((#:imported-modules modules '())
1028 `((gnu build locale)
1029 ,@%gnu-build-system-modules))
1030 ((#:phases phases)
1031 `(modify-phases ,phases
1032 (replace 'build
1033 (lambda _
1034 (invoke "make" "localedata/install-locales"
1035 "-j" (number->string (parallel-job-count)))))
1036 (add-after 'build 'symlink-normalized-codesets
1037 (lambda* (#:key outputs #:allow-other-keys)
1038 ;; The above phase does not install locales with names using
1039 ;; the "normalized codeset." Thus, create symlinks like:
1040 ;; en_US.utf8 -> en_US.UTF-8
1041 (define (locale-directory? file stat)
1042 (and (file-is-directory? file)
1043 (string-index (basename file) #\_)
1044 (string-rindex (basename file) #\.)))
1045
1046 (let* ((out (assoc-ref outputs "out"))
1047 (locales (find-files out locale-directory?
1048 #:directories? #t)))
1049 (for-each (lambda (directory)
1050 (let*-values (((base)
1051 (basename directory))
1052 ((name codeset)
1053 (locale->name+codeset base))
1054 ((normalized)
1055 (normalize-codeset codeset)))
1056 (unless (string=? codeset normalized)
1057 (symlink base
1058 (string-append (dirname directory)
1059 "/" name "."
1060 normalized)))))
1061 locales)
1062 #t)))
1063 (delete 'install)
1064 (delete 'move-static-libs)))
1065 ((#:configure-flags flags)
1066 `(append ,flags
1067 ;; Use $(libdir)/locale/X.Y as is the case by default.
1068 (list (string-append "libc_cv_complocaledir="
1069 (assoc-ref %outputs "out")
1070 "/lib/locale/"
1071 ,(version-major+minor
1072 (package-version glibc)))))))))))
1073
1074 (define-public (make-glibc-utf8-locales glibc)
1075 (package
1076 (name "glibc-utf8-locales")
1077 (version (package-version glibc))
1078 (source #f)
1079 (build-system trivial-build-system)
1080 (arguments
1081 `(#:modules ((guix build utils))
1082 #:builder (begin
1083 (use-modules (guix build utils))
1084
1085 (let* ((libc (assoc-ref %build-inputs "glibc"))
1086 (gzip (assoc-ref %build-inputs "gzip"))
1087 (out (assoc-ref %outputs "out"))
1088 (localedir (string-append out "/lib/locale/"
1089 ,(version-major+minor version))))
1090 ;; 'localedef' needs 'gzip'.
1091 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1092
1093 (mkdir-p localedir)
1094 (for-each (lambda (locale)
1095 (define file
1096 ;; Use the "normalized codeset" by
1097 ;; default--e.g., "en_US.utf8".
1098 (string-append localedir "/" locale ".utf8"))
1099
1100 (invoke "localedef" "--no-archive"
1101 "--prefix" localedir
1102 "-i" locale
1103 "-f" "UTF-8" file)
1104
1105 ;; For backward compatibility with Guix
1106 ;; <= 0.8.3, add "xx_YY.UTF-8".
1107 (symlink (string-append locale ".utf8")
1108 (string-append localedir "/"
1109 locale ".UTF-8")))
1110
1111 ;; These are the locales commonly used for
1112 ;; tests---e.g., in Guile's i18n tests.
1113 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
1114 #t))))
1115 (native-inputs `(("glibc" ,glibc)
1116 ("gzip" ,gzip)))
1117 (synopsis "Small sample of UTF-8 locales")
1118 (description
1119 "This package provides a small sample of UTF-8 locales mostly useful in
1120 test environments.")
1121 (home-page (package-home-page glibc))
1122 (license (package-license glibc))))
1123
1124 (define-public glibc-locales
1125 (make-glibc-locales glibc))
1126 (define-public glibc-utf8-locales
1127 (make-glibc-utf8-locales glibc))
1128
1129 ;; Packages provided to ease use of binaries linked against the previous libc.
1130 (define-public glibc-locales-2.28
1131 (package (inherit (make-glibc-locales glibc-2.28))
1132 (name "glibc-locales-2.28")))
1133 (define-public glibc-utf8-locales-2.28
1134 (package (inherit (make-glibc-utf8-locales glibc-2.28))
1135 (name "glibc-utf8-locales-2.28")))
1136
1137 ;; These should no longer be needed.
1138 (define-public glibc-utf8-locales-2.27
1139 (deprecated-package "glibc-utf8-locales-2.27" glibc-utf8-locales-2.28))
1140 (define-public glibc-locales-2.27
1141 (deprecated-package "glibc-locales-2.27" glibc-locales-2.28))
1142
1143 (define-public which
1144 (package
1145 (name "which")
1146 (version "2.21")
1147 (source (origin
1148 (method url-fetch)
1149 (uri (string-append "mirror://gnu/which/which-"
1150 version ".tar.gz"))
1151 (sha256
1152 (base32
1153 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1154 (build-system gnu-build-system)
1155 (home-page "https://gnu.org/software/which/")
1156 (synopsis "Find full path of shell commands")
1157 (description
1158 "The which program finds the location of executables in PATH, with a
1159 variety of options. It is an alternative to the shell \"type\" built-in
1160 command.")
1161 (license gpl3+))) ; some files are under GPLv2+
1162
1163 (define-public glibc/hurd-headers
1164 (package (inherit glibc)
1165 (name "glibc-hurd-headers")
1166 (outputs '("out"))
1167 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1168 ("hurd-headers" ,hurd-headers)))
1169 (arguments
1170 (substitute-keyword-arguments (package-arguments glibc)
1171 ;; We just pass the flags really needed to build the headers.
1172 ((#:configure-flags _)
1173 `(list "--enable-add-ons"
1174 "--host=i586-pc-gnu"))
1175 ((#:phases _)
1176 '(modify-phases %standard-phases
1177 (replace 'install
1178 (lambda* (#:key outputs #:allow-other-keys)
1179 (invoke "make" "install-headers")
1180
1181 ;; Make an empty stubs.h to work around not being able to
1182 ;; produce a valid stubs.h and causing the build to fail. See
1183 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1184 (let ((out (assoc-ref outputs "out")))
1185 (close-port
1186 (open-output-file
1187 (string-append out "/include/gnu/stubs.h"))))
1188 #t))
1189 (delete 'build))))))) ; nothing to build
1190
1191 (define-public tzdata
1192 (package
1193 (name "tzdata")
1194 (version "2019c")
1195 (source (origin
1196 (method url-fetch)
1197 (uri (string-append
1198 "https://data.iana.org/time-zones/releases/tzdata"
1199 version ".tar.gz"))
1200 (sha256
1201 (base32
1202 "0z7w1yv37cfk8yhix2cillam091vgp1j4g8fv84261q9mdnq1ivr"))))
1203 (build-system gnu-build-system)
1204 (arguments
1205 '(#:tests? #f
1206 #:make-flags (let ((out (assoc-ref %outputs "out"))
1207 (tmp (getenv "TMPDIR")))
1208 (list (string-append "TOPDIR=" out)
1209 (string-append "TZDIR=" out "/share/zoneinfo")
1210 (string-append "TZDEFAULT=" out
1211 "/share/zoneinfo/localtime")
1212
1213 ;; Likewise for the C library routines.
1214 (string-append "LIBDIR=" tmp "/lib")
1215 (string-append "MANDIR=" tmp "/man")
1216
1217 "AWK=awk"
1218 "CC=gcc"))
1219 #:modules ((guix build utils)
1220 (guix build gnu-build-system)
1221 (srfi srfi-1))
1222 #:phases
1223 (modify-phases %standard-phases
1224 (replace 'unpack
1225 (lambda* (#:key source inputs #:allow-other-keys)
1226 (invoke "tar" "xvf" source)
1227 (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
1228 (add-after 'install 'post-install
1229 (lambda* (#:key outputs #:allow-other-keys)
1230 ;; Move data in the right place.
1231 (let ((out (assoc-ref outputs "out")))
1232 ;; Discard zic, dump, and tzselect, already
1233 ;; provided by glibc.
1234 (delete-file-recursively (string-append out "/usr"))
1235 (symlink (string-append out "/share/zoneinfo")
1236 (string-append out "/share/zoneinfo/posix"))
1237 (delete-file-recursively
1238 (string-append out "/share/zoneinfo-posix"))
1239 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1240 (string-append out "/share/zoneinfo/right"))
1241 (delete-file-recursively
1242 (string-append out "/share/zoneinfo-leaps"))
1243 #t)))
1244 (delete 'configure))))
1245 (inputs `(("tzcode" ,(origin
1246 (method url-fetch)
1247 (uri (string-append
1248 "https://data.iana.org/time-zones/releases/tzcode"
1249 version ".tar.gz"))
1250 (sha256
1251 (base32
1252 "1m3y2rnf1nggxxhxplab5zdd5whvar3ijyrv7lifvm82irkd7szn"))))))
1253 (home-page "https://www.iana.org/time-zones")
1254 (synopsis "Database of current and historical time zones")
1255 (description "The Time Zone Database (often called tz or zoneinfo)
1256 contains code and data that represent the history of local time for many
1257 representative locations around the globe. It is updated periodically to
1258 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1259 and daylight-saving rules.")
1260 (license public-domain)))
1261
1262 ;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1263 ;;; and a few other places. We can update this whenever we are able to rebuild
1264 ;;; thousands of packages (for example, in a core-updates rebuild). This package
1265 ;;; will typically be obsolete and should never be referred to by a built
1266 ;;; package.
1267 (define-public tzdata-for-tests
1268 (hidden-package
1269 (package
1270 (inherit tzdata)
1271 (version "2019b")
1272 (source (origin
1273 (method url-fetch)
1274 (uri (string-append
1275 "https://data.iana.org/time-zones/releases/tzdata"
1276 version ".tar.gz"))
1277 (sha256
1278 (base32
1279 "0r0clnlslwm15m1c61dinf1fi9ffgl6aipng7i7yryfwj0n0kn85"))))
1280 (inputs
1281 `(("tzcode" ,(origin
1282 (method url-fetch)
1283 (uri (string-append
1284 "https://data.iana.org/time-zones/releases/tzcode"
1285 version ".tar.gz"))
1286 (sha256
1287 (base32
1288 "0vbmswvv3li25s31shyllq5v24449lxnrki9hr043nipjd09sirf")))))))))
1289
1290 (define-public libiconv
1291 (package
1292 (name "libiconv")
1293 (version "1.15")
1294 (source (origin
1295 (method url-fetch)
1296 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1297 version ".tar.gz"))
1298 (sha256
1299 (base32
1300 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1301 (modules '((guix build utils)))
1302 (snippet
1303 ;; Work around "declared gets" error on glibc systems (fixed by
1304 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1305 '(begin
1306 (substitute* "srclib/stdio.in.h"
1307 (("^#undef gets") "")
1308 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1309 #t))))
1310 (build-system gnu-build-system)
1311 (synopsis "Character set conversion library")
1312 (description
1313 "libiconv provides an implementation of the iconv function for systems
1314 that lack it. iconv is used to convert between character encodings in a
1315 program. It supports a wide variety of different encodings.")
1316 (home-page "https://www.gnu.org/software/libiconv/")
1317 (license lgpl3+)))
1318
1319 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1320 "Return either a libiconv package specification to include in a dependency
1321 list for platforms that have an incomplete libc, or the empty list. If a
1322 package needs iconv ,@(libiconv-if-needed) should be added."
1323 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1324 ;; without iconv, such as MinGW, must return the then clause.
1325 (if (target-mingw? target)
1326 `(("libiconv" ,libiconv))
1327 '()))
1328
1329 (define-public (canonical-package package)
1330 ;; Avoid circular dependency by lazily resolving 'commencement'.
1331 (let* ((iface (resolve-interface '(gnu packages commencement)))
1332 (proc (module-ref iface 'canonical-package)))
1333 (proc package)))
1334
1335 (define-public (%final-inputs)
1336 "Return the list of \"final inputs\"."
1337 ;; Avoid circular dependency by lazily resolving 'commencement'.
1338 (let ((iface (resolve-interface '(gnu packages commencement))))
1339 (module-ref iface '%final-inputs)))
1340
1341 ;;; base.scm ends here