Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / base.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016 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 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 Efraim Flashner <efraim@flashner.co.il>
9 ;;;
10 ;;; This file is part of GNU Guix.
11 ;;;
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
16 ;;;
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
21 ;;;
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24
25 (define-module (gnu packages base)
26 #:use-module ((guix licenses)
27 #:select (gpl3+ lgpl2.0+ public-domain))
28 #:use-module (gnu packages)
29 #:use-module (gnu packages acl)
30 #:use-module (gnu packages bash)
31 #:use-module (gnu packages ed)
32 #:use-module (gnu packages guile)
33 #:use-module (gnu packages multiprecision)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages perl)
36 #:use-module (gnu packages linux)
37 #:use-module (gnu packages texinfo)
38 #:use-module (gnu packages hurd)
39 #:use-module (gnu packages pkg-config)
40 #:use-module (gnu packages gettext)
41 #:use-module (guix utils)
42 #:use-module (guix packages)
43 #:use-module (guix download)
44 #:use-module (guix git-download)
45 #:use-module (guix build-system gnu)
46 #:use-module (guix build-system trivial))
47
48 ;;; Commentary:
49 ;;;
50 ;;; Base packages of the Guix-based GNU user-land software distribution.
51 ;;;
52 ;;; Code:
53
54 (define-public hello
55 (package
56 (name "hello")
57 (version "2.10")
58 (source (origin
59 (method url-fetch)
60 (uri (string-append "mirror://gnu/hello/hello-" version
61 ".tar.gz"))
62 (sha256
63 (base32
64 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
65 (build-system gnu-build-system)
66 (synopsis "Hello, GNU world: An example GNU package")
67 (description
68 "GNU Hello prints the message \"Hello, world!\" and then exits. It
69 serves as an example of standard GNU coding practices. As such, it supports
70 command-line arguments, multiple languages, and so on.")
71 (home-page "http://www.gnu.org/software/hello/")
72 (license gpl3+)))
73
74 (define-public grep
75 (package
76 (name "grep")
77 (version "2.22")
78 (source (origin
79 (method url-fetch)
80 (uri (string-append "mirror://gnu/grep/grep-"
81 version ".tar.xz"))
82 (sha256
83 (base32
84 "1srn321x7whlhs5ks36zlcrrmj4iahll8fxwsh1vbz3v04px54fa"))
85 (patches
86 (list (search-patch "grep-timing-sensitive-test.patch")))))
87 (build-system gnu-build-system)
88 (native-inputs `(("perl" ,perl))) ;some of the tests require it
89 (synopsis "Print lines matching a pattern")
90 (description
91 "grep is a tool for finding text inside files. Text is found by
92 matching a pattern provided by the user in one or many files. The pattern
93 may be provided as a basic or extended regular expression, or as fixed
94 strings. By default, the matching text is simply printed to the screen,
95 however the output can be greatly customized to include, for example, line
96 numbers. GNU grep offers many extensions over the standard utility,
97 including, for example, recursive directory searching.")
98 (license gpl3+)
99 (home-page "http://www.gnu.org/software/grep/")))
100
101 (define-public sed
102 (package
103 (name "sed")
104 (version "4.2.2")
105 (source (origin
106 (method url-fetch)
107 (uri (string-append "mirror://gnu/sed/sed-" version
108 ".tar.bz2"))
109 (sha256
110 (base32
111 "1myvrmh99jsvk7v3d7crm0gcrq51hmmm1r2kjyyci152in1x2j7h"))
112 (patches (list (search-patch "sed-hurd-path-max.patch")))))
113 (build-system gnu-build-system)
114 (synopsis "Stream editor")
115 (arguments
116 (if (%current-target-system)
117 '()
118 `(#:phases (alist-cons-before
119 'patch-source-shebangs 'patch-test-suite
120 (lambda* (#:key inputs #:allow-other-keys)
121 (let ((bash (assoc-ref inputs "bash")))
122 (patch-makefile-SHELL "testsuite/Makefile.tests")
123 (substitute* '("testsuite/bsd.sh"
124 "testsuite/bug-regex9.c")
125 (("/bin/sh")
126 (string-append bash "/bin/bash")))))
127 %standard-phases))))
128 (description
129 "Sed is a non-interactive, text stream editor. It receives a text
130 input from a file or from standard input and it then applies a series of text
131 editing commands to the stream and prints its output to standard output. It
132 is often used for substituting text patterns in a stream. The GNU
133 implementation offers several extensions over the standard utility.")
134 (license gpl3+)
135 (home-page "http://www.gnu.org/software/sed/")))
136
137 (define-public tar
138 (package
139 (name "tar")
140 (version "1.28")
141 (source (origin
142 (method url-fetch)
143 (uri (string-append "mirror://gnu/tar/tar-"
144 version ".tar.xz"))
145 (sha256
146 (base32
147 "1wi2zwm4c9r3h3b8y4w0nm0qq897kn8kyj9k22ba0iqvxj48vvk4"))
148 (patches (map search-patch
149 '("tar-d_ino_in_dirent-fix.patch"
150 "tar-skip-unreliable-tests.patch")))))
151 (build-system gnu-build-system)
152 (synopsis "Managing tar archives")
153 (description
154 "Tar provides the ability to create tar archives, as well as the
155 ability to extract, update or list files in an existing archive. It is
156 useful for combining many files into one larger file, while maintaining
157 directory structure and file information such as permissions and
158 creation/modification dates. GNU tar offers many extensions over the
159 standard utility.")
160 (license gpl3+)
161 (home-page "http://www.gnu.org/software/tar/")))
162
163 (define-public patch
164 (package
165 (name "patch")
166 (version "2.7.5")
167 (source (origin
168 (method url-fetch)
169 (uri (string-append "mirror://gnu/patch/patch-"
170 version ".tar.xz"))
171 (sha256
172 (base32
173 "16d2r9kpivaak948mxzc0bai45mqfw73m113wrkmbffnalv1b5gx"))
174 (patches (list (search-patch "patch-hurd-path-max.patch")))))
175 (build-system gnu-build-system)
176 (native-inputs `(("ed", ed)))
177 (synopsis "Apply differences to originals, with optional backups")
178 (description
179 "Patch is a program that applies changes to files based on differences
180 laid out as by the program \"diff\". The changes may be applied to one or more
181 files depending on the contents of the diff file. It accepts several
182 different diff formats. It may also be used to revert previously applied
183 differences.")
184 (license gpl3+)
185 (home-page "http://savannah.gnu.org/projects/patch/")))
186
187 (define-public diffutils
188 (package
189 (name "diffutils")
190 (version "3.3")
191 (source (origin
192 (method url-fetch)
193 (uri (string-append "mirror://gnu/diffutils/diffutils-"
194 version ".tar.xz"))
195 (sha256
196 (base32
197 "1761vymxbp4wb5rzjvabhdkskk95pghnn67464byvzb5mfl8jpm2"))))
198 (build-system gnu-build-system)
199 (synopsis "Comparing and merging files")
200 (description
201 "GNU Diffutils is a package containing tools for finding the
202 differences between files. The \"diff\" command is used to show how two files
203 differ, while \"cmp\" shows the offsets and line numbers where they differ.
204 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
205 interactive means to merge two files.")
206 (license gpl3+)
207 (home-page "http://www.gnu.org/software/diffutils/")))
208
209 (define-public findutils
210 (package
211 (name "findutils")
212 (version "4.6.0")
213 (source (origin
214 (method url-fetch)
215 (uri (string-append "mirror://gnu/findutils/findutils-"
216 version ".tar.gz"))
217 (sha256
218 (base32
219 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
220 (patches (map search-patch
221 '("findutils-localstatedir.patch"
222 "findutils-test-xargs.patch")))))
223 (build-system gnu-build-system)
224 (arguments
225 `(#:configure-flags (list
226 ;; Tell 'updatedb' to write to /var.
227 "--localstatedir=/var"
228
229 ;; Work around cross-compilation failure. See
230 ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
231 ,@(if (%current-target-system)
232 '("gl_cv_func_wcwidth_works=yes")
233 '()))))
234 (synopsis "Operating on files matching given criteria")
235 (description
236 "Findutils supplies the basic file directory searching utilities of the
237 GNU system. It consists of two primary searching utilities: \"find\"
238 recursively searches for files in a directory according to given criteria and
239 \"locate\" lists files in a database that match a query. Two auxiliary tools
240 are included: \"updatedb\" updates the file name database and \"xargs\" may be
241 used to apply commands with arbitrarily long arguments.")
242 (license gpl3+)
243 (home-page "http://www.gnu.org/software/findutils/")))
244
245 (define-public coreutils
246 (package
247 (name "coreutils")
248 (version "8.24")
249 (source (origin
250 (method url-fetch)
251 (uri (string-append "mirror://gnu/coreutils/coreutils-"
252 version ".tar.xz"))
253 (sha256
254 (base32
255 "0w11jw3fb5sslf0f72kxy7llxgk1ia3a6bcw0c9kmvxrlj355mx2"))
256 (patches
257 (list (origin
258 (method url-fetch)
259 (uri "http://git.savannah.gnu.org/cgit/coreutils.git/\
260 patch/?id=3ba68f9e64fa2eb8af22d510437a0c6441feb5e0")
261 (sha256
262 (base32
263 "1dnlszhc8lihhg801i9sz896mlrgfsjfcz62636prb27k5hmixqz"))
264 (file-name "coreutils-tail-inotify-race.patch"))))))
265 (build-system gnu-build-system)
266 (inputs `(("acl" ,acl) ; TODO: add SELinux
267 ("gmp" ,gmp) ;bignums in 'expr', yay!
268
269 ;; Drop the dependency on libcap when cross-compiling since it's
270 ;; not quite cross-compilable.
271 ,@(if (%current-target-system)
272 '()
273 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
274 (native-inputs
275 ;; Perl is needed to run tests in native builds, and to run the bundled
276 ;; copy of help2man. However, don't pass it when cross-compiling since
277 ;; that would lead it to try to run programs to get their '--help' output
278 ;; for help2man.
279 (if (%current-target-system)
280 '()
281 `(("perl" ,perl))))
282 (outputs '("out" "debug"))
283 (arguments
284 `(#:parallel-build? #f ; help2man may be called too early
285 #:phases (alist-cons-before
286 'build 'patch-shell-references
287 (lambda* (#:key inputs #:allow-other-keys)
288 (let ((bash (assoc-ref inputs "bash")))
289 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
290 ;; that tests pass, since /bin/sh isn't in the chroot.
291 (setenv "SHELL" (which "sh"))
292
293 (substitute* (find-files "gnulib-tests" "\\.c$")
294 (("/bin/sh")
295 (format #f "~a/bin/sh" bash)))
296 (substitute* (find-files "tests" "\\.sh$")
297 (("#!/bin/sh")
298 (format #f "#!~a/bin/sh" bash)))))
299 %standard-phases)))
300 (synopsis "Core GNU utilities (file, text, shell)")
301 (description
302 "GNU Coreutils includes all of the basic command-line tools that are
303 expected in a POSIX system. These provide the basic file, shell and text
304 manipulation functions of the GNU system. Most of these tools offer extended
305 functionality beyond that which is outlined in the POSIX standard.")
306 (license gpl3+)
307 (home-page "http://www.gnu.org/software/coreutils/")))
308
309 (define-public coreutils-minimal
310 ;; Coreutils without its optional dependencies.
311 (package
312 (inherit coreutils)
313 (name "coreutils-minimal")
314 (outputs '("out"))
315 (inputs '())))
316
317 (define-public gnu-make
318 (package
319 (name "make")
320 (version "4.1")
321 (source (origin
322 (method url-fetch)
323 (uri (string-append "mirror://gnu/make/make-" version
324 ".tar.bz2"))
325 (sha256
326 (base32
327 "19gwwhik3wdwn0r42b7xcihkbxvjl9r2bdal8nifc3k5i4rn3iqb"))
328 (patches (list (search-patch "make-impure-dirs.patch")))))
329 (build-system gnu-build-system)
330 (native-inputs `(("pkg-config", pkg-config))) ; to detect Guile
331 (inputs `(("guile" ,guile-2.0)))
332 (outputs '("out" "debug"))
333 (arguments
334 '(#:phases (alist-cons-before
335 'build 'set-default-shell
336 (lambda* (#:key inputs #:allow-other-keys)
337 ;; Change the default shell from /bin/sh.
338 (let ((bash (assoc-ref inputs "bash")))
339 (substitute* "job.c"
340 (("default_shell =.*$")
341 (format #f "default_shell = \"~a/bin/bash\";\n"
342 bash)))))
343 %standard-phases)))
344 (synopsis "Remake files automatically")
345 (description
346 "Make is a program that is used to control the production of
347 executables or other files from their source files. The process is
348 controlled from a Makefile, in which the developer specifies how each file is
349 generated from its source. It has powerful dependency resolution and the
350 ability to determine when files have to be regenerated after their sources
351 change. GNU make offers many powerful extensions over the standard utility.")
352 (license gpl3+)
353 (home-page "http://www.gnu.org/software/make/")))
354
355 (define-public binutils
356 (package
357 (name "binutils")
358 (version "2.25.1")
359 (source (origin
360 (method url-fetch)
361 (uri (string-append "mirror://gnu/binutils/binutils-"
362 version ".tar.bz2"))
363 (sha256
364 (base32
365 "08lzmhidzc16af1zbx34f8cy4z7mzrswpdbhrb8shy3xxpflmcdm"))
366 (patches (list (search-patch "binutils-ld-new-dtags.patch")
367 (search-patch "binutils-loongson-workaround.patch")))))
368 (build-system gnu-build-system)
369
370 ;; TODO: Add dependency on zlib + those for Gold.
371 (arguments
372 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
373 ;; on GCC when bootstrapping.
374 "LDFLAGS=-static-libgcc"
375
376 ;; Don't search under /usr/lib & co.
377 "--with-lib-path=/no-ld-lib-path"
378
379 ;; Glibc 2.17 has a "comparison of unsigned
380 ;; expression >= 0 is always true" in wchar.h.
381 "--disable-werror"
382
383 ;; Install BFD. It ends up in a hidden directory,
384 ;; but it's here.
385 "--enable-install-libbfd"
386
387 ;; Make sure 'ar' and 'ranlib' produce archives in a
388 ;; deterministic fashion.
389 "--enable-deterministic-archives")))
390
391 (synopsis "Binary utilities: bfd gas gprof ld")
392 (description
393 "GNU Binutils is a collection of tools for working with binary files.
394 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
395 Other tools include programs to display binary profiling information, list
396 the strings in a binary file, and utilities for working with archives. The
397 \"bfd\" library for working with executable and object formats is also
398 included.")
399 (license gpl3+)
400 (home-page "http://www.gnu.org/software/binutils/")))
401
402 (define* (make-ld-wrapper name #:key binutils
403 (guile (canonical-package guile-2.0))
404 (bash (canonical-package bash)) target
405 (guile-for-build guile))
406 "Return a package called NAME that contains a wrapper for the 'ld' program
407 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. When
408 TARGET is not #f, make a wrapper for the cross-linker for TARGET, called
409 'TARGET-ld'. The wrapper uses GUILE and BASH."
410 (package
411 (name name)
412 (version "0")
413 (source #f)
414 (build-system trivial-build-system)
415 (inputs `(("binutils" ,binutils)
416 ("guile" ,guile)
417 ("bash" ,bash)
418 ("wrapper" ,(search-path %load-path
419 "gnu/packages/ld-wrapper.in"))))
420 (arguments
421 `(#:guile ,guile-for-build
422 #:modules ((guix build utils))
423 #:builder (begin
424 (use-modules (guix build utils)
425 (system base compile))
426
427 (let* ((out (assoc-ref %outputs "out"))
428 (bin (string-append out "/bin"))
429 (ld ,(if target
430 `(string-append bin "/" ,target "-ld")
431 '(string-append bin "/ld")))
432 (go (string-append ld ".go")))
433
434 (setvbuf (current-output-port) _IOLBF)
435 (format #t "building ~s/bin/ld wrapper in ~s~%"
436 (assoc-ref %build-inputs "binutils")
437 out)
438
439 (mkdir-p bin)
440 (copy-file (assoc-ref %build-inputs "wrapper") ld)
441 (substitute* ld
442 (("@SELF@")
443 ld)
444 (("@GUILE@")
445 (string-append (assoc-ref %build-inputs "guile")
446 "/bin/guile"))
447 (("@BASH@")
448 (string-append (assoc-ref %build-inputs "bash")
449 "/bin/bash"))
450 (("@LD@")
451 (string-append (assoc-ref %build-inputs "binutils")
452 ,(if target
453 (string-append "/bin/"
454 target "-ld")
455 "/bin/ld"))))
456 (chmod ld #o555)
457 (compile-file ld #:output-file go)))))
458 (synopsis "The linker wrapper")
459 (description
460 "The linker wrapper (or 'ld-wrapper') wraps the linker to add any
461 missing '-rpath' flags, and to detect any misuse of libraries outside of the
462 store.")
463 (home-page "http://www.gnu.org/software/guix/")
464 (license gpl3+)))
465
466 (export make-ld-wrapper)
467
468 (define-public glibc
469 (package
470 (name "glibc")
471 (version "2.22")
472 (source (origin
473 (method url-fetch)
474 (uri (string-append "mirror://gnu/glibc/glibc-"
475 version ".tar.xz"))
476 (sha256
477 (base32
478 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
479 (snippet
480 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
481 ;; required on LFS distros to avoid loading the distro's libc.so
482 ;; instead of ours.
483 '(substitute* "sysdeps/unix/sysv/linux/configure"
484 (("use_ldconfig=yes")
485 "use_ldconfig=no")))
486 (modules '((guix build utils)))
487 (patches (map search-patch
488 '("glibc-ldd-x86_64.patch"
489 "glibc-locale-incompatibility.patch"
490 "glibc-versioned-locpath.patch"
491 "glibc-o-largefile.patch")))))
492 (build-system gnu-build-system)
493
494 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
495 ;; users should automatically pull Linux headers as well.
496 (propagated-inputs `(("linux-headers" ,linux-libre-headers)))
497
498 (outputs '("out" "debug"))
499
500 (arguments
501 `(#:out-of-source? #t
502
503 ;; In version 2.21, there a race in the 'elf' directory, see
504 ;; <http://lists.gnu.org/archive/html/guix-devel/2015-02/msg00709.html>.
505 #:parallel-build? #f
506
507 ;; The libraries have an empty RUNPATH, but some, such as the versioned
508 ;; libraries (libdl-2.22.so, etc.) have ld.so marked as NEEDED. Since
509 ;; these libraries are always going to be found anyway, just skip
510 ;; RUNPATH checks.
511 #:validate-runpath? #f
512
513 #:configure-flags
514 (list "--enable-add-ons"
515 "--sysconfdir=/etc"
516
517 ;; Installing a locale archive with all the locales is to
518 ;; expensive (~100 MiB), so we rely on users to install the
519 ;; locales they really want.
520 ;;
521 ;; Set the default locale path. In practice, $LOCPATH may be
522 ;; defined to point whatever locales users want. However, setuid
523 ;; binaries don't honor $LOCPATH, so they'll instead look into
524 ;; $libc_cv_localedir; we choose /run/current-system/locale/X.Y,
525 ;; with the idea that it is going to be populated by the sysadmin.
526 ;; The "X.Y" sub-directory is because locale data formats are
527 ;; incompatible across libc versions; see
528 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
529 ;;
530 ;; `--localedir' is not honored, so work around it.
531 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
532 (string-append "libc_cv_localedir=/run/current-system/locale/"
533 ,version)
534
535 (string-append "--with-headers="
536 (assoc-ref %build-inputs "linux-headers")
537 "/include")
538
539 ;; This is the default for most architectures as of GNU libc 2.21,
540 ;; but we specify it explicitly for clarity and consistency. See
541 ;; "kernel-features.h" in the GNU libc for details.
542 "--enable-kernel=2.6.32"
543
544 ;; Use our Bash instead of /bin/sh.
545 (string-append "BASH_SHELL="
546 (assoc-ref %build-inputs "bash")
547 "/bin/bash")
548
549 ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
550 "libc_cv_ssp=no")
551
552 #:tests? #f ; XXX
553 #:phases (modify-phases %standard-phases
554 (add-before
555 'configure 'pre-configure
556 (lambda* (#:key inputs native-inputs outputs
557 #:allow-other-keys)
558 (let* ((out (assoc-ref outputs "out"))
559 (bin (string-append out "/bin"))
560 ;; FIXME: Normally we would look it up only in INPUTS
561 ;; but cross-base uses it as a native input.
562 (bash (or (assoc-ref inputs "static-bash")
563 (assoc-ref native-inputs "static-bash"))))
564 ;; Use `pwd', not `/bin/pwd'.
565 (substitute* "configure"
566 (("/bin/pwd") "pwd"))
567
568 ;; Install the rpc data base file under `$out/etc/rpc'.
569 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
570 (substitute* "sunrpc/Makefile"
571 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
572 (string-append out "/etc/rpc" suffix "\n"))
573 (("^install-others =.*$")
574 (string-append "install-others = " out "/etc/rpc\n")))
575
576 (substitute* "Makeconfig"
577 ;; According to
578 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
579 ;; linking against libgcc_s is not needed with GCC
580 ;; 4.7.1.
581 ((" -lgcc_s") ""))
582
583 ;; Have `system' use that Bash.
584 (substitute* "sysdeps/posix/system.c"
585 (("#define[[:blank:]]+SHELL_PATH.*$")
586 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
587 bash)))
588
589 ;; Same for `popen'.
590 (substitute* "libio/iopopen.c"
591 (("/bin/sh")
592 (string-append bash "/bin/bash")))
593
594 ;; Same for the shell used by the 'exec' functions for
595 ;; scripts that lack a shebang.
596 (substitute* (find-files "." "^paths\\.h$")
597 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
598 (string-append "#define _PATH_BSHELL \""
599 bash "/bin/bash\"\n")))
600
601 ;; Nscd uses __DATE__ and __TIME__ to create a string to
602 ;; make sure the client and server come from the same
603 ;; libc. Use something deterministic instead.
604 (substitute* "nscd/nscd_stat.c"
605 (("static const char compilation\\[21\\] =.*$")
606 (string-append
607 "static const char compilation[21] = \""
608 (string-take (basename out) 20) "\";\n")))
609
610 ;; Make sure we don't retain a reference to the
611 ;; bootstrap Perl.
612 (substitute* "malloc/mtrace.pl"
613 (("^#!.*")
614 ;; The shebang can be omitted, because there's the
615 ;; "bilingual" eval/exec magic at the top of the file.
616 "")
617 (("exec @PERL@")
618 "exec perl"))))))))
619
620 (inputs `(("static-bash" ,static-bash)))
621
622 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
623 ;; install the message catalogs, with 'msgfmt'.
624 (native-inputs `(("texinfo" ,texinfo)
625 ("perl" ,perl)
626 ("gettext" ,gnu-gettext)))
627
628 (native-search-paths
629 ;; Search path for packages that provide locale data. This is useful
630 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
631 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
632 ;; distros.
633 (list (search-path-specification
634 (variable "GUIX_LOCPATH")
635 (files '("lib/locale")))))
636
637 (synopsis "The GNU C Library")
638 (description
639 "Any Unix-like operating system needs a C library: the library which
640 defines the \"system calls\" and other basic facilities such as open, malloc,
641 printf, exit...
642
643 The GNU C library is used as the C library in the GNU system and most systems
644 with the Linux kernel.")
645 (license lgpl2.0+)
646 (home-page "http://www.gnu.org/software/libc/")))
647
648 (define-public glibc-2.21
649 ;; The old libc, which we use mostly to build locale data in the old format
650 ;; (which the new libc can cope with.)
651 (package
652 (inherit glibc)
653 (version "2.21")
654 (source (origin
655 (inherit (package-source glibc))
656 (uri (string-append "mirror://gnu/glibc/glibc-"
657 version ".tar.xz"))
658 (sha256
659 (base32
660 "1f135546j34s9bfkydmx2nhh9vwxlx60jldi80zmsnln6wj3dsxf"))
661 (patches (list (search-patch "glibc-ldd-x86_64.patch")))))))
662
663 (define-public glibc-locales
664 (package
665 (inherit glibc)
666 (name "glibc-locales")
667 (source (origin (inherit (package-source glibc))
668 (patches (cons (search-patch "glibc-locales.patch")
669 (origin-patches (package-source glibc))))))
670 (synopsis "All the locales supported by the GNU C Library")
671 (description
672 "This package provides all the locales supported by the GNU C Library,
673 more than 400 in total. To use them set the 'LOCPATH' environment variable to
674 the 'share/locale' sub-directory of this package.")
675 (outputs '("out")) ;110+ MiB
676 (native-search-paths '())
677 (arguments
678 (let ((args `(#:tests? #f #:strip-binaries? #f
679 ,@(package-arguments glibc))))
680 (substitute-keyword-arguments args
681 ((#:phases phases)
682 `(alist-replace
683 'build
684 (lambda* (#:key outputs #:allow-other-keys)
685 (zero? (system* "make" "localedata/install-locales"
686 "-j" (number->string (parallel-job-count)))))
687 (alist-delete 'install ,phases)))
688 ((#:configure-flags flags)
689 `(append ,flags
690 ;; Use $(libdir)/locale/X.Y as is the case by default.
691 (list (string-append "libc_cv_localedir="
692 (assoc-ref %outputs "out")
693 "/lib/locale/"
694 ,(package-version glibc))))))))))
695
696 (define-public glibc-utf8-locales
697 (package
698 (name "glibc-utf8-locales")
699 (version (package-version glibc))
700 (source #f)
701 (build-system trivial-build-system)
702 (arguments
703 `(#:modules ((guix build utils))
704 #:builder (begin
705 (use-modules (srfi srfi-1)
706 (guix build utils))
707
708 (let* ((libc (assoc-ref %build-inputs "glibc"))
709 (gzip (assoc-ref %build-inputs "gzip"))
710 (out (assoc-ref %outputs "out"))
711 (localedir (string-append out "/lib/locale/"
712 ,version)))
713 ;; 'localedef' needs 'gzip'.
714 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
715
716 (mkdir-p localedir)
717 (every (lambda (locale)
718 (define file
719 ;; Use the "normalized codeset" by
720 ;; default--e.g., "en_US.utf8".
721 (string-append localedir "/" locale ".utf8"))
722
723 (and (zero? (system* "localedef" "--no-archive"
724 "--prefix" localedir
725 "-i" locale
726 "-f" "UTF-8" file))
727 (begin
728 ;; For backward compatibility with Guix
729 ;; <= 0.8.3, add "xx_YY.UTF-8".
730 (symlink (string-append locale ".utf8")
731 (string-append localedir "/"
732 locale ".UTF-8"))
733 #t)))
734
735 ;; These are the locales commonly used for
736 ;; tests---e.g., in Guile's i18n tests.
737 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))))))
738 (inputs `(("glibc" ,glibc)
739 ("gzip" ,gzip)))
740 (synopsis "Small sample of UTF-8 locales")
741 (description
742 "This package provides a small sample of UTF-8 locales mostly useful in
743 test environments.")
744 (home-page (package-home-page glibc))
745 (license (package-license glibc))))
746
747 (define-public which
748 (package
749 (name "which")
750 (version "2.21")
751 (source (origin
752 (method url-fetch)
753 (uri (string-append "mirror://gnu/which/which-"
754 version ".tar.gz"))
755 (sha256
756 (base32
757 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
758 (build-system gnu-build-system)
759 (home-page "https://gnu.org/software/which/")
760 (synopsis "Find full path of shell commands")
761 (description
762 "The which program finds the location of executables in PATH, with a
763 variety of options. It is an alternative to the shell \"type\" built-in
764 command.")
765 (license gpl3+))) ; some files are under GPLv2+
766
767 (define-public glibc/hurd
768 ;; The Hurd's libc variant.
769 (package (inherit glibc)
770 (name "glibc-hurd")
771 (version "2.18")
772 (source (origin
773 (method git-fetch)
774 (uri (git-reference
775 (url "git://git.sv.gnu.org/hurd/glibc")
776 (commit "cc94b3cfe65523f980359e5f0e93a26196bda1d3")))
777 (sha256
778 (base32
779 "17gsh0kaz0zyvghjmx861mi2p65m9901lngi179x61zm6v2v3xc4"))
780 (file-name (string-append name "-" version))
781 (patches (map search-patch
782 '("glibc-hurd-extern-inline.patch")))))
783
784 ;; Libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
785 ;; so both should be propagated.
786 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
787 ("hurd-headers" ,hurd-headers)
788 ("hurd-minimal" ,hurd-minimal)))
789 (native-inputs
790 `(,@(package-native-inputs glibc)
791 ("patch/libpthread-patch" ,(search-patch "libpthread-glibc-preparation.patch"))
792 ("mig" ,mig)
793 ("perl" ,perl)
794 ("libpthread" ,(origin
795 (method git-fetch)
796 (uri (git-reference
797 (url "git://git.sv.gnu.org/hurd/libpthread")
798 (commit "0ef7b75c4ba91b6660f0d3d8b51d14d25e3d5bfb")))
799 (sha256
800 (base32
801 "031py18fls15z0wprni33mf762kg6fx8xqijppimhp83yp6ky3l3"))
802 (file-name "libpthread")))))
803
804 (arguments
805 (substitute-keyword-arguments (package-arguments glibc)
806 ((#:configure-flags original-configure-flags)
807 `(append (list "--host=i686-pc-gnu"
808
809 ;; nscd fails to build for GNU/Hurd:
810 ;; <https://lists.gnu.org/archive/html/bug-hurd/2014-07/msg00006.html>.
811 ;; Disable it.
812 "--disable-nscd")
813 (filter (lambda (flag)
814 (not (or (string-prefix? "--with-headers=" flag)
815 (string-prefix? "--enable-kernel=" flag))))
816 ;; Evaluate 'original-configure-flags' in a
817 ;; lexical environment that has a dummy
818 ;; "linux-headers" input, to prevent errors.
819 (let ((%build-inputs `(("linux-headers" . "@DUMMY@")
820 ,@%build-inputs)))
821 ,original-configure-flags))))
822 ((#:phases phases)
823 `(alist-cons-after
824 'unpack 'prepare-libpthread
825 (lambda* (#:key inputs #:allow-other-keys)
826 (copy-recursively (assoc-ref inputs "libpthread") "libpthread")
827
828 (system* "patch" "--force" "-p1" "-i"
829 (assoc-ref inputs "patch/libpthread-patch"))
830 #t)
831 ,phases))))
832 (synopsis "The GNU C Library (GNU Hurd variant)")
833 (supported-systems %hurd-systems)))
834
835 (define-public glibc/hurd-headers
836 (package (inherit glibc/hurd)
837 (name "glibc-hurd-headers")
838 (outputs '("out"))
839 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
840 ("hurd-headers" ,hurd-headers)))
841 (arguments
842 (substitute-keyword-arguments (package-arguments glibc/hurd)
843 ;; We just pass the flags really needed to build the headers.
844 ((#:configure-flags _)
845 `(list "--enable-add-ons"
846 "--host=i686-pc-gnu"
847 "--enable-obsolete-rpc"))
848 ((#:phases _)
849 '(alist-replace
850 'install
851 (lambda* (#:key outputs #:allow-other-keys)
852 (and (zero? (system* "make" "install-headers"))
853
854 ;; Make an empty stubs.h to work around not being able to
855 ;; produce a valid stubs.h and causing the build to fail. See
856 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
857 (let ((out (assoc-ref outputs "out")))
858 (close-port
859 (open-output-file
860 (string-append out "/include/gnu/stubs.h"))))))
861
862 ;; Nothing to build.
863 (alist-delete
864 'build
865
866 (alist-cons-before
867 'configure 'pre-configure
868 (lambda _
869 ;; Use the right 'pwd'.
870 (substitute* "configure"
871 (("/bin/pwd") "pwd")))
872 %standard-phases))))))))
873
874 (define-public tzdata
875 (package
876 (name "tzdata")
877 (version "2015g")
878 (source (origin
879 (method url-fetch)
880 (uri (string-append
881 "http://www.iana.org/time-zones/repository/releases/tzdata"
882 version ".tar.gz"))
883 (sha256
884 (base32
885 "0qb1awqrn3215zd2jikpqnmkzrxwfjf0d3dw2xmnk4c40yzws8xr"))))
886 (build-system gnu-build-system)
887 (arguments
888 '(#:tests? #f
889 #:make-flags (let ((out (assoc-ref %outputs "out"))
890 (tmp (getenv "TMPDIR")))
891 (list (string-append "TOPDIR=" out)
892 (string-append "TZDIR=" out "/share/zoneinfo")
893
894 ;; Discard zic, dump, and tzselect, already
895 ;; provided by glibc.
896 (string-append "ETCDIR=" tmp "/etc")
897
898 ;; Likewise for the C library routines.
899 (string-append "LIBDIR=" tmp "/lib")
900 (string-append "MANDIR=" tmp "/man")
901
902 "AWK=awk"
903 "CC=gcc"))
904 #:modules ((guix build utils)
905 (guix build gnu-build-system)
906 (srfi srfi-1))
907 #:phases
908 (alist-replace
909 'unpack
910 (lambda* (#:key source inputs #:allow-other-keys)
911 (and (zero? (system* "tar" "xvf" source))
912 (zero? (system* "tar" "xvf" (assoc-ref inputs "tzcode")))))
913 (alist-cons-after
914 'install 'post-install
915 (lambda* (#:key outputs #:allow-other-keys)
916 ;; Move data in the right place.
917 (let ((out (assoc-ref outputs "out")))
918 (copy-recursively (string-append out "/share/zoneinfo-posix")
919 (string-append out "/share/zoneinfo/posix"))
920 (copy-recursively (string-append out "/share/zoneinfo-leaps")
921 (string-append out "/share/zoneinfo/right"))
922 (delete-file-recursively (string-append out "/share/zoneinfo-posix"))
923 (delete-file-recursively (string-append out "/share/zoneinfo-leaps"))))
924 (alist-delete 'configure %standard-phases)))))
925 (inputs `(("tzcode" ,(origin
926 (method url-fetch)
927 (uri (string-append
928 "http://www.iana.org/time-zones/repository/releases/tzcode"
929 version ".tar.gz"))
930 (sha256
931 (base32
932 "1i3y1kzjiz2j62c7vd4wf85983sqk9x9lg3473njvbdz4kph5r0q"))))))
933 (home-page "http://www.iana.org/time-zones")
934 (synopsis "Database of current and historical time zones")
935 (description "The Time Zone Database (often called tz or zoneinfo)
936 contains code and data that represent the history of local time for many
937 representative locations around the globe. It is updated periodically to
938 reflect changes made by political bodies to time zone boundaries, UTC offsets,
939 and daylight-saving rules.")
940 (license public-domain)))
941
942 (define-public (canonical-package package)
943 ;; Avoid circular dependency by lazily resolving 'commencement'.
944 (let* ((iface (resolve-interface '(gnu packages commencement)))
945 (proc (module-ref iface 'canonical-package)))
946 (proc package)))
947
948 ;;; base.scm ends here