base.scm 61 KB

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