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