1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 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 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 Mathieu Othacehe <m.othacehe@gmail.com>
13 ;;; Copyright © 2017, 2018 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 "055mqp6vrd0brkygmygb2673qwz409a7kyp1mzbfy6cn94f58q5r"))
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 "0smxcx66vx29djzb542nxcynl7qnzxqa5032ibazi7x2s267d198"))))
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 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
264 (patches (search-patches
265 "findutils-gnulib-libio.patch"
266 "findutils-localstatedir.patch"
267 "findutils-makedev.patch"
268 "findutils-test-xargs.patch"))
269 (modules '((guix build utils)))
272 ;; The gnulib test-lock test is prone to writer starvation
273 ;; with our glibc@2.25, which prefers readers, so disable it.
274 ;; The gnulib commit b20e8afb0b2 should fix this once
275 ;; incorporated here.
276 (substitute* "tests/Makefile.in"
277 (("test-lock\\$\\(EXEEXT\\) ") ""))
279 (build-system gnu-build-system)
281 `(#:configure-flags (list
282 ;; Tell 'updatedb' to write to /var.
283 "--localstatedir=/var"
285 ;; Work around cross-compilation failure. See
286 ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
287 ,@(if (%current-target-system)
288 '("gl_cv_func_wcwidth_works=yes")
290 (synopsis "Operating on files matching given criteria")
292 "Findutils supplies the basic file directory searching utilities of the
293 GNU system. It consists of two primary searching utilities: \"find\"
294 recursively searches for files in a directory according to given criteria and
295 \"locate\" lists files in a database that match a query. Two auxiliary tools
296 are included: \"updatedb\" updates the file name database and \"xargs\" may be
297 used to apply commands with arbitrarily long arguments.")
299 (home-page "https://www.gnu.org/software/findutils/")))
301 (define-public coreutils
307 (uri (string-append "mirror://gnu/coreutils/coreutils-"
311 "1zg9m79x1i2nifj4kb0waf9x3i5h6ydkypkjnbsb9rnwis8rqypz"))))
312 (build-system gnu-build-system)
313 (inputs `(("acl" ,acl) ; TODO: add SELinux
314 ("gmp" ,gmp) ;bignums in 'expr', yay!
316 ;; Drop the dependency on libcap when cross-compiling since it's
317 ;; not quite cross-compilable.
318 ,@(if (%current-target-system)
320 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
322 ;; Perl is needed to run tests in native builds, and to run the bundled
323 ;; copy of help2man. However, don't pass it when cross-compiling since
324 ;; that would lead it to try to run programs to get their '--help' output
326 (if (%current-target-system)
329 (outputs '("out" "debug"))
331 `(#:parallel-build? #f ; help2man may be called too early
332 #:phases (modify-phases %standard-phases
333 (add-before 'build 'patch-shell-references
335 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
336 ;; that tests pass, since /bin/sh isn't in the chroot.
337 (setenv "SHELL" (which "sh"))
339 (substitute* (find-files "gnulib-tests" "\\.c$")
340 (("/bin/sh") (which "sh")))
341 (substitute* (find-files "tests" "\\.sh$")
342 (("#!/bin/sh") (string-append "#!" (which "sh"))))
344 (add-before 'check 'disable-broken-test
346 ;; This test hits the 127 character shebang limit in the build
347 ;; environment due to the way "env -S" splits arguments into
348 ;; shebangs. Note that "env-S-script.sh" works around this
349 ;; specific issue, but "env-S.pl" is not adjusted for build
350 ;; environments with long prefixes (/tmp/guix-build-...).
351 (substitute* "Makefile"
352 (("^.*tests/misc/env-S.pl.*$") ""))
354 (synopsis "Core GNU utilities (file, text, shell)")
356 "GNU Coreutils includes all of the basic command-line tools that are
357 expected in a POSIX system. These provide the basic file, shell and text
358 manipulation functions of the GNU system. Most of these tools offer extended
359 functionality beyond that which is outlined in the POSIX standard.")
361 (home-page "https://www.gnu.org/software/coreutils/")))
363 (define-public coreutils-minimal
364 ;; Coreutils without its optional dependencies.
367 (name "coreutils-minimal")
371 (define-public gnu-make
377 (uri (string-append "mirror://gnu/make/make-" version
381 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
382 (patches (search-patches "make-impure-dirs.patch"
383 "make-glibc-compat.patch"))))
384 (build-system gnu-build-system)
385 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
386 (inputs `(("guile" ,guile-2.0)))
387 (outputs '("out" "debug"))
389 '(;; Work around faulty glob detection with glibc 2.27. See
390 ;; <https://lists.nongnu.org/archive/html/bug-make/2017-11/msg00027.html>.
391 #:configure-flags '("make_cv_sys_gnu_glob=yes")
393 (modify-phases %standard-phases
394 (add-before 'build 'set-default-shell
395 (lambda* (#:key inputs #:allow-other-keys)
396 ;; Change the default shell from /bin/sh.
397 (let ((bash (assoc-ref inputs "bash")))
399 (("default_shell =.*$")
400 (format #f "default_shell = \"~a/bin/sh\";\n"
403 (synopsis "Remake files automatically")
405 "Make is a program that is used to control the production of
406 executables or other files from their source files. The process is
407 controlled from a Makefile, in which the developer specifies how each file is
408 generated from its source. It has powerful dependency resolution and the
409 ability to determine when files have to be regenerated after their sources
410 change. GNU make offers many powerful extensions over the standard utility.")
412 (home-page "https://www.gnu.org/software/make/")))
414 (define-public binutils
420 (uri (string-append "mirror://gnu/binutils/binutils-"
424 "0b8767nyal1bc4cyzg5h9iis8kpkln1i3wkamig75cifj1fb2f6y"))
425 (patches (search-patches "binutils-loongson-workaround.patch"))))
426 (build-system gnu-build-system)
428 ;; TODO: Add dependency on zlib + those for Gold.
430 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
431 ;; on GCC when bootstrapping.
432 "LDFLAGS=-static-libgcc"
434 ;; Turn on --enable-new-dtags by default to make the
435 ;; linker set RUNPATH instead of RPATH on binaries.
436 ;; This is important because RUNPATH can be overriden
437 ;; using LD_LIBRARY_PATH at runtime.
440 ;; Don't search under /usr/lib & co.
441 "--with-lib-path=/no-ld-lib-path"
443 ;; Install BFD. It ends up in a hidden directory,
445 "--enable-install-libbfd"
447 ;; Make sure 'ar' and 'ranlib' produce archives in a
448 ;; deterministic fashion.
449 "--enable-deterministic-archives")))
451 (synopsis "Binary utilities: bfd gas gprof ld")
453 "GNU Binutils is a collection of tools for working with binary files.
454 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
455 Other tools include programs to display binary profiling information, list
456 the strings in a binary file, and utilities for working with archives. The
457 \"bfd\" library for working with executable and object formats is also
460 (home-page "https://www.gnu.org/software/binutils/")))
462 (define-public binutils-gold
465 (name "binutils-gold")
468 (modify-phases %standard-phases
469 (add-after 'patch-source-shebangs 'patch-more-shebangs
471 (substitute* "gold/Makefile.in"
472 (("/bin/sh") (which "sh")))
474 ,@(substitute-keyword-arguments (package-arguments binutils)
475 ; Upstream is aware of unrelocatable test failures on arm*.
477 (if (any (cute string-prefix? <> (or (%current-target-system)
481 ((#:configure-flags flags)
482 `(cons* "--enable-gold=default"
483 (delete "LDFLAGS=-static-libgcc" ,flags))))))
487 `(("gcc:lib" ,gcc "lib")))))
489 (define* (make-ld-wrapper name #:key
492 (guile (canonical-package guile-2.2))
493 (bash (canonical-package bash))
494 (guile-for-build guile))
495 "Return a package called NAME that contains a wrapper for the 'ld' program
496 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
497 wrapper uses GUILE and BASH.
499 TARGET must be a one-argument procedure that, given a system type, returns a
500 cross-compilation target triplet or #f. When the result is not #f, make a
501 wrapper for the cross-linker for that target, called 'TARGET-ld'."
502 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
503 ;; its result can be delayed until the 'arguments' field is evaluated, thus
504 ;; in a context where '%current-system' is accurate.
509 (build-system trivial-build-system)
510 (inputs `(("binutils" ,binutils)
513 ("wrapper" ,(search-path %load-path
514 "gnu/packages/ld-wrapper.in"))))
516 (let ((target (target (%current-system))))
517 `(#:guile ,guile-for-build
518 #:modules ((guix build utils))
520 (use-modules (guix build utils)
521 (system base compile))
523 (let* ((out (assoc-ref %outputs "out"))
524 (bin (string-append out "/bin"))
526 `(string-append bin "/" ,target "-ld")
527 '(string-append bin "/ld")))
528 (go (string-append ld ".go")))
530 (setvbuf (current-output-port) _IOLBF)
531 (format #t "building ~s/bin/ld wrapper in ~s~%"
532 (assoc-ref %build-inputs "binutils")
536 (copy-file (assoc-ref %build-inputs "wrapper") ld)
541 (string-append (assoc-ref %build-inputs "guile")
544 (string-append (assoc-ref %build-inputs "bash")
547 (string-append (assoc-ref %build-inputs "binutils")
549 (string-append "/bin/"
553 (compile-file ld #:output-file go)
555 (synopsis "The linker wrapper")
557 "The linker wrapper (or @code{ld-wrapper}) wraps the linker to add any
558 missing @code{-rpath} flags, and to detect any misuse of libraries outside of
560 (home-page "https://www.gnu.org/software/guix//")
563 (export make-ld-wrapper)
566 ;; This is the GNU C Library, used on GNU/Linux and GNU/Hurd. Prior to
567 ;; version 2.28, GNU/Hurd used a different glibc branch.
573 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
576 "0jzh58728flfh939a8k9pi1zdyalfzlxmwra7k0rzji5gvavivpk"))
578 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
579 ;; required on LFS distros to avoid loading the distro's libc.so
582 (substitute* "sysdeps/unix/sysv/linux/configure"
583 (("use_ldconfig=yes")
586 (modules '((guix build utils)))
587 (patches (search-patches "glibc-ldd-x86_64.patch"
588 "glibc-CVE-2019-7309.patch"
589 "glibc-CVE-2019-9169.patch"
590 "glibc-2.29-git-updates.patch"
591 "glibc-hidden-visibility-ldconfig.patch"
592 "glibc-versioned-locpath.patch"
593 "glibc-allow-kernel-2.6.32.patch"
594 "glibc-reinstate-prlimit64-fallback.patch"
595 "glibc-supported-locales.patch"))))
596 (build-system gnu-build-system)
598 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
599 ;; users should automatically pull Linux headers as well. On GNU/Hurd,
600 ;; libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
601 ;; so both should be propagated.
604 `(("hurd-core-headers" ,hurd-core-headers))
605 `(("kernel-headers" ,linux-libre-headers))))
607 (outputs '("out" "debug"
608 "static")) ;9 MiB of .a files
611 `(#:out-of-source? #t
613 ;; The libraries have an empty RUNPATH, but some, such as the versioned
614 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
615 ;; these libraries are always going to be found anyway, just skip
617 #:validate-runpath? #f
619 #:modules ((ice-9 ftw)
622 (guix build gnu-build-system))
625 (list "--sysconfdir=/etc"
627 ;; Installing a locale archive with all the locales is to
628 ;; expensive (~100 MiB), so we rely on users to install the
629 ;; locales they really want.
631 ;; Set the default locale path. In practice, $LOCPATH may be
632 ;; defined to point whatever locales users want. However, setuid
633 ;; binaries don't honor $LOCPATH, so they'll instead look into
634 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
635 ;; with the idea that it is going to be populated by the sysadmin.
636 ;; The "X.Y" sub-directory is because locale data formats are
637 ;; incompatible across libc versions; see
638 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
640 ;; `--localedir' is not honored, so work around it.
641 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
642 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
643 ,(version-major+minor version))
645 (string-append "--with-headers="
646 (assoc-ref ,(if (%current-target-system)
647 '%build-target-inputs
652 ;; This is the default for most architectures as of GNU libc 2.26,
653 ;; but we specify it explicitly for clarity and consistency. See
654 ;; "kernel-features.h" in the GNU libc for details.
655 "--enable-kernel=3.2.0"
657 ;; Use our Bash instead of /bin/sh.
658 (string-append "BASH_SHELL="
659 (assoc-ref %build-inputs "bash")
662 ;; On GNU/Hurd we get discarded-qualifiers warnings for
663 ;; 'device_write_inband' among other things. Ignore them.
665 '("--disable-werror")
669 #:phases (modify-phases %standard-phases
671 'configure 'pre-configure
672 (lambda* (#:key inputs native-inputs outputs
674 (let* ((out (assoc-ref outputs "out"))
675 (bin (string-append out "/bin"))
676 ;; FIXME: Normally we would look it up only in INPUTS
677 ;; but cross-base uses it as a native input.
678 (bash (or (assoc-ref inputs "static-bash")
679 (assoc-ref native-inputs "static-bash"))))
680 ;; Install the rpc data base file under `$out/etc/rpc'.
681 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
682 (substitute* "sunrpc/Makefile"
683 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
684 (string-append out "/etc/rpc" suffix "\n"))
685 (("^install-others =.*$")
686 (string-append "install-others = " out "/etc/rpc\n")))
688 (substitute* "Makeconfig"
690 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
691 ;; linking against libgcc_s is not needed with GCC
695 ;; Have `system' use that Bash.
696 (substitute* "sysdeps/posix/system.c"
697 (("#define[[:blank:]]+SHELL_PATH.*$")
698 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
702 (substitute* "libio/iopopen.c"
704 (string-append bash "/bin/sh")))
706 ;; Same for the shell used by the 'exec' functions for
707 ;; scripts that lack a shebang.
708 (substitute* (find-files "." "^paths\\.h$")
709 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
710 (string-append "#define _PATH_BSHELL \""
711 bash "/bin/sh\"\n")))
713 ;; Nscd uses __DATE__ and __TIME__ to create a string to
714 ;; make sure the client and server come from the same
715 ;; libc. Use something deterministic instead.
716 (substitute* "nscd/nscd_stat.c"
717 (("static const char compilation\\[21\\] =.*$")
719 "static const char compilation[21] = \""
720 (string-take (basename out) 20) "\";\n")))
722 ;; Make sure we don't retain a reference to the
724 (substitute* "malloc/mtrace.pl"
726 ;; The shebang can be omitted, because there's the
727 ;; "bilingual" eval/exec magic at the top of the file.
734 (add-after 'install 'move-static-libs
735 (lambda* (#:key outputs #:allow-other-keys)
736 ;; Move static libraries to the "static" output.
737 (define (static-library? file)
738 ;; Return true if FILE is a static library. The
739 ;; "_nonshared.a" files are referred to by libc.so,
740 ;; libpthread.so, etc., which are in fact linker
742 (and (string-suffix? ".a" file)
743 (not (string-contains file "_nonshared"))))
745 (define (linker-script? file)
746 ;; Guess whether FILE, a ".a" file, is actually a
748 (and (not (ar-file? file))
749 (not (elf-file? file))))
751 (let* ((out (assoc-ref outputs "out"))
752 (lib (string-append out "/lib"))
753 (files (scandir lib static-library?))
754 (static (assoc-ref outputs "static"))
755 (slib (string-append static "/lib")))
757 (for-each (lambda (base)
758 (rename-file (string-append lib "/" base)
759 (string-append slib "/" base)))
762 ;; Usually libm.a is a linker script so we need to
763 ;; change the file names in there to refer to STATIC
765 (for-each (lambda (ld-script)
766 (substitute* ld-script
768 (filter linker-script?
769 (map (cut string-append slib "/" <>)
774 '((add-after 'install 'augment-libc.so
775 (lambda* (#:key outputs #:allow-other-keys)
776 (let* ((out (assoc-ref outputs "out")))
777 (substitute* (string-append out "/lib/libc.so")
778 (("/[^ ]+/lib/libc.so.0.3")
779 (string-append out "/lib/libc.so.0.3"
780 " libmachuser.so libhurduser.so"))))
784 (inputs `(("static-bash" ,static-bash)))
786 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
787 ;; install the message catalogs, with 'msgfmt'.
788 (native-inputs `(("texinfo" ,texinfo)
791 ("gettext" ,gettext-minimal)
792 ("python" ,python-minimal)
800 ;; Search path for packages that provide locale data. This is useful
801 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
802 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
804 (list (search-path-specification
805 (variable "GUIX_LOCPATH")
806 (files '("lib/locale")))))
808 (synopsis "The GNU C Library")
810 "Any Unix-like operating system needs a C library: the library which
811 defines the \"system calls\" and other basic facilities such as open, malloc,
814 The GNU C library is used as the C library in the GNU system and most systems
815 with the Linux kernel.")
817 (home-page "https://www.gnu.org/software/libc/")))
819 ;; Below are old libc versions, which we use mostly to build locale data in
820 ;; the old format (which the new libc cannot cope with.)
822 (define-public glibc-2.28
827 (inherit (package-source glibc))
828 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
831 "10iha5ynvdj5m62vgpgqbq4cwvc2yhyl2w9yyyjgfxmdmx8h145i"))
832 (patches (search-patches "glibc-ldd-x86_64.patch"
833 "glibc-2.28-git-fixes.patch"
834 "glibc-hidden-visibility-ldconfig.patch"
835 "glibc-versioned-locpath.patch"
836 "glibc-allow-kernel-2.6.32.patch"
837 "glibc-reinstate-prlimit64-fallback.patch"
838 "glibc-hurd-magic-pid.patch"
839 "glibc-2.28-supported-locales.patch"))))))
841 (define-public glibc-2.27
846 (inherit (package-source glibc))
847 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
850 "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"))
851 (patches (search-patches "glibc-ldd-x86_64.patch"
852 "glibc-2.27-git-fixes.patch"
853 "glibc-hidden-visibility-ldconfig.patch"
854 "glibc-versioned-locpath.patch"
855 "glibc-allow-kernel-2.6.32.patch"
856 "glibc-reinstate-prlimit64-fallback.patch"
857 "glibc-2.27-supported-locales.patch"
858 "glibc-CVE-2018-11236.patch"
859 "glibc-CVE-2018-11237.patch"))))
860 (properties `((lint-hidden-cve . ("CVE-2017-18269")))))) ; glibc-2.27-git-fixes
862 (define-public glibc-2.26
865 ;; This version number corresponds to the output of `git describe` and the
866 ;; archive can be generated by checking out the commit ID and running:
867 ;; git archive --prefix=$(git describe)/ HEAD | xz > $(git describe).tar.xz
868 ;; See <https://bugs.gnu.org/29406> for why this was necessary.
869 (version "2.26.105-g0890d5379c")
871 (inherit (package-source glibc))
872 (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/"
873 "glibc-" (version-major+minor version) "-"
874 (caddr (string-split version #\.)) ".tar.xz"))
877 "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
878 (patches (search-patches "glibc-ldd-x86_64.patch"
879 "glibc-versioned-locpath.patch"
880 "glibc-allow-kernel-2.6.32.patch"))))))
882 (define-public glibc-2.25
887 (inherit (package-source glibc))
888 (uri (string-append "mirror://gnu/glibc/glibc-"
892 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
893 (patches (search-patches "glibc-ldd-x86_64.patch"
894 "glibc-versioned-locpath.patch"
895 "glibc-vectorized-strcspn-guards.patch"
896 "glibc-CVE-2017-1000366-pt1.patch"
897 "glibc-CVE-2017-1000366-pt2.patch"
898 "glibc-CVE-2017-1000366-pt3.patch"))))))
900 (define-public glibc-2.24
905 (inherit (package-source glibc))
906 (uri (string-append "mirror://gnu/glibc/glibc-"
910 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
911 (patches (search-patches "glibc-ldd-x86_64.patch"
912 "glibc-versioned-locpath.patch"
913 "glibc-vectorized-strcspn-guards.patch"
914 "glibc-CVE-2015-5180.patch"
915 "glibc-CVE-2017-1000366-pt1.patch"
916 "glibc-CVE-2017-1000366-pt2.patch"
917 "glibc-CVE-2017-1000366-pt3.patch"))))))
919 (define-public glibc-2.23
924 (inherit (package-source glibc))
925 (uri (string-append "mirror://gnu/glibc/glibc-"
929 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
930 (patches (search-patches "glibc-ldd-x86_64.patch"
931 "glibc-versioned-locpath.patch"
932 "glibc-vectorized-strcspn-guards.patch"
933 "glibc-CVE-2015-5180.patch"
934 "glibc-CVE-2016-3075.patch"
935 "glibc-CVE-2016-3706.patch"
936 "glibc-CVE-2016-4429.patch"
937 "glibc-CVE-2017-1000366-pt1.patch"
938 "glibc-CVE-2017-1000366-pt2.patch"
939 "glibc-CVE-2017-1000366-pt3.patch"))))))
941 (define-public glibc-2.22
946 (inherit (package-source glibc))
947 (uri (string-append "mirror://gnu/glibc/glibc-"
951 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
952 (patches (search-patches "glibc-ldd-x86_64.patch"
953 "glibc-o-largefile.patch"
954 "glibc-vectorized-strcspn-guards.patch"
955 "glibc-CVE-2015-5180.patch"
956 "glibc-CVE-2015-7547.patch"
957 "glibc-CVE-2016-3075.patch"
958 "glibc-CVE-2016-3706.patch"
959 "glibc-CVE-2016-4429.patch"
960 "glibc-CVE-2017-1000366-pt1.patch"
961 "glibc-CVE-2017-1000366-pt2.patch"
962 "glibc-CVE-2017-1000366-pt3.patch"))))
964 (substitute-keyword-arguments (package-arguments glibc)
966 `(modify-phases ,phases
967 (add-before 'configure 'fix-pwd
969 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
970 (substitute* "configure"
971 (("/bin/pwd") "pwd"))
974 (define-public (make-gcc-libc base-gcc libc)
975 "Return a GCC that targets LIBC."
976 (package (inherit base-gcc)
977 (name (string-append (package-name base-gcc) "-"
978 (package-name libc) "-"
979 (package-version libc)))
981 (substitute-keyword-arguments
982 (ensure-keyword-arguments (package-arguments base-gcc)
983 '(#:implicit-inputs? #f))
984 ((#:make-flags flags)
985 `(let ((libc (assoc-ref %build-inputs "libc")))
986 ;; FLAGS_FOR_TARGET are needed for the target libraries to receive
987 ;; the -Bxxx for the startfiles.
988 (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib")
992 ("libc:static" ,libc "static")
993 ,@(append (package-inputs base-gcc)
994 (fold alist-delete (%final-inputs) '("libc" "libc:static")))))
997 (define-public (make-glibc-locales glibc)
1000 (name "glibc-locales")
1001 (source (origin (inherit (package-source glibc))
1002 ;; The patch for glibc 2.28 and earlier replaces the same
1003 ;; content, but the context in the patch is different
1004 ;; enough to fail to merge.
1005 (patches (cons (search-patch
1006 (if (version>=? (package-version glibc)
1008 "glibc-locales.patch"
1009 "glibc-locales-2.28.patch"))
1010 (origin-patches (package-source glibc))))))
1011 (synopsis "All the locales supported by the GNU C Library")
1013 "This package provides all the locales supported by the GNU C Library,
1014 more than 400 in total. To use them set the @code{LOCPATH} environment variable
1015 to the @code{share/locale} sub-directory of this package.")
1016 (outputs '("out")) ;110+ MiB
1017 (native-search-paths '())
1019 (let ((args `(#:tests? #f #:strip-binaries? #f
1020 ,@(package-arguments glibc))))
1021 (substitute-keyword-arguments args
1022 ((#:modules modules '((guix build utils)
1023 (guix build gnu-build-system)))
1027 ((#:imported-modules modules '())
1028 `((gnu build locale)
1029 ,@%gnu-build-system-modules))
1031 `(modify-phases ,phases
1034 (invoke "make" "localedata/install-locales"
1035 "-j" (number->string (parallel-job-count)))))
1036 (add-after 'build 'symlink-normalized-codesets
1037 (lambda* (#:key outputs #:allow-other-keys)
1038 ;; The above phase does not install locales with names using
1039 ;; the "normalized codeset." Thus, create symlinks like:
1040 ;; en_US.utf8 -> en_US.UTF-8
1041 (define (locale-directory? file stat)
1042 (and (file-is-directory? file)
1043 (string-index (basename file) #\_)
1044 (string-rindex (basename file) #\.)))
1046 (let* ((out (assoc-ref outputs "out"))
1047 (locales (find-files out locale-directory?
1048 #:directories? #t)))
1049 (for-each (lambda (directory)
1050 (let*-values (((base)
1051 (basename directory))
1053 (locale->name+codeset base))
1055 (normalize-codeset codeset)))
1056 (unless (string=? codeset normalized)
1058 (string-append (dirname directory)
1064 (delete 'move-static-libs)))
1065 ((#:configure-flags flags)
1067 ;; Use $(libdir)/locale/X.Y as is the case by default.
1068 (list (string-append "libc_cv_complocaledir="
1069 (assoc-ref %outputs "out")
1071 ,(version-major+minor
1072 (package-version glibc)))))))))))
1074 (define-public (make-glibc-utf8-locales glibc)
1076 (name "glibc-utf8-locales")
1077 (version (package-version glibc))
1079 (build-system trivial-build-system)
1081 `(#:modules ((guix build utils))
1083 (use-modules (guix build utils))
1085 (let* ((libc (assoc-ref %build-inputs "glibc"))
1086 (gzip (assoc-ref %build-inputs "gzip"))
1087 (out (assoc-ref %outputs "out"))
1088 (localedir (string-append out "/lib/locale/"
1089 ,(version-major+minor version))))
1090 ;; 'localedef' needs 'gzip'.
1091 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1094 (for-each (lambda (locale)
1096 ;; Use the "normalized codeset" by
1097 ;; default--e.g., "en_US.utf8".
1098 (string-append localedir "/" locale ".utf8"))
1100 (invoke "localedef" "--no-archive"
1101 "--prefix" localedir
1105 ;; For backward compatibility with Guix
1106 ;; <= 0.8.3, add "xx_YY.UTF-8".
1107 (symlink (string-append locale ".utf8")
1108 (string-append localedir "/"
1111 ;; These are the locales commonly used for
1112 ;; tests---e.g., in Guile's i18n tests.
1113 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
1115 (native-inputs `(("glibc" ,glibc)
1117 (synopsis "Small sample of UTF-8 locales")
1119 "This package provides a small sample of UTF-8 locales mostly useful in
1120 test environments.")
1121 (home-page (package-home-page glibc))
1122 (license (package-license glibc))))
1124 (define-public glibc-locales
1125 (make-glibc-locales glibc))
1126 (define-public glibc-utf8-locales
1127 (make-glibc-utf8-locales glibc))
1129 (define-public glibc-locales-2.27
1130 (package (inherit (make-glibc-locales glibc-2.27))
1131 (name "glibc-locales-2.27")))
1132 (define-public glibc-utf8-locales-2.27
1133 (package (inherit (make-glibc-utf8-locales glibc-2.27))
1134 (name "glibc-utf8-locales-2.27")))
1136 (define-public which
1142 (uri (string-append "mirror://gnu/which/which-"
1146 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1147 (build-system gnu-build-system)
1148 (home-page "https://gnu.org/software/which/")
1149 (synopsis "Find full path of shell commands")
1151 "The which program finds the location of executables in PATH, with a
1152 variety of options. It is an alternative to the shell \"type\" built-in
1154 (license gpl3+))) ; some files are under GPLv2+
1156 (define-public glibc/hurd-headers
1157 (package (inherit glibc)
1158 (name "glibc-hurd-headers")
1160 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1161 ("hurd-headers" ,hurd-headers)))
1163 (substitute-keyword-arguments (package-arguments glibc)
1164 ;; We just pass the flags really needed to build the headers.
1165 ((#:configure-flags _)
1166 `(list "--enable-add-ons"
1167 "--host=i586-pc-gnu"))
1169 '(modify-phases %standard-phases
1171 (lambda* (#:key outputs #:allow-other-keys)
1172 (invoke "make" "install-headers")
1174 ;; Make an empty stubs.h to work around not being able to
1175 ;; produce a valid stubs.h and causing the build to fail. See
1176 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1177 (let ((out (assoc-ref outputs "out")))
1180 (string-append out "/include/gnu/stubs.h"))))
1182 (delete 'build))))))) ; nothing to build
1184 (define-public tzdata
1191 "https://data.iana.org/time-zones/releases/tzdata"
1195 "0r0clnlslwm15m1c61dinf1fi9ffgl6aipng7i7yryfwj0n0kn85"))))
1196 (build-system gnu-build-system)
1199 #:make-flags (let ((out (assoc-ref %outputs "out"))
1200 (tmp (getenv "TMPDIR")))
1201 (list (string-append "TOPDIR=" out)
1202 (string-append "TZDIR=" out "/share/zoneinfo")
1203 (string-append "TZDEFAULT=" out
1204 "/share/zoneinfo/localtime")
1206 ;; Likewise for the C library routines.
1207 (string-append "LIBDIR=" tmp "/lib")
1208 (string-append "MANDIR=" tmp "/man")
1212 #:modules ((guix build utils)
1213 (guix build gnu-build-system)
1216 (modify-phases %standard-phases
1218 (lambda* (#:key source inputs #:allow-other-keys)
1219 (invoke "tar" "xvf" source)
1220 (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
1221 (add-after 'install 'post-install
1222 (lambda* (#:key outputs #:allow-other-keys)
1223 ;; Move data in the right place.
1224 (let ((out (assoc-ref outputs "out")))
1225 ;; Discard zic, dump, and tzselect, already
1226 ;; provided by glibc.
1227 (delete-file-recursively (string-append out "/usr"))
1228 (symlink (string-append out "/share/zoneinfo")
1229 (string-append out "/share/zoneinfo/posix"))
1230 (delete-file-recursively
1231 (string-append out "/share/zoneinfo-posix"))
1232 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1233 (string-append out "/share/zoneinfo/right"))
1234 (delete-file-recursively
1235 (string-append out "/share/zoneinfo-leaps"))
1237 (delete 'configure))))
1238 (inputs `(("tzcode" ,(origin
1241 "https://data.iana.org/time-zones/releases/tzcode"
1245 "0vbmswvv3li25s31shyllq5v24449lxnrki9hr043nipjd09sirf"))))))
1246 (home-page "https://www.iana.org/time-zones")
1247 (synopsis "Database of current and historical time zones")
1248 (description "The Time Zone Database (often called tz or zoneinfo)
1249 contains code and data that represent the history of local time for many
1250 representative locations around the globe. It is updated periodically to
1251 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1252 and daylight-saving rules.")
1253 (license public-domain)))
1255 ;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1256 ;;; and a few other places. We can update this whenever we are able to rebuild
1257 ;;; thousands of packages (for example, in a core-updates rebuild). This package
1258 ;;; will typically be obsolete and should never be referred to by a built
1260 (define-public tzdata-for-tests
1265 (define-public libiconv
1271 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1275 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1276 (modules '((guix build utils)))
1278 ;; Work around "declared gets" error on glibc systems (fixed by
1279 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1281 (substitute* "srclib/stdio.in.h"
1282 (("^#undef gets") "")
1283 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1285 (build-system gnu-build-system)
1286 (synopsis "Character set conversion library")
1288 "libiconv provides an implementation of the iconv function for systems
1289 that lack it. iconv is used to convert between character encodings in a
1290 program. It supports a wide variety of different encodings.")
1291 (home-page "https://www.gnu.org/software/libiconv/")
1294 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1295 "Return either a libiconv package specification to include in a dependency
1296 list for platforms that have an incomplete libc, or the empty list. If a
1297 package needs iconv ,@(libiconv-if-needed) should be added."
1298 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1299 ;; without iconv, such as MinGW, must return the then clause.
1300 (if (target-mingw? target)
1301 `(("libiconv" ,libiconv))
1304 (define-public (canonical-package package)
1305 ;; Avoid circular dependency by lazily resolving 'commencement'.
1306 (let* ((iface (resolve-interface '(gnu packages commencement)))
1307 (proc (module-ref iface 'canonical-package)))
1310 (define-public (%final-inputs)
1311 "Return the list of \"final inputs\"."
1312 ;; Avoid circular dependency by lazily resolving 'commencement'.
1313 (let ((iface (resolve-interface '(gnu packages commencement))))
1314 (module-ref iface '%final-inputs)))
1316 ;;; base.scm ends here