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