1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 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 gettext)
53 #:use-module (guix utils)
54 #:use-module (guix packages)
55 #:use-module (guix download)
56 #:use-module (guix git-download)
57 #:use-module (guix build-system gnu)
58 #:use-module (guix build-system trivial)
59 #:use-module (ice-9 match)
60 #:use-module (srfi srfi-1)
61 #:use-module (srfi srfi-26)
67 ;;; Base packages of the Guix-based GNU user-land software distribution.
77 (uri (string-append "mirror://gnu/hello/hello-" version
81 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
82 (build-system gnu-build-system)
83 (synopsis "Hello, GNU world: An example GNU package")
85 "GNU Hello prints the message \"Hello, world!\" and then exits. It
86 serves as an example of standard GNU coding practices. As such, it supports
87 command-line arguments, multiple languages, and so on.")
88 (home-page "https://www.gnu.org/software/hello/")
97 (uri (string-append "mirror://gnu/grep/grep-"
101 "055mqp6vrd0brkygmygb2673qwz409a7kyp1mzbfy6cn94f58q5r"))
102 (patches (search-patches "grep-timing-sensitive-test.patch"))))
103 (build-system gnu-build-system)
104 (native-inputs `(("perl" ,perl))) ;some of the tests require it
105 (inputs `(("pcre" ,pcre)))
108 (modify-phases %standard-phases
109 (add-after 'install 'fix-egrep-and-fgrep
110 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
111 ;; absolute file name instead of searching for it in $PATH.
112 (lambda* (#:key outputs #:allow-other-keys)
113 (let* ((out (assoc-ref outputs "out"))
114 (bin (string-append out "/bin")))
115 (substitute* (list (string-append bin "/egrep")
116 (string-append bin "/fgrep"))
118 (string-append "exec " bin "/grep")))
120 (synopsis "Print lines matching a pattern")
122 "grep is a tool for finding text inside files. Text is found by
123 matching a pattern provided by the user in one or many files. The pattern
124 may be provided as a basic or extended regular expression, or as fixed
125 strings. By default, the matching text is simply printed to the screen,
126 however the output can be greatly customized to include, for example, line
127 numbers. GNU grep offers many extensions over the standard utility,
128 including, for example, recursive directory searching.")
130 (home-page "https://www.gnu.org/software/grep/")))
138 (uri (string-append "mirror://gnu/sed/sed-" version
142 "0smxcx66vx29djzb542nxcynl7qnzxqa5032ibazi7x2s267d198"))))
143 (build-system gnu-build-system)
144 (synopsis "Stream editor")
146 `(("perl" ,perl))) ;for tests
148 "Sed is a non-interactive, text stream editor. It receives a text
149 input from a file or from standard input and it then applies a series of text
150 editing commands to the stream and prints its output to standard output. It
151 is often used for substituting text patterns in a stream. The GNU
152 implementation offers several extensions over the standard utility.")
154 (home-page "https://www.gnu.org/software/sed/")))
162 (uri (string-append "mirror://gnu/tar/tar-"
166 "1h9dxhjhz1jnyhmh6jfhqw1g1sxqbg3cd32vpwg7x2xxxqffzwrp"))
167 (patches (search-patches "tar-skip-unreliable-tests.patch"
168 "tar-remove-wholesparse-check.patch"))))
169 (build-system gnu-build-system)
170 ;; Note: test suite requires ~1GiB of disk space.
172 `(#:phases (modify-phases %standard-phases
173 (add-before 'build 'set-shell-file-name
174 (lambda* (#:key inputs #:allow-other-keys)
175 ;; Do not use "/bin/sh" to run programs.
176 (let ((bash (assoc-ref inputs "bash")))
177 (substitute* "src/system.c"
179 (string-append bash "/bin/sh")))
182 ;; Work around a cross-compilation bug whereby libgnu.a would provide
183 ;; '__mktime_internal', which conflicts with the one in libc.a.
184 ,@(if (%current-target-system)
185 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
188 ;; Test #92 "link mismatch" expects "a/z: Not linked to a/y" but gets
189 ;; "a/y: Not linked to a/z" and fails, presumably due to differences in
190 ;; the order in which 'diff' traverses directories. That leads to a
191 ;; test failure even though conceptually the test passes. Skip it.
192 ;; Test 117 and 118 are prone to race conditions too, particularly
193 ;; when cross-compiling, so we skip those as well. All issues have
194 ;; been fixed upstream in these commits:
195 ;; <https://git.savannah.gnu.org/cgit/tar.git/commit/?id=847a36f>
196 ;; <https://git.savannah.gnu.org/cgit/tar.git/commit/?id=64b43fd>
197 #:make-flags (list (string-append
198 "TESTSUITEFLAGS= -k '!link mismatch,"
199 "!directory removed before reading,"
200 "!explicitly named directory removed before reading'"))))
202 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
203 ;; to refer to the target Bash.
204 (inputs (if (%current-target-system)
208 (synopsis "Managing tar archives")
210 "Tar provides the ability to create tar archives, as well as the
211 ability to extract, update or list files in an existing archive. It is
212 useful for combining many files into one larger file, while maintaining
213 directory structure and file information such as permissions and
214 creation/modification dates. GNU tar offers many extensions over the
217 (home-page "https://www.gnu.org/software/tar/")))
225 (uri (string-append "mirror://gnu/patch/patch-"
229 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
230 (patches (search-patches "patch-hurd-path-max.patch"))))
231 (build-system gnu-build-system)
233 ;; Work around a cross-compilation bug whereby libpatch.a would provide
234 ;; '__mktime_internal', which conflicts with the one in libc.a.
235 (if (%current-target-system)
236 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
238 (native-inputs `(("ed" ,ed)))
239 (synopsis "Apply differences to originals, with optional backups")
241 "Patch is a program that applies changes to files based on differences
242 laid out as by the program \"diff\". The changes may be applied to one or more
243 files depending on the contents of the diff file. It accepts several
244 different diff formats. It may also be used to revert previously applied
247 (home-page "https://savannah.gnu.org/projects/patch/")))
249 (define-public diffutils
255 (uri (string-append "mirror://gnu/diffutils/diffutils-"
259 "09isrg0isjinv8c535nxsi1s86wfdfzml80dbw41dj9x3hiad9xk"))))
260 (build-system gnu-build-system)
261 (native-inputs `(("perl" ,perl)))
262 (synopsis "Comparing and merging files")
264 "GNU Diffutils is a package containing tools for finding the
265 differences between files. The \"diff\" command is used to show how two files
266 differ, while \"cmp\" shows the offsets and line numbers where they differ.
267 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
268 interactive means to merge two files.")
270 (home-page "https://www.gnu.org/software/diffutils/")))
272 (define-public findutils
278 (uri (string-append "mirror://gnu/findutils/findutils-"
282 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
283 (patches (search-patches
284 "findutils-gnulib-libio.patch"
285 "findutils-localstatedir.patch"
286 "findutils-makedev.patch"
287 "findutils-test-xargs.patch"))
288 (modules '((guix build utils)))
291 ;; The gnulib test-lock test is prone to writer starvation
292 ;; with our glibc@2.25, which prefers readers, so disable it.
293 ;; The gnulib commit b20e8afb0b2 should fix this once
294 ;; incorporated here.
295 (substitute* "tests/Makefile.in"
296 (("test-lock\\$\\(EXEEXT\\) ") ""))
298 (build-system gnu-build-system)
300 `(#:configure-flags (list
301 ;; Tell 'updatedb' to write to /var.
302 "--localstatedir=/var"
304 ;; Work around cross-compilation failure. See
305 ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
306 ,@(if (%current-target-system)
307 '("gl_cv_func_wcwidth_works=yes")
309 (synopsis "Operating on files matching given criteria")
311 "Findutils supplies the basic file directory searching utilities of the
312 GNU system. It consists of two primary searching utilities: \"find\"
313 recursively searches for files in a directory according to given criteria and
314 \"locate\" lists files in a database that match a query. Two auxiliary tools
315 are included: \"updatedb\" updates the file name database and \"xargs\" may be
316 used to apply commands with arbitrarily long arguments.")
318 (home-page "https://www.gnu.org/software/findutils/")))
320 (define-public coreutils
326 (uri (string-append "mirror://gnu/coreutils/coreutils-"
330 "0mxhw43d4wpqmvg0l4znk1vm10fy92biyh90lzdnqjcic2lb6cg8"))))
331 (build-system gnu-build-system)
332 (inputs `(("acl" ,acl) ; TODO: add SELinux
333 ("gmp" ,gmp) ;bignums in 'expr', yay!
335 ;; Drop the dependency on libcap when cross-compiling since it's
336 ;; not quite cross-compilable.
337 ,@(if (%current-target-system)
339 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
341 ;; Perl is needed to run tests in native builds, and to run the bundled
342 ;; copy of help2man. However, don't pass it when cross-compiling since
343 ;; that would lead it to try to run programs to get their '--help' output
345 (if (%current-target-system)
348 (outputs '("out" "debug"))
350 `(#:parallel-build? #f ; help2man may be called too early
351 #:phases (modify-phases %standard-phases
352 (add-before 'build 'patch-shell-references
354 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
355 ;; that tests pass, since /bin/sh isn't in the chroot.
356 (setenv "SHELL" (which "sh"))
358 (substitute* (find-files "gnulib-tests" "\\.c$")
359 (("/bin/sh") (which "sh")))
360 (substitute* (find-files "tests" "\\.sh$")
361 (("#!/bin/sh") (string-append "#!" (which "sh"))))
363 (add-before 'check 'disable-broken-test
365 ;; This test hits the 127 character shebang limit in the build
366 ;; environment due to the way "env -S" splits arguments into
367 ;; shebangs. Note that "env-S-script.sh" works around this
368 ;; specific issue, but "env-S.pl" is not adjusted for build
369 ;; environments with long prefixes (/tmp/guix-build-...).
370 (substitute* "Makefile"
371 (("^.*tests/misc/env-S.pl.*$") ""))
374 ;; Work around a cross-compilation bug whereby libcoreutils.a would
375 ;; provide '__mktime_internal', which conflicts with the one in libc.a.
376 ,@(if (%current-target-system)
377 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
379 (synopsis "Core GNU utilities (file, text, shell)")
381 "GNU Coreutils includes all of the basic command-line tools that are
382 expected in a POSIX system. These provide the basic file, shell and text
383 manipulation functions of the GNU system. Most of these tools offer extended
384 functionality beyond that which is outlined in the POSIX standard.")
386 (home-page "https://www.gnu.org/software/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 "make-glibc-compat.patch"))))
409 (build-system gnu-build-system)
410 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
411 (inputs `(("guile" ,guile-2.0)))
412 (outputs '("out" "debug"))
414 '(;; Work around faulty glob detection with glibc 2.27. See
415 ;; <https://lists.nongnu.org/archive/html/bug-make/2017-11/msg00027.html>.
416 #:configure-flags '("make_cv_sys_gnu_glob=yes")
418 (modify-phases %standard-phases
419 (add-before 'build 'set-default-shell
420 (lambda* (#:key inputs #:allow-other-keys)
421 ;; Change the default shell from /bin/sh.
422 (let ((bash (assoc-ref inputs "bash")))
424 (("default_shell =.*$")
425 (format #f "default_shell = \"~a/bin/sh\";\n"
428 (synopsis "Remake files automatically")
430 "Make is a program that is used to control the production of
431 executables or other files from their source files. The process is
432 controlled from a Makefile, in which the developer specifies how each file is
433 generated from its source. It has powerful dependency resolution and the
434 ability to determine when files have to be regenerated after their sources
435 change. GNU make offers many powerful extensions over the standard utility.")
437 (home-page "https://www.gnu.org/software/make/")))
439 (define-public binutils
445 (uri (string-append "mirror://gnu/binutils/binutils-"
449 "0b8767nyal1bc4cyzg5h9iis8kpkln1i3wkamig75cifj1fb2f6y"))
450 (patches (search-patches "binutils-loongson-workaround.patch"))))
451 (build-system gnu-build-system)
453 ;; TODO: Add dependency on zlib + those for Gold.
455 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
456 ;; on GCC when bootstrapping.
457 "LDFLAGS=-static-libgcc"
459 ;; Turn on --enable-new-dtags by default to make the
460 ;; linker set RUNPATH instead of RPATH on binaries.
461 ;; This is important because RUNPATH can be overriden
462 ;; using LD_LIBRARY_PATH at runtime.
465 ;; Don't search under /usr/lib & co.
466 "--with-lib-path=/no-ld-lib-path"
468 ;; Install BFD. It ends up in a hidden directory,
470 "--enable-install-libbfd"
472 ;; Make sure 'ar' and 'ranlib' produce archives in a
473 ;; deterministic fashion.
474 "--enable-deterministic-archives")))
476 (synopsis "Binary utilities: bfd gas gprof ld")
478 "GNU Binutils is a collection of tools for working with binary files.
479 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
480 Other tools include programs to display binary profiling information, list
481 the strings in a binary file, and utilities for working with archives. The
482 \"bfd\" library for working with executable and object formats is also
485 (home-page "https://www.gnu.org/software/binutils/")))
487 (define-public binutils-gold
490 (name "binutils-gold")
493 (modify-phases %standard-phases
494 (add-after 'patch-source-shebangs 'patch-more-shebangs
496 (substitute* "gold/Makefile.in"
497 (("/bin/sh") (which "sh")))
499 ,@(substitute-keyword-arguments (package-arguments binutils)
500 ; Upstream is aware of unrelocatable test failures on arm*.
502 (if (any (cute string-prefix? <> (or (%current-target-system)
506 ((#:configure-flags flags)
507 `(cons* "--enable-gold=default"
508 (delete "LDFLAGS=-static-libgcc" ,flags))))))
512 `(("gcc:lib" ,gcc "lib")))))
514 (define* (make-ld-wrapper name #:key
517 (guile (canonical-package guile-2.2))
518 (bash (canonical-package bash))
519 (guile-for-build guile))
520 "Return a package called NAME that contains a wrapper for the 'ld' program
521 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
522 wrapper uses GUILE and BASH.
524 TARGET must be a one-argument procedure that, given a system type, returns a
525 cross-compilation target triplet or #f. When the result is not #f, make a
526 wrapper for the cross-linker for that target, called 'TARGET-ld'."
527 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
528 ;; its result can be delayed until the 'arguments' field is evaluated, thus
529 ;; in a context where '%current-system' is accurate.
534 (build-system trivial-build-system)
535 (inputs `(("binutils" ,binutils)
538 ("wrapper" ,(search-path %load-path
539 "gnu/packages/ld-wrapper.in"))))
541 (let ((target (target (%current-system))))
542 `(#:guile ,guile-for-build
543 #:modules ((guix build utils))
545 (use-modules (guix build utils)
546 (system base compile))
548 (let* ((out (assoc-ref %outputs "out"))
549 (bin (string-append out "/bin"))
551 `(string-append bin "/" ,target "-ld")
552 '(string-append bin "/ld")))
553 (go (string-append ld ".go")))
555 (setvbuf (current-output-port) _IOLBF)
556 (format #t "building ~s/bin/ld wrapper in ~s~%"
557 (assoc-ref %build-inputs "binutils")
561 (copy-file (assoc-ref %build-inputs "wrapper") ld)
566 (string-append (assoc-ref %build-inputs "guile")
569 (string-append (assoc-ref %build-inputs "bash")
572 (string-append (assoc-ref %build-inputs "binutils")
574 (string-append "/bin/"
578 (compile-file ld #:output-file go)
580 (synopsis "The linker wrapper")
582 "The linker wrapper (or 'ld-wrapper') wraps the linker to add any
583 missing '-rpath' flags, and to detect any misuse of libraries outside of the
585 (home-page "https://www.gnu.org/software/guix//")
588 (export make-ld-wrapper)
591 ;; This is the GNU C Library, used on GNU/Linux and GNU/Hurd. Prior to
592 ;; version 2.28, GNU/Hurd used a different glibc branch.
595 ;; Note: Always use a dot after the minor version since various places rely
596 ;; on "version-major+minor" to determine where locales are found.
600 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
603 "10iha5ynvdj5m62vgpgqbq4cwvc2yhyl2w9yyyjgfxmdmx8h145i"))
605 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
606 ;; required on LFS distros to avoid loading the distro's libc.so
609 (substitute* "sysdeps/unix/sysv/linux/configure"
610 (("use_ldconfig=yes")
613 (modules '((guix build utils)))
614 (patches (search-patches "glibc-ldd-x86_64.patch"
615 "glibc-2.28-git-fixes.patch"
616 "glibc-hidden-visibility-ldconfig.patch"
617 "glibc-versioned-locpath.patch"
618 "glibc-allow-kernel-2.6.32.patch"
619 "glibc-reinstate-prlimit64-fallback.patch"
620 "glibc-hurd-magic-pid.patch"
621 "glibc-supported-locales.patch"))))
622 (build-system gnu-build-system)
624 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
625 ;; users should automatically pull Linux headers as well. On GNU/Hurd,
626 ;; libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
627 ;; so both should be propagated.
630 `(("hurd-core-headers" ,hurd-core-headers))
631 `(("kernel-headers" ,linux-libre-headers))))
633 (outputs '("out" "debug"
634 "static")) ;9 MiB of .a files
637 `(#:out-of-source? #t
639 ;; The libraries have an empty RUNPATH, but some, such as the versioned
640 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
641 ;; these libraries are always going to be found anyway, just skip
643 #:validate-runpath? #f
645 #:modules ((ice-9 ftw)
648 (guix build gnu-build-system))
651 (list "--sysconfdir=/etc"
653 ;; Installing a locale archive with all the locales is to
654 ;; expensive (~100 MiB), so we rely on users to install the
655 ;; locales they really want.
657 ;; Set the default locale path. In practice, $LOCPATH may be
658 ;; defined to point whatever locales users want. However, setuid
659 ;; binaries don't honor $LOCPATH, so they'll instead look into
660 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
661 ;; with the idea that it is going to be populated by the sysadmin.
662 ;; The "X.Y" sub-directory is because locale data formats are
663 ;; incompatible across libc versions; see
664 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
666 ;; `--localedir' is not honored, so work around it.
667 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
668 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
669 ,(version-major+minor version))
671 (string-append "--with-headers="
672 (assoc-ref ,(if (%current-target-system)
673 '%build-target-inputs
678 ;; This is the default for most architectures as of GNU libc 2.26,
679 ;; but we specify it explicitly for clarity and consistency. See
680 ;; "kernel-features.h" in the GNU libc for details.
681 "--enable-kernel=3.2.0"
683 ;; Use our Bash instead of /bin/sh.
684 (string-append "BASH_SHELL="
685 (assoc-ref %build-inputs "bash")
688 ;; On GNU/Hurd we get discarded-qualifiers warnings for
689 ;; 'device_write_inband' among other things. Ignore them.
691 '("--disable-werror")
695 #:phases (modify-phases %standard-phases
697 'configure 'pre-configure
698 (lambda* (#:key inputs native-inputs outputs
700 (let* ((out (assoc-ref outputs "out"))
701 (bin (string-append out "/bin"))
702 ;; FIXME: Normally we would look it up only in INPUTS
703 ;; but cross-base uses it as a native input.
704 (bash (or (assoc-ref inputs "static-bash")
705 (assoc-ref native-inputs "static-bash"))))
706 ;; Install the rpc data base file under `$out/etc/rpc'.
707 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
708 (substitute* "sunrpc/Makefile"
709 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
710 (string-append out "/etc/rpc" suffix "\n"))
711 (("^install-others =.*$")
712 (string-append "install-others = " out "/etc/rpc\n")))
714 (substitute* "Makeconfig"
716 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
717 ;; linking against libgcc_s is not needed with GCC
721 ;; Have `system' use that Bash.
722 (substitute* "sysdeps/posix/system.c"
723 (("#define[[:blank:]]+SHELL_PATH.*$")
724 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
728 (substitute* "libio/iopopen.c"
730 (string-append bash "/bin/sh")))
732 ;; Same for the shell used by the 'exec' functions for
733 ;; scripts that lack a shebang.
734 (substitute* (find-files "." "^paths\\.h$")
735 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
736 (string-append "#define _PATH_BSHELL \""
737 bash "/bin/sh\"\n")))
739 ;; Nscd uses __DATE__ and __TIME__ to create a string to
740 ;; make sure the client and server come from the same
741 ;; libc. Use something deterministic instead.
742 (substitute* "nscd/nscd_stat.c"
743 (("static const char compilation\\[21\\] =.*$")
745 "static const char compilation[21] = \""
746 (string-take (basename out) 20) "\";\n")))
748 ;; Make sure we don't retain a reference to the
750 (substitute* "malloc/mtrace.pl"
752 ;; The shebang can be omitted, because there's the
753 ;; "bilingual" eval/exec magic at the top of the file.
760 (add-after 'install 'move-static-libs
761 (lambda* (#:key outputs #:allow-other-keys)
762 ;; Move static libraries to the "static" output.
763 (define (static-library? file)
764 ;; Return true if FILE is a static library. The
765 ;; "_nonshared.a" files are referred to by libc.so,
766 ;; libpthread.so, etc., which are in fact linker
768 (and (string-suffix? ".a" file)
769 (not (string-contains file "_nonshared"))))
771 (define (linker-script? file)
772 ;; Guess whether FILE, a ".a" file, is actually a
774 (and (not (ar-file? file))
775 (not (elf-file? file))))
777 (let* ((out (assoc-ref outputs "out"))
778 (lib (string-append out "/lib"))
779 (files (scandir lib static-library?))
780 (static (assoc-ref outputs "static"))
781 (slib (string-append static "/lib")))
783 (for-each (lambda (base)
784 (rename-file (string-append lib "/" base)
785 (string-append slib "/" base)))
788 ;; Usually libm.a is a linker script so we need to
789 ;; change the file names in there to refer to STATIC
791 (for-each (lambda (ld-script)
792 (substitute* ld-script
794 (filter linker-script?
795 (map (cut string-append slib "/" <>)
800 '((add-after 'install 'augment-libc.so
801 (lambda* (#:key outputs #:allow-other-keys)
802 (let* ((out (assoc-ref outputs "out")))
803 (substitute* (string-append out "/lib/libc.so")
804 (("/[^ ]+/lib/libc.so.0.3")
805 (string-append out "/lib/libc.so.0.3"
806 " libmachuser.so libhurduser.so"))))
810 (inputs `(("static-bash" ,static-bash)))
812 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
813 ;; install the message catalogs, with 'msgfmt'.
814 (native-inputs `(("texinfo" ,texinfo)
817 ("gettext" ,gettext-minimal)
825 ;; Search path for packages that provide locale data. This is useful
826 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
827 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
829 (list (search-path-specification
830 (variable "GUIX_LOCPATH")
831 (files '("lib/locale")))))
833 (synopsis "The GNU C Library")
835 "Any Unix-like operating system needs a C library: the library which
836 defines the \"system calls\" and other basic facilities such as open, malloc,
839 The GNU C library is used as the C library in the GNU system and most systems
840 with the Linux kernel.")
842 (home-page "https://www.gnu.org/software/libc/")))
844 ;; Below are old libc versions, which we use mostly to build locale data in
845 ;; the old format (which the new libc cannot cope with.)
847 (define-public glibc-2.27
852 (inherit (package-source glibc))
853 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
856 "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"))
857 (patches (search-patches "glibc-ldd-x86_64.patch"
858 "glibc-2.27-git-fixes.patch"
859 "glibc-hidden-visibility-ldconfig.patch"
860 "glibc-versioned-locpath.patch"
861 "glibc-allow-kernel-2.6.32.patch"
862 "glibc-reinstate-prlimit64-fallback.patch"
863 "glibc-supported-locales.patch"))))))
865 (define-public glibc-2.26
868 ;; This version number corresponds to the output of `git describe` and the
869 ;; archive can be generated by checking out the commit ID and running:
870 ;; git archive --prefix=$(git describe)/ HEAD | xz > $(git describe).tar.xz
871 ;; See <https://bugs.gnu.org/29406> for why this was necessary.
872 (version "2.26.105-g0890d5379c")
874 (inherit (package-source glibc))
875 (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/"
876 "glibc-" (version-major+minor version) "-"
877 (caddr (string-split version #\.)) ".tar.xz"))
880 "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
881 (patches (search-patches "glibc-ldd-x86_64.patch"
882 "glibc-versioned-locpath.patch"
883 "glibc-allow-kernel-2.6.32.patch"))))))
885 (define-public glibc-2.25
890 (inherit (package-source glibc))
891 (uri (string-append "mirror://gnu/glibc/glibc-"
895 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
896 (patches (search-patches "glibc-ldd-x86_64.patch"
897 "glibc-versioned-locpath.patch"
898 "glibc-vectorized-strcspn-guards.patch"
899 "glibc-CVE-2017-1000366-pt1.patch"
900 "glibc-CVE-2017-1000366-pt2.patch"
901 "glibc-CVE-2017-1000366-pt3.patch"))))))
903 (define-public glibc-2.24
908 (inherit (package-source glibc))
909 (uri (string-append "mirror://gnu/glibc/glibc-"
913 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
914 (patches (search-patches "glibc-ldd-x86_64.patch"
915 "glibc-versioned-locpath.patch"
916 "glibc-vectorized-strcspn-guards.patch"
917 "glibc-CVE-2015-5180.patch"
918 "glibc-CVE-2017-1000366-pt1.patch"
919 "glibc-CVE-2017-1000366-pt2.patch"
920 "glibc-CVE-2017-1000366-pt3.patch"))))))
922 (define-public glibc-2.23
927 (inherit (package-source glibc))
928 (uri (string-append "mirror://gnu/glibc/glibc-"
932 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
933 (patches (search-patches "glibc-ldd-x86_64.patch"
934 "glibc-versioned-locpath.patch"
935 "glibc-vectorized-strcspn-guards.patch"
936 "glibc-CVE-2015-5180.patch"
937 "glibc-CVE-2016-3075.patch"
938 "glibc-CVE-2016-3706.patch"
939 "glibc-CVE-2016-4429.patch"
940 "glibc-CVE-2017-1000366-pt1.patch"
941 "glibc-CVE-2017-1000366-pt2.patch"
942 "glibc-CVE-2017-1000366-pt3.patch"))))))
944 (define-public glibc-2.22
949 (inherit (package-source glibc))
950 (uri (string-append "mirror://gnu/glibc/glibc-"
954 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
955 (patches (search-patches "glibc-ldd-x86_64.patch"
956 "glibc-o-largefile.patch"
957 "glibc-vectorized-strcspn-guards.patch"
958 "glibc-CVE-2015-5180.patch"
959 "glibc-CVE-2015-7547.patch"
960 "glibc-CVE-2016-3075.patch"
961 "glibc-CVE-2016-3706.patch"
962 "glibc-CVE-2016-4429.patch"
963 "glibc-CVE-2017-1000366-pt1.patch"
964 "glibc-CVE-2017-1000366-pt2.patch"
965 "glibc-CVE-2017-1000366-pt3.patch"))))
967 (substitute-keyword-arguments (package-arguments glibc)
969 `(modify-phases ,phases
970 (add-before 'configure 'fix-pwd
972 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
973 (substitute* "configure"
974 (("/bin/pwd") "pwd"))
977 (define-public (make-glibc-locales glibc)
980 (name "glibc-locales")
981 (source (origin (inherit (package-source glibc))
982 (patches (cons (search-patch "glibc-locales.patch")
983 (origin-patches (package-source glibc))))))
984 (synopsis "All the locales supported by the GNU C Library")
986 "This package provides all the locales supported by the GNU C Library,
987 more than 400 in total. To use them set the 'LOCPATH' environment variable to
988 the 'share/locale' sub-directory of this package.")
989 (outputs '("out")) ;110+ MiB
990 (native-search-paths '())
992 (let ((args `(#:tests? #f #:strip-binaries? #f
993 ,@(package-arguments glibc))))
994 (substitute-keyword-arguments args
996 `(modify-phases ,phases
999 (invoke "make" "localedata/install-locales"
1000 "-j" (number->string (parallel-job-count)))))
1002 (delete 'move-static-libs)))
1003 ((#:configure-flags flags)
1005 ;; Use $(libdir)/locale/X.Y as is the case by default.
1006 (list (string-append "libc_cv_complocaledir="
1007 (assoc-ref %outputs "out")
1009 ,(version-major+minor
1010 (package-version glibc)))))))))))
1012 (define-public (make-glibc-utf8-locales glibc)
1014 (name "glibc-utf8-locales")
1015 (version (package-version glibc))
1017 (build-system trivial-build-system)
1019 `(#:modules ((guix build utils))
1021 (use-modules (guix build utils))
1023 (let* ((libc (assoc-ref %build-inputs "glibc"))
1024 (gzip (assoc-ref %build-inputs "gzip"))
1025 (out (assoc-ref %outputs "out"))
1026 (localedir (string-append out "/lib/locale/"
1027 ,(version-major+minor version))))
1028 ;; 'localedef' needs 'gzip'.
1029 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1032 (for-each (lambda (locale)
1034 ;; Use the "normalized codeset" by
1035 ;; default--e.g., "en_US.utf8".
1036 (string-append localedir "/" locale ".utf8"))
1038 (invoke "localedef" "--no-archive"
1039 "--prefix" localedir
1043 ;; For backward compatibility with Guix
1044 ;; <= 0.8.3, add "xx_YY.UTF-8".
1045 (symlink (string-append locale ".utf8")
1046 (string-append localedir "/"
1049 ;; These are the locales commonly used for
1050 ;; tests---e.g., in Guile's i18n tests.
1051 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
1053 (inputs `(("glibc" ,glibc)
1055 (synopsis "Small sample of UTF-8 locales")
1057 "This package provides a small sample of UTF-8 locales mostly useful in
1058 test environments.")
1059 (home-page (package-home-page glibc))
1060 (license (package-license glibc))))
1062 (define-public glibc-locales
1063 (make-glibc-locales glibc))
1064 (define-public glibc-utf8-locales
1065 (make-glibc-utf8-locales glibc))
1067 (define-public glibc-locales-2.27
1068 (package (inherit (make-glibc-locales glibc-2.27))
1069 (name "glibc-locales-2.27")))
1070 (define-public glibc-utf8-locales-2.27
1071 (package (inherit (make-glibc-utf8-locales glibc-2.27))
1072 (name "glibc-utf8-locales-2.27")))
1074 (define-public which
1080 (uri (string-append "mirror://gnu/which/which-"
1084 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1085 (build-system gnu-build-system)
1086 (home-page "https://gnu.org/software/which/")
1087 (synopsis "Find full path of shell commands")
1089 "The which program finds the location of executables in PATH, with a
1090 variety of options. It is an alternative to the shell \"type\" built-in
1092 (license gpl3+))) ; some files are under GPLv2+
1094 (define-public glibc/hurd-headers
1095 (package (inherit glibc)
1096 (name "glibc-hurd-headers")
1098 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1099 ("hurd-headers" ,hurd-headers)))
1101 (substitute-keyword-arguments (package-arguments glibc)
1102 ;; We just pass the flags really needed to build the headers.
1103 ((#:configure-flags _)
1104 `(list "--enable-add-ons"
1105 "--host=i586-pc-gnu"))
1107 '(modify-phases %standard-phases
1109 (lambda* (#:key outputs #:allow-other-keys)
1110 (invoke "make" "install-headers")
1112 ;; Make an empty stubs.h to work around not being able to
1113 ;; produce a valid stubs.h and causing the build to fail. See
1114 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1115 (let ((out (assoc-ref outputs "out")))
1118 (string-append out "/include/gnu/stubs.h"))))
1120 (delete 'build))))))) ; nothing to build
1122 (define-public tzdata
1129 "https://www.iana.org/time-zones/repository/releases/tzdata"
1133 "1n80ih8agibagic401smqscz3xxqvs5bm5x3lk803g539kw5xi42"))))
1134 (build-system gnu-build-system)
1137 #:make-flags (let ((out (assoc-ref %outputs "out"))
1138 (tmp (getenv "TMPDIR")))
1139 (list (string-append "TOPDIR=" out)
1140 (string-append "TZDIR=" out "/share/zoneinfo")
1141 (string-append "TZDEFAULT=" out
1142 "/share/zoneinfo/localtime")
1144 ;; Likewise for the C library routines.
1145 (string-append "LIBDIR=" tmp "/lib")
1146 (string-append "MANDIR=" tmp "/man")
1150 #:modules ((guix build utils)
1151 (guix build gnu-build-system)
1154 (modify-phases %standard-phases
1156 (lambda* (#:key source inputs #:allow-other-keys)
1157 (invoke "tar" "xvf" source)
1158 (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
1159 (add-after 'install 'post-install
1160 (lambda* (#:key outputs #:allow-other-keys)
1161 ;; Move data in the right place.
1162 (let ((out (assoc-ref outputs "out")))
1163 ;; Discard zic, dump, and tzselect, already
1164 ;; provided by glibc.
1165 (delete-file-recursively (string-append out "/usr"))
1166 (symlink (string-append out "/share/zoneinfo")
1167 (string-append out "/share/zoneinfo/posix"))
1168 (delete-file-recursively
1169 (string-append out "/share/zoneinfo-posix"))
1170 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1171 (string-append out "/share/zoneinfo/right"))
1172 (delete-file-recursively
1173 (string-append out "/share/zoneinfo-leaps"))
1175 (delete 'configure))))
1176 (inputs `(("tzcode" ,(origin
1179 "http://www.iana.org/time-zones/repository/releases/tzcode"
1183 "1p1jxlnryaxknj0l768h3dmlk2jpqz5n5d24w9c9vyx6dj3xpb5a"))))))
1184 (home-page "https://www.iana.org/time-zones")
1185 (synopsis "Database of current and historical time zones")
1186 (description "The Time Zone Database (often called tz or zoneinfo)
1187 contains code and data that represent the history of local time for many
1188 representative locations around the globe. It is updated periodically to
1189 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1190 and daylight-saving rules.")
1191 (license public-domain)))
1193 ;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1194 ;;; and a few other places. We can update this whenever we are able to rebuild
1195 ;;; thousands of packages (for example, in a core-updates rebuild). This package
1196 ;;; will typically be obsolete and should never be referred to by a built
1198 (define-public tzdata-for-tests
1206 "https://www.iana.org/time-zones/repository/releases/tzdata"
1210 "05kayi3w9pvhj6ljx1hvwd0r8mxfzn436fjmwhx53xkj919xxpq2"))))
1212 `(("tzcode" ,(origin
1215 "http://www.iana.org/time-zones/repository/releases/tzcode"
1219 "09y44fzcdq3c06saa8iqqa0a59cyw6ni3p31ps0j1w3hcpxz8lxa")))))))))
1221 (define-public libiconv
1227 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1231 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1232 (modules '((guix build utils)))
1234 ;; Work around "declared gets" error on glibc systems (fixed by
1235 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1237 (substitute* "srclib/stdio.in.h"
1238 (("^#undef gets") "")
1239 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1241 (build-system gnu-build-system)
1242 (synopsis "Character set conversion library")
1244 "libiconv provides an implementation of the iconv function for systems
1245 that lack it. iconv is used to convert between character encodings in a
1246 program. It supports a wide variety of different encodings.")
1247 (home-page "https://www.gnu.org/software/libiconv/")
1250 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1251 "Return either a libiconv package specification to include in a dependency
1252 list for platforms that have an incomplete libc, or the empty list. If a
1253 package needs iconv ,@(libiconv-if-needed) should be added."
1254 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1255 ;; without iconv, such as MinGW, must return the then clause.
1256 (if (target-mingw? target)
1257 `(("libiconv" ,libiconv))
1260 (define-public (canonical-package package)
1261 ;; Avoid circular dependency by lazily resolving 'commencement'.
1262 (let* ((iface (resolve-interface '(gnu packages commencement)))
1263 (proc (module-ref iface 'canonical-package)))
1266 (define-public (%final-inputs)
1267 "Return the list of \"final inputs\"."
1268 ;; Avoid circular dependency by lazily resolving 'commencement'.
1269 (let ((iface (resolve-interface '(gnu packages commencement))))
1270 (module-ref iface '%final-inputs)))
1272 ;;; base.scm ends here