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