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