base.scm 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2014, 2019 Andreas Enge <andreas@enge.fr>
  4. ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
  5. ;;; Copyright © 2014, 2015, 2016, 2018 Mark H Weaver <mhw@netris.org>
  6. ;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
  7. ;;; Copyright © 2014, 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
  8. ;;; Copyright © 2016, 2017, 2019 Efraim Flashner <efraim@flashner.co.il>
  9. ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
  10. ;;; Copyright © 2016, 2018 Alex Vong <alexvong1995@gmail.com>
  11. ;;; Copyright © 2017 Rene Saavedra <rennes@openmailbox.org>
  12. ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
  13. ;;; Copyright © 2017, 2018 Marius Bakke <mbakke@fastmail.com>
  14. ;;; Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
  15. ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
  16. ;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
  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. (define-module (gnu packages base)
  33. #:use-module ((guix licenses)
  34. #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
  35. #:use-module (gnu packages)
  36. #:use-module (gnu packages acl)
  37. #:use-module (gnu packages algebra)
  38. #:use-module (gnu packages bash)
  39. #:use-module (gnu packages bison)
  40. #:use-module (gnu packages ed)
  41. #:use-module (gnu packages gcc)
  42. #:use-module (gnu packages guile)
  43. #:use-module (gnu packages multiprecision)
  44. #:use-module (gnu packages compression)
  45. #:use-module (gnu packages perl)
  46. #:use-module (gnu packages linux)
  47. #:use-module (gnu packages pcre)
  48. #:use-module (gnu packages texinfo)
  49. #:use-module (gnu packages hurd)
  50. #:use-module (gnu packages pkg-config)
  51. #:use-module (gnu packages gettext)
  52. #:use-module (guix utils)
  53. #:use-module (guix packages)
  54. #:use-module (guix download)
  55. #:use-module (guix git-download)
  56. #:use-module (guix build-system gnu)
  57. #:use-module (guix build-system trivial)
  58. #:use-module (ice-9 match)
  59. #:use-module (srfi srfi-1)
  60. #:use-module (srfi srfi-26)
  61. #:export (glibc
  62. libiconv-if-needed))
  63. ;;; Commentary:
  64. ;;;
  65. ;;; Base packages of the Guix-based GNU user-land software distribution.
  66. ;;;
  67. ;;; Code:
  68. (define-public hello
  69. (package
  70. (name "hello")
  71. (version "2.10")
  72. (source (origin
  73. (method url-fetch)
  74. (uri (string-append "mirror://gnu/hello/hello-" version
  75. ".tar.gz"))
  76. (sha256
  77. (base32
  78. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  79. (build-system gnu-build-system)
  80. (synopsis "Hello, GNU world: An example GNU package")
  81. (description
  82. "GNU Hello prints the message \"Hello, world!\" and then exits. It
  83. serves as an example of standard GNU coding practices. As such, it supports
  84. command-line arguments, multiple languages, and so on.")
  85. (home-page "https://www.gnu.org/software/hello/")
  86. (license gpl3+)))
  87. (define-public grep
  88. (package
  89. (name "grep")
  90. (version "3.1")
  91. (source (origin
  92. (method url-fetch)
  93. (uri (string-append "mirror://gnu/grep/grep-"
  94. version ".tar.xz"))
  95. (sha256
  96. (base32
  97. "0zm0ywmyz9g8vn1plw14mn8kj74yipx5qsljndbyfgmvndx5qqnv"))
  98. (patches (search-patches "grep-timing-sensitive-test.patch"))))
  99. (build-system gnu-build-system)
  100. (native-inputs `(("perl" ,perl))) ;some of the tests require it
  101. (inputs `(("pcre" ,pcre)))
  102. (arguments
  103. `(#:phases
  104. (modify-phases %standard-phases
  105. (add-before 'check 'disable-failing-tests
  106. (lambda _
  107. ;; These tests are expected to fail due to a glibc bug which has
  108. ;; been fixed in 2.28, so they are unexpectedly passing. They
  109. ;; should be fixed for grep versions > 3.1.
  110. (substitute* "tests/Makefile.in"
  111. (("^[[:blank:]]+backref-alt[[:blank:]]+\\\\") "\\")
  112. (("^[[:blank:]]+triple-backref[[:blank:]]+\\\\") "\\"))
  113. #t))
  114. (add-after 'install 'fix-egrep-and-fgrep
  115. ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
  116. ;; absolute file name instead of searching for it in $PATH.
  117. (lambda* (#:key outputs #:allow-other-keys)
  118. (let* ((out (assoc-ref outputs "out"))
  119. (bin (string-append out "/bin")))
  120. (substitute* (list (string-append bin "/egrep")
  121. (string-append bin "/fgrep"))
  122. (("^exec grep")
  123. (string-append "exec " bin "/grep")))
  124. #t))))))
  125. (synopsis "Print lines matching a pattern")
  126. (description
  127. "grep is a tool for finding text inside files. Text is found by
  128. matching a pattern provided by the user in one or many files. The pattern
  129. may be provided as a basic or extended regular expression, or as fixed
  130. strings. By default, the matching text is simply printed to the screen,
  131. however the output can be greatly customized to include, for example, line
  132. numbers. GNU grep offers many extensions over the standard utility,
  133. including, for example, recursive directory searching.")
  134. (license gpl3+)
  135. (home-page "https://www.gnu.org/software/grep/")))
  136. (define-public sed
  137. (package
  138. (name "sed")
  139. (version "4.5")
  140. (source (origin
  141. (method url-fetch)
  142. (uri (string-append "mirror://gnu/sed/sed-" version
  143. ".tar.xz"))
  144. (sha256
  145. (base32
  146. "0h3b2jfj57wmz680vkbyavlsrkak556qhvs7m7fdlawwhg477bbs"))))
  147. (build-system gnu-build-system)
  148. (synopsis "Stream editor")
  149. (arguments
  150. `(#:phases
  151. (modify-phases %standard-phases
  152. (add-after 'unpack 'dont-rebuild-sed.1
  153. (lambda _
  154. ;; Make sure we do not attempt to rebuild 'doc/sed.1', which does
  155. ;; not work when cross-compiling because we cannot run 'sed'.
  156. ;; This is fixed upstream as commit a0a25e3.
  157. (substitute* "Makefile.in"
  158. (("^doc/sed\\.1:.*")
  159. "doc/sed.1:\n"))
  160. #t)))))
  161. (native-inputs
  162. `(("perl" ,perl))) ;for tests
  163. (description
  164. "Sed is a non-interactive, text stream editor. It receives a text
  165. input from a file or from standard input and it then applies a series of text
  166. editing commands to the stream and prints its output to standard output. It
  167. is often used for substituting text patterns in a stream. The GNU
  168. implementation offers several extensions over the standard utility.")
  169. (license gpl3+)
  170. (home-page "https://www.gnu.org/software/sed/")))
  171. (define-public tar
  172. (package
  173. (name "tar")
  174. (version "1.30")
  175. (source (origin
  176. (method url-fetch)
  177. (uri (string-append "mirror://gnu/tar/tar-"
  178. version ".tar.xz"))
  179. (sha256
  180. (base32
  181. "1lyjyk8z8hdddsxw0ikchrsfg3i0x3fsh7l63a8jgaz1n7dr5gzi"))
  182. (patches (search-patches "tar-skip-unreliable-tests.patch"
  183. "tar-remove-wholesparse-check.patch"))))
  184. (build-system gnu-build-system)
  185. ;; Note: test suite requires ~1GiB of disk space.
  186. (arguments
  187. `(#:phases (modify-phases %standard-phases
  188. (add-before 'build 'set-shell-file-name
  189. (lambda* (#:key inputs #:allow-other-keys)
  190. ;; Do not use "/bin/sh" to run programs.
  191. (let ((bash (assoc-ref inputs "bash")))
  192. (substitute* "src/system.c"
  193. (("/bin/sh")
  194. (string-append bash "/bin/sh")))
  195. #t))))
  196. ;; Work around a cross-compilation bug whereby libgnu.a would provide
  197. ;; '__mktime_internal', which conflicts with the one in libc.a.
  198. ,@(if (%current-target-system)
  199. `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
  200. '())
  201. ;; Test #92 "link mismatch" expects "a/z: Not linked to a/y" but gets
  202. ;; "a/y: Not linked to a/z" and fails, presumably due to differences in
  203. ;; the order in which 'diff' traverses directories. That leads to a
  204. ;; test failure even though conceptually the test passes. Skip it.
  205. ;; Test 117 and 118 are prone to race conditions too, particularly
  206. ;; when cross-compiling, so we skip those as well. All issues have
  207. ;; been fixed upstream in these commits:
  208. ;; <https://git.savannah.gnu.org/cgit/tar.git/commit/?id=847a36f>
  209. ;; <https://git.savannah.gnu.org/cgit/tar.git/commit/?id=64b43fd>
  210. #:make-flags (list (string-append
  211. "TESTSUITEFLAGS= -k '!link mismatch,"
  212. "!directory removed before reading,"
  213. "!explicitly named directory removed before reading'"))))
  214. ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
  215. ;; to refer to the target Bash.
  216. (inputs (if (%current-target-system)
  217. `(("bash" ,bash))
  218. '()))
  219. (synopsis "Managing tar archives")
  220. (description
  221. "Tar provides the ability to create tar archives, as well as the
  222. ability to extract, update or list files in an existing archive. It is
  223. useful for combining many files into one larger file, while maintaining
  224. directory structure and file information such as permissions and
  225. creation/modification dates. GNU tar offers many extensions over the
  226. standard utility.")
  227. (license gpl3+)
  228. (home-page "https://www.gnu.org/software/tar/")))
  229. (define-public patch
  230. (package
  231. (name "patch")
  232. (version "2.7.6")
  233. (source (origin
  234. (method url-fetch)
  235. (uri (string-append "mirror://gnu/patch/patch-"
  236. version ".tar.xz"))
  237. (sha256
  238. (base32
  239. "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
  240. (patches (search-patches "patch-hurd-path-max.patch"))))
  241. (build-system gnu-build-system)
  242. (arguments
  243. ;; Work around a cross-compilation bug whereby libpatch.a would provide
  244. ;; '__mktime_internal', which conflicts with the one in libc.a.
  245. (if (%current-target-system)
  246. `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
  247. '()))
  248. (native-inputs `(("ed" ,ed)))
  249. (synopsis "Apply differences to originals, with optional backups")
  250. (description
  251. "Patch is a program that applies changes to files based on differences
  252. laid out as by the program \"diff\". The changes may be applied to one or more
  253. files depending on the contents of the diff file. It accepts several
  254. different diff formats. It may also be used to revert previously applied
  255. differences.")
  256. (license gpl3+)
  257. (home-page "https://savannah.gnu.org/projects/patch/")))
  258. (define-public diffutils
  259. (package
  260. (name "diffutils")
  261. (version "3.6")
  262. (source (origin
  263. (method url-fetch)
  264. (uri (string-append "mirror://gnu/diffutils/diffutils-"
  265. version ".tar.xz"))
  266. (sha256
  267. (base32
  268. "1mivg0fy3a6fcn535ln8nkgfj6vxh5hsxxs5h6692wxmsjyyh8fn"))
  269. (patches (search-patches "diffutils-getopt.patch"))))
  270. (build-system gnu-build-system)
  271. (synopsis "Comparing and merging files")
  272. (description
  273. "GNU Diffutils is a package containing tools for finding the
  274. differences between files. The \"diff\" command is used to show how two files
  275. differ, while \"cmp\" shows the offsets and line numbers where they differ.
  276. \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
  277. interactive means to merge two files.")
  278. (license gpl3+)
  279. (home-page "https://www.gnu.org/software/diffutils/")))
  280. (define-public findutils
  281. (package
  282. (name "findutils")
  283. (version "4.6.0")
  284. (source (origin
  285. (method url-fetch)
  286. (uri (string-append "mirror://gnu/findutils/findutils-"
  287. version ".tar.gz"))
  288. (sha256
  289. (base32
  290. "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
  291. (patches (search-patches
  292. "findutils-gnulib-libio.patch"
  293. "findutils-localstatedir.patch"
  294. "findutils-makedev.patch"
  295. "findutils-test-xargs.patch"))
  296. (modules '((guix build utils)))
  297. (snippet
  298. '(begin
  299. ;; The gnulib test-lock test is prone to writer starvation
  300. ;; with our glibc@2.25, which prefers readers, so disable it.
  301. ;; The gnulib commit b20e8afb0b2 should fix this once
  302. ;; incorporated here.
  303. (substitute* "tests/Makefile.in"
  304. (("test-lock\\$\\(EXEEXT\\) ") ""))
  305. #t))))
  306. (build-system gnu-build-system)
  307. (arguments
  308. `(#:configure-flags (list
  309. ;; Tell 'updatedb' to write to /var.
  310. "--localstatedir=/var"
  311. ;; Work around cross-compilation failure. See
  312. ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
  313. ,@(if (%current-target-system)
  314. '("gl_cv_func_wcwidth_works=yes")
  315. '()))))
  316. (synopsis "Operating on files matching given criteria")
  317. (description
  318. "Findutils supplies the basic file directory searching utilities of the
  319. GNU system. It consists of two primary searching utilities: \"find\"
  320. recursively searches for files in a directory according to given criteria and
  321. \"locate\" lists files in a database that match a query. Two auxiliary tools
  322. are included: \"updatedb\" updates the file name database and \"xargs\" may be
  323. used to apply commands with arbitrarily long arguments.")
  324. (license gpl3+)
  325. (home-page "https://www.gnu.org/software/findutils/")))
  326. (define-public coreutils
  327. (package
  328. (name "coreutils")
  329. (version "8.30")
  330. (source (origin
  331. (method url-fetch)
  332. (uri (string-append "mirror://gnu/coreutils/coreutils-"
  333. version ".tar.xz"))
  334. (sha256
  335. (base32
  336. "0mxhw43d4wpqmvg0l4znk1vm10fy92biyh90lzdnqjcic2lb6cg8"))))
  337. (build-system gnu-build-system)
  338. (inputs `(("acl" ,acl) ; TODO: add SELinux
  339. ("gmp" ,gmp) ;bignums in 'expr', yay!
  340. ;; Drop the dependency on libcap when cross-compiling since it's
  341. ;; not quite cross-compilable.
  342. ,@(if (%current-target-system)
  343. '()
  344. `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
  345. (native-inputs
  346. ;; Perl is needed to run tests in native builds, and to run the bundled
  347. ;; copy of help2man. However, don't pass it when cross-compiling since
  348. ;; that would lead it to try to run programs to get their '--help' output
  349. ;; for help2man.
  350. (if (%current-target-system)
  351. '()
  352. `(("perl" ,perl))))
  353. (outputs '("out" "debug"))
  354. (arguments
  355. `(#:parallel-build? #f ; help2man may be called too early
  356. #:phases (modify-phases %standard-phases
  357. (add-before 'build 'patch-shell-references
  358. (lambda _
  359. ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
  360. ;; that tests pass, since /bin/sh isn't in the chroot.
  361. (setenv "SHELL" (which "sh"))
  362. (substitute* (find-files "gnulib-tests" "\\.c$")
  363. (("/bin/sh") (which "sh")))
  364. (substitute* (find-files "tests" "\\.sh$")
  365. (("#!/bin/sh") (string-append "#!" (which "sh"))))
  366. #t))
  367. (add-before 'check 'disable-broken-test
  368. (lambda _
  369. ;; This test hits the 127 character shebang limit in the build
  370. ;; environment due to the way "env -S" splits arguments into
  371. ;; shebangs. Note that "env-S-script.sh" works around this
  372. ;; specific issue, but "env-S.pl" is not adjusted for build
  373. ;; environments with long prefixes (/tmp/guix-build-...).
  374. (substitute* "Makefile"
  375. (("^.*tests/misc/env-S.pl.*$") ""))
  376. #t)))
  377. ;; Work around a cross-compilation bug whereby libcoreutils.a would
  378. ;; provide '__mktime_internal', which conflicts with the one in libc.a.
  379. ,@(if (%current-target-system)
  380. `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
  381. '())))
  382. (synopsis "Core GNU utilities (file, text, shell)")
  383. (description
  384. "GNU Coreutils includes all of the basic command-line tools that are
  385. expected in a POSIX system. These provide the basic file, shell and text
  386. manipulation functions of the GNU system. Most of these tools offer extended
  387. functionality beyond that which is outlined in the POSIX standard.")
  388. (license gpl3+)
  389. (home-page "https://www.gnu.org/software/coreutils/")))
  390. (define-public coreutils-minimal
  391. ;; Coreutils without its optional dependencies.
  392. (package
  393. (inherit coreutils)
  394. (name "coreutils-minimal")
  395. (outputs '("out"))
  396. (inputs '())))
  397. (define-public gnu-make
  398. (package
  399. (name "make")
  400. (version "4.2.1")
  401. (source (origin
  402. (method url-fetch)
  403. (uri (string-append "mirror://gnu/make/make-" version
  404. ".tar.bz2"))
  405. (sha256
  406. (base32
  407. "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
  408. (patches (search-patches "make-impure-dirs.patch"
  409. "make-glibc-compat.patch"))))
  410. (build-system gnu-build-system)
  411. (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
  412. (inputs `(("guile" ,guile-2.0)))
  413. (outputs '("out" "debug"))
  414. (arguments
  415. '(;; Work around faulty glob detection with glibc 2.27. See
  416. ;; <https://lists.nongnu.org/archive/html/bug-make/2017-11/msg00027.html>.
  417. #:configure-flags '("make_cv_sys_gnu_glob=yes")
  418. #:phases
  419. (modify-phases %standard-phases
  420. (add-before 'build 'set-default-shell
  421. (lambda* (#:key inputs #:allow-other-keys)
  422. ;; Change the default shell from /bin/sh.
  423. (let ((bash (assoc-ref inputs "bash")))
  424. (substitute* "job.c"
  425. (("default_shell =.*$")
  426. (format #f "default_shell = \"~a/bin/sh\";\n"
  427. bash)))
  428. #t))))))
  429. (synopsis "Remake files automatically")
  430. (description
  431. "Make is a program that is used to control the production of
  432. executables or other files from their source files. The process is
  433. controlled from a Makefile, in which the developer specifies how each file is
  434. generated from its source. It has powerful dependency resolution and the
  435. ability to determine when files have to be regenerated after their sources
  436. change. GNU make offers many powerful extensions over the standard utility.")
  437. (license gpl3+)
  438. (home-page "https://www.gnu.org/software/make/")))
  439. (define-public binutils
  440. (package
  441. (name "binutils")
  442. (version "2.31.1")
  443. (source (origin
  444. (method url-fetch)
  445. (uri (string-append "mirror://gnu/binutils/binutils-"
  446. version ".tar.bz2"))
  447. (sha256
  448. (base32
  449. "1l34hn1zkmhr1wcrgf0d4z7r3najxnw3cx2y2fk7v55zjlk3ik7z"))
  450. (patches (search-patches "binutils-loongson-workaround.patch"))))
  451. (build-system gnu-build-system)
  452. ;; TODO: Add dependency on zlib + those for Gold.
  453. (arguments
  454. `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
  455. ;; on GCC when bootstrapping.
  456. "LDFLAGS=-static-libgcc"
  457. ;; Turn on --enable-new-dtags by default to make the
  458. ;; linker set RUNPATH instead of RPATH on binaries.
  459. ;; This is important because RUNPATH can be overriden
  460. ;; using LD_LIBRARY_PATH at runtime.
  461. "--enable-new-dtags"
  462. ;; Don't search under /usr/lib & co.
  463. "--with-lib-path=/no-ld-lib-path"
  464. ;; Install BFD. It ends up in a hidden directory,
  465. ;; but it's here.
  466. "--enable-install-libbfd"
  467. ;; Make sure 'ar' and 'ranlib' produce archives in a
  468. ;; deterministic fashion.
  469. "--enable-deterministic-archives")))
  470. (synopsis "Binary utilities: bfd gas gprof ld")
  471. (description
  472. "GNU Binutils is a collection of tools for working with binary files.
  473. Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
  474. Other tools include programs to display binary profiling information, list
  475. the strings in a binary file, and utilities for working with archives. The
  476. \"bfd\" library for working with executable and object formats is also
  477. included.")
  478. (license gpl3+)
  479. (home-page "https://www.gnu.org/software/binutils/")))
  480. (define-public binutils-gold
  481. (package
  482. (inherit binutils)
  483. (name "binutils-gold")
  484. (arguments
  485. `(#:phases
  486. (modify-phases %standard-phases
  487. (add-after 'patch-source-shebangs 'patch-more-shebangs
  488. (lambda _
  489. (substitute* "gold/Makefile.in"
  490. (("/bin/sh") (which "sh")))
  491. #t)))
  492. ,@(substitute-keyword-arguments (package-arguments binutils)
  493. ; Upstream is aware of unrelocatable test failures on arm*.
  494. ((#:tests? _ #f)
  495. (if (any (cute string-prefix? <> (or (%current-target-system)
  496. (%current-system)))
  497. '("i686" "x86_64"))
  498. '#t '#f))
  499. ((#:configure-flags flags)
  500. `(cons* "--enable-gold=default"
  501. (delete "LDFLAGS=-static-libgcc" ,flags))))))
  502. (native-inputs
  503. `(("bc" ,bc)))
  504. (inputs
  505. `(("gcc:lib" ,gcc "lib")))))
  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. TARGET must be a one-argument procedure that, given a system type, returns a
  516. cross-compilation target triplet or #f. When the result is not #f, make a
  517. wrapper for the cross-linker for that target, called 'TARGET-ld'."
  518. ;; Note: #:system->target-triplet is a procedure so that the evaluation of
  519. ;; its result can be delayed until the 'arguments' field is evaluated, thus
  520. ;; in a context where '%current-system' is accurate.
  521. (package
  522. (name name)
  523. (version "0")
  524. (source #f)
  525. (build-system trivial-build-system)
  526. (inputs `(("binutils" ,binutils)
  527. ("guile" ,guile)
  528. ("bash" ,bash)
  529. ("wrapper" ,(search-path %load-path
  530. "gnu/packages/ld-wrapper.in"))))
  531. (arguments
  532. (let ((target (target (%current-system))))
  533. `(#:guile ,guile-for-build
  534. #:modules ((guix build utils))
  535. #:builder (begin
  536. (use-modules (guix build utils)
  537. (system base compile))
  538. (let* ((out (assoc-ref %outputs "out"))
  539. (bin (string-append out "/bin"))
  540. (ld ,(if target
  541. `(string-append bin "/" ,target "-ld")
  542. '(string-append bin "/ld")))
  543. (go (string-append ld ".go")))
  544. (setvbuf (current-output-port) _IOLBF)
  545. (format #t "building ~s/bin/ld wrapper in ~s~%"
  546. (assoc-ref %build-inputs "binutils")
  547. out)
  548. (mkdir-p bin)
  549. (copy-file (assoc-ref %build-inputs "wrapper") ld)
  550. (substitute* ld
  551. (("@SELF@")
  552. ld)
  553. (("@GUILE@")
  554. (string-append (assoc-ref %build-inputs "guile")
  555. "/bin/guile"))
  556. (("@BASH@")
  557. (string-append (assoc-ref %build-inputs "bash")
  558. "/bin/bash"))
  559. (("@LD@")
  560. (string-append (assoc-ref %build-inputs "binutils")
  561. ,(if target
  562. (string-append "/bin/"
  563. target "-ld")
  564. "/bin/ld"))))
  565. (chmod ld #o555)
  566. (compile-file ld #:output-file go)
  567. #t)))))
  568. (synopsis "The linker wrapper")
  569. (description
  570. "The linker wrapper (or 'ld-wrapper') wraps the linker to add any
  571. missing '-rpath' flags, and to detect any misuse of libraries outside of the
  572. store.")
  573. (home-page "https://www.gnu.org/software/guix//")
  574. (license gpl3+)))
  575. (export make-ld-wrapper)
  576. (define-public glibc
  577. ;; This is the GNU C Library, used on GNU/Linux and GNU/Hurd. Prior to
  578. ;; version 2.28, GNU/Hurd used a different glibc branch.
  579. (package
  580. (name "glibc")
  581. ;; Note: Always use a dot after the minor version since various places rely
  582. ;; on "version-major+minor" to determine where locales are found.
  583. (version "2.28")
  584. (source (origin
  585. (method url-fetch)
  586. (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
  587. (sha256
  588. (base32
  589. "10iha5ynvdj5m62vgpgqbq4cwvc2yhyl2w9yyyjgfxmdmx8h145i"))
  590. (snippet
  591. ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
  592. ;; required on LFS distros to avoid loading the distro's libc.so
  593. ;; instead of ours.
  594. '(begin
  595. (substitute* "sysdeps/unix/sysv/linux/configure"
  596. (("use_ldconfig=yes")
  597. "use_ldconfig=no"))
  598. #t))
  599. (modules '((guix build utils)))
  600. (patches (search-patches "glibc-ldd-x86_64.patch"
  601. "glibc-2.28-git-fixes.patch"
  602. "glibc-hidden-visibility-ldconfig.patch"
  603. "glibc-versioned-locpath.patch"
  604. "glibc-allow-kernel-2.6.32.patch"
  605. "glibc-reinstate-prlimit64-fallback.patch"))))
  606. (build-system gnu-build-system)
  607. ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
  608. ;; users should automatically pull Linux headers as well. On GNU/Hurd,
  609. ;; libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
  610. ;; so both should be propagated.
  611. (propagated-inputs
  612. (if (hurd-target?)
  613. `(("hurd-core-headers" ,hurd-core-headers))
  614. `(("kernel-headers" ,linux-libre-headers))))
  615. (outputs '("out" "debug"
  616. "static")) ;9 MiB of .a files
  617. (arguments
  618. `(#:out-of-source? #t
  619. ;; The libraries have an empty RUNPATH, but some, such as the versioned
  620. ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
  621. ;; these libraries are always going to be found anyway, just skip
  622. ;; RUNPATH checks.
  623. #:validate-runpath? #f
  624. #:modules ((ice-9 ftw)
  625. (srfi srfi-26)
  626. (guix build utils)
  627. (guix build gnu-build-system))
  628. #:configure-flags
  629. (list "--sysconfdir=/etc"
  630. ;; Installing a locale archive with all the locales is to
  631. ;; expensive (~100 MiB), so we rely on users to install the
  632. ;; locales they really want.
  633. ;;
  634. ;; Set the default locale path. In practice, $LOCPATH may be
  635. ;; defined to point whatever locales users want. However, setuid
  636. ;; binaries don't honor $LOCPATH, so they'll instead look into
  637. ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
  638. ;; with the idea that it is going to be populated by the sysadmin.
  639. ;; The "X.Y" sub-directory is because locale data formats are
  640. ;; incompatible across libc versions; see
  641. ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
  642. ;;
  643. ;; `--localedir' is not honored, so work around it.
  644. ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
  645. (string-append "libc_cv_complocaledir=/run/current-system/locale/"
  646. ,(version-major+minor version))
  647. (string-append "--with-headers="
  648. (assoc-ref ,(if (%current-target-system)
  649. '%build-target-inputs
  650. '%build-inputs)
  651. "kernel-headers")
  652. "/include")
  653. ;; This is the default for most architectures as of GNU libc 2.26,
  654. ;; but we specify it explicitly for clarity and consistency. See
  655. ;; "kernel-features.h" in the GNU libc for details.
  656. "--enable-kernel=3.2.0"
  657. ;; Use our Bash instead of /bin/sh.
  658. (string-append "BASH_SHELL="
  659. (assoc-ref %build-inputs "bash")
  660. "/bin/bash")
  661. ;; On GNU/Hurd we get discarded-qualifiers warnings for
  662. ;; 'device_write_inband' among other things. Ignore them.
  663. ,@(if (hurd-target?)
  664. '("--disable-werror")
  665. '()))
  666. #:tests? #f ; XXX
  667. #:phases (modify-phases %standard-phases
  668. ,@(if (hurd-target?)
  669. `((add-after 'unpack 'apply-hurd-patch
  670. (lambda* (#:key inputs native-inputs
  671. #:allow-other-keys)
  672. ;; TODO: Move this to 'patches' field.
  673. (let ((patch (or (assoc-ref native-inputs
  674. "hurd-magic-pid-patch")
  675. (assoc-ref inputs
  676. "hurd-magic-pid-patch"))))
  677. (invoke "patch" "-p1" "--force" "--input"
  678. patch)))))
  679. '())
  680. (add-before
  681. 'configure 'pre-configure
  682. (lambda* (#:key inputs native-inputs outputs
  683. #:allow-other-keys)
  684. (let* ((out (assoc-ref outputs "out"))
  685. (bin (string-append out "/bin"))
  686. ;; FIXME: Normally we would look it up only in INPUTS
  687. ;; but cross-base uses it as a native input.
  688. (bash (or (assoc-ref inputs "static-bash")
  689. (assoc-ref native-inputs "static-bash"))))
  690. ;; Install the rpc data base file under `$out/etc/rpc'.
  691. ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
  692. (substitute* "sunrpc/Makefile"
  693. (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
  694. (string-append out "/etc/rpc" suffix "\n"))
  695. (("^install-others =.*$")
  696. (string-append "install-others = " out "/etc/rpc\n")))
  697. (substitute* "Makeconfig"
  698. ;; According to
  699. ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
  700. ;; linking against libgcc_s is not needed with GCC
  701. ;; 4.7.1.
  702. ((" -lgcc_s") ""))
  703. ;; Have `system' use that Bash.
  704. (substitute* "sysdeps/posix/system.c"
  705. (("#define[[:blank:]]+SHELL_PATH.*$")
  706. (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
  707. bash)))
  708. ;; Same for `popen'.
  709. (substitute* "libio/iopopen.c"
  710. (("/bin/sh")
  711. (string-append bash "/bin/sh")))
  712. ;; Same for the shell used by the 'exec' functions for
  713. ;; scripts that lack a shebang.
  714. (substitute* (find-files "." "^paths\\.h$")
  715. (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
  716. (string-append "#define _PATH_BSHELL \""
  717. bash "/bin/sh\"\n")))
  718. ;; Nscd uses __DATE__ and __TIME__ to create a string to
  719. ;; make sure the client and server come from the same
  720. ;; libc. Use something deterministic instead.
  721. (substitute* "nscd/nscd_stat.c"
  722. (("static const char compilation\\[21\\] =.*$")
  723. (string-append
  724. "static const char compilation[21] = \""
  725. (string-take (basename out) 20) "\";\n")))
  726. ;; Make sure we don't retain a reference to the
  727. ;; bootstrap Perl.
  728. (substitute* "malloc/mtrace.pl"
  729. (("^#!.*")
  730. ;; The shebang can be omitted, because there's the
  731. ;; "bilingual" eval/exec magic at the top of the file.
  732. "")
  733. (("exec @PERL@")
  734. "exec perl"))
  735. #t)))
  736. (add-after 'install 'move-static-libs
  737. (lambda* (#:key outputs #:allow-other-keys)
  738. ;; Move static libraries to the "static" output.
  739. (define (static-library? file)
  740. ;; Return true if FILE is a static library. The
  741. ;; "_nonshared.a" files are referred to by libc.so,
  742. ;; libpthread.so, etc., which are in fact linker
  743. ;; scripts.
  744. (and (string-suffix? ".a" file)
  745. (not (string-contains file "_nonshared"))))
  746. (define (linker-script? file)
  747. ;; Guess whether FILE, a ".a" file, is actually a
  748. ;; linker script.
  749. (and (not (ar-file? file))
  750. (not (elf-file? file))))
  751. (let* ((out (assoc-ref outputs "out"))
  752. (lib (string-append out "/lib"))
  753. (files (scandir lib static-library?))
  754. (static (assoc-ref outputs "static"))
  755. (slib (string-append static "/lib")))
  756. (mkdir-p slib)
  757. (for-each (lambda (base)
  758. (rename-file (string-append lib "/" base)
  759. (string-append slib "/" base)))
  760. files)
  761. ;; Usually libm.a is a linker script so we need to
  762. ;; change the file names in there to refer to STATIC
  763. ;; instead of OUT.
  764. (for-each (lambda (ld-script)
  765. (substitute* ld-script
  766. ((out) static)))
  767. (filter linker-script?
  768. (map (cut string-append slib "/" <>)
  769. files)))
  770. #t)))
  771. ,@(if (hurd-target?)
  772. '((add-after 'install 'augment-libc.so
  773. (lambda* (#:key outputs #:allow-other-keys)
  774. (let* ((out (assoc-ref outputs "out")))
  775. (substitute* (string-append out "/lib/libc.so")
  776. (("/[^ ]+/lib/libc.so.0.3")
  777. (string-append out "/lib/libc.so.0.3"
  778. " libmachuser.so libhurduser.so"))))
  779. #t)))
  780. '()))))
  781. (inputs `(("static-bash" ,static-bash)))
  782. ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
  783. ;; install the message catalogs, with 'msgfmt'.
  784. (native-inputs `(("texinfo" ,texinfo)
  785. ("perl" ,perl)
  786. ("bison" ,bison)
  787. ("gettext" ,gettext-minimal)
  788. ,@(if (hurd-target?)
  789. `(("mig" ,mig)
  790. ("perl" ,perl)
  791. ("hurd-magic-pid-patch"
  792. ,(search-patch "glibc-hurd-magic-pid.patch")))
  793. '())))
  794. (native-search-paths
  795. ;; Search path for packages that provide locale data. This is useful
  796. ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
  797. ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
  798. ;; distros.
  799. (list (search-path-specification
  800. (variable "GUIX_LOCPATH")
  801. (files '("lib/locale")))))
  802. (synopsis "The GNU C Library")
  803. (description
  804. "Any Unix-like operating system needs a C library: the library which
  805. defines the \"system calls\" and other basic facilities such as open, malloc,
  806. printf, exit...
  807. The GNU C library is used as the C library in the GNU system and most systems
  808. with the Linux kernel.")
  809. (license lgpl2.0+)
  810. (home-page "https://www.gnu.org/software/libc/")))
  811. ;; Below are old libc versions, which we use mostly to build locale data in
  812. ;; the old format (which the new libc cannot cope with.)
  813. (define-public glibc-2.27
  814. (package
  815. (inherit glibc)
  816. (version "2.27")
  817. (source (origin
  818. (inherit (package-source glibc))
  819. (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
  820. (sha256
  821. (base32
  822. "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"))
  823. (patches (search-patches "glibc-ldd-x86_64.patch"
  824. "glibc-2.27-git-fixes.patch"
  825. "glibc-hidden-visibility-ldconfig.patch"
  826. "glibc-versioned-locpath.patch"
  827. "glibc-allow-kernel-2.6.32.patch"
  828. "glibc-reinstate-prlimit64-fallback.patch"
  829. "glibc-CVE-2018-11236.patch"
  830. "glibc-CVE-2018-11237.patch"))))
  831. (properties `((lint-hidden-cve . ("CVE-2017-18269")))))) ; glibc-2.27-git-fixes
  832. (define-public glibc-2.26
  833. (package
  834. (inherit glibc)
  835. ;; This version number corresponds to the output of `git describe` and the
  836. ;; archive can be generated by checking out the commit ID and running:
  837. ;; git archive --prefix=$(git describe)/ HEAD | xz > $(git describe).tar.xz
  838. ;; See <https://bugs.gnu.org/29406> for why this was necessary.
  839. (version "2.26.105-g0890d5379c")
  840. (source (origin
  841. (inherit (package-source glibc))
  842. (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/"
  843. "glibc-" (version-major+minor version) "-"
  844. (caddr (string-split version #\.)) ".tar.xz"))
  845. (sha256
  846. (base32
  847. "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
  848. (patches (search-patches "glibc-ldd-x86_64.patch"
  849. "glibc-versioned-locpath.patch"
  850. "glibc-allow-kernel-2.6.32.patch"))))))
  851. (define-public glibc-2.25
  852. (package
  853. (inherit glibc)
  854. (version "2.25")
  855. (source (origin
  856. (inherit (package-source glibc))
  857. (uri (string-append "mirror://gnu/glibc/glibc-"
  858. version ".tar.xz"))
  859. (sha256
  860. (base32
  861. "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
  862. (patches (search-patches "glibc-ldd-x86_64.patch"
  863. "glibc-versioned-locpath.patch"
  864. "glibc-vectorized-strcspn-guards.patch"
  865. "glibc-CVE-2017-1000366-pt1.patch"
  866. "glibc-CVE-2017-1000366-pt2.patch"
  867. "glibc-CVE-2017-1000366-pt3.patch"))))))
  868. (define-public glibc-2.24
  869. (package
  870. (inherit glibc)
  871. (version "2.24")
  872. (source (origin
  873. (inherit (package-source glibc))
  874. (uri (string-append "mirror://gnu/glibc/glibc-"
  875. version ".tar.xz"))
  876. (sha256
  877. (base32
  878. "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
  879. (patches (search-patches "glibc-ldd-x86_64.patch"
  880. "glibc-versioned-locpath.patch"
  881. "glibc-vectorized-strcspn-guards.patch"
  882. "glibc-CVE-2015-5180.patch"
  883. "glibc-CVE-2017-1000366-pt1.patch"
  884. "glibc-CVE-2017-1000366-pt2.patch"
  885. "glibc-CVE-2017-1000366-pt3.patch"))))))
  886. (define-public glibc-2.23
  887. (package
  888. (inherit glibc)
  889. (version "2.23")
  890. (source (origin
  891. (inherit (package-source glibc))
  892. (uri (string-append "mirror://gnu/glibc/glibc-"
  893. version ".tar.xz"))
  894. (sha256
  895. (base32
  896. "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
  897. (patches (search-patches "glibc-ldd-x86_64.patch"
  898. "glibc-versioned-locpath.patch"
  899. "glibc-vectorized-strcspn-guards.patch"
  900. "glibc-CVE-2015-5180.patch"
  901. "glibc-CVE-2016-3075.patch"
  902. "glibc-CVE-2016-3706.patch"
  903. "glibc-CVE-2016-4429.patch"
  904. "glibc-CVE-2017-1000366-pt1.patch"
  905. "glibc-CVE-2017-1000366-pt2.patch"
  906. "glibc-CVE-2017-1000366-pt3.patch"))))))
  907. (define-public glibc-2.22
  908. (package
  909. (inherit glibc)
  910. (version "2.22")
  911. (source (origin
  912. (inherit (package-source glibc))
  913. (uri (string-append "mirror://gnu/glibc/glibc-"
  914. version ".tar.xz"))
  915. (sha256
  916. (base32
  917. "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
  918. (patches (search-patches "glibc-ldd-x86_64.patch"
  919. "glibc-o-largefile.patch"
  920. "glibc-vectorized-strcspn-guards.patch"
  921. "glibc-CVE-2015-5180.patch"
  922. "glibc-CVE-2015-7547.patch"
  923. "glibc-CVE-2016-3075.patch"
  924. "glibc-CVE-2016-3706.patch"
  925. "glibc-CVE-2016-4429.patch"
  926. "glibc-CVE-2017-1000366-pt1.patch"
  927. "glibc-CVE-2017-1000366-pt2.patch"
  928. "glibc-CVE-2017-1000366-pt3.patch"))))
  929. (arguments
  930. (substitute-keyword-arguments (package-arguments glibc)
  931. ((#:phases phases)
  932. `(modify-phases ,phases
  933. (add-before 'configure 'fix-pwd
  934. (lambda _
  935. ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
  936. (substitute* "configure"
  937. (("/bin/pwd") "pwd"))
  938. #t))))))))
  939. (define-public (make-glibc-locales glibc)
  940. (package
  941. (inherit glibc)
  942. (name "glibc-locales")
  943. (source (origin (inherit (package-source glibc))
  944. (patches (cons (search-patch "glibc-locales.patch")
  945. (origin-patches (package-source glibc))))))
  946. (synopsis "All the locales supported by the GNU C Library")
  947. (description
  948. "This package provides all the locales supported by the GNU C Library,
  949. more than 400 in total. To use them set the 'LOCPATH' environment variable to
  950. the 'share/locale' sub-directory of this package.")
  951. (outputs '("out")) ;110+ MiB
  952. (native-search-paths '())
  953. (arguments
  954. (let ((args `(#:tests? #f #:strip-binaries? #f
  955. ,@(package-arguments glibc))))
  956. (substitute-keyword-arguments args
  957. ((#:phases phases)
  958. `(modify-phases ,phases
  959. (replace 'build
  960. (lambda _
  961. (invoke "make" "localedata/install-locales"
  962. "-j" (number->string (parallel-job-count)))))
  963. (delete 'install)
  964. (delete 'move-static-libs)))
  965. ((#:configure-flags flags)
  966. `(append ,flags
  967. ;; Use $(libdir)/locale/X.Y as is the case by default.
  968. (list (string-append "libc_cv_complocaledir="
  969. (assoc-ref %outputs "out")
  970. "/lib/locale/"
  971. ,(version-major+minor
  972. (package-version glibc)))))))))))
  973. (define-public (make-glibc-utf8-locales glibc)
  974. (package
  975. (name "glibc-utf8-locales")
  976. (version (package-version glibc))
  977. (source #f)
  978. (build-system trivial-build-system)
  979. (arguments
  980. `(#:modules ((guix build utils))
  981. #:builder (begin
  982. (use-modules (guix build utils))
  983. (let* ((libc (assoc-ref %build-inputs "glibc"))
  984. (gzip (assoc-ref %build-inputs "gzip"))
  985. (out (assoc-ref %outputs "out"))
  986. (localedir (string-append out "/lib/locale/"
  987. ,(version-major+minor version))))
  988. ;; 'localedef' needs 'gzip'.
  989. (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
  990. (mkdir-p localedir)
  991. (for-each (lambda (locale)
  992. (define file
  993. ;; Use the "normalized codeset" by
  994. ;; default--e.g., "en_US.utf8".
  995. (string-append localedir "/" locale ".utf8"))
  996. (invoke "localedef" "--no-archive"
  997. "--prefix" localedir
  998. "-i" locale
  999. "-f" "UTF-8" file)
  1000. ;; For backward compatibility with Guix
  1001. ;; <= 0.8.3, add "xx_YY.UTF-8".
  1002. (symlink (string-append locale ".utf8")
  1003. (string-append localedir "/"
  1004. locale ".UTF-8")))
  1005. ;; These are the locales commonly used for
  1006. ;; tests---e.g., in Guile's i18n tests.
  1007. '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
  1008. #t))))
  1009. (inputs `(("glibc" ,glibc)
  1010. ("gzip" ,gzip)))
  1011. (synopsis "Small sample of UTF-8 locales")
  1012. (description
  1013. "This package provides a small sample of UTF-8 locales mostly useful in
  1014. test environments.")
  1015. (home-page (package-home-page glibc))
  1016. (license (package-license glibc))))
  1017. (define-public glibc-locales
  1018. (make-glibc-locales glibc))
  1019. (define-public glibc-utf8-locales
  1020. (make-glibc-utf8-locales glibc))
  1021. (define-public glibc-locales-2.27
  1022. (package (inherit (make-glibc-locales glibc-2.27))
  1023. (name "glibc-locales-2.27")))
  1024. (define-public glibc-utf8-locales-2.27
  1025. (package (inherit (make-glibc-utf8-locales glibc-2.27))
  1026. (name "glibc-utf8-locales-2.27")))
  1027. (define-public which
  1028. (package
  1029. (name "which")
  1030. (version "2.21")
  1031. (source (origin
  1032. (method url-fetch)
  1033. (uri (string-append "mirror://gnu/which/which-"
  1034. version ".tar.gz"))
  1035. (sha256
  1036. (base32
  1037. "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
  1038. (build-system gnu-build-system)
  1039. (home-page "https://gnu.org/software/which/")
  1040. (synopsis "Find full path of shell commands")
  1041. (description
  1042. "The which program finds the location of executables in PATH, with a
  1043. variety of options. It is an alternative to the shell \"type\" built-in
  1044. command.")
  1045. (license gpl3+))) ; some files are under GPLv2+
  1046. (define-public glibc/hurd-headers
  1047. (package (inherit glibc)
  1048. (name "glibc-hurd-headers")
  1049. (outputs '("out"))
  1050. (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
  1051. ("hurd-headers" ,hurd-headers)))
  1052. (arguments
  1053. (substitute-keyword-arguments (package-arguments glibc)
  1054. ;; We just pass the flags really needed to build the headers.
  1055. ((#:configure-flags _)
  1056. `(list "--enable-add-ons"
  1057. "--host=i586-pc-gnu"))
  1058. ((#:phases _)
  1059. '(modify-phases %standard-phases
  1060. (replace 'install
  1061. (lambda* (#:key outputs #:allow-other-keys)
  1062. (invoke "make" "install-headers")
  1063. ;; Make an empty stubs.h to work around not being able to
  1064. ;; produce a valid stubs.h and causing the build to fail. See
  1065. ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
  1066. (let ((out (assoc-ref outputs "out")))
  1067. (close-port
  1068. (open-output-file
  1069. (string-append out "/include/gnu/stubs.h"))))
  1070. #t))
  1071. (delete 'build))))))) ; nothing to build
  1072. (define-public tzdata
  1073. (package
  1074. (name "tzdata")
  1075. (version "2018i")
  1076. (source (origin
  1077. (method url-fetch)
  1078. (uri (string-append
  1079. "https://www.iana.org/time-zones/repository/releases/tzdata"
  1080. version ".tar.gz"))
  1081. (sha256
  1082. (base32
  1083. "1n80ih8agibagic401smqscz3xxqvs5bm5x3lk803g539kw5xi42"))))
  1084. (build-system gnu-build-system)
  1085. (arguments
  1086. '(#:tests? #f
  1087. #:make-flags (let ((out (assoc-ref %outputs "out"))
  1088. (tmp (getenv "TMPDIR")))
  1089. (list (string-append "TOPDIR=" out)
  1090. (string-append "TZDIR=" out "/share/zoneinfo")
  1091. (string-append "TZDEFAULT=" out
  1092. "/share/zoneinfo/localtime")
  1093. ;; Likewise for the C library routines.
  1094. (string-append "LIBDIR=" tmp "/lib")
  1095. (string-append "MANDIR=" tmp "/man")
  1096. "AWK=awk"
  1097. "CC=gcc"))
  1098. #:modules ((guix build utils)
  1099. (guix build gnu-build-system)
  1100. (srfi srfi-1))
  1101. #:phases
  1102. (modify-phases %standard-phases
  1103. (replace 'unpack
  1104. (lambda* (#:key source inputs #:allow-other-keys)
  1105. (invoke "tar" "xvf" source)
  1106. (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
  1107. (add-after 'install 'post-install
  1108. (lambda* (#:key outputs #:allow-other-keys)
  1109. ;; Move data in the right place.
  1110. (let ((out (assoc-ref outputs "out")))
  1111. ;; Discard zic, dump, and tzselect, already
  1112. ;; provided by glibc.
  1113. (delete-file-recursively (string-append out "/usr"))
  1114. (symlink (string-append out "/share/zoneinfo")
  1115. (string-append out "/share/zoneinfo/posix"))
  1116. (delete-file-recursively
  1117. (string-append out "/share/zoneinfo-posix"))
  1118. (copy-recursively (string-append out "/share/zoneinfo-leaps")
  1119. (string-append out "/share/zoneinfo/right"))
  1120. (delete-file-recursively
  1121. (string-append out "/share/zoneinfo-leaps"))
  1122. #t)))
  1123. (delete 'configure))))
  1124. (inputs `(("tzcode" ,(origin
  1125. (method url-fetch)
  1126. (uri (string-append
  1127. "http://www.iana.org/time-zones/repository/releases/tzcode"
  1128. version ".tar.gz"))
  1129. (sha256
  1130. (base32
  1131. "1p1jxlnryaxknj0l768h3dmlk2jpqz5n5d24w9c9vyx6dj3xpb5a"))))))
  1132. (home-page "https://www.iana.org/time-zones")
  1133. (synopsis "Database of current and historical time zones")
  1134. (description "The Time Zone Database (often called tz or zoneinfo)
  1135. contains code and data that represent the history of local time for many
  1136. representative locations around the globe. It is updated periodically to
  1137. reflect changes made by political bodies to time zone boundaries, UTC offsets,
  1138. and daylight-saving rules.")
  1139. (license public-domain)))
  1140. ;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
  1141. ;;; and a few other places. We can update this whenever we are able to rebuild
  1142. ;;; thousands of packages (for example, in a core-updates rebuild). This package
  1143. ;;; will typically be obsolete and should never be referred to by a built
  1144. ;;; package.
  1145. (define-public tzdata-for-tests
  1146. (hidden-package
  1147. (package
  1148. (inherit tzdata)
  1149. (version "2018g")
  1150. (source (origin
  1151. (method url-fetch)
  1152. (uri (string-append
  1153. "https://www.iana.org/time-zones/repository/releases/tzdata"
  1154. version ".tar.gz"))
  1155. (sha256
  1156. (base32
  1157. "05kayi3w9pvhj6ljx1hvwd0r8mxfzn436fjmwhx53xkj919xxpq2"))))
  1158. (inputs
  1159. `(("tzcode" ,(origin
  1160. (method url-fetch)
  1161. (uri (string-append
  1162. "http://www.iana.org/time-zones/repository/releases/tzcode"
  1163. version ".tar.gz"))
  1164. (sha256
  1165. (base32
  1166. "09y44fzcdq3c06saa8iqqa0a59cyw6ni3p31ps0j1w3hcpxz8lxa")))))))))
  1167. (define-public libiconv
  1168. (package
  1169. (name "libiconv")
  1170. (version "1.15")
  1171. (source (origin
  1172. (method url-fetch)
  1173. (uri (string-append "mirror://gnu/libiconv/libiconv-"
  1174. version ".tar.gz"))
  1175. (sha256
  1176. (base32
  1177. "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
  1178. (modules '((guix build utils)))
  1179. (snippet
  1180. ;; Work around "declared gets" error on glibc systems (fixed by
  1181. ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
  1182. '(begin
  1183. (substitute* "srclib/stdio.in.h"
  1184. (("^#undef gets") "")
  1185. (("^_GL_WARN_ON_USE \\(gets.*") ""))
  1186. #t))))
  1187. (build-system gnu-build-system)
  1188. (synopsis "Character set conversion library")
  1189. (description
  1190. "libiconv provides an implementation of the iconv function for systems
  1191. that lack it. iconv is used to convert between character encodings in a
  1192. program. It supports a wide variety of different encodings.")
  1193. (home-page "https://www.gnu.org/software/libiconv/")
  1194. (license lgpl3+)))
  1195. (define* (libiconv-if-needed #:optional (target (%current-target-system)))
  1196. "Return either a libiconv package specification to include in a dependency
  1197. list for platforms that have an incomplete libc, or the empty list. If a
  1198. package needs iconv ,@(libiconv-if-needed) should be added."
  1199. ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
  1200. ;; without iconv, such as MinGW, must return the then clause.
  1201. (if (target-mingw? target)
  1202. `(("libiconv" ,libiconv))
  1203. '()))
  1204. (define-public (canonical-package package)
  1205. ;; Avoid circular dependency by lazily resolving 'commencement'.
  1206. (let* ((iface (resolve-interface '(gnu packages commencement)))
  1207. (proc (module-ref iface 'canonical-package)))
  1208. (proc package)))
  1209. (define-public (%final-inputs)
  1210. "Return the list of \"final inputs\"."
  1211. ;; Avoid circular dependency by lazily resolving 'commencement'.
  1212. (let ((iface (resolve-interface '(gnu packages commencement))))
  1213. (module-ref iface '%final-inputs)))
  1214. ;;; base.scm ends here