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