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