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