gnu: coreutils: Fix cross-compilation.
[jackhill/guix/guix.git] / gnu / packages / base.scm
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>
17 ;;;
18 ;;; This file is part of GNU Guix.
19 ;;;
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.
24 ;;;
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.
29 ;;;
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/>.
32
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)
63 #:export (glibc
64 libiconv-if-needed))
65
66 ;;; Commentary:
67 ;;;
68 ;;; Base packages of the Guix-based GNU user-land software distribution.
69 ;;;
70 ;;; Code:
71
72 (define-public hello
73 (package
74 (name "hello")
75 (version "2.10")
76 (source (origin
77 (method url-fetch)
78 (uri (string-append "mirror://gnu/hello/hello-" version
79 ".tar.gz"))
80 (sha256
81 (base32
82 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
83 (build-system gnu-build-system)
84 (synopsis "Hello, GNU world: An example GNU package")
85 (description
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/")
90 (license gpl3+)))
91
92 (define-public grep
93 (package
94 (name "grep")
95 (version "3.4")
96 (source (origin
97 (method url-fetch)
98 (uri (string-append "mirror://gnu/grep/grep-"
99 version ".tar.xz"))
100 (sha256
101 (base32
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)))
107 (arguments
108 `(#:phases
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"))
118 (("^exec grep")
119 (string-append "exec " bin "/grep")))
120 #t))))))
121 (synopsis "Print lines matching a pattern")
122 (description
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.")
130 (license gpl3+)
131 (home-page "https://www.gnu.org/software/grep/")))
132
133 (define-public sed
134 (package
135 (name "sed")
136 (version "4.8")
137 (source (origin
138 (method url-fetch)
139 (uri (string-append "mirror://gnu/sed/sed-" version
140 ".tar.gz"))
141 (sha256
142 (base32
143 "0alqagh0nliymz23kfjg6g9w3cr086k0sfni56gi8fhzqwa3xksk"))))
144 (build-system gnu-build-system)
145 (synopsis "Stream editor")
146 (native-inputs
147 `(("perl" ,perl))) ;for tests
148 (description
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.")
154 (license gpl3+)
155 (home-page "https://www.gnu.org/software/sed/")))
156
157 (define-public tar
158 (package
159 (name "tar")
160 (version "1.32")
161 (source (origin
162 (method url-fetch)
163 (uri (string-append "mirror://gnu/tar/tar-"
164 version ".tar.xz"))
165 (sha256
166 (base32
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.
172 (arguments
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"
179 (("/bin/sh")
180 (string-append bash "/bin/sh")))
181 #t))))))
182
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)
186 `(("bash" ,bash))
187 '()))
188
189 (synopsis "Managing tar archives")
190 (description
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
196 standard utility.")
197 (license gpl3+)
198 (home-page "https://www.gnu.org/software/tar/")))
199
200 (define-public patch
201 (package
202 (name "patch")
203 (version "2.7.6")
204 (source (origin
205 (method url-fetch)
206 (uri (string-append "mirror://gnu/patch/patch-"
207 version ".tar.xz"))
208 (sha256
209 (base32
210 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
211 (patches (search-patches "patch-hurd-path-max.patch"))))
212 (build-system gnu-build-system)
213 (arguments
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"))
218 '()))
219 (native-inputs `(("ed" ,ed)))
220 (synopsis "Apply differences to originals, with optional backups")
221 (description
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
226 differences.")
227 (license gpl3+)
228 (home-page "https://savannah.gnu.org/projects/patch/")))
229
230 (define-public diffutils
231 (package
232 (name "diffutils")
233 (version "3.7")
234 (source (origin
235 (method url-fetch)
236 (uri (string-append "mirror://gnu/diffutils/diffutils-"
237 version ".tar.xz"))
238 (sha256
239 (base32
240 "09isrg0isjinv8c535nxsi1s86wfdfzml80dbw41dj9x3hiad9xk"))))
241 (build-system gnu-build-system)
242 (native-inputs `(("perl" ,perl)))
243 (synopsis "Comparing and merging files")
244 (description
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.")
250 (license gpl3+)
251 (home-page "https://www.gnu.org/software/diffutils/")))
252
253 (define-public findutils
254 (package
255 (name "findutils")
256 (version "4.7.0")
257 (source (origin
258 (method url-fetch)
259 (uri (string-append "mirror://gnu/findutils/findutils-"
260 version ".tar.xz"))
261 (sha256
262 (base32
263 "16kqz9yz98dasmj70jwf5py7jk558w96w0vgp3zf9xsqk3gzpzn5"))
264 (patches (search-patches "findutils-localstatedir.patch"
265 "findutils-test-rwlock-threads.patch"))))
266 (build-system gnu-build-system)
267 (arguments
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
273 (lambda _
274 (substitute* '("tests/xargs/verbose-quote.sh"
275 "tests/find/exec-plus-last-file.sh")
276 (("#!/bin/sh")
277 (string-append "#!" (which "sh"))))
278 #t)))))
279 (synopsis "Operating on files matching given criteria")
280 (description
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.")
287 (license gpl3+)
288 (home-page "https://www.gnu.org/software/findutils/")))
289
290 (define-public coreutils
291 (package
292 (name "coreutils")
293 (version "8.32")
294 (source (origin
295 (method url-fetch)
296 (uri (string-append "mirror://gnu/coreutils/coreutils-"
297 version ".tar.xz"))
298 (sha256
299 (base32
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!
305
306 ;; Drop the dependency on libcap when cross-compiling since it's
307 ;; not quite cross-compilable.
308 ,@(if (%current-target-system)
309 '()
310 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
311 (native-inputs
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
315 ;; for help2man.
316 (if (%current-target-system)
317 '()
318 `(("perl" ,perl))))
319 (outputs '("out" "debug"))
320 (arguments
321 `(#:parallel-build? #f ; help2man may be called too early
322 #:phases (modify-phases %standard-phases
323 (add-before 'build 'patch-shell-references
324 (lambda _
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"))
328
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"))))
333 #t)))))
334 (synopsis "Core GNU utilities (file, text, shell)")
335 (description
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.")
340 (license gpl3+)
341 (home-page "https://www.gnu.org/software/coreutils/")))
342
343 (define-public coreutils-minimal
344 ;; Coreutils without its optional dependencies.
345 (package
346 (inherit coreutils)
347 (name "coreutils-minimal")
348 (outputs '("out"))
349 (inputs '())))
350
351 (define-public gnu-make
352 (package
353 (name "make")
354 (version "4.3")
355 (source (origin
356 (method url-fetch)
357 (uri (string-append "mirror://gnu/make/make-" version
358 ".tar.gz"))
359 (sha256
360 (base32
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"))
367 (arguments
368 '(#:phases
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"
377 bash)))
378 #t))))))
379 (synopsis "Remake files automatically")
380 (description
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.")
387 (license gpl3+)
388 (home-page "https://www.gnu.org/software/make/")))
389
390 (define-public binutils
391 (package
392 (name "binutils")
393 (version "2.34")
394 (source (origin
395 (method url-fetch)
396 (uri (string-append "mirror://gnu/binutils/binutils-"
397 version ".tar.bz2"))
398 (sha256
399 (base32
400 "1rin1f5c7wm4n3piky6xilcrpf2s0n3dd5vqq8irrxkcic3i1w49"))
401 (patches (search-patches "binutils-loongson-workaround.patch"))))
402 (build-system gnu-build-system)
403
404 ;; TODO: Add dependency on zlib + those for Gold.
405 (arguments
406 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
407 ;; on GCC when bootstrapping.
408 "LDFLAGS=-static-libgcc"
409
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.
414 "--enable-new-dtags"
415
416 ;; Don't search under /usr/lib & co.
417 "--with-lib-path=/no-ld-lib-path"
418
419 ;; Install BFD. It ends up in a hidden directory,
420 ;; but it's here.
421 "--enable-install-libbfd"
422
423 ;; Make sure 'ar' and 'ranlib' produce archives in a
424 ;; deterministic fashion.
425 "--enable-deterministic-archives")
426
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")))
432
433 ;; ...and "hide" this package so that users who install binutils get the
434 ;; version with documentation defined below.
435 (properties '((hidden? . #t)))
436
437 (synopsis "Binary utilities: bfd gas gprof ld")
438 (description
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
444 included.")
445 (license gpl3+)
446 (home-page "https://www.gnu.org/software/binutils/")))
447
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
451 (package/inherit
452 binutils
453 (native-inputs
454 `(("texinfo" ,texinfo)))
455 (arguments
456 (substitute-keyword-arguments (package-arguments binutils)
457 ((#:make-flags _ ''()) ''())))
458 (properties '())))
459
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
464 (package/inherit
465 binutils
466 (version "2.33.1")
467 (source (origin
468 (inherit (package-source binutils))
469 (uri (string-append "mirror://gnu/binutils/binutils-"
470 version ".tar.bz2"))
471 (sha256
472 (base32
473 "1cmd0riv37bqy9mwbg6n3523qgr8b3bbm5kwj19sjrasl4yq9d0c"))))
474 (arguments
475 (substitute-keyword-arguments (package-arguments binutils)
476 ((#:make-flags _ ''()) ''())))
477 (properties '())))
478
479 (define-public binutils-gold
480 (package
481 (inherit binutils)
482 (name "binutils-gold")
483 (arguments
484 `(#:phases
485 (modify-phases %standard-phases
486 (add-after 'patch-source-shebangs 'patch-more-shebangs
487 (lambda _
488 (substitute* "gold/Makefile.in"
489 (("/bin/sh") (which "sh")))
490 #t)))
491 ,@(substitute-keyword-arguments (package-arguments binutils)
492 ; Upstream is aware of unrelocatable test failures on arm*.
493 ((#:tests? _ #f)
494 (if (any (cute string-prefix? <> (or (%current-target-system)
495 (%current-system)))
496 '("i686" "x86_64"))
497 '#t '#f))
498 ((#:configure-flags flags)
499 `(cons* "--enable-gold=default"
500 (delete "LDFLAGS=-static-libgcc" ,flags))))))
501 (native-inputs
502 `(("bc" ,bc)))
503 (inputs
504 `(("gcc:lib" ,gcc "lib")))))
505
506 (define* (make-ld-wrapper name #:key
507 (target (const #f))
508 binutils
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.
515
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.
522 (package
523 (name name)
524 (version "0")
525 (source #f)
526 (build-system trivial-build-system)
527 (inputs `(("binutils" ,binutils)
528 ("guile" ,guile)
529 ("bash" ,bash)
530 ("wrapper" ,(search-path %load-path
531 "gnu/packages/ld-wrapper.in"))))
532 (arguments
533 (let ((target (target (%current-system))))
534 `(#:guile ,guile-for-build
535 #:modules ((guix build utils))
536 #:builder (begin
537 (use-modules (guix build utils)
538 (system base compile))
539
540 (let* ((out (assoc-ref %outputs "out"))
541 (bin (string-append out "/bin"))
542 (ld ,(if target
543 `(string-append bin "/" ,target "-ld")
544 '(string-append bin "/ld")))
545 (go (string-append ld ".go")))
546
547 (setvbuf (current-output-port) _IOLBF)
548 (format #t "building ~s/bin/ld wrapper in ~s~%"
549 (assoc-ref %build-inputs "binutils")
550 out)
551
552 (mkdir-p bin)
553 (copy-file (assoc-ref %build-inputs "wrapper") ld)
554 (substitute* ld
555 (("@SELF@")
556 ld)
557 (("@GUILE@")
558 (string-append (assoc-ref %build-inputs "guile")
559 "/bin/guile"))
560 (("@BASH@")
561 (string-append (assoc-ref %build-inputs "bash")
562 "/bin/bash"))
563 (("@LD@")
564 (string-append (assoc-ref %build-inputs "binutils")
565 ,(if target
566 (string-append "/bin/"
567 target "-ld")
568 "/bin/ld"))))
569 (chmod ld #o555)
570 (compile-file ld #:output-file go)
571 #t)))))
572 (synopsis "The linker wrapper")
573 (description
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
576 the store.")
577 (home-page "https://www.gnu.org/software/guix//")
578 (license gpl3+)))
579
580 (export make-ld-wrapper)
581
582 (define-public glibc
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.
585 (package
586 (name "glibc")
587 (version "2.31")
588 (source (origin
589 (method url-fetch)
590 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
591 (sha256
592 (base32
593 "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
594 (snippet
595 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
596 ;; required on LFS distros to avoid loading the distro's libc.so
597 ;; instead of ours.
598 '(begin
599 (substitute* "sysdeps/unix/sysv/linux/configure"
600 (("use_ldconfig=yes")
601 "use_ldconfig=no"))
602 #t))
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)
611
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.
616 (propagated-inputs
617 (if (hurd-target?)
618 `(("hurd-core-headers" ,hurd-core-headers))
619 `(("kernel-headers" ,linux-libre-headers))))
620
621 (outputs '("out" "debug"
622 "static")) ;9 MiB of .a files
623
624 (arguments
625 `(#:out-of-source? #t
626
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
630 ;; RUNPATH checks.
631 #:validate-runpath? #f
632
633 #:modules ((ice-9 ftw)
634 (srfi srfi-26)
635 (guix build utils)
636 (guix build gnu-build-system))
637
638 #:configure-flags
639 (list "--sysconfdir=/etc"
640
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.
644 ;;
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>.
653 ;;
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))
658
659 (string-append "--with-headers="
660 (assoc-ref ,(if (%current-target-system)
661 '%build-target-inputs
662 '%build-inputs)
663 "kernel-headers")
664 "/include")
665
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"
670
671 ;; Use our Bash instead of /bin/sh.
672 (string-append "BASH_SHELL="
673 (assoc-ref %build-inputs "bash")
674 "/bin/bash")
675
676 ;; On GNU/Hurd we get discarded-qualifiers warnings for
677 ;; 'device_write_inband' among other things. Ignore them.
678 ,@(if (hurd-target?)
679 '("--disable-werror")
680 '()))
681
682 #:tests? #f ; XXX
683 #:phases (modify-phases %standard-phases
684 (add-before
685 'configure 'pre-configure
686 (lambda* (#:key inputs native-inputs outputs
687 #:allow-other-keys)
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")))
701
702 (substitute* "Makeconfig"
703 ;; According to
704 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
705 ;; linking against libgcc_s is not needed with GCC
706 ;; 4.7.1.
707 ((" -lgcc_s") ""))
708
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"
713 bash)))
714
715 ;; Same for `popen'.
716 (substitute* "libio/iopopen.c"
717 (("/bin/sh")
718 (string-append bash "/bin/sh")))
719
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")))
726
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\\] =.*$")
732 (string-append
733 "static const char compilation[21] = \""
734 (string-take (basename out) 20) "\";\n")))
735
736 ;; Make sure we don't retain a reference to the
737 ;; bootstrap Perl.
738 (substitute* "malloc/mtrace.pl"
739 (("^#!.*")
740 ;; The shebang can be omitted, because there's the
741 ;; "bilingual" eval/exec magic at the top of the file.
742 "")
743 (("exec @PERL@")
744 "exec perl"))
745
746 #t)))
747
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
755 ;; scripts.
756 (and (string-suffix? ".a" file)
757 (not (string-contains file "_nonshared"))))
758
759 (define (linker-script? file)
760 ;; Guess whether FILE, a ".a" file, is actually a
761 ;; linker script.
762 (and (not (ar-file? file))
763 (not (elf-file? file))))
764
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")))
770 (mkdir-p slib)
771 (for-each (lambda (base)
772 (rename-file (string-append lib "/" base)
773 (string-append slib "/" base)))
774 files)
775
776 ;; Usually libm.a is a linker script so we need to
777 ;; change the file names in there to refer to STATIC
778 ;; instead of OUT.
779 (for-each (lambda (ld-script)
780 (substitute* ld-script
781 ((out) static)))
782 (filter linker-script?
783 (map (cut string-append slib "/" <>)
784 files)))
785 #t)))
786
787 ,@(if (hurd-target?)
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"))))
795 #t)))
796 '()))))
797
798 (inputs `(("static-bash" ,static-bash)))
799
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)
803 ("perl" ,perl)
804 ("bison" ,bison)
805 ("gettext" ,gettext-minimal)
806 ("python" ,python-minimal)
807
808 ,@(if (hurd-target?)
809 `(("mig" ,mig)
810 ("perl" ,perl))
811 '())))
812
813 (native-search-paths
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
817 ;; distros.
818 (list (search-path-specification
819 (variable "GUIX_LOCPATH")
820 (files '("lib/locale")))))
821
822 (synopsis "The GNU C Library")
823 (description
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,
826 printf, exit...
827
828 The GNU C library is used as the C library in the GNU system and most systems
829 with the Linux kernel.")
830 (license lgpl2.0+)
831 (home-page "https://www.gnu.org/software/libc/")))
832
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.)
835
836 (define-public glibc-2.30
837 (package
838 (inherit glibc)
839 (version "2.30")
840 (source (origin
841 (inherit (package-source glibc))
842 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
843 (sha256
844 (base32
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"))))))
853
854 (define-public glibc-2.29
855 (package
856 (inherit glibc)
857 (version "2.29")
858 (source (origin
859 (inherit (package-source glibc))
860 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
861 (sha256
862 (base32
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"))))))
873
874 (define-public glibc-2.28
875 (package
876 (inherit glibc)
877 (version "2.28")
878 (source (origin
879 (inherit (package-source glibc))
880 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
881 (sha256
882 (base32
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"))))))
892
893 (define-public glibc-2.27
894 (package
895 (inherit glibc)
896 (version "2.27")
897 (source (origin
898 (inherit (package-source glibc))
899 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
900 (sha256
901 (base32
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
913
914 (define-public glibc-2.26
915 (package
916 (inherit glibc)
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")
922 (source (origin
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"))
927 (sha256
928 (base32
929 "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
930 (patches (search-patches "glibc-ldd-x86_64.patch"
931 "glibc-versioned-locpath.patch"
932 "glibc-allow-kernel-2.6.32.patch"))))))
933
934 (define-public glibc-2.25
935 (package
936 (inherit glibc)
937 (version "2.25")
938 (source (origin
939 (inherit (package-source glibc))
940 (uri (string-append "mirror://gnu/glibc/glibc-"
941 version ".tar.xz"))
942 (sha256
943 (base32
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"))))))
951
952 (define-public glibc-2.24
953 (package
954 (inherit glibc)
955 (version "2.24")
956 (source (origin
957 (inherit (package-source glibc))
958 (uri (string-append "mirror://gnu/glibc/glibc-"
959 version ".tar.xz"))
960 (sha256
961 (base32
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"))))))
970
971 (define-public glibc-2.23
972 (package
973 (inherit glibc)
974 (version "2.23")
975 (source (origin
976 (inherit (package-source glibc))
977 (uri (string-append "mirror://gnu/glibc/glibc-"
978 version ".tar.xz"))
979 (sha256
980 (base32
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"))))))
992
993 (define-public glibc-2.22
994 (package
995 (inherit glibc)
996 (version "2.22")
997 (source (origin
998 (inherit (package-source glibc))
999 (uri (string-append "mirror://gnu/glibc/glibc-"
1000 version ".tar.xz"))
1001 (sha256
1002 (base32
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"))))
1015 (arguments
1016 (substitute-keyword-arguments (package-arguments glibc)
1017 ((#:phases phases)
1018 `(modify-phases ,phases
1019 (add-before 'configure 'fix-pwd
1020 (lambda _
1021 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
1022 (substitute* "configure"
1023 (("/bin/pwd") "pwd"))
1024 #t))))))))
1025
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)))
1032 (arguments
1033 (ensure-keyword-arguments (package-arguments base-gcc)
1034 '(#:implicit-inputs? #f)))
1035 (native-inputs
1036 `(,@(package-native-inputs base-gcc)
1037 ,@(append (fold alist-delete (%final-inputs) '("libc" "libc:static")))
1038 ("libc" ,libc)
1039 ("libc:static" ,libc "static")))))
1040
1041 (define-public (make-glibc-locales glibc)
1042 (package
1043 (inherit 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)
1051 "2.29")
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")
1056 (description
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 '())
1062 (arguments
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)))
1068 `((srfi srfi-11)
1069 (gnu build locale)
1070 ,@modules))
1071 ((#:imported-modules modules '())
1072 `((gnu build locale)
1073 ,@%gnu-build-system-modules))
1074 ((#:phases phases)
1075 `(modify-phases ,phases
1076 (replace 'build
1077 (lambda _
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) #\.)))
1089
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))
1096 ((name codeset)
1097 (locale->name+codeset base))
1098 ((normalized)
1099 (normalize-codeset codeset)))
1100 (unless (string=? codeset normalized)
1101 (symlink base
1102 (string-append (dirname directory)
1103 "/" name "."
1104 normalized)))))
1105 locales)
1106 #t)))
1107 (delete 'install)
1108 (delete 'move-static-libs)))
1109 ((#:configure-flags flags)
1110 `(append ,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")
1114 "/lib/locale/"
1115 ,(version-major+minor
1116 (package-version glibc)))))))))))
1117
1118 (define-public (make-glibc-utf8-locales glibc)
1119 (package
1120 (name "glibc-utf8-locales")
1121 (version (package-version glibc))
1122 (source #f)
1123 (build-system trivial-build-system)
1124 (arguments
1125 `(#:modules ((guix build utils))
1126 #:builder (begin
1127 (use-modules (guix build utils))
1128
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"))
1136
1137 (mkdir-p localedir)
1138 (for-each (lambda (locale)
1139 (define file
1140 ;; Use the "normalized codeset" by
1141 ;; default--e.g., "en_US.utf8".
1142 (string-append localedir "/" locale ".utf8"))
1143
1144 (invoke "localedef" "--no-archive"
1145 "--prefix" localedir
1146 "-i" locale
1147 "-f" "UTF-8" file)
1148
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 "/"
1153 locale ".UTF-8")))
1154
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"))
1158 #t))))
1159 (native-inputs `(("glibc" ,glibc)
1160 ("gzip" ,gzip)))
1161 (synopsis "Small sample of UTF-8 locales")
1162 (description
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))))
1167
1168 (define-public glibc-locales
1169 (make-glibc-locales glibc))
1170 (define-public glibc-utf8-locales
1171 (make-glibc-utf8-locales glibc))
1172
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")))
1180
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))
1186
1187 (define-public which
1188 (package
1189 (name "which")
1190 (version "2.21")
1191 (source (origin
1192 (method url-fetch)
1193 (uri (string-append "mirror://gnu/which/which-"
1194 version ".tar.gz"))
1195 (sha256
1196 (base32
1197 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1198 (build-system gnu-build-system)
1199 (home-page "https://gnu.org/software/which/")
1200 (synopsis "Find full path of shell commands")
1201 (description
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
1204 command.")
1205 (license gpl3+))) ; some files are under GPLv2+
1206
1207 (define-public glibc/hurd-headers
1208 (package (inherit glibc)
1209 (name "glibc-hurd-headers")
1210 (outputs '("out"))
1211 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1212 ("hurd-headers" ,hurd-headers)))
1213 (arguments
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"))
1219 ((#:phases _)
1220 '(modify-phases %standard-phases
1221 (replace 'install
1222 (lambda* (#:key outputs #:allow-other-keys)
1223 (invoke "make" "install-headers")
1224
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")))
1229 (close-port
1230 (open-output-file
1231 (string-append out "/include/gnu/stubs.h"))))
1232 #t))
1233 (delete 'build))))))) ; nothing to build
1234
1235 (define-public tzdata
1236 (package
1237 (name "tzdata")
1238 (version "2019c")
1239 (source (origin
1240 (method url-fetch)
1241 (uri (string-append
1242 "https://data.iana.org/time-zones/releases/tzdata"
1243 version ".tar.gz"))
1244 (sha256
1245 (base32
1246 "0z7w1yv37cfk8yhix2cillam091vgp1j4g8fv84261q9mdnq1ivr"))))
1247 (build-system gnu-build-system)
1248 (arguments
1249 '(#:tests? #f
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")
1256
1257 ;; Likewise for the C library routines.
1258 (string-append "LIBDIR=" tmp "/lib")
1259 (string-append "MANDIR=" tmp "/man")
1260
1261 "AWK=awk"
1262 "CC=gcc"))
1263 #:modules ((guix build utils)
1264 (guix build gnu-build-system)
1265 (srfi srfi-1))
1266 #:phases
1267 (modify-phases %standard-phases
1268 (replace 'unpack
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"))
1287 #t)))
1288 (delete 'configure))))
1289 (inputs `(("tzcode" ,(origin
1290 (method url-fetch)
1291 (uri (string-append
1292 "https://data.iana.org/time-zones/releases/tzcode"
1293 version ".tar.gz"))
1294 (sha256
1295 (base32
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)))
1305
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
1310 ;;; package.
1311 (define-public tzdata-for-tests
1312 (hidden-package
1313 (package/inherit tzdata)))
1314
1315 (define-public libiconv
1316 (package
1317 (name "libiconv")
1318 (version "1.15")
1319 (source (origin
1320 (method url-fetch)
1321 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1322 version ".tar.gz"))
1323 (sha256
1324 (base32
1325 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1326 (modules '((guix build utils)))
1327 (snippet
1328 ;; Work around "declared gets" error on glibc systems (fixed by
1329 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1330 '(begin
1331 (substitute* "srclib/stdio.in.h"
1332 (("^#undef gets") "")
1333 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1334 #t))))
1335 (build-system gnu-build-system)
1336 (synopsis "Character set conversion library")
1337 (description
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/")
1342 (license lgpl3+)))
1343
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))
1352 '()))
1353
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)))
1358 (proc package)))
1359
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)))
1365
1366 ;;; base.scm ends here