gnu: glibc@2.23: Fix CVE-2015-5180, CVE-2016-{3075,3706,4429}.
[jackhill/guix/guix.git] / gnu / packages / base.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
8a296947 2;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
722111ab 3;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
233e7676 4;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
3729ff41 5;;; Copyright © 2014, 2015, 2016 Mark H Weaver <mhw@netris.org>
4c8425b7 6;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
21a8fe1b 7;;; Copyright © 2014, 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
665d6a59 8;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
7309045c 9;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
e162050d 10;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
e3ce5d70 11;;;
233e7676 12;;; This file is part of GNU Guix.
e3ce5d70 13;;;
233e7676 14;;; GNU Guix is free software; you can redistribute it and/or modify it
e3ce5d70
LC
15;;; under the terms of the GNU General Public License as published by
16;;; the Free Software Foundation; either version 3 of the License, or (at
17;;; your option) any later version.
18;;;
233e7676 19;;; GNU Guix is distributed in the hope that it will be useful, but
e3ce5d70
LC
20;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22;;; GNU General Public License for more details.
23;;;
24;;; You should have received a copy of the GNU General Public License
233e7676 25;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
e3ce5d70 26
1ffa7090 27(define-module (gnu packages base)
c6d7e299 28 #:use-module ((guix licenses)
7309045c 29 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
59a43334 30 #:use-module (gnu packages)
1ffa7090
LC
31 #:use-module (gnu packages acl)
32 #:use-module (gnu packages bash)
b5ef82e0 33 #:use-module (gnu packages ed)
1ffa7090
LC
34 #:use-module (gnu packages guile)
35 #:use-module (gnu packages multiprecision)
c9505f3f 36 #:use-module (gnu packages compression)
1ffa7090
LC
37 #:use-module (gnu packages perl)
38 #:use-module (gnu packages linux)
8fd6487e 39 #:use-module (gnu packages texinfo)
21a8fe1b 40 #:use-module (gnu packages hurd)
aa6b0d6b 41 #:use-module (gnu packages pkg-config)
a635ed5c 42 #:use-module (gnu packages gettext)
aee6180c 43 #:use-module (guix utils)
e3ce5d70 44 #:use-module (guix packages)
87f5d366 45 #:use-module (guix download)
21a8fe1b 46 #:use-module (guix git-download)
c9505f3f 47 #:use-module (guix build-system gnu)
b09617da
MR
48 #:use-module (guix build-system trivial)
49 #:use-module (ice-9 match)
4dab8c59
JN
50 #:export (glibc
51 libiconv-if-needed))
e3ce5d70
LC
52
53;;; Commentary:
54;;;
1722d680 55;;; Base packages of the Guix-based GNU user-land software distribution.
e3ce5d70
LC
56;;;
57;;; Code:
58
59(define-public hello
60 (package
17d8e33f
ML
61 (name "hello")
62 (version "2.10")
63 (source (origin
64 (method url-fetch)
65 (uri (string-append "mirror://gnu/hello/hello-" version
66 ".tar.gz"))
67 (sha256
68 (base32
69 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
70 (build-system gnu-build-system)
71 (synopsis "Hello, GNU world: An example GNU package")
72 (description
73 "GNU Hello prints the message \"Hello, world!\" and then exits. It
a22dc0c4
LC
74serves as an example of standard GNU coding practices. As such, it supports
75command-line arguments, multiple languages, and so on.")
6fd52309 76 (home-page "https://www.gnu.org/software/hello/")
17d8e33f 77 (license gpl3+)))
d7672884 78
6794b278
LC
79(define-public grep
80 (package
81 (name "grep")
f3a79f88 82 (version "3.0")
6794b278 83 (source (origin
87f5d366 84 (method url-fetch)
0db342a5 85 (uri (string-append "mirror://gnu/grep/grep-"
6794b278
LC
86 version ".tar.xz"))
87 (sha256
88 (base32
f3a79f88 89 "1dcasjp3a578nrvzrcn38mpizb8w1q6mvfzhjmcqqgkf0nsivj72"))
fc1adab1 90 (patches (search-patches "grep-timing-sensitive-test.patch"))))
6794b278 91 (build-system gnu-build-system)
304e4f51 92 (native-inputs `(("perl" ,perl))) ;some of the tests require it
1063d325
MW
93 (arguments
94 `(#:phases
95 (modify-phases %standard-phases
96 (add-after 'install 'fix-egrep-and-fgrep
97 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
98 ;; absolute file name instead of searching for it in $PATH.
99 (lambda* (#:key outputs #:allow-other-keys)
100 (let* ((out (assoc-ref outputs "out"))
101 (bin (string-append out "/bin")))
102 (substitute* (list (string-append bin "/egrep")
103 (string-append bin "/fgrep"))
104 (("^exec grep")
105 (string-append "exec " bin "/grep")))
106 #t))))))
f50d2669 107 (synopsis "Print lines matching a pattern")
d45122f5 108 (description
12bcf94a 109 "grep is a tool for finding text inside files. Text is found by
a22dc0c4 110matching a pattern provided by the user in one or many files. The pattern
79c311b8
LC
111may be provided as a basic or extended regular expression, or as fixed
112strings. By default, the matching text is simply printed to the screen,
113however the output can be greatly customized to include, for example, line
114numbers. GNU grep offers many extensions over the standard utility,
115including, for example, recursive directory searching.")
4a44e743 116 (license gpl3+)
6fd52309 117 (home-page "https://www.gnu.org/software/grep/")))
6794b278 118
8dcad9aa
LC
119(define-public sed
120 (package
121 (name "sed")
d6592d84 122 (version "4.4")
8dcad9aa 123 (source (origin
87f5d366 124 (method url-fetch)
0db342a5 125 (uri (string-append "mirror://gnu/sed/sed-" version
7d7ea947 126 ".tar.xz"))
8dcad9aa
LC
127 (sha256
128 (base32
d6592d84 129 "0fv88bcnraixc8jvpacvxshi30p5x9m7yb8ns1hfv07hmb2ypmnb"))))
8dcad9aa 130 (build-system gnu-build-system)
f50d2669 131 (synopsis "Stream editor")
52b8e5fc 132 (arguments
8a296947
LC
133 `(#:phases
134 (modify-phases %standard-phases
c8b44fc1
LC
135 (add-after 'unpack 'dont-rebuild-sed.1
136 (lambda _
137 ;; Make sure we do not attempt to rebuild 'doc/sed.1', which does
138 ;; not work when cross-compiling because we cannot run 'sed'.
139 ;; This is fixed upstream as commit a0a25e3.
140 (substitute* "Makefile.in"
141 (("^doc/sed\\.1:.*")
142 "doc/sed.1:\n"))
143 #t))
8a296947
LC
144 (add-before 'patch-source-shebangs 'patch-test-suite
145 (lambda* (#:key inputs #:allow-other-keys)
146 (patch-makefile-SHELL "testsuite/Makefile.tests")
147 (substitute* '("testsuite/bsd.sh"
148 "testsuite/bug-regex9.c")
149 (("/bin/sh")
150 (which "sh")))
151 #t)))))
d45122f5 152 (description
a22dc0c4
LC
153 "Sed is a non-interactive, text stream editor. It receives a text
154input from a file or from standard input and it then applies a series of text
155editing commands to the stream and prints its output to standard output. It
79c311b8
LC
156is often used for substituting text patterns in a stream. The GNU
157implementation offers several extensions over the standard utility.")
4a44e743 158 (license gpl3+)
7d7ea947 159 (home-page "https://www.gnu.org/software/sed/")))
8dcad9aa 160
85240322
LC
161(define-public tar
162 (package
163 (name "tar")
74d63739 164 (version "1.29")
85240322 165 (source (origin
87f5d366 166 (method url-fetch)
0db342a5 167 (uri (string-append "mirror://gnu/tar/tar-"
d6535cf1 168 version ".tar.xz"))
85240322
LC
169 (sha256
170 (base32
74d63739 171 "097hx7sbzp8qirl4m930lw84kn0wmxhmq7v1qpra3mrg0b8cyba0"))
20be64dc
AV
172 (patches (search-patches "tar-CVE-2016-6321.patch"
173 "tar-skip-unreliable-tests.patch"))))
85240322 174 (build-system gnu-build-system)
74d63739
LC
175 ;; Note: test suite requires ~1GiB of disk space.
176 (arguments
177 '(#:phases (modify-phases %standard-phases
178 (add-before 'build 'set-shell-file-name
179 (lambda* (#:key inputs #:allow-other-keys)
180 ;; Do not use "/bin/sh" to run programs.
181 (let ((bash (assoc-ref inputs "bash")))
182 (substitute* "src/system.c"
183 (("/bin/sh")
184 (string-append bash "/bin/sh")))
185 #t))))))
bbe03294
LC
186
187 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
188 ;; to refer to the target Bash.
189 (inputs (if (%current-target-system)
190 `(("bash" ,bash))
191 '()))
192
f50d2669 193 (synopsis "Managing tar archives")
d45122f5 194 (description
a22dc0c4
LC
195 "Tar provides the ability to create tar archives, as well as the
196ability to extract, update or list files in an existing archive. It is
197useful for combining many files into one larger file, while maintaining
198directory structure and file information such as permissions and
79c311b8
LC
199creation/modification dates. GNU tar offers many extensions over the
200standard utility.")
4a44e743 201 (license gpl3+)
6fd52309 202 (home-page "https://www.gnu.org/software/tar/")))
85240322 203
fbeec3d9
LC
204(define-public patch
205 (package
206 (name "patch")
266d26df 207 (version "2.7.5")
f6408bc5
LC
208 (source (origin
209 (method url-fetch)
210 (uri (string-append "mirror://gnu/patch/patch-"
211 version ".tar.xz"))
212 (sha256
213 (base32
16cae799 214 "16d2r9kpivaak948mxzc0bai45mqfw73m113wrkmbffnalv1b5gx"))
fc1adab1 215 (patches (search-patches "patch-hurd-path-max.patch"))))
fbeec3d9 216 (build-system gnu-build-system)
b3546174 217 (native-inputs `(("ed" ,ed)))
f50d2669 218 (synopsis "Apply differences to originals, with optional backups")
d45122f5 219 (description
a22dc0c4 220 "Patch is a program that applies changes to files based on differences
79c311b8 221laid out as by the program \"diff\". The changes may be applied to one or more
a22dc0c4
LC
222files depending on the contents of the diff file. It accepts several
223different diff formats. It may also be used to revert previously applied
224differences.")
4a44e743 225 (license gpl3+)
6fd52309 226 (home-page "https://savannah.gnu.org/projects/patch/")))
fbeec3d9 227
04a32ee5
LC
228(define-public diffutils
229 (package
230 (name "diffutils")
1a93d094 231 (version "3.5")
04a32ee5 232 (source (origin
87f5d366 233 (method url-fetch)
0db342a5 234 (uri (string-append "mirror://gnu/diffutils/diffutils-"
04a32ee5
LC
235 version ".tar.xz"))
236 (sha256
237 (base32
1a93d094 238 "0csmqfz8ks23kdjsq0v2ll1acqiz8lva06dj19mwmymrsp69ilys"))))
04a32ee5 239 (build-system gnu-build-system)
f50d2669 240 (synopsis "Comparing and merging files")
d45122f5 241 (description
79c311b8
LC
242 "GNU Diffutils is a package containing tools for finding the
243differences between files. The \"diff\" command is used to show how two files
e881752c 244differ, while \"cmp\" shows the offsets and line numbers where they differ.
79c311b8 245\"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
a22dc0c4 246interactive means to merge two files.")
4a44e743 247 (license gpl3+)
6fd52309 248 (home-page "https://www.gnu.org/software/diffutils/")))
04a32ee5 249
af5521ca
LC
250(define-public findutils
251 (package
252 (name "findutils")
e80d2555 253 (version "4.6.0")
af5521ca 254 (source (origin
87f5d366 255 (method url-fetch)
0db342a5 256 (uri (string-append "mirror://gnu/findutils/findutils-"
af5521ca
LC
257 version ".tar.gz"))
258 (sha256
259 (base32
e80d2555 260 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
fc1adab1
AK
261 (patches (search-patches "findutils-localstatedir.patch"
262 "findutils-test-xargs.patch"))))
af5521ca 263 (build-system gnu-build-system)
af5521ca 264 (arguments
67dfa198
LC
265 `(#:configure-flags (list
266 ;; Tell 'updatedb' to write to /var.
267 "--localstatedir=/var"
268
269 ;; Work around cross-compilation failure. See
270 ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
271 ,@(if (%current-target-system)
272 '("gl_cv_func_wcwidth_works=yes")
273 '()))))
f50d2669 274 (synopsis "Operating on files matching given criteria")
d45122f5 275 (description
a22dc0c4
LC
276 "Findutils supplies the basic file directory searching utilities of the
277GNU system. It consists of two primary searching utilities: \"find\"
278recursively searches for files in a directory according to given criteria and
279\"locate\" lists files in a database that match a query. Two auxiliary tools
79c311b8
LC
280are included: \"updatedb\" updates the file name database and \"xargs\" may be
281used to apply commands with arbitrarily long arguments.")
4a44e743 282 (license gpl3+)
6fd52309 283 (home-page "https://www.gnu.org/software/findutils/")))
2c957cd2
LC
284
285(define-public coreutils
286 (package
287 (name "coreutils")
bec5022f 288 (version "8.26")
2c957cd2 289 (source (origin
87f5d366 290 (method url-fetch)
0db342a5 291 (uri (string-append "mirror://gnu/coreutils/coreutils-"
2c957cd2
LC
292 version ".tar.xz"))
293 (sha256
294 (base32
82a7a8c6
MR
295 "13lspazc7xkviy93qz7ks9jv4sldvgmwpq36ghrbrqpq93br8phm"))
296 (patches (search-patches "coreutils-fix-cross-compilation.patch"))))
2c957cd2 297 (build-system gnu-build-system)
de59af4d 298 (inputs `(("acl" ,acl) ; TODO: add SELinux
09cc7729 299 ("gmp" ,gmp) ;bignums in 'expr', yay!
62ea8865
LC
300
301 ;; Drop the dependency on libcap when cross-compiling since it's
302 ;; not quite cross-compilable.
303 ,@(if (%current-target-system)
304 '()
305 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
2c1dea85
LC
306 (native-inputs
307 ;; Perl is needed to run tests in native builds, and to run the bundled
7f31c71c
LC
308 ;; copy of help2man. However, don't pass it when cross-compiling since
309 ;; that would lead it to try to run programs to get their '--help' output
310 ;; for help2man.
d1e3f59c
LC
311 `(,@(if (%current-target-system)
312 '()
313 `(("perl" ,perl)))
314
315 ;; Apply this patch only on ARM to avoid a full rebuild.
316 ;; TODO: Move to 'patches' in the next update cycle.
317 ,@(if (string-prefix? "arm" (or (%current-target-system)
318 (%current-system)))
319 `(("cut-test.patch"
320 ,(search-patch "coreutils-cut-huge-range-test.patch")))
321 '())))
9bf62d9b 322 (outputs '("out" "debug"))
2c957cd2 323 (arguments
8ba8aeb7 324 `(#:parallel-build? #f ; help2man may be called too early
e7479644 325 #:parallel-tests? #f ; race condition fixed after 8.26
8ba8aeb7
LC
326 #:phases (alist-cons-before
327 'build 'patch-shell-references
328 (lambda* (#:key inputs #:allow-other-keys)
329 (let ((bash (assoc-ref inputs "bash")))
b47b2b52
LC
330 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
331 ;; that tests pass, since /bin/sh isn't in the chroot.
332 (setenv "SHELL" (which "sh"))
333
334 (substitute* (find-files "gnulib-tests" "\\.c$")
8ba8aeb7
LC
335 (("/bin/sh")
336 (format #f "~a/bin/sh" bash)))
337 (substitute* (find-files "tests" "\\.sh$")
338 (("#!/bin/sh")
b47b2b52 339 (format #f "#!~a/bin/sh" bash)))))
d1e3f59c
LC
340
341 ,@(if (string-prefix? "arm" (or (%current-target-system)
342 (%current-system)))
343 '((alist-cons-before
344 'build 'patch-cut-test
345 (lambda* (#:key inputs native-inputs
346 #:allow-other-keys)
347 (let ((patch (or (assoc-ref inputs
348 "cut-test.patch")
349 (assoc-ref native-inputs
350 "cut-test.patch"))))
351 (zero?
352 (system* "patch" "-p1" "--force"
353 "--input" patch))))
354 %standard-phases))
355 '(%standard-phases)))))
f50d2669 356 (synopsis "Core GNU utilities (file, text, shell)")
d45122f5 357 (description
79c311b8 358 "GNU Coreutils includes all of the basic command-line tools that are
a22dc0c4
LC
359expected in a POSIX system. These provide the basic file, shell and text
360manipulation functions of the GNU system. Most of these tools offer extended
361functionality beyond that which is outlined in the POSIX standard.")
4a44e743 362 (license gpl3+)
6fd52309 363 (home-page "https://www.gnu.org/software/coreutils/")))
af5521ca 364
e162050d
MB
365;; We add version 8.27 here for use in (gnu system) due to a time
366;; zone bug in `date' versions 8.25 - 8.26.
367;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=23035
368;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26238
369(define-public coreutils-8.27
370 (package
371 (inherit coreutils)
372 (version "8.27")
373 (source (origin
374 (method url-fetch)
375 (uri (string-append "mirror://gnu/coreutils/coreutils-"
376 version ".tar.xz"))
377 (sha256
378 (base32
fd6ec6bd
LC
379 "0sv547572iq8ayy8klir4hnngnx92a9nsazmf1wgzfc7xr4x74c8"))))
380 (arguments
381 (if (string-prefix? "arm" (or (%current-target-system)
382 (%current-system)))
383 (substitute-keyword-arguments (package-arguments coreutils)
384 ((#:phases phases)
385 `(alist-delete 'patch-cut-test ,phases)))
386 (package-arguments coreutils)))))
e162050d 387
d0f74308 388(define-public coreutils-minimal
28cbc587
LC
389 ;; Coreutils without its optional dependencies.
390 (package
391 (inherit coreutils)
d0f74308 392 (name "coreutils-minimal")
28cbc587
LC
393 (outputs '("out"))
394 (inputs '())))
395
ab776865
LC
396(define-public gnu-make
397 (package
398 (name "make")
6d2b94f2 399 (version "4.2.1")
ab776865 400 (source (origin
87f5d366 401 (method url-fetch)
0db342a5 402 (uri (string-append "mirror://gnu/make/make-" version
ab776865
LC
403 ".tar.bz2"))
404 (sha256
405 (base32
6d2b94f2 406 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
fc1adab1 407 (patches (search-patches "make-impure-dirs.patch"))))
ab776865 408 (build-system gnu-build-system)
b3546174 409 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
ed41d48e 410 (inputs `(("guile" ,guile-2.0)))
9bf62d9b 411 (outputs '("out" "debug"))
ea8fbbf2 412 (arguments
6cc83b68
EF
413 '(#:phases
414 (modify-phases %standard-phases
415 (add-before 'build 'set-default-shell
416 (lambda* (#:key inputs #:allow-other-keys)
417 ;; Change the default shell from /bin/sh.
418 (let ((bash (assoc-ref inputs "bash")))
419 (substitute* "job.c"
420 (("default_shell =.*$")
60f3ad8c 421 (format #f "default_shell = \"~a/bin/sh\";\n"
6cc83b68 422 bash)))))))))
f50d2669 423 (synopsis "Remake files automatically")
d45122f5 424 (description
a22dc0c4
LC
425 "Make is a program that is used to control the production of
426executables or other files from their source files. The process is
427controlled from a Makefile, in which the developer specifies how each file is
428generated from its source. It has powerful dependency resolution and the
429ability to determine when files have to be regenerated after their sources
79c311b8 430change. GNU make offers many powerful extensions over the standard utility.")
4a44e743 431 (license gpl3+)
6fd52309 432 (home-page "https://www.gnu.org/software/make/")))
ab776865 433
8f6201a3
LC
434(define-public binutils
435 (package
436 (name "binutils")
4148ed46 437 (version "2.27")
8f6201a3 438 (source (origin
87f5d366 439 (method url-fetch)
0db342a5 440 (uri (string-append "mirror://gnu/binutils/binutils-"
8f6201a3
LC
441 version ".tar.bz2"))
442 (sha256
443 (base32
4148ed46 444 "125clslv17xh1sab74343fg6v31msavpmaa1c1394zsqa773g5rn"))
fc1adab1 445 (patches (search-patches "binutils-ld-new-dtags.patch"
789f09a0
LC
446 "binutils-loongson-workaround.patch"
447 "binutils-mips-bash-bug.patch"))))
8f6201a3
LC
448 (build-system gnu-build-system)
449
450 ;; TODO: Add dependency on zlib + those for Gold.
8f6201a3 451 (arguments
de80b504 452 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
01d45404
LC
453 ;; on GCC when bootstrapping.
454 "LDFLAGS=-static-libgcc"
8f6201a3 455
01d45404 456 ;; Don't search under /usr/lib & co.
444c64b0
LC
457 "--with-lib-path=/no-ld-lib-path"
458
459 ;; Glibc 2.17 has a "comparison of unsigned
460 ;; expression >= 0 is always true" in wchar.h.
6c95f363
LC
461 "--disable-werror"
462
463 ;; Install BFD. It ends up in a hidden directory,
464 ;; but it's here.
cc0a1282
LC
465 "--enable-install-libbfd"
466
467 ;; Make sure 'ar' and 'ranlib' produce archives in a
468 ;; deterministic fashion.
469 "--enable-deterministic-archives")))
8f6201a3 470
f50d2669 471 (synopsis "Binary utilities: bfd gas gprof ld")
d45122f5 472 (description
a22dc0c4 473 "GNU Binutils is a collection of tools for working with binary files.
c5779c93
LC
474Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
475Other tools include programs to display binary profiling information, list
476the strings in a binary file, and utilities for working with archives. The
477\"bfd\" library for working with executable and object formats is also
478included.")
4a44e743 479 (license gpl3+)
6fd52309 480 (home-page "https://www.gnu.org/software/binutils/")))
8f6201a3 481
5bde4503
LC
482(define* (make-ld-wrapper name #:key
483 (target (const #f))
484 binutils
4a740d0f 485 (guile (canonical-package guile-2.0))
5bde4503 486 (bash (canonical-package bash))
8fdd4101
LC
487 (guile-for-build guile))
488 "Return a package called NAME that contains a wrapper for the 'ld' program
5bde4503
LC
489of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
490wrapper uses GUILE and BASH.
491
492TARGET must be a one-argument procedure that, given a system type, returns a
493cross-compilation target triplet or #f. When the result is not #f, make a
494wrapper for the cross-linker for that target, called 'TARGET-ld'."
495 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
496 ;; its result can be delayed until the 'arguments' field is evaluated, thus
497 ;; in a context where '%current-system' is accurate.
8fdd4101
LC
498 (package
499 (name name)
500 (version "0")
501 (source #f)
502 (build-system trivial-build-system)
503 (inputs `(("binutils" ,binutils)
504 ("guile" ,guile)
505 ("bash" ,bash)
506 ("wrapper" ,(search-path %load-path
c8bfa5b4 507 "gnu/packages/ld-wrapper.in"))))
8fdd4101 508 (arguments
5bde4503
LC
509 (let ((target (target (%current-system))))
510 `(#:guile ,guile-for-build
511 #:modules ((guix build utils))
512 #:builder (begin
513 (use-modules (guix build utils)
514 (system base compile))
8fdd4101 515
5bde4503
LC
516 (let* ((out (assoc-ref %outputs "out"))
517 (bin (string-append out "/bin"))
518 (ld ,(if target
519 `(string-append bin "/" ,target "-ld")
520 '(string-append bin "/ld")))
521 (go (string-append ld ".go")))
8fdd4101 522
5bde4503
LC
523 (setvbuf (current-output-port) _IOLBF)
524 (format #t "building ~s/bin/ld wrapper in ~s~%"
525 (assoc-ref %build-inputs "binutils")
526 out)
8fdd4101 527
5bde4503
LC
528 (mkdir-p bin)
529 (copy-file (assoc-ref %build-inputs "wrapper") ld)
530 (substitute* ld
531 (("@SELF@")
532 ld)
533 (("@GUILE@")
534 (string-append (assoc-ref %build-inputs "guile")
535 "/bin/guile"))
536 (("@BASH@")
537 (string-append (assoc-ref %build-inputs "bash")
538 "/bin/bash"))
539 (("@LD@")
540 (string-append (assoc-ref %build-inputs "binutils")
541 ,(if target
542 (string-append "/bin/"
543 target "-ld")
544 "/bin/ld"))))
545 (chmod ld #o555)
546 (compile-file ld #:output-file go))))))
8fdd4101
LC
547 (synopsis "The linker wrapper")
548 (description
549 "The linker wrapper (or 'ld-wrapper') wraps the linker to add any
550missing '-rpath' flags, and to detect any misuse of libraries outside of the
551store.")
6fd52309 552 (home-page "https://www.gnu.org/software/guix//")
8fdd4101
LC
553 (license gpl3+)))
554
555(export make-ld-wrapper)
556
b09617da 557(define-public glibc/linux
7cdeac02
LC
558 (package
559 (name "glibc")
242c0927 560 (version "2.25")
665d6a59 561 (replacement glibc-2.25-patched)
7cdeac02 562 (source (origin
87f5d366 563 (method url-fetch)
0db342a5 564 (uri (string-append "mirror://gnu/glibc/glibc-"
7cdeac02
LC
565 version ".tar.xz"))
566 (sha256
567 (base32
242c0927 568 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
13990c73
LC
569 (snippet
570 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
571 ;; required on LFS distros to avoid loading the distro's libc.so
572 ;; instead of ours.
573 '(substitute* "sysdeps/unix/sysv/linux/configure"
574 (("use_ldconfig=yes")
575 "use_ldconfig=no")))
1faca892 576 (modules '((guix build utils)))
c3052d6b
ML
577 (patches (search-patches "glibc-ldd-x86_64.patch"
578 "glibc-versioned-locpath.patch"
579 "glibc-o-largefile.patch"))))
7cdeac02 580 (build-system gnu-build-system)
0a3da5b7
LC
581
582 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
583 ;; users should automatically pull Linux headers as well.
55de892b 584 (propagated-inputs `(("kernel-headers" ,linux-libre-headers)))
0a3da5b7 585
97e11209 586 (outputs '("out" "debug"))
7f614e49 587
7cdeac02 588 (arguments
8197c978 589 `(#:out-of-source? #t
211db2f6
LC
590
591 ;; In version 2.21, there a race in the 'elf' directory, see
592 ;; <http://lists.gnu.org/archive/html/guix-devel/2015-02/msg00709.html>.
593 #:parallel-build? #f
594
112da588 595 ;; The libraries have an empty RUNPATH, but some, such as the versioned
67fcf235 596 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
112da588
LC
597 ;; these libraries are always going to be found anyway, just skip
598 ;; RUNPATH checks.
599 #:validate-runpath? #f
600
7cdeac02
LC
601 #:configure-flags
602 (list "--enable-add-ons"
603 "--sysconfdir=/etc"
7f614e49 604
97e11209
LC
605 ;; Installing a locale archive with all the locales is to
606 ;; expensive (~100 MiB), so we rely on users to install the
607 ;; locales they really want.
608 ;;
609 ;; Set the default locale path. In practice, $LOCPATH may be
610 ;; defined to point whatever locales users want. However, setuid
611 ;; binaries don't honor $LOCPATH, so they'll instead look into
9f58fe3d 612 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
46bd6edd
LC
613 ;; with the idea that it is going to be populated by the sysadmin.
614 ;; The "X.Y" sub-directory is because locale data formats are
615 ;; incompatible across libc versions; see
616 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
97e11209 617 ;;
7f614e49
LC
618 ;; `--localedir' is not honored, so work around it.
619 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
9f58fe3d 620 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
46bd6edd 621 ,version)
7f614e49 622
7cdeac02 623 (string-append "--with-headers="
28dc10a4
LC
624 (assoc-ref ,(if (%current-target-system)
625 '%build-target-inputs
626 '%build-inputs)
aeafff53 627 "kernel-headers")
7cdeac02 628 "/include")
5f456680 629
fdaae613 630 ;; This is the default for most architectures as of GNU libc 2.21,
39ccbfad
MW
631 ;; but we specify it explicitly for clarity and consistency. See
632 ;; "kernel-features.h" in the GNU libc for details.
633 "--enable-kernel=2.6.32"
5f456680 634
6e32f6c0 635 ;; Use our Bash instead of /bin/sh.
8cd8e97c 636 (string-append "BASH_SHELL="
6e32f6c0 637 (assoc-ref %build-inputs "bash")
8cd8e97c
LC
638 "/bin/bash")
639
640 ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
e37595d9 641 "libc_cv_ssp=no" "libc_cv_ssp_strong=no")
6e32f6c0 642
7cdeac02 643 #:tests? #f ; XXX
57f65bcc
LC
644 #:phases (modify-phases %standard-phases
645 (add-before
646 'configure 'pre-configure
647 (lambda* (#:key inputs native-inputs outputs
648 #:allow-other-keys)
649 (let* ((out (assoc-ref outputs "out"))
650 (bin (string-append out "/bin"))
651 ;; FIXME: Normally we would look it up only in INPUTS
652 ;; but cross-base uses it as a native input.
653 (bash (or (assoc-ref inputs "static-bash")
654 (assoc-ref native-inputs "static-bash"))))
57f65bcc
LC
655 ;; Install the rpc data base file under `$out/etc/rpc'.
656 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
657 (substitute* "sunrpc/Makefile"
658 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
659 (string-append out "/etc/rpc" suffix "\n"))
660 (("^install-others =.*$")
661 (string-append "install-others = " out "/etc/rpc\n")))
662
663 (substitute* "Makeconfig"
664 ;; According to
665 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
666 ;; linking against libgcc_s is not needed with GCC
667 ;; 4.7.1.
668 ((" -lgcc_s") ""))
669
b2fd8f63
RW
670 ;; Apply patch only on i686.
671 ;; TODO: Move the patch to 'patches' in the next update cycle.
672 ,@(if (string-prefix? "i686" (or (%current-target-system)
673 (%current-system)))
c2e4f14a
RW
674 `((unless (zero? (system* "patch" "-p1" "--force"
675 "--input"
676 (or (assoc-ref native-inputs
677 "glibc-memchr-overflow-i686.patch")
678 (assoc-ref inputs
679 "glibc-memchr-overflow-i686.patch"))))
680 (error "patch failed for glibc-memchr-overflow-i686.patch")))
b2fd8f63
RW
681 '())
682
57f65bcc
LC
683 ;; Have `system' use that Bash.
684 (substitute* "sysdeps/posix/system.c"
685 (("#define[[:blank:]]+SHELL_PATH.*$")
686 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
687 bash)))
688
689 ;; Same for `popen'.
690 (substitute* "libio/iopopen.c"
691 (("/bin/sh")
11b66876 692 (string-append bash "/bin/sh")))
57f65bcc 693
d56f8d5e
LC
694 ;; Same for the shell used by the 'exec' functions for
695 ;; scripts that lack a shebang.
696 (substitute* (find-files "." "^paths\\.h$")
697 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
698 (string-append "#define _PATH_BSHELL \""
e4831391 699 bash "/bin/sh\"\n")))
d56f8d5e 700
c5b65f7e
LC
701 ;; Nscd uses __DATE__ and __TIME__ to create a string to
702 ;; make sure the client and server come from the same
703 ;; libc. Use something deterministic instead.
704 (substitute* "nscd/nscd_stat.c"
705 (("static const char compilation\\[21\\] =.*$")
706 (string-append
707 "static const char compilation[21] = \""
708 (string-take (basename out) 20) "\";\n")))
709
57f65bcc
LC
710 ;; Make sure we don't retain a reference to the
711 ;; bootstrap Perl.
712 (substitute* "malloc/mtrace.pl"
713 (("^#!.*")
714 ;; The shebang can be omitted, because there's the
715 ;; "bilingual" eval/exec magic at the top of the file.
716 "")
717 (("exec @PERL@")
718 "exec perl"))))))))
7f614e49 719
90d891fc 720 (inputs `(("static-bash" ,static-bash)))
8fd6487e 721
6162b95d
LC
722 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
723 ;; install the message catalogs, with 'msgfmt'.
8fd6487e 724 (native-inputs `(("texinfo" ,texinfo)
6162b95d 725 ("perl" ,perl)
b2fd8f63
RW
726 ("gettext" ,gettext-minimal)
727
728 ;; Apply this patch only on i686 to avoid a full rebuild.
729 ;; TODO: Move to 'patches' in the next update cycle.
730 ,@(if (string-prefix? "i686" (or (%current-target-system)
731 (%current-system)))
732 `(("glibc-memchr-overflow-i686.patch"
733 ,(search-patch "glibc-memchr-overflow-i686.patch")))
734 '())))
8fd6487e 735
d6718df4
LC
736 (native-search-paths
737 ;; Search path for packages that provide locale data. This is useful
85e57214
LC
738 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
739 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
740 ;; distros.
d6718df4 741 (list (search-path-specification
fbb909ac 742 (variable "GUIX_LOCPATH")
f211b2af 743 (files '("lib/locale")))))
d6718df4 744
d45122f5
LC
745 (synopsis "The GNU C Library")
746 (description
7cdeac02
LC
747 "Any Unix-like operating system needs a C library: the library which
748defines the \"system calls\" and other basic facilities such as open, malloc,
749printf, exit...
750
751The GNU C library is used as the C library in the GNU system and most systems
752with the Linux kernel.")
4a44e743 753 (license lgpl2.0+)
6fd52309 754 (home-page "https://www.gnu.org/software/libc/")))
7cdeac02 755
b09617da
MR
756(define-public glibc/hurd
757 ;; The Hurd's libc variant.
758 (package (inherit glibc/linux)
759 (name "glibc-hurd")
1d9c8898 760 (version "2.23")
b09617da
MR
761 (source (origin
762 (method url-fetch)
763 (uri (string-append "http://alpha.gnu.org/gnu/hurd/glibc-"
1d9c8898 764 version "-hurd+libpthread-20161218" ".tar.gz"))
b09617da
MR
765 (sha256
766 (base32
1d9c8898 767 "0vpdv05j6j3ria5bw8gp468i64gij94cslxkxj9xkfgi6p615b8p"))))
b09617da
MR
768
769 ;; Libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
770 ;; so both should be propagated.
771 (propagated-inputs `(("hurd-core-headers" ,hurd-core-headers)))
772 (native-inputs
773 `(,@(package-native-inputs glibc/linux)
774 ("mig" ,mig)
775 ("perl" ,perl)))
776
777 (arguments
778 (substitute-keyword-arguments (package-arguments glibc/linux)
779 ((#:phases original-phases)
780 ;; Add libmachuser.so and libhurduser.so to libc.so's search path.
781 ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-07/msg00051.html>.
711a0dce 782 `(modify-phases ,original-phases
441e99d4
RW
783 ;; TODO: This is almost an exact copy of the phase of the same name
784 ;; in glibc/linux. The only difference is that the i686 patch is
785 ;; not applied here. In the next update cycle the patch moves to
786 ;; the patches field and this overwritten phase won't be needed any
787 ;; more.
788 (replace 'pre-configure
789 (lambda* (#:key inputs native-inputs outputs
790 #:allow-other-keys)
791 (let* ((out (assoc-ref outputs "out"))
792 (bin (string-append out "/bin"))
793 ;; FIXME: Normally we would look it up only in INPUTS
794 ;; but cross-base uses it as a native input.
795 (bash (or (assoc-ref inputs "static-bash")
796 (assoc-ref native-inputs "static-bash"))))
797 ;; Install the rpc data base file under `$out/etc/rpc'.
798 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
799 (substitute* "sunrpc/Makefile"
800 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
801 (string-append out "/etc/rpc" suffix "\n"))
802 (("^install-others =.*$")
803 (string-append "install-others = " out "/etc/rpc\n")))
804
805 (substitute* "Makeconfig"
806 ;; According to
807 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
808 ;; linking against libgcc_s is not needed with GCC
809 ;; 4.7.1.
810 ((" -lgcc_s") ""))
811
812 ;; Have `system' use that Bash.
813 (substitute* "sysdeps/posix/system.c"
814 (("#define[[:blank:]]+SHELL_PATH.*$")
815 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
816 bash)))
817
818 ;; Same for `popen'.
819 (substitute* "libio/iopopen.c"
820 (("/bin/sh")
821 (string-append bash "/bin/sh")))
822
823 ;; Same for the shell used by the 'exec' functions for
824 ;; scripts that lack a shebang.
825 (substitute* (find-files "." "^paths\\.h$")
826 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
827 (string-append "#define _PATH_BSHELL \""
828 bash "/bin/sh\"\n")))
829
830 ;; Nscd uses __DATE__ and __TIME__ to create a string to
831 ;; make sure the client and server come from the same
832 ;; libc. Use something deterministic instead.
833 (substitute* "nscd/nscd_stat.c"
834 (("static const char compilation\\[21\\] =.*$")
835 (string-append
836 "static const char compilation[21] = \""
837 (string-take (basename out) 20) "\";\n")))
838
839 ;; Make sure we don't retain a reference to the
840 ;; bootstrap Perl.
841 (substitute* "malloc/mtrace.pl"
842 (("^#!.*")
843 ;; The shebang can be omitted, because there's the
844 ;; "bilingual" eval/exec magic at the top of the file.
845 "")
846 (("exec @PERL@")
847 "exec perl")))))
711a0dce
RW
848 (add-after 'install 'augment-libc.so
849 (lambda* (#:key outputs #:allow-other-keys)
850 (let* ((out (assoc-ref outputs "out")))
851 (substitute* (string-append out "/lib/libc.so")
852 (("/[^ ]+/lib/libc.so.0.3")
853 (string-append out "/lib/libc.so.0.3" " libmachuser.so" " libhurduser.so"))))
854 #t))
855 (add-after 'pre-configure 'pre-configure-set-pwd
856 (lambda _
857 ;; Use the right 'pwd'.
858 (substitute* "configure"
859 (("/bin/pwd") "pwd"))
860 #t))
861 (replace 'build
862 (lambda _
863 ;; Force mach/hurd/libpthread subdirs to build first in order to avoid
864 ;; linking errors.
865 ;; See <https://lists.gnu.org/archive/html/bug-hurd/2016-11/msg00045.html>
866 (let ((-j (list "-j" (number->string (parallel-job-count)))))
867 (let-syntax ((make (syntax-rules ()
868 ((_ target)
869 (zero? (apply system* "make" target -j))))))
870 (and (make "mach/subdir_lib")
871 (make "hurd/subdir_lib")
872 (make "libpthread/subdir_lib")
873 (zero? (apply system* "make" -j)))))))))
b09617da
MR
874 ((#:configure-flags original-configure-flags)
875 `(append (list "--host=i586-pc-gnu"
876
877 ;; We need this to get a working openpty() function.
878 "--enable-pt_chown"
879
367f7013
MR
880 ;; <https://lists.gnu.org/archive/html/bug-hurd/2016-10/msg00033.html>
881 "--disable-werror"
882
b09617da
MR
883 ;; nscd fails to build for GNU/Hurd:
884 ;; <https://lists.gnu.org/archive/html/bug-hurd/2014-07/msg00006.html>.
885 ;; Disable it.
886 "--disable-nscd")
887 (filter (lambda (flag)
888 (not (string-prefix? "--enable-kernel=" flag)))
889 ,original-configure-flags)))))
890 (synopsis "The GNU C Library (GNU Hurd variant)")
891 (supported-systems %hurd-systems)))
892
893(define* (glibc-for-target #:optional
894 (target (or (%current-target-system)
895 (%current-system))))
896 "Return the glibc for TARGET, GLIBC/LINUX for a Linux host or
897GLIBC/HURD for a Hurd host"
898 (match target
899 ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
900 (_ glibc/linux)))
901
902(define-syntax glibc
903 (identifier-syntax (glibc-for-target)))
904
665d6a59
EF
905(define glibc-2.25-patched
906 (package
907 (inherit glibc)
665d6a59
EF
908 (source (origin
909 (inherit (package-source glibc))
910 (patches (search-patches "glibc-ldd-x86_64.patch"
911 "glibc-versioned-locpath.patch"
912 "glibc-o-largefile.patch"
ffc015be 913 "glibc-vectorized-strcspn-guards.patch"
665d6a59
EF
914 "glibc-CVE-2017-1000366-pt1.patch"
915 "glibc-CVE-2017-1000366-pt2.patch"
916 "glibc-CVE-2017-1000366-pt3.patch"))))))
917
ffc015be
MW
918;; Below are old libc versions, which we use mostly to build locale data in
919;; the old format (which the new libc cannot cope with.)
920
7ca72ec4
EF
921(define-public glibc-2.24
922 (package
923 (inherit glibc)
924 (version "2.24")
925 (source (origin
926 (inherit (package-source glibc))
927 (uri (string-append "mirror://gnu/glibc/glibc-"
928 version ".tar.xz"))
929 (sha256
930 (base32
665d6a59
EF
931 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
932 (patches (search-patches "glibc-ldd-x86_64.patch"
933 "glibc-versioned-locpath.patch"
934 "glibc-o-largefile.patch"
ffc015be 935 "glibc-vectorized-strcspn-guards.patch"
575e5e4e 936 "glibc-CVE-2015-5180.patch"
665d6a59
EF
937 "glibc-CVE-2017-1000366-pt1.patch"
938 "glibc-CVE-2017-1000366-pt2.patch"
939 "glibc-CVE-2017-1000366-pt3.patch"))))))
7ca72ec4 940
19ac2ba8
LC
941(define-public glibc-2.23
942 (package
943 (inherit glibc)
944 (version "2.23")
945 (source (origin
946 (inherit (package-source glibc))
947 (uri (string-append "mirror://gnu/glibc/glibc-"
948 version ".tar.xz"))
949 (sha256
950 (base32
665d6a59
EF
951 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
952 (patches (search-patches "glibc-ldd-x86_64.patch"
953 "glibc-versioned-locpath.patch"
954 "glibc-o-largefile.patch"
ffc015be 955 "glibc-vectorized-strcspn-guards.patch"
a0ae64a3
EF
956 "glibc-CVE-2015-5180.patch"
957 "glibc-CVE-2016-3075.patch"
958 "glibc-CVE-2016-3706.patch"
959 "glibc-CVE-2016-4429.patch"
665d6a59
EF
960 "glibc-CVE-2017-1000366-pt1.patch"
961 "glibc-CVE-2017-1000366-pt2.patch"
962 "glibc-CVE-2017-1000366-pt3.patch"))))))
19ac2ba8 963
c2c54ebd 964(define-public glibc-2.22
455859a5 965 (package
0832787e 966 (inherit glibc)
c2c54ebd 967 (version "2.22")
137d957e
LC
968 (source (origin
969 (inherit (package-source glibc))
970 (uri (string-append "mirror://gnu/glibc/glibc-"
971 version ".tar.xz"))
972 (sha256
973 (base32
c2c54ebd 974 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
665d6a59 975 (patches (search-patches "glibc-ldd-x86_64.patch"
ffc015be 976 "glibc-vectorized-strcspn-guards.patch"
665d6a59
EF
977 "glibc-CVE-2017-1000366-pt1.patch"
978 "glibc-CVE-2017-1000366-pt2.patch"
979 "glibc-CVE-2017-1000366-pt3.patch"))))
38e9373b
EF
980 (arguments
981 (substitute-keyword-arguments (package-arguments glibc)
982 ((#:phases phases)
983 `(modify-phases ,phases
984 (add-before 'configure 'fix-pwd
985 (lambda _
6d833b13 986 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
38e9373b 987 (substitute* "configure"
56ed97c8
MW
988 (("/bin/pwd") "pwd"))
989 #t))))))))
137d957e 990
aee6180c
LC
991(define-public glibc-locales
992 (package
993 (inherit glibc)
994 (name "glibc-locales")
995 (source (origin (inherit (package-source glibc))
996 (patches (cons (search-patch "glibc-locales.patch")
997 (origin-patches (package-source glibc))))))
998 (synopsis "All the locales supported by the GNU C Library")
999 (description
1000 "This package provides all the locales supported by the GNU C Library,
1001more than 400 in total. To use them set the 'LOCPATH' environment variable to
1002the 'share/locale' sub-directory of this package.")
1003 (outputs '("out")) ;110+ MiB
605217be 1004 (native-search-paths '())
aee6180c
LC
1005 (arguments
1006 (let ((args `(#:tests? #f #:strip-binaries? #f
1007 ,@(package-arguments glibc))))
1008 (substitute-keyword-arguments args
1009 ((#:phases phases)
1010 `(alist-replace
1011 'build
1012 (lambda* (#:key outputs #:allow-other-keys)
aee6180c
LC
1013 (zero? (system* "make" "localedata/install-locales"
1014 "-j" (number->string (parallel-job-count)))))
1015 (alist-delete 'install ,phases)))
1016 ((#:configure-flags flags)
1017 `(append ,flags
85e57214 1018 ;; Use $(libdir)/locale/X.Y as is the case by default.
85860fdf 1019 (list (string-append "libc_cv_complocaledir="
aee6180c 1020 (assoc-ref %outputs "out")
f2d7bbb5
LC
1021 "/lib/locale/"
1022 ,(package-version glibc))))))))))
aee6180c 1023
c9505f3f
LC
1024(define-public glibc-utf8-locales
1025 (package
1026 (name "glibc-utf8-locales")
1027 (version (package-version glibc))
1028 (source #f)
1029 (build-system trivial-build-system)
1030 (arguments
f2d7bbb5 1031 `(#:modules ((guix build utils))
c9505f3f
LC
1032 #:builder (begin
1033 (use-modules (srfi srfi-1)
1034 (guix build utils))
1035
1036 (let* ((libc (assoc-ref %build-inputs "glibc"))
1037 (gzip (assoc-ref %build-inputs "gzip"))
1038 (out (assoc-ref %outputs "out"))
f2d7bbb5
LC
1039 (localedir (string-append out "/lib/locale/"
1040 ,version)))
c9505f3f
LC
1041 ;; 'localedef' needs 'gzip'.
1042 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1043
1044 (mkdir-p localedir)
1045 (every (lambda (locale)
8a55e217
LC
1046 (define file
1047 ;; Use the "normalized codeset" by
1048 ;; default--e.g., "en_US.utf8".
1049 (string-append localedir "/" locale ".utf8"))
1050
1051 (and (zero? (system* "localedef" "--no-archive"
1052 "--prefix" localedir
1053 "-i" locale
1054 "-f" "UTF-8" file))
1055 (begin
1056 ;; For backward compatibility with Guix
1057 ;; <= 0.8.3, add "xx_YY.UTF-8".
1058 (symlink (string-append locale ".utf8")
c9505f3f 1059 (string-append localedir "/"
8a55e217
LC
1060 locale ".UTF-8"))
1061 #t)))
c9505f3f
LC
1062
1063 ;; These are the locales commonly used for
1064 ;; tests---e.g., in Guile's i18n tests.
1065 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))))))
1066 (inputs `(("glibc" ,glibc)
1067 ("gzip" ,gzip)))
1068 (synopsis "Small sample of UTF-8 locales")
1069 (description
1070 "This package provides a small sample of UTF-8 locales mostly useful in
1071test environments.")
1072 (home-page (package-home-page glibc))
1073 (license (package-license glibc))))
aee6180c 1074
ce0614dd
LC
1075(define-public which
1076 (package
1077 (name "which")
70ca2e94 1078 (version "2.21")
ce0614dd
LC
1079 (source (origin
1080 (method url-fetch)
1081 (uri (string-append "mirror://gnu/which/which-"
1082 version ".tar.gz"))
1083 (sha256
1084 (base32
70ca2e94 1085 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
ce0614dd
LC
1086 (build-system gnu-build-system)
1087 (home-page "https://gnu.org/software/which/")
1088 (synopsis "Find full path of shell commands")
1089 (description
1090 "The which program finds the location of executables in PATH, with a
1091variety of options. It is an alternative to the shell \"type\" built-in
1092command.")
1093 (license gpl3+))) ; some files are under GPLv2+
1094
21a8fe1b
MR
1095(define-public glibc/hurd-headers
1096 (package (inherit glibc/hurd)
1097 (name "glibc-hurd-headers")
1098 (outputs '("out"))
1099 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1100 ("hurd-headers" ,hurd-headers)))
1101 (arguments
1102 (substitute-keyword-arguments (package-arguments glibc/hurd)
1103 ;; We just pass the flags really needed to build the headers.
1104 ((#:configure-flags _)
1105 `(list "--enable-add-ons"
aa81eb73 1106 "--host=i586-pc-gnu"
21a8fe1b
MR
1107 "--enable-obsolete-rpc"))
1108 ((#:phases _)
1109 '(alist-replace
1110 'install
1111 (lambda* (#:key outputs #:allow-other-keys)
1112 (and (zero? (system* "make" "install-headers"))
1113
1114 ;; Make an empty stubs.h to work around not being able to
1115 ;; produce a valid stubs.h and causing the build to fail. See
1116 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1117 (let ((out (assoc-ref outputs "out")))
1118 (close-port
1119 (open-output-file
1120 (string-append out "/include/gnu/stubs.h"))))))
1121
1122 ;; Nothing to build.
1123 (alist-delete
1124 'build
1125
1126 (alist-cons-before
1127 'configure 'pre-configure
1128 (lambda _
1129 ;; Use the right 'pwd'.
1130 (substitute* "configure"
1131 (("/bin/pwd") "pwd")))
1132 %standard-phases))))))))
1133
e789d9a8
LC
1134(define-public tzdata
1135 (package
1136 (name "tzdata")
52196aea 1137 (version "2017b")
e789d9a8
LC
1138 (source (origin
1139 (method url-fetch)
1140 (uri (string-append
80b63e67 1141 "https://www.iana.org/time-zones/repository/releases/tzdata"
e789d9a8
LC
1142 version ".tar.gz"))
1143 (sha256
1144 (base32
52196aea 1145 "11l0s43vx33dcs78p80122i8s5s9l1sjwkzzwh66njd35r92l97q"))))
e789d9a8
LC
1146 (build-system gnu-build-system)
1147 (arguments
1148 '(#:tests? #f
1149 #:make-flags (let ((out (assoc-ref %outputs "out"))
1150 (tmp (getenv "TMPDIR")))
1151 (list (string-append "TOPDIR=" out)
1152 (string-append "TZDIR=" out "/share/zoneinfo")
1153
1154 ;; Discard zic, dump, and tzselect, already
1155 ;; provided by glibc.
1156 (string-append "ETCDIR=" tmp "/etc")
1157
1158 ;; Likewise for the C library routines.
1159 (string-append "LIBDIR=" tmp "/lib")
1160 (string-append "MANDIR=" tmp "/man")
1161
1162 "AWK=awk"
1163 "CC=gcc"))
1164 #:modules ((guix build utils)
1165 (guix build gnu-build-system)
1166 (srfi srfi-1))
1167 #:phases
c8f35458
JD
1168 (modify-phases %standard-phases
1169 (replace 'unpack
1170 (lambda* (#:key source inputs #:allow-other-keys)
1171 (and (zero? (system* "tar" "xvf" source))
1172 (zero? (system* "tar" "xvf" (assoc-ref inputs "tzcode"))))))
1173 (add-after 'install 'post-install
1174 (lambda* (#:key outputs #:allow-other-keys)
1175 ;; Move data in the right place.
1176 (let ((out (assoc-ref outputs "out")))
1177 (symlink (string-append out "/share/zoneinfo")
1178 (string-append out "/share/zoneinfo/posix"))
1179 (delete-file-recursively
1180 (string-append out "/share/zoneinfo-posix"))
1181 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1182 (string-append out "/share/zoneinfo/right"))
1183 (delete-file-recursively
1184 (string-append out "/share/zoneinfo-leaps")))))
1185 (delete 'configure))))
e789d9a8
LC
1186 (inputs `(("tzcode" ,(origin
1187 (method url-fetch)
1188 (uri (string-append
1189 "http://www.iana.org/time-zones/repository/releases/tzcode"
1190 version ".tar.gz"))
1191 (sha256
1192 (base32
52196aea 1193 "0h1d567gn8l3iqgyadcswwdy2yh07nhz3lfl8ds8saz2ajxka5sd"))))))
80b63e67 1194 (home-page "https://www.iana.org/time-zones")
e789d9a8
LC
1195 (synopsis "Database of current and historical time zones")
1196 (description "The Time Zone Database (often called tz or zoneinfo)
1197contains code and data that represent the history of local time for many
35b9e423 1198representative locations around the globe. It is updated periodically to
e789d9a8
LC
1199reflect changes made by political bodies to time zone boundaries, UTC offsets,
1200and daylight-saving rules.")
1201 (license public-domain)))
1202
3ffaec13
LF
1203;;; A "fixed" version of tzdata, which is used in the test suites of
1204;;; glib and R. We can update this whenever we are able to rebuild
1205;;; thousands of packages (for example, in a core-updates rebuild).
1206(define-public tzdata-2017a
1207 (package
1208 (inherit tzdata)
1209 (version "2017a")
1210 (source
1211 (origin
1212 (method url-fetch)
1213 (uri (string-append "https://www.iana.org/time-zones/repository"
1214 "/releases/tzdata" version ".tar.gz"))
1215 (sha256
1216 (base32
1217 "1mmv4rvcs12lrvgghw4fidczvb69yv69cmzknghcvw1c196mqfnz"))))
1218 (inputs `(("tzcode" ,(origin
1219 (method url-fetch)
1220 (uri (string-append
1221 "http://www.iana.org/time-zones/repository/releases/tzcode"
1222 version ".tar.gz"))
1223 (sha256
1224 (base32
1225 "1b1q7gnlsh5hjgs5065pvajd37rmbc3k9b8cgzad1vcrifswdwh2"))))))))
1226
1227
7309045c
JN
1228(define-public libiconv
1229 (package
1230 (name "libiconv")
5c6b6827 1231 (version "1.15")
7309045c
JN
1232 (source (origin
1233 (method url-fetch)
1234 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1235 version ".tar.gz"))
1236 (sha256
1237 (base32
5c6b6827 1238 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
7309045c
JN
1239 (modules '((guix build utils)))
1240 (snippet
1241 ;; Work around "declared gets" error on glibc systems (fixed by
1242 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1243 '(substitute* "srclib/stdio.in.h"
1244 (("^#undef gets") "")
1245 (("^_GL_WARN_ON_USE \\(gets.*") "")))))
1246 (build-system gnu-build-system)
1247 (synopsis "Character set conversion library")
1248 (description
1249 "libiconv provides an implementation of the iconv function for systems
1250that lack it. iconv is used to convert between character encodings in a
1251program. It supports a wide variety of different encodings.")
6fd52309 1252 (home-page "https://www.gnu.org/software/libiconv/")
7309045c
JN
1253 (license lgpl3+)))
1254
4dab8c59
JN
1255(define* (libiconv-if-needed #:optional (target (%current-target-system)))
1256 "Return either a libiconv package specification to include in a dependency
1257list for platforms that have an incomplete libc, or the empty list. If a
1258package needs iconv ,@(libiconv-if-needed) should be added."
1259 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1260 ;; without iconv, such as MinGW, must return the then clause.
1261 (if (target-mingw? target)
1262 `(("libiconv" ,libiconv))
1263 '()))
1264
bdb36958
LC
1265(define-public (canonical-package package)
1266 ;; Avoid circular dependency by lazily resolving 'commencement'.
1267 (let* ((iface (resolve-interface '(gnu packages commencement)))
1268 (proc (module-ref iface 'canonical-package)))
1269 (proc package)))
571aa6cd 1270
fb77c614
LC
1271(define-public (%final-inputs)
1272 "Return the list of \"final inputs\"."
1273 ;; Avoid circular dependency by lazily resolving 'commencement'.
1274 (let ((iface (resolve-interface '(gnu packages commencement))))
1275 (module-ref iface '%final-inputs)))
1276
1722d680 1277;;; base.scm ends here