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