1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2019 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
5 ;;; Copyright © 2014, 2015, 2016, 2018 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, 2017, 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
9 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
10 ;;; Copyright © 2016, 2018 Alex Vong <alexvong1995@gmail.com>
11 ;;; Copyright © 2017 Rene Saavedra <rennes@openmailbox.org>
12 ;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
13 ;;; Copyright © 2017, 2018, 2020 Marius Bakke <mbakke@fastmail.com>
14 ;;; Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
15 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
16 ;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
18 ;;; This file is part of GNU Guix.
20 ;;; GNU Guix is free software; you can redistribute it and/or modify it
21 ;;; under the terms of the GNU General Public License as published by
22 ;;; the Free Software Foundation; either version 3 of the License, or (at
23 ;;; your option) any later version.
25 ;;; GNU Guix is distributed in the hope that it will be useful, but
26 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
27 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 ;;; GNU General Public License for more details.
30 ;;; You should have received a copy of the GNU General Public License
31 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
33 (define-module (gnu packages base)
34 #:use-module ((guix licenses)
35 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
36 #:use-module (gnu packages)
37 #:use-module (gnu packages acl)
38 #:use-module (gnu packages algebra)
39 #:use-module (gnu packages bash)
40 #:use-module (gnu packages bison)
41 #:use-module (gnu packages ed)
42 #:use-module (gnu packages gcc)
43 #:use-module (gnu packages guile)
44 #:use-module (gnu packages multiprecision)
45 #:use-module (gnu packages compression)
46 #:use-module (gnu packages perl)
47 #:use-module (gnu packages linux)
48 #:use-module (gnu packages pcre)
49 #:use-module (gnu packages texinfo)
50 #:use-module (gnu packages hurd)
51 #:use-module (gnu packages pkg-config)
52 #:use-module (gnu packages python)
53 #:use-module (gnu packages gettext)
54 #:use-module (guix utils)
55 #:use-module (guix packages)
56 #:use-module (guix download)
57 #:use-module (guix git-download)
58 #:use-module (guix build-system gnu)
59 #:use-module (guix build-system trivial)
60 #:use-module (ice-9 match)
61 #:use-module (srfi srfi-1)
62 #:use-module (srfi srfi-26)
68 ;;; Base packages of the Guix-based GNU user-land software distribution.
78 (uri (string-append "mirror://gnu/hello/hello-" version
82 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
83 (build-system gnu-build-system)
84 (synopsis "Hello, GNU world: An example GNU package")
86 "GNU Hello prints the message \"Hello, world!\" and then exits. It
87 serves as an example of standard GNU coding practices. As such, it supports
88 command-line arguments, multiple languages, and so on.")
89 (home-page "https://www.gnu.org/software/hello/")
98 (uri (string-append "mirror://gnu/grep/grep-"
102 "1yy33kiwrxrwj2nxa4fg15bvmwyghqbs8qwkdvy5phm784f7brjq"))
103 (patches (search-patches "grep-timing-sensitive-test.patch"))))
104 (build-system gnu-build-system)
105 (native-inputs `(("perl" ,perl))) ;some of the tests require it
106 (inputs `(("pcre" ,pcre)))
109 (modify-phases %standard-phases
110 (add-after 'install 'fix-egrep-and-fgrep
111 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
112 ;; absolute file name instead of searching for it in $PATH.
113 (lambda* (#:key outputs #:allow-other-keys)
114 (let* ((out (assoc-ref outputs "out"))
115 (bin (string-append out "/bin")))
116 (substitute* (list (string-append bin "/egrep")
117 (string-append bin "/fgrep"))
119 (string-append "exec " bin "/grep")))
121 (synopsis "Print lines matching a pattern")
123 "grep is a tool for finding text inside files. Text is found by
124 matching a pattern provided by the user in one or many files. The pattern
125 may be provided as a basic or extended regular expression, or as fixed
126 strings. By default, the matching text is simply printed to the screen,
127 however the output can be greatly customized to include, for example, line
128 numbers. GNU grep offers many extensions over the standard utility,
129 including, for example, recursive directory searching.")
131 (home-page "https://www.gnu.org/software/grep/")))
139 (uri (string-append "mirror://gnu/sed/sed-" version
143 "0alqagh0nliymz23kfjg6g9w3cr086k0sfni56gi8fhzqwa3xksk"))))
144 (build-system gnu-build-system)
145 (synopsis "Stream editor")
147 `(("perl" ,perl))) ;for tests
149 "Sed is a non-interactive, text stream editor. It receives a text
150 input from a file or from standard input and it then applies a series of text
151 editing commands to the stream and prints its output to standard output. It
152 is often used for substituting text patterns in a stream. The GNU
153 implementation offers several extensions over the standard utility.")
155 (home-page "https://www.gnu.org/software/sed/")))
163 (uri (string-append "mirror://gnu/tar/tar-"
167 "1n7xy657ii0sa42zx6944v2m4v9qrh6sqgmw17l3nch3y43sxlyh"))
168 (patches (search-patches "tar-skip-unreliable-tests.patch"
169 "tar-remove-wholesparse-check.patch"))))
170 (build-system gnu-build-system)
171 ;; Note: test suite requires ~1GiB of disk space.
173 `(#:phases (modify-phases %standard-phases
174 (add-before 'build 'set-shell-file-name
175 (lambda* (#:key inputs #:allow-other-keys)
176 ;; Do not use "/bin/sh" to run programs.
177 (let ((bash (assoc-ref inputs "bash")))
178 (substitute* "src/system.c"
180 (string-append bash "/bin/sh")))
183 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
184 ;; to refer to the target Bash.
185 (inputs (if (%current-target-system)
189 (synopsis "Managing tar archives")
191 "Tar provides the ability to create tar archives, as well as the
192 ability to extract, update or list files in an existing archive. It is
193 useful for combining many files into one larger file, while maintaining
194 directory structure and file information such as permissions and
195 creation/modification dates. GNU tar offers many extensions over the
198 (home-page "https://www.gnu.org/software/tar/")))
206 (uri (string-append "mirror://gnu/patch/patch-"
210 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
211 (patches (search-patches "patch-hurd-path-max.patch"))))
212 (build-system gnu-build-system)
214 ;; Work around a cross-compilation bug whereby libpatch.a would provide
215 ;; '__mktime_internal', which conflicts with the one in libc.a.
216 (if (%current-target-system)
217 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
219 (native-inputs `(("ed" ,ed)))
220 (synopsis "Apply differences to originals, with optional backups")
222 "Patch is a program that applies changes to files based on differences
223 laid out as by the program \"diff\". The changes may be applied to one or more
224 files depending on the contents of the diff file. It accepts several
225 different diff formats. It may also be used to revert previously applied
228 (home-page "https://savannah.gnu.org/projects/patch/")))
230 (define-public diffutils
236 (uri (string-append "mirror://gnu/diffutils/diffutils-"
240 "09isrg0isjinv8c535nxsi1s86wfdfzml80dbw41dj9x3hiad9xk"))))
241 (build-system gnu-build-system)
242 (native-inputs `(("perl" ,perl)))
243 (synopsis "Comparing and merging files")
245 "GNU Diffutils is a package containing tools for finding the
246 differences between files. The \"diff\" command is used to show how two files
247 differ, while \"cmp\" shows the offsets and line numbers where they differ.
248 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
249 interactive means to merge two files.")
251 (home-page "https://www.gnu.org/software/diffutils/")))
253 (define-public findutils
259 (uri (string-append "mirror://gnu/findutils/findutils-"
263 "16kqz9yz98dasmj70jwf5py7jk558w96w0vgp3zf9xsqk3gzpzn5"))
264 (patches (search-patches "findutils-localstatedir.patch"
265 "findutils-test-rwlock-threads.patch"))))
266 (build-system gnu-build-system)
268 `(#:configure-flags (list
269 ;; Tell 'updatedb' to write to /var.
270 "--localstatedir=/var")
271 #:phases (modify-phases %standard-phases
272 (add-before 'check 'adjust-test-shebangs
274 (substitute* '("tests/xargs/verbose-quote.sh"
275 "tests/find/exec-plus-last-file.sh")
277 (string-append "#!" (which "sh"))))
279 (synopsis "Operating on files matching given criteria")
281 "Findutils supplies the basic file directory searching utilities of the
282 GNU system. It consists of two primary searching utilities: \"find\"
283 recursively searches for files in a directory according to given criteria and
284 \"locate\" lists files in a database that match a query. Two auxiliary tools
285 are included: \"updatedb\" updates the file name database and \"xargs\" may be
286 used to apply commands with arbitrarily long arguments.")
288 (home-page "https://www.gnu.org/software/findutils/")))
290 (define-public coreutils
296 (uri (string-append "mirror://gnu/coreutils/coreutils-"
300 "1yjcrh5hw70c0yn8zw55pd6j51dj90anpq8mmg649ps9g3gdhn24"))
301 (patches (search-patches "coreutils-ls.patch"))))
302 (build-system gnu-build-system)
303 (inputs `(("acl" ,acl) ; TODO: add SELinux
304 ("gmp" ,gmp) ;bignums in 'expr', yay!
306 ;; Drop the dependency on libcap when cross-compiling since it's
307 ;; not quite cross-compilable.
308 ,@(if (%current-target-system)
310 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
312 ;; Perl is needed to run tests in native builds, and to run the bundled
313 ;; copy of help2man. However, don't pass it when cross-compiling since
314 ;; that would lead it to try to run programs to get their '--help' output
316 (if (%current-target-system)
319 (outputs '("out" "debug"))
321 `(#:parallel-build? #f ; help2man may be called too early
322 #:phases (modify-phases %standard-phases
323 (add-before 'build 'patch-shell-references
325 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
326 ;; that tests pass, since /bin/sh isn't in the chroot.
327 (setenv "SHELL" (which "sh"))
329 (substitute* (find-files "gnulib-tests" "\\.c$")
330 (("/bin/sh") (which "sh")))
331 (substitute* (find-files "tests" "\\.sh$")
332 (("#!/bin/sh") (string-append "#!" (which "sh"))))
334 (synopsis "Core GNU utilities (file, text, shell)")
336 "GNU Coreutils includes all of the basic command-line tools that are
337 expected in a POSIX system. These provide the basic file, shell and text
338 manipulation functions of the GNU system. Most of these tools offer extended
339 functionality beyond that which is outlined in the POSIX standard.")
341 (home-page "https://www.gnu.org/software/coreutils/")))
343 (define-public coreutils-minimal
344 ;; Coreutils without its optional dependencies.
347 (name "coreutils-minimal")
351 (define-public gnu-make
357 (uri (string-append "mirror://gnu/make/make-" version
361 "06cfqzpqsvdnsxbysl5p2fgdgxgl9y4p7scpnrfa8z2zgkjdspz0"))
362 (patches (search-patches "make-impure-dirs.patch"))))
363 (build-system gnu-build-system)
364 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
365 (inputs `(("guile" ,guile-3.0)))
366 (outputs '("out" "debug"))
369 (modify-phases %standard-phases
370 (add-before 'build 'set-default-shell
371 (lambda* (#:key inputs #:allow-other-keys)
372 ;; Change the default shell from /bin/sh.
373 (let ((bash (assoc-ref inputs "bash")))
374 (substitute* "src/job.c"
375 (("default_shell =.*$")
376 (format #f "default_shell = \"~a/bin/sh\";\n"
379 (synopsis "Remake files automatically")
381 "Make is a program that is used to control the production of
382 executables or other files from their source files. The process is
383 controlled from a Makefile, in which the developer specifies how each file is
384 generated from its source. It has powerful dependency resolution and the
385 ability to determine when files have to be regenerated after their sources
386 change. GNU make offers many powerful extensions over the standard utility.")
388 (home-page "https://www.gnu.org/software/make/")))
390 (define-public binutils
396 (uri (string-append "mirror://gnu/binutils/binutils-"
400 "1rin1f5c7wm4n3piky6xilcrpf2s0n3dd5vqq8irrxkcic3i1w49"))
401 (patches (search-patches "binutils-loongson-workaround.patch"))))
402 (build-system gnu-build-system)
404 ;; TODO: Add dependency on zlib + those for Gold.
406 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
407 ;; on GCC when bootstrapping.
408 "LDFLAGS=-static-libgcc"
410 ;; Turn on --enable-new-dtags by default to make the
411 ;; linker set RUNPATH instead of RPATH on binaries.
412 ;; This is important because RUNPATH can be overriden
413 ;; using LD_LIBRARY_PATH at runtime.
416 ;; Don't search under /usr/lib & co.
417 "--with-lib-path=/no-ld-lib-path"
419 ;; Install BFD. It ends up in a hidden directory,
421 "--enable-install-libbfd"
423 ;; Make sure 'ar' and 'ranlib' produce archives in a
424 ;; deterministic fashion.
425 "--enable-deterministic-archives")
427 ;; XXX: binutils 2.34 was mistakenly released without generated manuals:
428 ;; <https://sourceware.org/bugzilla/show_bug.cgi?id=25491>. To avoid a
429 ;; circular dependency on texinfo, prevent the build system from creating
430 ;; the manuals by calling "true" instead of "makeinfo"...
431 #:make-flags '("MAKEINFO=true")))
433 ;; ...and "hide" this package so that users who install binutils get the
434 ;; version with documentation defined below.
435 (properties '((hidden? . #t)))
437 (synopsis "Binary utilities: bfd gas gprof ld")
439 "GNU Binutils is a collection of tools for working with binary files.
440 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
441 Other tools include programs to display binary profiling information, list
442 the strings in a binary file, and utilities for working with archives. The
443 \"bfd\" library for working with executable and object formats is also
446 (home-page "https://www.gnu.org/software/binutils/")))
448 ;; Work around a problem with binutils 2.34 whereby manuals are missing from
449 ;; the release tarball. Remove this and the related code above when updating.
450 (define-public binutils+documentation
454 `(("texinfo" ,texinfo)))
456 (substitute-keyword-arguments (package-arguments binutils)
457 ((#:make-flags _ ''()) ''())))
460 ;; FIXME: ath9k-firmware-htc-binutils.patch do not apply on 2.34 because of a
461 ;; big refactoring of xtensa-modules.c (commit 567607c11fbf7105 upstream).
462 ;; Keep this version around until the patch is updated.
463 (define-public binutils-2.33
468 (inherit (package-source binutils))
469 (uri (string-append "mirror://gnu/binutils/binutils-"
473 "1cmd0riv37bqy9mwbg6n3523qgr8b3bbm5kwj19sjrasl4yq9d0c"))))
475 (substitute-keyword-arguments (package-arguments binutils)
476 ((#:make-flags _ ''()) ''())))
479 (define-public binutils-gold
482 (name "binutils-gold")
485 (modify-phases %standard-phases
486 (add-after 'patch-source-shebangs 'patch-more-shebangs
488 (substitute* "gold/Makefile.in"
489 (("/bin/sh") (which "sh")))
491 ,@(substitute-keyword-arguments (package-arguments binutils)
492 ; Upstream is aware of unrelocatable test failures on arm*.
494 (if (any (cute string-prefix? <> (or (%current-target-system)
498 ((#:configure-flags flags)
499 `(cons* "--enable-gold=default"
500 (delete "LDFLAGS=-static-libgcc" ,flags))))))
504 `(("gcc:lib" ,gcc "lib")))))
506 (define* (make-ld-wrapper name #:key
509 (guile (canonical-package guile-2.2))
510 (bash (canonical-package bash))
511 (guile-for-build guile))
512 "Return a package called NAME that contains a wrapper for the 'ld' program
513 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
514 wrapper uses GUILE and BASH.
516 TARGET must be a one-argument procedure that, given a system type, returns a
517 cross-compilation target triplet or #f. When the result is not #f, make a
518 wrapper for the cross-linker for that target, called 'TARGET-ld'."
519 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
520 ;; its result can be delayed until the 'arguments' field is evaluated, thus
521 ;; in a context where '%current-system' is accurate.
526 (build-system trivial-build-system)
527 (inputs `(("binutils" ,binutils)
530 ("wrapper" ,(search-path %load-path
531 "gnu/packages/ld-wrapper.in"))))
533 (let ((target (target (%current-system))))
534 `(#:guile ,guile-for-build
535 #:modules ((guix build utils))
537 (use-modules (guix build utils)
538 (system base compile))
540 (let* ((out (assoc-ref %outputs "out"))
541 (bin (string-append out "/bin"))
543 `(string-append bin "/" ,target "-ld")
544 '(string-append bin "/ld")))
545 (go (string-append ld ".go")))
547 (setvbuf (current-output-port) _IOLBF)
548 (format #t "building ~s/bin/ld wrapper in ~s~%"
549 (assoc-ref %build-inputs "binutils")
553 (copy-file (assoc-ref %build-inputs "wrapper") ld)
558 (string-append (assoc-ref %build-inputs "guile")
561 (string-append (assoc-ref %build-inputs "bash")
564 (string-append (assoc-ref %build-inputs "binutils")
566 (string-append "/bin/"
570 (compile-file ld #:output-file go)
572 (synopsis "The linker wrapper")
574 "The linker wrapper (or @code{ld-wrapper}) wraps the linker to add any
575 missing @code{-rpath} flags, and to detect any misuse of libraries outside of
577 (home-page "https://www.gnu.org/software/guix//")
580 (export make-ld-wrapper)
583 ;; This is the GNU C Library, used on GNU/Linux and GNU/Hurd. Prior to
584 ;; version 2.28, GNU/Hurd used a different glibc branch.
590 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
593 "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
595 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
596 ;; required on LFS distros to avoid loading the distro's libc.so
599 (substitute* "sysdeps/unix/sysv/linux/configure"
600 (("use_ldconfig=yes")
603 (modules '((guix build utils)))
604 (patches (search-patches "glibc-ldd-x86_64.patch"
605 "glibc-hidden-visibility-ldconfig.patch"
606 "glibc-versioned-locpath.patch"
607 "glibc-allow-kernel-2.6.32.patch"
608 "glibc-reinstate-prlimit64-fallback.patch"
609 "glibc-supported-locales.patch"))))
610 (build-system gnu-build-system)
612 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
613 ;; users should automatically pull Linux headers as well. On GNU/Hurd,
614 ;; libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
615 ;; so both should be propagated.
618 `(("hurd-core-headers" ,hurd-core-headers))
619 `(("kernel-headers" ,linux-libre-headers))))
621 (outputs '("out" "debug"
622 "static")) ;9 MiB of .a files
625 `(#:out-of-source? #t
627 ;; The libraries have an empty RUNPATH, but some, such as the versioned
628 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
629 ;; these libraries are always going to be found anyway, just skip
631 #:validate-runpath? #f
633 #:modules ((ice-9 ftw)
636 (guix build gnu-build-system))
639 (list "--sysconfdir=/etc"
641 ;; Installing a locale archive with all the locales is to
642 ;; expensive (~100 MiB), so we rely on users to install the
643 ;; locales they really want.
645 ;; Set the default locale path. In practice, $LOCPATH may be
646 ;; defined to point whatever locales users want. However, setuid
647 ;; binaries don't honor $LOCPATH, so they'll instead look into
648 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
649 ;; with the idea that it is going to be populated by the sysadmin.
650 ;; The "X.Y" sub-directory is because locale data formats are
651 ;; incompatible across libc versions; see
652 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
654 ;; `--localedir' is not honored, so work around it.
655 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
656 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
657 ,(version-major+minor version))
659 (string-append "--with-headers="
660 (assoc-ref ,(if (%current-target-system)
661 '%build-target-inputs
666 ;; This is the default for most architectures as of GNU libc 2.26,
667 ;; but we specify it explicitly for clarity and consistency. See
668 ;; "kernel-features.h" in the GNU libc for details.
669 "--enable-kernel=3.2.0"
671 ;; Use our Bash instead of /bin/sh.
672 (string-append "BASH_SHELL="
673 (assoc-ref %build-inputs "bash")
676 ;; On GNU/Hurd we get discarded-qualifiers warnings for
677 ;; 'device_write_inband' among other things. Ignore them.
679 '("--disable-werror")
683 #:phases (modify-phases %standard-phases
685 'configure 'pre-configure
686 (lambda* (#:key inputs native-inputs outputs
688 (let* ((out (assoc-ref outputs "out"))
689 (bin (string-append out "/bin"))
690 ;; FIXME: Normally we would look it up only in INPUTS
691 ;; but cross-base uses it as a native input.
692 (bash (or (assoc-ref inputs "static-bash")
693 (assoc-ref native-inputs "static-bash"))))
694 ;; Install the rpc data base file under `$out/etc/rpc'.
695 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
696 (substitute* "sunrpc/Makefile"
697 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
698 (string-append out "/etc/rpc" suffix "\n"))
699 (("^install-others =.*$")
700 (string-append "install-others = " out "/etc/rpc\n")))
702 (substitute* "Makeconfig"
704 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
705 ;; linking against libgcc_s is not needed with GCC
709 ;; Have `system' use that Bash.
710 (substitute* "sysdeps/posix/system.c"
711 (("#define[[:blank:]]+SHELL_PATH.*$")
712 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
716 (substitute* "libio/iopopen.c"
718 (string-append bash "/bin/sh")))
720 ;; Same for the shell used by the 'exec' functions for
721 ;; scripts that lack a shebang.
722 (substitute* (find-files "." "^paths\\.h$")
723 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
724 (string-append "#define _PATH_BSHELL \""
725 bash "/bin/sh\"\n")))
727 ;; Nscd uses __DATE__ and __TIME__ to create a string to
728 ;; make sure the client and server come from the same
729 ;; libc. Use something deterministic instead.
730 (substitute* "nscd/nscd_stat.c"
731 (("static const char compilation\\[21\\] =.*$")
733 "static const char compilation[21] = \""
734 (string-take (basename out) 20) "\";\n")))
736 ;; Make sure we don't retain a reference to the
738 (substitute* "malloc/mtrace.pl"
740 ;; The shebang can be omitted, because there's the
741 ;; "bilingual" eval/exec magic at the top of the file.
748 (add-after 'install 'move-static-libs
749 (lambda* (#:key outputs #:allow-other-keys)
750 ;; Move static libraries to the "static" output.
751 (define (static-library? file)
752 ;; Return true if FILE is a static library. The
753 ;; "_nonshared.a" files are referred to by libc.so,
754 ;; libpthread.so, etc., which are in fact linker
756 (and (string-suffix? ".a" file)
757 (not (string-contains file "_nonshared"))))
759 (define (linker-script? file)
760 ;; Guess whether FILE, a ".a" file, is actually a
762 (and (not (ar-file? file))
763 (not (elf-file? file))))
765 (let* ((out (assoc-ref outputs "out"))
766 (lib (string-append out "/lib"))
767 (files (scandir lib static-library?))
768 (static (assoc-ref outputs "static"))
769 (slib (string-append static "/lib")))
771 (for-each (lambda (base)
772 (rename-file (string-append lib "/" base)
773 (string-append slib "/" base)))
776 ;; Usually libm.a is a linker script so we need to
777 ;; change the file names in there to refer to STATIC
779 (for-each (lambda (ld-script)
780 (substitute* ld-script
782 (filter linker-script?
783 (map (cut string-append slib "/" <>)
788 '((add-after 'install 'augment-libc.so
789 (lambda* (#:key outputs #:allow-other-keys)
790 (let* ((out (assoc-ref outputs "out")))
791 (substitute* (string-append out "/lib/libc.so")
792 (("/[^ ]+/lib/libc.so.0.3")
793 (string-append out "/lib/libc.so.0.3"
794 " libmachuser.so libhurduser.so"))))
798 (inputs `(("static-bash" ,static-bash)))
800 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
801 ;; install the message catalogs, with 'msgfmt'.
802 (native-inputs `(("texinfo" ,texinfo)
805 ("gettext" ,gettext-minimal)
806 ("python" ,python-minimal)
814 ;; Search path for packages that provide locale data. This is useful
815 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
816 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
818 (list (search-path-specification
819 (variable "GUIX_LOCPATH")
820 (files '("lib/locale")))))
822 (synopsis "The GNU C Library")
824 "Any Unix-like operating system needs a C library: the library which
825 defines the \"system calls\" and other basic facilities such as open, malloc,
828 The GNU C library is used as the C library in the GNU system and most systems
829 with the Linux kernel.")
831 (home-page "https://www.gnu.org/software/libc/")))
833 ;; Below are old libc versions, which we use mostly to build locale data in
834 ;; the old format (which the new libc cannot cope with.)
836 (define-public glibc-2.30
841 (inherit (package-source glibc))
842 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
845 "1bxqpg91d02qnaz837a5kamm0f43pr1il4r9pknygywsar713i72"))
846 (patches (search-patches "glibc-ldd-x86_64.patch"
847 "glibc-CVE-2019-19126.patch"
848 "glibc-hidden-visibility-ldconfig.patch"
849 "glibc-versioned-locpath.patch"
850 "glibc-allow-kernel-2.6.32.patch"
851 "glibc-reinstate-prlimit64-fallback.patch"
852 "glibc-2.29-supported-locales.patch"))))))
854 (define-public glibc-2.29
859 (inherit (package-source glibc))
860 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
863 "0jzh58728flfh939a8k9pi1zdyalfzlxmwra7k0rzji5gvavivpk"))
864 (patches (search-patches "glibc-ldd-x86_64.patch"
865 "glibc-CVE-2019-7309.patch"
866 "glibc-CVE-2019-9169.patch"
867 "glibc-2.29-git-updates.patch"
868 "glibc-hidden-visibility-ldconfig.patch"
869 "glibc-versioned-locpath.patch"
870 "glibc-allow-kernel-2.6.32.patch"
871 "glibc-reinstate-prlimit64-fallback.patch"
872 "glibc-2.29-supported-locales.patch"))))))
874 (define-public glibc-2.28
879 (inherit (package-source glibc))
880 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
883 "10iha5ynvdj5m62vgpgqbq4cwvc2yhyl2w9yyyjgfxmdmx8h145i"))
884 (patches (search-patches "glibc-ldd-x86_64.patch"
885 "glibc-2.28-git-fixes.patch"
886 "glibc-hidden-visibility-ldconfig.patch"
887 "glibc-versioned-locpath.patch"
888 "glibc-allow-kernel-2.6.32.patch"
889 "glibc-reinstate-prlimit64-fallback.patch"
890 "glibc-hurd-magic-pid.patch"
891 "glibc-2.28-supported-locales.patch"))))))
893 (define-public glibc-2.27
898 (inherit (package-source glibc))
899 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
902 "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"))
903 (patches (search-patches "glibc-ldd-x86_64.patch"
904 "glibc-2.27-git-fixes.patch"
905 "glibc-hidden-visibility-ldconfig.patch"
906 "glibc-versioned-locpath.patch"
907 "glibc-allow-kernel-2.6.32.patch"
908 "glibc-reinstate-prlimit64-fallback.patch"
909 "glibc-2.27-supported-locales.patch"
910 "glibc-CVE-2018-11236.patch"
911 "glibc-CVE-2018-11237.patch"))))
912 (properties `((lint-hidden-cve . ("CVE-2017-18269")))))) ; glibc-2.27-git-fixes
914 (define-public glibc-2.26
917 ;; This version number corresponds to the output of `git describe` and the
918 ;; archive can be generated by checking out the commit ID and running:
919 ;; git archive --prefix=$(git describe)/ HEAD | xz > $(git describe).tar.xz
920 ;; See <https://bugs.gnu.org/29406> for why this was necessary.
921 (version "2.26.105-g0890d5379c")
923 (inherit (package-source glibc))
924 (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/"
925 "glibc-" (version-major+minor version) "-"
926 (caddr (string-split version #\.)) ".tar.xz"))
929 "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
930 (patches (search-patches "glibc-ldd-x86_64.patch"
931 "glibc-versioned-locpath.patch"
932 "glibc-allow-kernel-2.6.32.patch"))))))
934 (define-public glibc-2.25
939 (inherit (package-source glibc))
940 (uri (string-append "mirror://gnu/glibc/glibc-"
944 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
945 (patches (search-patches "glibc-ldd-x86_64.patch"
946 "glibc-versioned-locpath.patch"
947 "glibc-vectorized-strcspn-guards.patch"
948 "glibc-CVE-2017-1000366-pt1.patch"
949 "glibc-CVE-2017-1000366-pt2.patch"
950 "glibc-CVE-2017-1000366-pt3.patch"))))))
952 (define-public glibc-2.24
957 (inherit (package-source glibc))
958 (uri (string-append "mirror://gnu/glibc/glibc-"
962 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
963 (patches (search-patches "glibc-ldd-x86_64.patch"
964 "glibc-versioned-locpath.patch"
965 "glibc-vectorized-strcspn-guards.patch"
966 "glibc-CVE-2015-5180.patch"
967 "glibc-CVE-2017-1000366-pt1.patch"
968 "glibc-CVE-2017-1000366-pt2.patch"
969 "glibc-CVE-2017-1000366-pt3.patch"))))))
971 (define-public glibc-2.23
976 (inherit (package-source glibc))
977 (uri (string-append "mirror://gnu/glibc/glibc-"
981 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
982 (patches (search-patches "glibc-ldd-x86_64.patch"
983 "glibc-versioned-locpath.patch"
984 "glibc-vectorized-strcspn-guards.patch"
985 "glibc-CVE-2015-5180.patch"
986 "glibc-CVE-2016-3075.patch"
987 "glibc-CVE-2016-3706.patch"
988 "glibc-CVE-2016-4429.patch"
989 "glibc-CVE-2017-1000366-pt1.patch"
990 "glibc-CVE-2017-1000366-pt2.patch"
991 "glibc-CVE-2017-1000366-pt3.patch"))))))
993 (define-public glibc-2.22
998 (inherit (package-source glibc))
999 (uri (string-append "mirror://gnu/glibc/glibc-"
1003 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
1004 (patches (search-patches "glibc-ldd-x86_64.patch"
1005 "glibc-o-largefile.patch"
1006 "glibc-vectorized-strcspn-guards.patch"
1007 "glibc-CVE-2015-5180.patch"
1008 "glibc-CVE-2015-7547.patch"
1009 "glibc-CVE-2016-3075.patch"
1010 "glibc-CVE-2016-3706.patch"
1011 "glibc-CVE-2016-4429.patch"
1012 "glibc-CVE-2017-1000366-pt1.patch"
1013 "glibc-CVE-2017-1000366-pt2.patch"
1014 "glibc-CVE-2017-1000366-pt3.patch"))))
1016 (substitute-keyword-arguments (package-arguments glibc)
1018 `(modify-phases ,phases
1019 (add-before 'configure 'fix-pwd
1021 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
1022 (substitute* "configure"
1023 (("/bin/pwd") "pwd"))
1026 (define-public (make-gcc-libc base-gcc libc)
1027 "Return a GCC that targets LIBC."
1028 (package (inherit base-gcc)
1029 (name (string-append (package-name base-gcc) "-"
1030 (package-name libc) "-"
1031 (package-version libc)))
1033 (ensure-keyword-arguments (package-arguments base-gcc)
1034 '(#:implicit-inputs? #f)))
1036 `(,@(package-native-inputs base-gcc)
1037 ,@(append (fold alist-delete (%final-inputs) '("libc" "libc:static")))
1039 ("libc:static" ,libc "static")))))
1041 (define-public (make-glibc-locales glibc)
1044 (name "glibc-locales")
1045 (source (origin (inherit (package-source glibc))
1046 ;; The patch for glibc 2.28 and earlier replaces the same
1047 ;; content, but the context in the patch is different
1048 ;; enough to fail to merge.
1049 (patches (cons (search-patch
1050 (if (version>=? (package-version glibc)
1052 "glibc-locales.patch"
1053 "glibc-locales-2.28.patch"))
1054 (origin-patches (package-source glibc))))))
1055 (synopsis "All the locales supported by the GNU C Library")
1057 "This package provides all the locales supported by the GNU C Library,
1058 more than 400 in total. To use them set the @code{LOCPATH} environment variable
1059 to the @code{share/locale} sub-directory of this package.")
1060 (outputs '("out")) ;110+ MiB
1061 (native-search-paths '())
1063 (let ((args `(#:tests? #f #:strip-binaries? #f
1064 ,@(package-arguments glibc))))
1065 (substitute-keyword-arguments args
1066 ((#:modules modules '((guix build utils)
1067 (guix build gnu-build-system)))
1071 ((#:imported-modules modules '())
1072 `((gnu build locale)
1073 ,@%gnu-build-system-modules))
1075 `(modify-phases ,phases
1078 (invoke "make" "localedata/install-locales"
1079 "-j" (number->string (parallel-job-count)))))
1080 (add-after 'build 'symlink-normalized-codesets
1081 (lambda* (#:key outputs #:allow-other-keys)
1082 ;; The above phase does not install locales with names using
1083 ;; the "normalized codeset." Thus, create symlinks like:
1084 ;; en_US.utf8 -> en_US.UTF-8
1085 (define (locale-directory? file stat)
1086 (and (file-is-directory? file)
1087 (string-index (basename file) #\_)
1088 (string-rindex (basename file) #\.)))
1090 (let* ((out (assoc-ref outputs "out"))
1091 (locales (find-files out locale-directory?
1092 #:directories? #t)))
1093 (for-each (lambda (directory)
1094 (let*-values (((base)
1095 (basename directory))
1097 (locale->name+codeset base))
1099 (normalize-codeset codeset)))
1100 (unless (string=? codeset normalized)
1102 (string-append (dirname directory)
1108 (delete 'move-static-libs)))
1109 ((#:configure-flags flags)
1111 ;; Use $(libdir)/locale/X.Y as is the case by default.
1112 (list (string-append "libc_cv_complocaledir="
1113 (assoc-ref %outputs "out")
1115 ,(version-major+minor
1116 (package-version glibc)))))))))))
1118 (define-public (make-glibc-utf8-locales glibc)
1120 (name "glibc-utf8-locales")
1121 (version (package-version glibc))
1123 (build-system trivial-build-system)
1125 `(#:modules ((guix build utils))
1127 (use-modules (guix build utils))
1129 (let* ((libc (assoc-ref %build-inputs "glibc"))
1130 (gzip (assoc-ref %build-inputs "gzip"))
1131 (out (assoc-ref %outputs "out"))
1132 (localedir (string-append out "/lib/locale/"
1133 ,(version-major+minor version))))
1134 ;; 'localedef' needs 'gzip'.
1135 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1138 (for-each (lambda (locale)
1140 ;; Use the "normalized codeset" by
1141 ;; default--e.g., "en_US.utf8".
1142 (string-append localedir "/" locale ".utf8"))
1144 (invoke "localedef" "--no-archive"
1145 "--prefix" localedir
1149 ;; For backward compatibility with Guix
1150 ;; <= 0.8.3, add "xx_YY.UTF-8".
1151 (symlink (string-append locale ".utf8")
1152 (string-append localedir "/"
1155 ;; These are the locales commonly used for
1156 ;; tests---e.g., in Guile's i18n tests.
1157 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
1159 (native-inputs `(("glibc" ,glibc)
1161 (synopsis "Small sample of UTF-8 locales")
1163 "This package provides a small sample of UTF-8 locales mostly useful in
1164 test environments.")
1165 (home-page (package-home-page glibc))
1166 (license (package-license glibc))))
1168 (define-public glibc-locales
1169 (make-glibc-locales glibc))
1170 (define-public glibc-utf8-locales
1171 (make-glibc-utf8-locales glibc))
1173 ;; Packages provided to ease use of binaries linked against the previous libc.
1174 (define-public glibc-locales-2.28
1175 (package (inherit (make-glibc-locales glibc-2.28))
1176 (name "glibc-locales-2.28")))
1177 (define-public glibc-utf8-locales-2.28
1178 (package (inherit (make-glibc-utf8-locales glibc-2.28))
1179 (name "glibc-utf8-locales-2.28")))
1181 ;; These should no longer be needed.
1182 (define-public glibc-utf8-locales-2.27
1183 (deprecated-package "glibc-utf8-locales-2.27" glibc-utf8-locales-2.28))
1184 (define-public glibc-locales-2.27
1185 (deprecated-package "glibc-locales-2.27" glibc-locales-2.28))
1187 (define-public which
1193 (uri (string-append "mirror://gnu/which/which-"
1197 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1198 (build-system gnu-build-system)
1199 (home-page "https://gnu.org/software/which/")
1200 (synopsis "Find full path of shell commands")
1202 "The which program finds the location of executables in PATH, with a
1203 variety of options. It is an alternative to the shell \"type\" built-in
1205 (license gpl3+))) ; some files are under GPLv2+
1207 (define-public glibc/hurd-headers
1208 (package (inherit glibc)
1209 (name "glibc-hurd-headers")
1211 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1212 ("hurd-headers" ,hurd-headers)))
1214 (substitute-keyword-arguments (package-arguments glibc)
1215 ;; We just pass the flags really needed to build the headers.
1216 ((#:configure-flags _)
1217 `(list "--enable-add-ons"
1218 "--host=i586-pc-gnu"))
1220 '(modify-phases %standard-phases
1222 (lambda* (#:key outputs #:allow-other-keys)
1223 (invoke "make" "install-headers")
1225 ;; Make an empty stubs.h to work around not being able to
1226 ;; produce a valid stubs.h and causing the build to fail. See
1227 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1228 (let ((out (assoc-ref outputs "out")))
1231 (string-append out "/include/gnu/stubs.h"))))
1233 (delete 'build))))))) ; nothing to build
1235 (define-public tzdata
1242 "https://data.iana.org/time-zones/releases/tzdata"
1246 "0z7w1yv37cfk8yhix2cillam091vgp1j4g8fv84261q9mdnq1ivr"))))
1247 (build-system gnu-build-system)
1250 #:make-flags (let ((out (assoc-ref %outputs "out"))
1251 (tmp (getenv "TMPDIR")))
1252 (list (string-append "TOPDIR=" out)
1253 (string-append "TZDIR=" out "/share/zoneinfo")
1254 (string-append "TZDEFAULT=" out
1255 "/share/zoneinfo/localtime")
1257 ;; Likewise for the C library routines.
1258 (string-append "LIBDIR=" tmp "/lib")
1259 (string-append "MANDIR=" tmp "/man")
1263 #:modules ((guix build utils)
1264 (guix build gnu-build-system)
1267 (modify-phases %standard-phases
1269 (lambda* (#:key source inputs #:allow-other-keys)
1270 (invoke "tar" "xvf" source)
1271 (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
1272 (add-after 'install 'post-install
1273 (lambda* (#:key outputs #:allow-other-keys)
1274 ;; Move data in the right place.
1275 (let ((out (assoc-ref outputs "out")))
1276 ;; Discard zic, dump, and tzselect, already
1277 ;; provided by glibc.
1278 (delete-file-recursively (string-append out "/usr"))
1279 (symlink (string-append out "/share/zoneinfo")
1280 (string-append out "/share/zoneinfo/posix"))
1281 (delete-file-recursively
1282 (string-append out "/share/zoneinfo-posix"))
1283 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1284 (string-append out "/share/zoneinfo/right"))
1285 (delete-file-recursively
1286 (string-append out "/share/zoneinfo-leaps"))
1288 (delete 'configure))))
1289 (inputs `(("tzcode" ,(origin
1292 "https://data.iana.org/time-zones/releases/tzcode"
1296 "1m3y2rnf1nggxxhxplab5zdd5whvar3ijyrv7lifvm82irkd7szn"))))))
1297 (home-page "https://www.iana.org/time-zones")
1298 (synopsis "Database of current and historical time zones")
1299 (description "The Time Zone Database (often called tz or zoneinfo)
1300 contains code and data that represent the history of local time for many
1301 representative locations around the globe. It is updated periodically to
1302 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1303 and daylight-saving rules.")
1304 (license public-domain)))
1306 ;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1307 ;;; and a few other places. We can update this whenever we are able to rebuild
1308 ;;; thousands of packages (for example, in a core-updates rebuild). This package
1309 ;;; will typically be obsolete and should never be referred to by a built
1311 (define-public tzdata-for-tests
1313 (package/inherit tzdata)))
1315 (define-public libiconv
1321 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1325 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1326 (modules '((guix build utils)))
1328 ;; Work around "declared gets" error on glibc systems (fixed by
1329 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1331 (substitute* "srclib/stdio.in.h"
1332 (("^#undef gets") "")
1333 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1335 (build-system gnu-build-system)
1336 (synopsis "Character set conversion library")
1338 "libiconv provides an implementation of the iconv function for systems
1339 that lack it. iconv is used to convert between character encodings in a
1340 program. It supports a wide variety of different encodings.")
1341 (home-page "https://www.gnu.org/software/libiconv/")
1344 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1345 "Return either a libiconv package specification to include in a dependency
1346 list for platforms that have an incomplete libc, or the empty list. If a
1347 package needs iconv ,@(libiconv-if-needed) should be added."
1348 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1349 ;; without iconv, such as MinGW, must return the then clause.
1350 (if (target-mingw? target)
1351 `(("libiconv" ,libiconv))
1354 (define-public (canonical-package package)
1355 ;; Avoid circular dependency by lazily resolving 'commencement'.
1356 (let* ((iface (resolve-interface '(gnu packages commencement)))
1357 (proc (module-ref iface 'canonical-package)))
1360 (define-public (%final-inputs)
1361 "Return the list of \"final inputs\"."
1362 ;; Avoid circular dependency by lazily resolving 'commencement'.
1363 (let ((iface (resolve-interface '(gnu packages commencement))))
1364 (module-ref iface '%final-inputs)))
1366 ;;; base.scm ends here