1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 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 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
12 ;;; This file is part of GNU Guix.
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27 (define-module (gnu packages base)
28 #:use-module ((guix licenses)
29 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
30 #:use-module (gnu packages)
31 #:use-module (gnu packages acl)
32 #:use-module (gnu packages bash)
33 #:use-module (gnu packages ed)
34 #:use-module (gnu packages guile)
35 #:use-module (gnu packages multiprecision)
36 #:use-module (gnu packages compression)
37 #:use-module (gnu packages perl)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages texinfo)
40 #:use-module (gnu packages hurd)
41 #:use-module (gnu packages pkg-config)
42 #:use-module (gnu packages gettext)
43 #:use-module (guix utils)
44 #:use-module (guix packages)
45 #:use-module (guix download)
46 #:use-module (guix git-download)
47 #:use-module (guix build-system gnu)
48 #:use-module (guix build-system trivial)
49 #:use-module (ice-9 match)
55 ;;; Base packages of the Guix-based GNU user-land software distribution.
65 (uri (string-append "mirror://gnu/hello/hello-" version
69 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
70 (build-system gnu-build-system)
71 (synopsis "Hello, GNU world: An example GNU package")
73 "GNU Hello prints the message \"Hello, world!\" and then exits. It
74 serves as an example of standard GNU coding practices. As such, it supports
75 command-line arguments, multiple languages, and so on.")
76 (home-page "https://www.gnu.org/software/hello/")
85 (uri (string-append "mirror://gnu/grep/grep-"
89 "1dcasjp3a578nrvzrcn38mpizb8w1q6mvfzhjmcqqgkf0nsivj72"))
90 (patches (search-patches "grep-timing-sensitive-test.patch"))))
91 (build-system gnu-build-system)
92 (native-inputs `(("perl" ,perl))) ;some of the tests require it
95 (modify-phases %standard-phases
96 (add-after 'install 'fix-egrep-and-fgrep
97 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
98 ;; absolute file name instead of searching for it in $PATH.
99 (lambda* (#:key outputs #:allow-other-keys)
100 (let* ((out (assoc-ref outputs "out"))
101 (bin (string-append out "/bin")))
102 (substitute* (list (string-append bin "/egrep")
103 (string-append bin "/fgrep"))
105 (string-append "exec " bin "/grep")))
107 (synopsis "Print lines matching a pattern")
109 "grep is a tool for finding text inside files. Text is found by
110 matching a pattern provided by the user in one or many files. The pattern
111 may be provided as a basic or extended regular expression, or as fixed
112 strings. By default, the matching text is simply printed to the screen,
113 however the output can be greatly customized to include, for example, line
114 numbers. GNU grep offers many extensions over the standard utility,
115 including, for example, recursive directory searching.")
117 (home-page "https://www.gnu.org/software/grep/")))
125 (uri (string-append "mirror://gnu/sed/sed-" version
129 "0fv88bcnraixc8jvpacvxshi30p5x9m7yb8ns1hfv07hmb2ypmnb"))))
130 (build-system gnu-build-system)
131 (synopsis "Stream editor")
134 (modify-phases %standard-phases
135 (add-after 'unpack 'dont-rebuild-sed.1
137 ;; Make sure we do not attempt to rebuild 'doc/sed.1', which does
138 ;; not work when cross-compiling because we cannot run 'sed'.
139 ;; This is fixed upstream as commit a0a25e3.
140 (substitute* "Makefile.in"
144 (add-before 'patch-source-shebangs 'patch-test-suite
145 (lambda* (#:key inputs #:allow-other-keys)
146 (patch-makefile-SHELL "testsuite/Makefile.tests")
147 (substitute* '("testsuite/bsd.sh"
148 "testsuite/bug-regex9.c")
153 "Sed is a non-interactive, text stream editor. It receives a text
154 input from a file or from standard input and it then applies a series of text
155 editing commands to the stream and prints its output to standard output. It
156 is often used for substituting text patterns in a stream. The GNU
157 implementation offers several extensions over the standard utility.")
159 (home-page "https://www.gnu.org/software/sed/")))
167 (uri (string-append "mirror://gnu/tar/tar-"
171 "097hx7sbzp8qirl4m930lw84kn0wmxhmq7v1qpra3mrg0b8cyba0"))
172 (patches (search-patches "tar-CVE-2016-6321.patch"
173 "tar-skip-unreliable-tests.patch"))))
174 (build-system gnu-build-system)
175 ;; Note: test suite requires ~1GiB of disk space.
177 '(#:phases (modify-phases %standard-phases
178 (add-before 'build 'set-shell-file-name
179 (lambda* (#:key inputs #:allow-other-keys)
180 ;; Do not use "/bin/sh" to run programs.
181 (let ((bash (assoc-ref inputs "bash")))
182 (substitute* "src/system.c"
184 (string-append bash "/bin/sh")))
187 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
188 ;; to refer to the target Bash.
189 (inputs (if (%current-target-system)
193 (synopsis "Managing tar archives")
195 "Tar provides the ability to create tar archives, as well as the
196 ability to extract, update or list files in an existing archive. It is
197 useful for combining many files into one larger file, while maintaining
198 directory structure and file information such as permissions and
199 creation/modification dates. GNU tar offers many extensions over the
202 (home-page "https://www.gnu.org/software/tar/")))
210 (uri (string-append "mirror://gnu/patch/patch-"
214 "16d2r9kpivaak948mxzc0bai45mqfw73m113wrkmbffnalv1b5gx"))
215 (patches (search-patches "patch-hurd-path-max.patch"))))
216 (build-system gnu-build-system)
217 (native-inputs `(("ed" ,ed)))
218 (synopsis "Apply differences to originals, with optional backups")
220 "Patch is a program that applies changes to files based on differences
221 laid out as by the program \"diff\". The changes may be applied to one or more
222 files depending on the contents of the diff file. It accepts several
223 different diff formats. It may also be used to revert previously applied
226 (home-page "https://savannah.gnu.org/projects/patch/")))
228 (define-public diffutils
234 (uri (string-append "mirror://gnu/diffutils/diffutils-"
238 "0csmqfz8ks23kdjsq0v2ll1acqiz8lva06dj19mwmymrsp69ilys"))))
239 (build-system gnu-build-system)
240 (synopsis "Comparing and merging files")
242 "GNU Diffutils is a package containing tools for finding the
243 differences between files. The \"diff\" command is used to show how two files
244 differ, while \"cmp\" shows the offsets and line numbers where they differ.
245 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
246 interactive means to merge two files.")
248 (home-page "https://www.gnu.org/software/diffutils/")))
250 (define-public findutils
256 (uri (string-append "mirror://gnu/findutils/findutils-"
260 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
261 (patches (search-patches "findutils-localstatedir.patch"
262 "findutils-test-xargs.patch"))))
263 (build-system gnu-build-system)
265 `(#:configure-flags (list
266 ;; Tell 'updatedb' to write to /var.
267 "--localstatedir=/var"
269 ;; Work around cross-compilation failure. See
270 ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
271 ,@(if (%current-target-system)
272 '("gl_cv_func_wcwidth_works=yes")
274 (synopsis "Operating on files matching given criteria")
276 "Findutils supplies the basic file directory searching utilities of the
277 GNU system. It consists of two primary searching utilities: \"find\"
278 recursively searches for files in a directory according to given criteria and
279 \"locate\" lists files in a database that match a query. Two auxiliary tools
280 are included: \"updatedb\" updates the file name database and \"xargs\" may be
281 used to apply commands with arbitrarily long arguments.")
283 (home-page "https://www.gnu.org/software/findutils/")))
285 (define-public coreutils
291 (uri (string-append "mirror://gnu/coreutils/coreutils-"
295 "13lspazc7xkviy93qz7ks9jv4sldvgmwpq36ghrbrqpq93br8phm"))
296 (patches (search-patches "coreutils-fix-cross-compilation.patch"))))
297 (build-system gnu-build-system)
298 (inputs `(("acl" ,acl) ; TODO: add SELinux
299 ("gmp" ,gmp) ;bignums in 'expr', yay!
301 ;; Drop the dependency on libcap when cross-compiling since it's
302 ;; not quite cross-compilable.
303 ,@(if (%current-target-system)
305 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
307 ;; Perl is needed to run tests in native builds, and to run the bundled
308 ;; copy of help2man. However, don't pass it when cross-compiling since
309 ;; that would lead it to try to run programs to get their '--help' output
311 `(,@(if (%current-target-system)
315 ;; Apply this patch only on ARM to avoid a full rebuild.
316 ;; TODO: Move to 'patches' in the next update cycle.
317 ,@(if (string-prefix? "arm" (or (%current-target-system)
320 ,(search-patch "coreutils-cut-huge-range-test.patch")))
322 (outputs '("out" "debug"))
324 `(#:parallel-build? #f ; help2man may be called too early
325 #:parallel-tests? #f ; race condition fixed after 8.26
326 #:phases (alist-cons-before
327 'build 'patch-shell-references
328 (lambda* (#:key inputs #:allow-other-keys)
329 (let ((bash (assoc-ref inputs "bash")))
330 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
331 ;; that tests pass, since /bin/sh isn't in the chroot.
332 (setenv "SHELL" (which "sh"))
334 (substitute* (find-files "gnulib-tests" "\\.c$")
336 (format #f "~a/bin/sh" bash)))
337 (substitute* (find-files "tests" "\\.sh$")
339 (format #f "#!~a/bin/sh" bash)))))
341 ,@(if (string-prefix? "arm" (or (%current-target-system)
344 'build 'patch-cut-test
345 (lambda* (#:key inputs native-inputs
347 (let ((patch (or (assoc-ref inputs
349 (assoc-ref native-inputs
352 (system* "patch" "-p1" "--force"
355 '(%standard-phases)))))
356 (synopsis "Core GNU utilities (file, text, shell)")
358 "GNU Coreutils includes all of the basic command-line tools that are
359 expected in a POSIX system. These provide the basic file, shell and text
360 manipulation functions of the GNU system. Most of these tools offer extended
361 functionality beyond that which is outlined in the POSIX standard.")
363 (home-page "https://www.gnu.org/software/coreutils/")))
365 ;; We add version 8.27 here for use in (gnu system) due to a time
366 ;; zone bug in `date' versions 8.25 - 8.26.
367 ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=23035
368 ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26238
369 (define-public coreutils-8.27
375 (uri (string-append "mirror://gnu/coreutils/coreutils-"
379 "0sv547572iq8ayy8klir4hnngnx92a9nsazmf1wgzfc7xr4x74c8"))))
381 (if (string-prefix? "arm" (or (%current-target-system)
383 (substitute-keyword-arguments (package-arguments coreutils)
385 `(alist-delete 'patch-cut-test ,phases)))
386 (package-arguments coreutils)))))
388 (define-public coreutils-minimal
389 ;; Coreutils without its optional dependencies.
392 (name "coreutils-minimal")
396 (define-public gnu-make
402 (uri (string-append "mirror://gnu/make/make-" version
406 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
407 (patches (search-patches "make-impure-dirs.patch"))))
408 (build-system gnu-build-system)
409 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
410 (inputs `(("guile" ,guile-2.0)))
411 (outputs '("out" "debug"))
414 (modify-phases %standard-phases
415 (add-before 'build 'set-default-shell
416 (lambda* (#:key inputs #:allow-other-keys)
417 ;; Change the default shell from /bin/sh.
418 (let ((bash (assoc-ref inputs "bash")))
420 (("default_shell =.*$")
421 (format #f "default_shell = \"~a/bin/sh\";\n"
423 (synopsis "Remake files automatically")
425 "Make is a program that is used to control the production of
426 executables or other files from their source files. The process is
427 controlled from a Makefile, in which the developer specifies how each file is
428 generated from its source. It has powerful dependency resolution and the
429 ability to determine when files have to be regenerated after their sources
430 change. GNU make offers many powerful extensions over the standard utility.")
432 (home-page "https://www.gnu.org/software/make/")))
434 (define-public binutils
440 (uri (string-append "mirror://gnu/binutils/binutils-"
444 "125clslv17xh1sab74343fg6v31msavpmaa1c1394zsqa773g5rn"))
445 (patches (search-patches "binutils-ld-new-dtags.patch"
446 "binutils-loongson-workaround.patch"
447 "binutils-mips-bash-bug.patch"))))
448 (build-system gnu-build-system)
450 ;; TODO: Add dependency on zlib + those for Gold.
452 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
453 ;; on GCC when bootstrapping.
454 "LDFLAGS=-static-libgcc"
456 ;; Don't search under /usr/lib & co.
457 "--with-lib-path=/no-ld-lib-path"
459 ;; Glibc 2.17 has a "comparison of unsigned
460 ;; expression >= 0 is always true" in wchar.h.
463 ;; Install BFD. It ends up in a hidden directory,
465 "--enable-install-libbfd"
467 ;; Make sure 'ar' and 'ranlib' produce archives in a
468 ;; deterministic fashion.
469 "--enable-deterministic-archives")))
471 (synopsis "Binary utilities: bfd gas gprof ld")
473 "GNU Binutils is a collection of tools for working with binary files.
474 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
475 Other tools include programs to display binary profiling information, list
476 the strings in a binary file, and utilities for working with archives. The
477 \"bfd\" library for working with executable and object formats is also
480 (home-page "https://www.gnu.org/software/binutils/")))
482 (define* (make-ld-wrapper name #:key
485 (guile (canonical-package guile-2.0))
486 (bash (canonical-package bash))
487 (guile-for-build guile))
488 "Return a package called NAME that contains a wrapper for the 'ld' program
489 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
490 wrapper uses GUILE and BASH.
492 TARGET must be a one-argument procedure that, given a system type, returns a
493 cross-compilation target triplet or #f. When the result is not #f, make a
494 wrapper for the cross-linker for that target, called 'TARGET-ld'."
495 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
496 ;; its result can be delayed until the 'arguments' field is evaluated, thus
497 ;; in a context where '%current-system' is accurate.
502 (build-system trivial-build-system)
503 (inputs `(("binutils" ,binutils)
506 ("wrapper" ,(search-path %load-path
507 "gnu/packages/ld-wrapper.in"))))
509 (let ((target (target (%current-system))))
510 `(#:guile ,guile-for-build
511 #:modules ((guix build utils))
513 (use-modules (guix build utils)
514 (system base compile))
516 (let* ((out (assoc-ref %outputs "out"))
517 (bin (string-append out "/bin"))
519 `(string-append bin "/" ,target "-ld")
520 '(string-append bin "/ld")))
521 (go (string-append ld ".go")))
523 (setvbuf (current-output-port) _IOLBF)
524 (format #t "building ~s/bin/ld wrapper in ~s~%"
525 (assoc-ref %build-inputs "binutils")
529 (copy-file (assoc-ref %build-inputs "wrapper") ld)
534 (string-append (assoc-ref %build-inputs "guile")
537 (string-append (assoc-ref %build-inputs "bash")
540 (string-append (assoc-ref %build-inputs "binutils")
542 (string-append "/bin/"
546 (compile-file ld #:output-file go))))))
547 (synopsis "The linker wrapper")
549 "The linker wrapper (or 'ld-wrapper') wraps the linker to add any
550 missing '-rpath' flags, and to detect any misuse of libraries outside of the
552 (home-page "https://www.gnu.org/software/guix//")
555 (export make-ld-wrapper)
557 (define-public glibc/linux
563 (uri (string-append "mirror://gnu/glibc/glibc-"
567 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
569 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
570 ;; required on LFS distros to avoid loading the distro's libc.so
572 '(substitute* "sysdeps/unix/sysv/linux/configure"
573 (("use_ldconfig=yes")
575 (modules '((guix build utils)))
576 (patches (search-patches "glibc-ldd-x86_64.patch"
577 "glibc-versioned-locpath.patch"
578 "glibc-o-largefile.patch"))))
579 (build-system gnu-build-system)
581 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
582 ;; users should automatically pull Linux headers as well.
583 (propagated-inputs `(("kernel-headers" ,linux-libre-headers)))
585 (outputs '("out" "debug"))
588 `(#:out-of-source? #t
590 ;; In version 2.21, there a race in the 'elf' directory, see
591 ;; <http://lists.gnu.org/archive/html/guix-devel/2015-02/msg00709.html>.
594 ;; The libraries have an empty RUNPATH, but some, such as the versioned
595 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
596 ;; these libraries are always going to be found anyway, just skip
598 #:validate-runpath? #f
601 (list "--enable-add-ons"
604 ;; Installing a locale archive with all the locales is to
605 ;; expensive (~100 MiB), so we rely on users to install the
606 ;; locales they really want.
608 ;; Set the default locale path. In practice, $LOCPATH may be
609 ;; defined to point whatever locales users want. However, setuid
610 ;; binaries don't honor $LOCPATH, so they'll instead look into
611 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
612 ;; with the idea that it is going to be populated by the sysadmin.
613 ;; The "X.Y" sub-directory is because locale data formats are
614 ;; incompatible across libc versions; see
615 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
617 ;; `--localedir' is not honored, so work around it.
618 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
619 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
622 (string-append "--with-headers="
623 (assoc-ref ,(if (%current-target-system)
624 '%build-target-inputs
629 ;; This is the default for most architectures as of GNU libc 2.21,
630 ;; but we specify it explicitly for clarity and consistency. See
631 ;; "kernel-features.h" in the GNU libc for details.
632 "--enable-kernel=2.6.32"
634 ;; Use our Bash instead of /bin/sh.
635 (string-append "BASH_SHELL="
636 (assoc-ref %build-inputs "bash")
639 ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
640 "libc_cv_ssp=no" "libc_cv_ssp_strong=no")
643 #:phases (modify-phases %standard-phases
645 'configure 'pre-configure
646 (lambda* (#:key inputs native-inputs outputs
648 (let* ((out (assoc-ref outputs "out"))
649 (bin (string-append out "/bin"))
650 ;; FIXME: Normally we would look it up only in INPUTS
651 ;; but cross-base uses it as a native input.
652 (bash (or (assoc-ref inputs "static-bash")
653 (assoc-ref native-inputs "static-bash"))))
654 ;; Install the rpc data base file under `$out/etc/rpc'.
655 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
656 (substitute* "sunrpc/Makefile"
657 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
658 (string-append out "/etc/rpc" suffix "\n"))
659 (("^install-others =.*$")
660 (string-append "install-others = " out "/etc/rpc\n")))
662 (substitute* "Makeconfig"
664 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
665 ;; linking against libgcc_s is not needed with GCC
669 ;; Apply patch only on i686.
670 ;; TODO: Move the patch to 'patches' in the next update cycle.
671 ,@(if (string-prefix? "i686" (or (%current-target-system)
673 `((unless (zero? (system* "patch" "-p1" "--force"
675 (or (assoc-ref native-inputs
676 "glibc-memchr-overflow-i686.patch")
678 "glibc-memchr-overflow-i686.patch"))))
679 (error "patch failed for glibc-memchr-overflow-i686.patch")))
682 ;; Have `system' use that Bash.
683 (substitute* "sysdeps/posix/system.c"
684 (("#define[[:blank:]]+SHELL_PATH.*$")
685 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
689 (substitute* "libio/iopopen.c"
691 (string-append bash "/bin/sh")))
693 ;; Same for the shell used by the 'exec' functions for
694 ;; scripts that lack a shebang.
695 (substitute* (find-files "." "^paths\\.h$")
696 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
697 (string-append "#define _PATH_BSHELL \""
698 bash "/bin/sh\"\n")))
700 ;; Nscd uses __DATE__ and __TIME__ to create a string to
701 ;; make sure the client and server come from the same
702 ;; libc. Use something deterministic instead.
703 (substitute* "nscd/nscd_stat.c"
704 (("static const char compilation\\[21\\] =.*$")
706 "static const char compilation[21] = \""
707 (string-take (basename out) 20) "\";\n")))
709 ;; Make sure we don't retain a reference to the
711 (substitute* "malloc/mtrace.pl"
713 ;; The shebang can be omitted, because there's the
714 ;; "bilingual" eval/exec magic at the top of the file.
719 (inputs `(("static-bash" ,static-bash)))
721 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
722 ;; install the message catalogs, with 'msgfmt'.
723 (native-inputs `(("texinfo" ,texinfo)
725 ("gettext" ,gettext-minimal)
727 ;; Apply this patch only on i686 to avoid a full rebuild.
728 ;; TODO: Move to 'patches' in the next update cycle.
729 ,@(if (string-prefix? "i686" (or (%current-target-system)
731 `(("glibc-memchr-overflow-i686.patch"
732 ,(search-patch "glibc-memchr-overflow-i686.patch")))
736 ;; Search path for packages that provide locale data. This is useful
737 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
738 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
740 (list (search-path-specification
741 (variable "GUIX_LOCPATH")
742 (files '("lib/locale")))))
744 (synopsis "The GNU C Library")
746 "Any Unix-like operating system needs a C library: the library which
747 defines the \"system calls\" and other basic facilities such as open, malloc,
750 The GNU C library is used as the C library in the GNU system and most systems
751 with the Linux kernel.")
753 (home-page "https://www.gnu.org/software/libc/")))
755 (define-public glibc/hurd
756 ;; The Hurd's libc variant.
757 (package (inherit glibc/linux)
762 (uri (string-append "http://alpha.gnu.org/gnu/hurd/glibc-"
763 version "-hurd+libpthread-20161218" ".tar.gz"))
766 "0vpdv05j6j3ria5bw8gp468i64gij94cslxkxj9xkfgi6p615b8p"))))
768 ;; Libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
769 ;; so both should be propagated.
770 (propagated-inputs `(("hurd-core-headers" ,hurd-core-headers)))
772 `(,@(package-native-inputs glibc/linux)
777 (substitute-keyword-arguments (package-arguments glibc/linux)
778 ((#:phases original-phases)
779 ;; Add libmachuser.so and libhurduser.so to libc.so's search path.
780 ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-07/msg00051.html>.
781 `(modify-phases ,original-phases
782 ;; TODO: This is almost an exact copy of the phase of the same name
783 ;; in glibc/linux. The only difference is that the i686 patch is
784 ;; not applied here. In the next update cycle the patch moves to
785 ;; the patches field and this overwritten phase won't be needed any
787 (replace 'pre-configure
788 (lambda* (#:key inputs native-inputs outputs
790 (let* ((out (assoc-ref outputs "out"))
791 (bin (string-append out "/bin"))
792 ;; FIXME: Normally we would look it up only in INPUTS
793 ;; but cross-base uses it as a native input.
794 (bash (or (assoc-ref inputs "static-bash")
795 (assoc-ref native-inputs "static-bash"))))
796 ;; Install the rpc data base file under `$out/etc/rpc'.
797 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
798 (substitute* "sunrpc/Makefile"
799 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
800 (string-append out "/etc/rpc" suffix "\n"))
801 (("^install-others =.*$")
802 (string-append "install-others = " out "/etc/rpc\n")))
804 (substitute* "Makeconfig"
806 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
807 ;; linking against libgcc_s is not needed with GCC
811 ;; Have `system' use that Bash.
812 (substitute* "sysdeps/posix/system.c"
813 (("#define[[:blank:]]+SHELL_PATH.*$")
814 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
818 (substitute* "libio/iopopen.c"
820 (string-append bash "/bin/sh")))
822 ;; Same for the shell used by the 'exec' functions for
823 ;; scripts that lack a shebang.
824 (substitute* (find-files "." "^paths\\.h$")
825 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
826 (string-append "#define _PATH_BSHELL \""
827 bash "/bin/sh\"\n")))
829 ;; Nscd uses __DATE__ and __TIME__ to create a string to
830 ;; make sure the client and server come from the same
831 ;; libc. Use something deterministic instead.
832 (substitute* "nscd/nscd_stat.c"
833 (("static const char compilation\\[21\\] =.*$")
835 "static const char compilation[21] = \""
836 (string-take (basename out) 20) "\";\n")))
838 ;; Make sure we don't retain a reference to the
840 (substitute* "malloc/mtrace.pl"
842 ;; The shebang can be omitted, because there's the
843 ;; "bilingual" eval/exec magic at the top of the file.
847 (add-after 'install 'augment-libc.so
848 (lambda* (#:key outputs #:allow-other-keys)
849 (let* ((out (assoc-ref outputs "out")))
850 (substitute* (string-append out "/lib/libc.so")
851 (("/[^ ]+/lib/libc.so.0.3")
852 (string-append out "/lib/libc.so.0.3" " libmachuser.so" " libhurduser.so"))))
854 (add-after 'pre-configure 'pre-configure-set-pwd
856 ;; Use the right 'pwd'.
857 (substitute* "configure"
858 (("/bin/pwd") "pwd"))
862 ;; Force mach/hurd/libpthread subdirs to build first in order to avoid
864 ;; See <https://lists.gnu.org/archive/html/bug-hurd/2016-11/msg00045.html>
865 (let ((-j (list "-j" (number->string (parallel-job-count)))))
866 (let-syntax ((make (syntax-rules ()
868 (zero? (apply system* "make" target -j))))))
869 (and (make "mach/subdir_lib")
870 (make "hurd/subdir_lib")
871 (make "libpthread/subdir_lib")
872 (zero? (apply system* "make" -j)))))))))
873 ((#:configure-flags original-configure-flags)
874 `(append (list "--host=i586-pc-gnu"
876 ;; We need this to get a working openpty() function.
879 ;; <https://lists.gnu.org/archive/html/bug-hurd/2016-10/msg00033.html>
882 ;; nscd fails to build for GNU/Hurd:
883 ;; <https://lists.gnu.org/archive/html/bug-hurd/2014-07/msg00006.html>.
886 (filter (lambda (flag)
887 (not (string-prefix? "--enable-kernel=" flag)))
888 ,original-configure-flags)))))
889 (synopsis "The GNU C Library (GNU Hurd variant)")
890 (supported-systems %hurd-systems)))
892 (define* (glibc-for-target #:optional
893 (target (or (%current-target-system)
895 "Return the glibc for TARGET, GLIBC/LINUX for a Linux host or
896 GLIBC/HURD for a Hurd host"
898 ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
902 (identifier-syntax (glibc-for-target)))
904 ;; Below are old libc versions, which we use mostly to build locale data in
905 ;; the old format (which the new libc cannot cope with.)
907 (define-public glibc-2.24
912 (inherit (package-source glibc))
913 (uri (string-append "mirror://gnu/glibc/glibc-"
917 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))))))
919 (define-public glibc-2.23
924 (inherit (package-source glibc))
925 (uri (string-append "mirror://gnu/glibc/glibc-"
929 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))))))
931 (define-public glibc-2.22
936 (inherit (package-source glibc))
937 (uri (string-append "mirror://gnu/glibc/glibc-"
941 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
942 (patches (search-patches "glibc-ldd-x86_64.patch"))))
944 (substitute-keyword-arguments (package-arguments glibc)
946 `(modify-phases ,phases
947 (add-before 'configure 'fix-pwd
949 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.21
950 (substitute* "configure"
951 (("/bin/pwd") "pwd"))))))))))
953 (define-public glibc-2.21
958 (inherit (package-source glibc))
959 (uri (string-append "mirror://gnu/glibc/glibc-"
963 "1f135546j34s9bfkydmx2nhh9vwxlx60jldi80zmsnln6wj3dsxf"))
964 (patches (search-patches "glibc-ldd-x86_64.patch"))))))
966 (define-public glibc-locales
969 (name "glibc-locales")
970 (source (origin (inherit (package-source glibc))
971 (patches (cons (search-patch "glibc-locales.patch")
972 (origin-patches (package-source glibc))))))
973 (synopsis "All the locales supported by the GNU C Library")
975 "This package provides all the locales supported by the GNU C Library,
976 more than 400 in total. To use them set the 'LOCPATH' environment variable to
977 the 'share/locale' sub-directory of this package.")
978 (outputs '("out")) ;110+ MiB
979 (native-search-paths '())
981 (let ((args `(#:tests? #f #:strip-binaries? #f
982 ,@(package-arguments glibc))))
983 (substitute-keyword-arguments args
987 (lambda* (#:key outputs #:allow-other-keys)
988 (zero? (system* "make" "localedata/install-locales"
989 "-j" (number->string (parallel-job-count)))))
990 (alist-delete 'install ,phases)))
991 ((#:configure-flags flags)
993 ;; Use $(libdir)/locale/X.Y as is the case by default.
994 (list (string-append "libc_cv_complocaledir="
995 (assoc-ref %outputs "out")
997 ,(package-version glibc))))))))))
999 (define-public glibc-utf8-locales
1001 (name "glibc-utf8-locales")
1002 (version (package-version glibc))
1004 (build-system trivial-build-system)
1006 `(#:modules ((guix build utils))
1008 (use-modules (srfi srfi-1)
1011 (let* ((libc (assoc-ref %build-inputs "glibc"))
1012 (gzip (assoc-ref %build-inputs "gzip"))
1013 (out (assoc-ref %outputs "out"))
1014 (localedir (string-append out "/lib/locale/"
1016 ;; 'localedef' needs 'gzip'.
1017 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1020 (every (lambda (locale)
1022 ;; Use the "normalized codeset" by
1023 ;; default--e.g., "en_US.utf8".
1024 (string-append localedir "/" locale ".utf8"))
1026 (and (zero? (system* "localedef" "--no-archive"
1027 "--prefix" localedir
1031 ;; For backward compatibility with Guix
1032 ;; <= 0.8.3, add "xx_YY.UTF-8".
1033 (symlink (string-append locale ".utf8")
1034 (string-append localedir "/"
1038 ;; These are the locales commonly used for
1039 ;; tests---e.g., in Guile's i18n tests.
1040 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))))))
1041 (inputs `(("glibc" ,glibc)
1043 (synopsis "Small sample of UTF-8 locales")
1045 "This package provides a small sample of UTF-8 locales mostly useful in
1046 test environments.")
1047 (home-page (package-home-page glibc))
1048 (license (package-license glibc))))
1050 (define-public which
1056 (uri (string-append "mirror://gnu/which/which-"
1060 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1061 (build-system gnu-build-system)
1062 (home-page "https://gnu.org/software/which/")
1063 (synopsis "Find full path of shell commands")
1065 "The which program finds the location of executables in PATH, with a
1066 variety of options. It is an alternative to the shell \"type\" built-in
1068 (license gpl3+))) ; some files are under GPLv2+
1070 (define-public glibc/hurd-headers
1071 (package (inherit glibc/hurd)
1072 (name "glibc-hurd-headers")
1074 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1075 ("hurd-headers" ,hurd-headers)))
1077 (substitute-keyword-arguments (package-arguments glibc/hurd)
1078 ;; We just pass the flags really needed to build the headers.
1079 ((#:configure-flags _)
1080 `(list "--enable-add-ons"
1081 "--host=i586-pc-gnu"
1082 "--enable-obsolete-rpc"))
1086 (lambda* (#:key outputs #:allow-other-keys)
1087 (and (zero? (system* "make" "install-headers"))
1089 ;; Make an empty stubs.h to work around not being able to
1090 ;; produce a valid stubs.h and causing the build to fail. See
1091 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1092 (let ((out (assoc-ref outputs "out")))
1095 (string-append out "/include/gnu/stubs.h"))))))
1097 ;; Nothing to build.
1102 'configure 'pre-configure
1104 ;; Use the right 'pwd'.
1105 (substitute* "configure"
1106 (("/bin/pwd") "pwd")))
1107 %standard-phases))))))))
1109 (define-public tzdata
1116 "https://www.iana.org/time-zones/repository/releases/tzdata"
1120 "11l0s43vx33dcs78p80122i8s5s9l1sjwkzzwh66njd35r92l97q"))))
1121 (build-system gnu-build-system)
1124 #:make-flags (let ((out (assoc-ref %outputs "out"))
1125 (tmp (getenv "TMPDIR")))
1126 (list (string-append "TOPDIR=" out)
1127 (string-append "TZDIR=" out "/share/zoneinfo")
1129 ;; Discard zic, dump, and tzselect, already
1130 ;; provided by glibc.
1131 (string-append "ETCDIR=" tmp "/etc")
1133 ;; Likewise for the C library routines.
1134 (string-append "LIBDIR=" tmp "/lib")
1135 (string-append "MANDIR=" tmp "/man")
1139 #:modules ((guix build utils)
1140 (guix build gnu-build-system)
1143 (modify-phases %standard-phases
1145 (lambda* (#:key source inputs #:allow-other-keys)
1146 (and (zero? (system* "tar" "xvf" source))
1147 (zero? (system* "tar" "xvf" (assoc-ref inputs "tzcode"))))))
1148 (add-after 'install 'post-install
1149 (lambda* (#:key outputs #:allow-other-keys)
1150 ;; Move data in the right place.
1151 (let ((out (assoc-ref outputs "out")))
1152 (symlink (string-append out "/share/zoneinfo")
1153 (string-append out "/share/zoneinfo/posix"))
1154 (delete-file-recursively
1155 (string-append out "/share/zoneinfo-posix"))
1156 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1157 (string-append out "/share/zoneinfo/right"))
1158 (delete-file-recursively
1159 (string-append out "/share/zoneinfo-leaps")))))
1160 (delete 'configure))))
1161 (inputs `(("tzcode" ,(origin
1164 "http://www.iana.org/time-zones/repository/releases/tzcode"
1168 "0h1d567gn8l3iqgyadcswwdy2yh07nhz3lfl8ds8saz2ajxka5sd"))))))
1169 (home-page "https://www.iana.org/time-zones")
1170 (synopsis "Database of current and historical time zones")
1171 (description "The Time Zone Database (often called tz or zoneinfo)
1172 contains code and data that represent the history of local time for many
1173 representative locations around the globe. It is updated periodically to
1174 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1175 and daylight-saving rules.")
1176 (license public-domain)))
1178 ;;; A "fixed" version of tzdata, which is used in the test suites of
1179 ;;; glib and R. We can update this whenever we are able to rebuild
1180 ;;; thousands of packages (for example, in a core-updates rebuild).
1181 (define-public tzdata-2017a
1188 (uri (string-append "https://www.iana.org/time-zones/repository"
1189 "/releases/tzdata" version ".tar.gz"))
1192 "1mmv4rvcs12lrvgghw4fidczvb69yv69cmzknghcvw1c196mqfnz"))))
1193 (inputs `(("tzcode" ,(origin
1196 "http://www.iana.org/time-zones/repository/releases/tzcode"
1200 "1b1q7gnlsh5hjgs5065pvajd37rmbc3k9b8cgzad1vcrifswdwh2"))))))))
1203 (define-public libiconv
1209 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1213 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1214 (modules '((guix build utils)))
1216 ;; Work around "declared gets" error on glibc systems (fixed by
1217 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1218 '(substitute* "srclib/stdio.in.h"
1219 (("^#undef gets") "")
1220 (("^_GL_WARN_ON_USE \\(gets.*") "")))))
1221 (build-system gnu-build-system)
1222 (synopsis "Character set conversion library")
1224 "libiconv provides an implementation of the iconv function for systems
1225 that lack it. iconv is used to convert between character encodings in a
1226 program. It supports a wide variety of different encodings.")
1227 (home-page "https://www.gnu.org/software/libiconv/")
1230 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1231 "Return either a libiconv package specification to include in a dependency
1232 list for platforms that have an incomplete libc, or the empty list. If a
1233 package needs iconv ,@(libiconv-if-needed) should be added."
1234 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1235 ;; without iconv, such as MinGW, must return the then clause.
1236 (if (target-mingw? target)
1237 `(("libiconv" ,libiconv))
1240 (define-public (canonical-package package)
1241 ;; Avoid circular dependency by lazily resolving 'commencement'.
1242 (let* ((iface (resolve-interface '(gnu packages commencement)))
1243 (proc (module-ref iface 'canonical-package)))
1246 (define-public (%final-inputs)
1247 "Return the list of \"final inputs\"."
1248 ;; Avoid circular dependency by lazily resolving 'commencement'.
1249 (let ((iface (resolve-interface '(gnu packages commencement))))
1250 (module-ref iface '%final-inputs)))
1252 ;;; base.scm ends here