Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / bootstrap.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
6 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22 (define-module (gnu packages bootstrap)
23 #:use-module (guix licenses)
24 #:use-module (gnu packages)
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix build-system)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system trivial)
30 #:use-module ((guix store)
31 #:select (run-with-store add-to-store add-text-to-store))
32 #:use-module ((guix derivations)
33 #:select (derivation derivation-input derivation->output-path))
34 #:use-module ((guix utils) #:select (gnu-triplet->nix-system))
35 #:use-module (guix memoization)
36 #:use-module (guix i18n)
37 #:use-module (srfi srfi-1)
38 #:use-module (srfi srfi-26)
39 #:use-module (srfi srfi-34)
40 #:use-module (srfi srfi-35)
41 #:use-module (ice-9 match)
42 #:export (bootstrap-origin
43 package-with-bootstrap-guile
44 glibc-dynamic-linker
45
46 bootstrap-executable
47 bootstrap-guile-origin
48
49 %bootstrap-guile
50 %bootstrap-coreutils&co
51 %bootstrap-linux-libre-headers
52 %bootstrap-binutils
53 %bootstrap-gcc
54 %bootstrap-glibc
55 %bootstrap-inputs
56 %bootstrap-mescc-tools
57 %bootstrap-mes
58
59 %bootstrap-inputs-for-tests))
60
61 ;;; Commentary:
62 ;;;
63 ;;; Pre-built packages that are used to bootstrap the
64 ;;; distribution--i.e., to build all the core packages from scratch.
65 ;;;
66 ;;; Code:
67
68
69 \f
70 ;;;
71 ;;; The bootstrap executables: 'bash', 'mkdir', 'tar', 'xz'. They allow us to
72 ;;; extract the very first tarball.
73 ;;;
74
75 (define %bootstrap-executables
76 ;; List of bootstrap executables and their recursive hashes (as per 'guix
77 ;; hash -r'), taking their executable bit into account.
78 `(("aarch64-linux"
79 ("bash"
80 ,(base32 "13aqhqb8nydlwq1ah9974q0iadx1pb95v13wzzyf7vgv6nasrwzr"))
81 ("mkdir"
82 ,(base32 "1pxhdp7ldwavmm71xbh9wc197cb2nr66acjn26yjx3732cixh9ws"))
83 ("tar"
84 ,(base32 "1j51gv08sfg277yxj73xd564wjq3f8xwd6s9rbcg8v9gms47m4cx"))
85 ("xz"
86 ,(base32 "1d779rwsrasphg5g3r37qppcqy3p7ay1jb1y83w7x4i3qsc7zjy2")))
87 ("armhf-linux"
88 ("bash"
89 ,(base32 "0s6f1s26g4dsrrkl39zblvwpxmbzi6n9mgqf6vxsqz42gik6bgyn"))
90 ("mkdir"
91 ,(base32 "1r5rcp35niyxfkrdf00y2ba8ifrq9bi76cr63lwjf2l655j1i5p7"))
92 ("tar"
93 ,(base32 "0dksx5im3fv8ximz7368bsax9f26nn47ds74298flm5lnvpv9xly"))
94 ("xz"
95 ,(base32 "1cqqavghjfr0iwxqf61lrssv27wfigysgq2rs4rm1gkmn04yn1k3")))
96 ("i686-linux"
97 ("bash"
98 ,(base32 "0rjaxyzjdllfkf1abczvgaf3cdcc7mmahyvdbkjmjzhgz92pv23g"))
99 ("mkdir"
100 ,(base32 "133ybmfpkmsnysrzbngwvbysqnsmfi8is8zifs7i7n6n600h4s1w"))
101 ("tar"
102 ,(base32 "07830bx29ad5i0l1ykj0g0b1jayjdblf01sr3ww9wbnwdbzinqms"))
103 ("xz"
104 ,(base32 "0i9kxdi17bm5gxfi2xzm0y73p3ii0cqxli1sbljm6rh2fjgyn90k")))
105 ("mips64el-linux"
106 ("bash"
107 ,(base32 "1aw046dhda240k9pb9iaj5aqkm23gkvxa9j82n4k7fk87nbrixw6"))
108 ("mkdir"
109 ,(base32 "0c9j6qgyw84zxbry3ypifzll13gy8ax71w40kdk1h11jbgla3f5k"))
110 ("tar"
111 ,(base32 "06gmqdjq3rl8lr47b9fyx4ifnm5x56ymc8lyryp1ax1j2s4y5jb4"))
112 ("xz"
113 ,(base32 "09j1d69qr0hhhx4k4ih8wp00dfc9y4rp01hfg3vc15yxd0jxabh5")))))
114
115 (define (bootstrap-executable-url program system)
116 "Return the URL where PROGRAM can be found for SYSTEM."
117 (string-append
118 "https://git.savannah.gnu.org/cgit/guix.git/plain/gnu/packages/bootstrap/"
119 system "/" program
120 "?id=44f07d1dc6806e97c4e9ee3e6be883cc59dc666e"))
121
122 (define bootstrap-executable
123 (mlambda (program system)
124 "Return an origin for PROGRAM, a statically-linked bootstrap executable
125 built for SYSTEM."
126 (let ((system (if (string=? system "x86_64-linux")
127 "i686-linux"
128 system)))
129 (match (assoc-ref (assoc-ref %bootstrap-executables system)
130 program)
131 (#f
132 (raise (condition
133 (&message
134 (message
135 (format #f (G_ "could not find bootstrap binary '~a' \
136 for system '~a'")
137 program system))))))
138 ((sha256)
139 (origin
140 (method url-fetch/executable)
141 (uri (bootstrap-executable-url program system))
142 (file-name program)
143 (sha256 sha256)))))))
144
145 \f
146 ;;;
147 ;;; Helper procedures.
148 ;;;
149
150 (define (bootstrap-origin source)
151 "Return a variant of SOURCE, an <origin> instance, whose method uses
152 %BOOTSTRAP-GUILE to do its job."
153 (define (boot fetch)
154 (lambda* (url hash-algo hash
155 #:optional name #:key system)
156 (fetch url hash-algo hash name
157 #:guile %bootstrap-guile
158 #:system system)))
159
160 (define %bootstrap-patch-inputs
161 ;; Packages used when an <origin> has a non-empty 'patches' field.
162 `(("tar" ,%bootstrap-coreutils&co)
163 ("xz" ,%bootstrap-coreutils&co)
164 ("bzip2" ,%bootstrap-coreutils&co)
165 ("gzip" ,%bootstrap-coreutils&co)
166 ("patch" ,%bootstrap-coreutils&co)))
167
168 (let ((orig-method (origin-method source)))
169 (origin (inherit source)
170 (method (cond ((eq? orig-method url-fetch)
171 (boot url-fetch))
172 (else orig-method)))
173 (patch-guile %bootstrap-guile)
174 (patch-inputs %bootstrap-patch-inputs)
175
176 ;; Patches can be origins as well, so process them.
177 (patches (map (match-lambda
178 ((? origin? patch)
179 (bootstrap-origin patch))
180 (patch patch))
181 (origin-patches source))))))
182
183 (define* (package-from-tarball name source program-to-test description
184 #:key snippet)
185 "Return a package that correspond to the extraction of SOURCE.
186 PROGRAM-TO-TEST is #f or a string: the program to run after extraction of
187 SOURCE to check whether everything is alright. If SNIPPET is provided, it is
188 evaluated after extracting SOURCE. SNIPPET should return true if successful,
189 or false to signal an error."
190 (package
191 (name name)
192 (version "0")
193 (build-system trivial-build-system)
194 (arguments
195 `(#:guile ,%bootstrap-guile
196 #:modules ((guix build utils))
197 #:builder
198 (begin
199 (use-modules (guix build utils))
200
201 (let ((out (assoc-ref %outputs "out"))
202 (tar (assoc-ref %build-inputs "tar"))
203 (xz (assoc-ref %build-inputs "xz"))
204 (tarball (assoc-ref %build-inputs "tarball")))
205
206 (mkdir out)
207 (copy-file tarball "binaries.tar.xz")
208 (invoke xz "-d" "binaries.tar.xz")
209 (let ((builddir (getcwd)))
210 (with-directory-excursion out
211 (invoke tar "xvf"
212 (string-append builddir "/binaries.tar"))
213 ,@(if snippet (list snippet) '())
214 (or (not ,program-to-test)
215 (invoke (string-append "bin/" ,program-to-test)
216 "--version"))))))))
217 (inputs
218 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
219 ("xz" ,(bootstrap-executable "xz" (%current-system)))
220 ("tarball" ,(bootstrap-origin (source (%current-system))))))
221 (source #f)
222 (synopsis description)
223 (description description)
224 (home-page #f)
225 (license gpl3+)))
226
227 (define package-with-bootstrap-guile
228 (mlambdaq (p)
229 "Return a variant of P such that all its origins are fetched with
230 %BOOTSTRAP-GUILE."
231 (define rewritten-input
232 (match-lambda
233 ((name (? origin? o))
234 `(,name ,(bootstrap-origin o)))
235 ((name (? package? p) sub-drvs ...)
236 `(,name ,(package-with-bootstrap-guile p) ,@sub-drvs))
237 (x x)))
238
239 (package (inherit p)
240 (source (match (package-source p)
241 ((? origin? o) (bootstrap-origin o))
242 (s s)))
243 (inputs (map rewritten-input
244 (package-inputs p)))
245 (native-inputs (map rewritten-input
246 (package-native-inputs p)))
247 (propagated-inputs (map rewritten-input
248 (package-propagated-inputs p)))
249 (replacement (and=> (package-replacement p)
250 package-with-bootstrap-guile)))))
251
252 (define* (glibc-dynamic-linker
253 #:optional (system (or (and=> (%current-target-system)
254 gnu-triplet->nix-system)
255 (%current-system))))
256 "Return the name of Glibc's dynamic linker for SYSTEM."
257 ;; See the 'SYSDEP_KNOWN_INTERPRETER_NAMES' cpp macro in libc.
258 (cond ((string=? system "x86_64-linux") "/lib/ld-linux-x86-64.so.2")
259 ((string=? system "i686-linux") "/lib/ld-linux.so.2")
260 ((string=? system "armhf-linux") "/lib/ld-linux-armhf.so.3")
261 ((string=? system "mips64el-linux") "/lib/ld.so.1")
262 ((string=? system "i586-gnu") "/lib/ld.so.1")
263 ((string=? system "i686-gnu") "/lib/ld.so.1")
264 ((string=? system "aarch64-linux") "/lib/ld-linux-aarch64.so.1")
265 ((string=? system "powerpc-linux") "/lib/ld.so.1")
266 ((string=? system "powerpc64le-linux") "/lib/ld64.so.2")
267 ((string=? system "alpha-linux") "/lib/ld-linux.so.2")
268 ((string=? system "s390x-linux") "/lib/ld64.so.1")
269 ((string=? system "riscv64-linux") "/lib/ld-linux-riscv64-lp64d.so.1")
270
271 ;; XXX: This one is used bare-bones, without a libc, so add a case
272 ;; here just so we can keep going.
273 ((string=? system "arm-elf") "no-ld.so")
274 ((string=? system "arm-eabi") "no-ld.so")
275 ((string=? system "xtensa-elf") "no-ld.so")
276 ((string=? system "avr") "no-ld.so")
277 ((string=? system "propeller-elf") "no-ld.so")
278 ((string=? system "i686-mingw") "no-ld.so")
279 ((string=? system "vc4-elf") "no-ld.so")
280
281 (else (error "dynamic linker name not known for this system"
282 system))))
283
284 \f
285 ;;;
286 ;;; Bootstrap packages.
287 ;;;
288
289 (define %bootstrap-base-urls
290 ;; This is where the initial binaries come from.
291 '("https://alpha.gnu.org/gnu/guix/bootstrap"
292 "http://alpha.gnu.org/gnu/guix/bootstrap"
293 "ftp://alpha.gnu.org/gnu/guix/bootstrap"
294 "http://www.fdn.fr/~lcourtes/software/guix/packages"
295 "http://flashner.co.il/guix/bootstrap"))
296
297 (define (bootstrap-guile-url-path system)
298 "Return the URI for FILE."
299 (string-append "/" system
300 (match system
301 ("aarch64-linux"
302 "/20170217/guile-2.0.14.tar.xz")
303 ("armhf-linux"
304 "/20150101/guile-2.0.11.tar.xz")
305 (_
306 "/20131110/guile-2.0.9.tar.xz"))))
307
308 (define (bootstrap-guile-hash system)
309 "Return the SHA256 hash of the Guile bootstrap tarball for SYSTEM."
310 (match system
311 ("x86_64-linux"
312 (base32 "1w2p5zyrglzzniqgvyn1b55vprfzhgk8vzbzkkbdgl5248si0yq3"))
313 ("i686-linux"
314 (base32 "0im800m30abgh7msh331pcbjvb4n02smz5cfzf1srv0kpx3csmxp"))
315 ("mips64el-linux"
316 (base32 "0fzp93lvi0hn54acc0fpvhc7bvl0yc853k62l958cihk03q80ilr"))
317 ("armhf-linux"
318 (base32 "1mi3brl7l58aww34rawhvja84xc7l1b4hmwdmc36fp9q9mfx0lg5"))
319 ("aarch64-linux"
320 (base32 "1giy2aprjmn5fp9c4s9r125fljw4wv6ixy5739i5bffw4jgr0f9r"))))
321
322 (define (bootstrap-guile-origin system)
323 "Return an <origin> object for the Guile tarball of SYSTEM."
324 (origin
325 (method url-fetch)
326 (uri (map (cute string-append <> (bootstrap-guile-url-path system))
327 %bootstrap-base-urls))
328 (sha256 (bootstrap-guile-hash system))))
329
330 (define (download-bootstrap-guile store system)
331 "Return a derivation that downloads the bootstrap Guile tarball for SYSTEM."
332 (let* ((path (bootstrap-guile-url-path system))
333 (base (basename path))
334 (urls (map (cut string-append <> path) %bootstrap-base-urls)))
335 (run-with-store store
336 (url-fetch urls 'sha256 (bootstrap-guile-hash system)
337 #:system system))))
338
339 (define* (raw-build store name inputs
340 #:key outputs system search-paths
341 #:allow-other-keys)
342 (define (->store file)
343 (run-with-store store
344 (origin->derivation (bootstrap-executable file system)
345 system)))
346
347 (let* ((tar (->store "tar"))
348 (xz (->store "xz"))
349 (mkdir (->store "mkdir"))
350 (bash (->store "bash"))
351 (guile (download-bootstrap-guile store system))
352 ;; The following code, run by the bootstrap guile after it is
353 ;; unpacked, creates a wrapper for itself to set its load path.
354 ;; This replaces the previous non-portable method based on
355 ;; reading the /proc/self/exe symlink.
356 (make-guile-wrapper
357 '(begin
358 (use-modules (ice-9 match))
359 (match (command-line)
360 ((_ out bash)
361 (let ((bin-dir (string-append out "/bin"))
362 (guile (string-append out "/bin/guile"))
363 (guile-real (string-append out "/bin/.guile-real"))
364 ;; We must avoid using a bare dollar sign in this code,
365 ;; because it would be interpreted by the shell.
366 (dollar (string (integer->char 36))))
367 (chmod bin-dir #o755)
368 (rename-file guile guile-real)
369 (call-with-output-file guile
370 (lambda (p)
371 (format p "\
372 #!~a
373 export GUILE_SYSTEM_PATH=~a/share/guile/2.0
374 export GUILE_SYSTEM_COMPILED_PATH=~a/lib/guile/2.0/ccache
375 exec -a \"~a0\" ~a \"~a@\"\n"
376 bash out out dollar guile-real dollar)))
377 (chmod guile #o555)
378 (chmod bin-dir #o555))))))
379 (builder
380 (add-text-to-store store
381 "build-bootstrap-guile.sh"
382 (format #f "
383 echo \"unpacking bootstrap Guile to '$out'...\"
384 ~a $out
385 cd $out
386 ~a -dc < $GUILE_TARBALL | ~a xv
387
388 # Use the bootstrap guile to create its own wrapper to set the load path.
389 GUILE_SYSTEM_PATH=$out/share/guile/2.0 \
390 GUILE_SYSTEM_COMPILED_PATH=$out/lib/guile/2.0/ccache \
391 $out/bin/guile -c ~s $out ~a
392
393 # Sanity check.
394 $out/bin/guile --version~%"
395 (derivation->output-path mkdir)
396 (derivation->output-path xz)
397 (derivation->output-path tar)
398 (format #f "~s" make-guile-wrapper)
399 (derivation->output-path bash)))))
400 (derivation store name
401 (derivation->output-path bash) `(,builder)
402 #:system system
403 #:inputs (map derivation-input
404 (list bash mkdir tar xz guile))
405 #:sources (list builder)
406 #:env-vars `(("GUILE_TARBALL"
407 . ,(derivation->output-path guile))))))
408
409 (define* (make-raw-bag name
410 #:key source inputs native-inputs outputs
411 system target)
412 (bag
413 (name name)
414 (system system)
415 (build-inputs inputs)
416 (build raw-build)))
417
418 (define %bootstrap-guile
419 ;; The Guile used to run the build scripts of the initial derivations.
420 ;; It is just unpacked from a tarball containing a pre-built binary.
421 ;; This is typically built using %GUILE-BOOTSTRAP-TARBALL below.
422 ;;
423 ;; XXX: Would need libc's `libnss_files2.so' for proper `getaddrinfo'
424 ;; support (for /etc/services).
425 (let ((raw (build-system
426 (name 'raw)
427 (description "Raw build system with direct store access")
428 (lower make-raw-bag))))
429 (package
430 (name "guile-bootstrap")
431 (version "2.0")
432 (source #f)
433 (build-system raw)
434 (synopsis "Bootstrap Guile")
435 (description "Pre-built Guile for bootstrapping purposes.")
436 (home-page #f)
437 (license lgpl3+))))
438
439 (define %bootstrap-coreutils&co
440 (package-from-tarball "bootstrap-binaries"
441 (lambda (system)
442 (origin
443 (method url-fetch)
444 (uri (map (cut string-append <> "/" system
445 (match system
446 ("armhf-linux"
447 "/20150101/static-binaries.tar.xz")
448 ("aarch64-linux"
449 "/20170217/static-binaries.tar.xz")
450 (_
451 "/20131110/static-binaries.tar.xz")))
452 %bootstrap-base-urls))
453 (sha256
454 (match system
455 ("x86_64-linux"
456 (base32
457 "0c533p9dhczzcsa1117gmfq3pc8w362g4mx84ik36srpr7cx2bg4"))
458 ("i686-linux"
459 (base32
460 "0s5b3jb315n13m1k8095l0a5hfrsz8g0fv1b6riyc5hnxqyphlak"))
461 ("armhf-linux"
462 (base32
463 "0gf0fn2kbpxkjixkmx5f4z6hv6qpmgixl69zgg74dbsfdfj8jdv5"))
464 ("aarch64-linux"
465 (base32
466 "18dfiq6c6xhsdpbidigw6480wh0vdgsxqq3xindq4lpdgqlccpfh"))
467 ("mips64el-linux"
468 (base32
469 "072y4wyfsj1bs80r6vbybbafy8ya4vfy7qj25dklwk97m6g71753"))))))
470 "fgrep" ; the program to test
471 "Bootstrap binaries of Coreutils, Awk, etc."
472 #:snippet
473 '(let ((path (list (string-append (getcwd) "/bin"))))
474 (chmod "bin" #o755)
475 (patch-shebang "bin/egrep" path)
476 (patch-shebang "bin/fgrep" path)
477 ;; Starting with grep@2.25 'egrep' and 'fgrep' are shell files
478 ;; that call 'grep'. If the bootstrap 'egrep' and 'fgrep'
479 ;; are not binaries then patch them to execute 'grep' via its
480 ;; absolute file name instead of searching for it in $PATH.
481 (if (not (elf-file? "bin/egrep"))
482 (substitute* '("bin/egrep" "bin/fgrep")
483 (("^exec grep") (string-append (getcwd) "/bin/grep"))))
484 (chmod "bin" #o555))))
485
486 (define-public %bootstrap-linux-libre-headers
487 (package-from-tarball
488 "linux-libre-headers-bootstrap"
489 (lambda (system)
490 (origin
491 (method url-fetch)
492 (uri (map (cute string-append <>
493 "/i686-linux/20181020/"
494 "linux-libre-headers-stripped-4.14.67-i686-linux.tar.xz")
495 %bootstrap-base-urls))
496 (sha256
497 (base32
498 "0sm2z9x4wk45bh6qfs94p0w1d6hsy6dqx9sw38qsqbvxwa1qzk8s"))))
499 #f ; no program to test
500 "Bootstrap linux-libre-headers"))
501
502 (define %bootstrap-binutils
503 (package-from-tarball "binutils-bootstrap"
504 (lambda (system)
505 (origin
506 (method url-fetch)
507 (uri (map (cut string-append <> "/" system
508 (match system
509 ("armhf-linux"
510 "/20150101/binutils-2.25.tar.xz")
511 ("aarch64-linux"
512 "/20170217/binutils-2.27.tar.xz")
513 (_
514 "/20131110/binutils-2.23.2.tar.xz")))
515 %bootstrap-base-urls))
516 (sha256
517 (match system
518 ("x86_64-linux"
519 (base32
520 "1j5yivz7zkjqfsfmxzrrrffwyayjqyfxgpi89df0w4qziqs2dg20"))
521 ("i686-linux"
522 (base32
523 "14jgwf9gscd7l2pnz610b1zia06dvcm2qyzvni31b8zpgmcai2v9"))
524 ("armhf-linux"
525 (base32
526 "1v7dj6bzn6m36f20gw31l99xaabq4xrhrx3gwqkhhig0mdlmr69q"))
527 ("aarch64-linux"
528 (base32
529 "111s7ilfiby033rczc71797xrmaa3qlv179wdvsaq132pd51xv3n"))
530 ("mips64el-linux"
531 (base32
532 "1x8kkhcxmfyzg1ddpz2pxs6fbdl6412r7x0nzbmi5n7mj8zw2gy7"))))))
533 "ld" ; the program to test
534 "Bootstrap binaries of the GNU Binutils"))
535
536 (define %bootstrap-glibc
537 ;; The initial libc.
538 (package
539 (name "glibc-bootstrap")
540 (version "0")
541 (source #f)
542 (build-system trivial-build-system)
543 (arguments
544 `(#:guile ,%bootstrap-guile
545 #:modules ((guix build utils))
546 #:builder
547 (begin
548 (use-modules (guix build utils))
549
550 (let ((out (assoc-ref %outputs "out"))
551 (tar (assoc-ref %build-inputs "tar"))
552 (xz (assoc-ref %build-inputs "xz"))
553 (tarball (assoc-ref %build-inputs "tarball")))
554
555 (mkdir out)
556 (copy-file tarball "binaries.tar.xz")
557 (invoke xz "-d" "binaries.tar.xz")
558 (let ((builddir (getcwd)))
559 (with-directory-excursion out
560 (invoke tar "xvf"
561 (string-append builddir
562 "/binaries.tar"))
563 (chmod "lib" #o755)
564
565 ;; Patch libc.so so it refers to the right path.
566 (substitute* "lib/libc.so"
567 (("/[^ ]+/lib/(libc|ld)" _ prefix)
568 (string-append out "/lib/" prefix)))
569
570 #t))))))
571 (inputs
572 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
573 ("xz" ,(bootstrap-executable "xz" (%current-system)))
574 ("tarball" ,(bootstrap-origin
575 (origin
576 (method url-fetch)
577 (uri (map (cut string-append <> "/" (%current-system)
578 (match (%current-system)
579 ("armhf-linux"
580 "/20150101/glibc-2.20.tar.xz")
581 ("aarch64-linux"
582 "/20170217/glibc-2.25.tar.xz")
583 (_
584 "/20131110/glibc-2.18.tar.xz")))
585 %bootstrap-base-urls))
586 (sha256
587 (match (%current-system)
588 ("x86_64-linux"
589 (base32
590 "0jlqrgavvnplj1b083s20jj9iddr4lzfvwybw5xrcis9spbfzk7v"))
591 ("i686-linux"
592 (base32
593 "1hgrccw1zqdc7lvgivwa54d9l3zsim5pqm0dykxg0z522h6gr05w"))
594 ("armhf-linux"
595 (base32
596 "18cmgvpllqfpn6khsmivqib7ys8ymnq0hdzi3qp24prik0ykz8gn"))
597 ("aarch64-linux"
598 (base32
599 "07nx3x8598i2924rjnlrncg6rm61c9bmcczbbcpbx0fb742nvv5c"))
600 ("mips64el-linux"
601 (base32
602 "0k97a3whzx3apsi9n2cbsrr79ad6lh00klxph9hw4fqyp1abkdsg")))))))))
603 (synopsis "Bootstrap binaries and headers of the GNU C Library")
604 (description synopsis)
605 (home-page #f)
606 (license lgpl2.1+)))
607
608 (define %bootstrap-gcc
609 ;; The initial GCC. Uses binaries from a tarball typically built by
610 ;; %GCC-BOOTSTRAP-TARBALL.
611 (package
612 (name "gcc-bootstrap")
613 (version "0")
614 (source #f)
615 (build-system trivial-build-system)
616 (arguments
617 `(#:guile ,%bootstrap-guile
618 #:modules ((guix build utils))
619 #:builder
620 (begin
621 (use-modules (guix build utils)
622 (ice-9 popen))
623
624 (let ((out (assoc-ref %outputs "out"))
625 (tar (assoc-ref %build-inputs "tar"))
626 (xz (assoc-ref %build-inputs "xz"))
627 (bash (assoc-ref %build-inputs "bash"))
628 (libc (assoc-ref %build-inputs "libc"))
629 (tarball (assoc-ref %build-inputs "tarball")))
630
631 (mkdir out)
632 (copy-file tarball "binaries.tar.xz")
633 (invoke xz "-d" "binaries.tar.xz")
634 (let ((builddir (getcwd))
635 (bindir (string-append out "/bin")))
636 (with-directory-excursion out
637 (invoke tar "xvf"
638 (string-append builddir "/binaries.tar")))
639
640 (with-directory-excursion bindir
641 (chmod "." #o755)
642 (rename-file "gcc" ".gcc-wrapped")
643 (call-with-output-file "gcc"
644 (lambda (p)
645 (format p "#!~a
646 exec ~a/bin/.gcc-wrapped -B~a/lib \
647 -Wl,-rpath -Wl,~a/lib \
648 -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
649 bash
650 out libc libc libc
651 ,(glibc-dynamic-linker))))
652
653 (chmod "gcc" #o555)
654 #t))))))
655 (inputs
656 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
657 ("xz" ,(bootstrap-executable "xz" (%current-system)))
658 ("bash" ,(bootstrap-executable "bash" (%current-system)))
659 ("libc" ,%bootstrap-glibc)
660 ("tarball" ,(bootstrap-origin
661 (origin
662 (method url-fetch)
663 (uri (map (cut string-append <> "/" (%current-system)
664 (match (%current-system)
665 ("armhf-linux"
666 "/20150101/gcc-4.8.4.tar.xz")
667 ("aarch64-linux"
668 "/20170217/gcc-5.4.0.tar.xz")
669 (_
670 "/20131110/gcc-4.8.2.tar.xz")))
671 %bootstrap-base-urls))
672 (sha256
673 (match (%current-system)
674 ("x86_64-linux"
675 (base32
676 "17ga4m6195n4fnbzdkmik834znkhs53nkypp6557pl1ps7dgqbls"))
677 ("i686-linux"
678 (base32
679 "150c1arrf2k8vfy6dpxh59vcgs4p1bgiz2av5m19dynpks7rjnyw"))
680 ("armhf-linux"
681 (base32
682 "0ghz825yzp43fxw53kd6afm8nkz16f7dxi9xi40bfwc8x3nbbr8v"))
683 ("aarch64-linux"
684 (base32
685 "1ar3vdzyqbfm0z36kmvazvfswxhcihlacl2dzdjgiq25cqnq9ih1"))
686 ("mips64el-linux"
687 (base32
688 "1m5miqkyng45l745n0sfafdpjkqv9225xf44jqkygwsipj2cv9ks")))))))))
689 (native-search-paths
690 (list (search-path-specification
691 (variable "CPATH")
692 (files '("include")))
693 (search-path-specification
694 (variable "LIBRARY_PATH")
695 (files '("lib" "lib64")))))
696 (synopsis "Bootstrap binaries of the GNU Compiler Collection")
697 (description synopsis)
698 (home-page #f)
699 (license gpl3+)))
700
701 (define %bootstrap-mescc-tools
702 ;; The initial MesCC tools. Uses binaries from a tarball typically built by
703 ;; %MESCC-TOOLS-BOOTSTRAP-TARBALL.
704 (package
705 (name "bootstrap-mescc-tools")
706 (version "0.5.2")
707 (source #f)
708 (build-system trivial-build-system)
709 (arguments
710 `(#:guile ,%bootstrap-guile
711 #:modules ((guix build utils))
712 #:builder
713 (begin
714 (use-modules (guix build utils)
715 (ice-9 popen))
716 (let ((out (assoc-ref %outputs "out"))
717 (tar (assoc-ref %build-inputs "tar"))
718 (xz (assoc-ref %build-inputs "xz"))
719 (tarball (assoc-ref %build-inputs "tarball")))
720
721 (mkdir out)
722 (copy-file tarball "binaries.tar.xz")
723 (invoke xz "-d" "binaries.tar.xz")
724 (let ((builddir (getcwd))
725 (bindir (string-append out "/bin")))
726 (with-directory-excursion out
727 (invoke tar "xvf"
728 (string-append builddir "/binaries.tar"))))))))
729 (inputs
730 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
731 ("xz" ,(bootstrap-executable "xz" (%current-system)))
732 ("tarball"
733 ,(bootstrap-origin
734 (origin
735 (method url-fetch)
736 (uri (map
737 (cute string-append <>
738 "/i686-linux/20181020/"
739 "mescc-tools-static-0.5.2-0.bb062b0-i686-linux.tar.xz")
740 %bootstrap-base-urls))
741 (sha256
742 (base32
743 "11lniw0vg61kmyhvnwkmcnkci9ym6hbmiksiqggd0hkipbq7hvlz")))))))
744 (synopsis "Bootstrap binaries of MesCC Tools")
745 (description synopsis)
746 (home-page #f)
747 (supported-systems '("i686-linux" "x86_64-linux"))
748 (license gpl3+)))
749
750 (define %bootstrap-mes
751 ;; The initial Mes. Uses binaries from a tarball typically built by
752 ;; %MES-BOOTSTRAP-TARBALL.
753 (package
754 (name "bootstrap-mes")
755 (version "0")
756 (source #f)
757 (build-system trivial-build-system)
758 (arguments
759 `(#:guile ,%bootstrap-guile
760 #:modules ((guix build utils))
761 #:builder
762 (begin
763 (use-modules (guix build utils)
764 (ice-9 popen))
765 (let ((out (assoc-ref %outputs "out"))
766 (tar (assoc-ref %build-inputs "tar"))
767 (xz (assoc-ref %build-inputs "xz"))
768 (tarball (assoc-ref %build-inputs "tarball")))
769
770 (mkdir out)
771 (copy-file tarball "binaries.tar.xz")
772 (invoke xz "-d" "binaries.tar.xz")
773 (let ((builddir (getcwd))
774 (bindir (string-append out "/bin")))
775 (with-directory-excursion out
776 (invoke tar "xvf"
777 (string-append builddir "/binaries.tar"))))))))
778 (inputs
779 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
780 ("xz" ,(bootstrap-executable "xz" (%current-system)))
781 ("tarball"
782 ,(bootstrap-origin
783 (origin
784 (method url-fetch)
785 (uri (map
786 (cute string-append <>
787 "/i686-linux/20181020/"
788 "mes-minimal-stripped-0.19-i686-linux.tar.xz")
789 %bootstrap-base-urls))
790 (sha256
791 (base32
792 "0k7kkl68a6xaadv47ij0nr9jm5ca1ffj38n7f2lg80y72wdkwr9h")))))))
793 (supported-systems '("i686-linux" "x86_64-linux"))
794 (synopsis "Bootstrap binaries of Mes")
795 (description synopsis)
796 (home-page #f)
797 (license gpl3+)))
798
799 (define (%bootstrap-inputs)
800 ;; The initial, pre-built inputs. From now on, we can start building our
801 ;; own packages.
802 `(,@(match (%current-system)
803 ((or "i686-linux" "x86_64-linux")
804 `(("linux-libre-headers" ,%bootstrap-linux-libre-headers)
805 ("bootstrap-mescc-tools" ,%bootstrap-mescc-tools)
806 ("mes" ,%bootstrap-mes)))
807 (_
808 `(("libc" ,%bootstrap-glibc)
809 ("gcc" ,%bootstrap-gcc)
810 ("binutils" ,%bootstrap-binutils))))
811 ("coreutils&co" ,%bootstrap-coreutils&co)
812
813 ;; In gnu-build-system.scm, we rely on the availability of Bash.
814 ("bash" ,%bootstrap-coreutils&co)))
815
816 (define %bootstrap-inputs-for-tests
817 ;; These are bootstrap inputs that are cheap to produce (no compilation
818 ;; needed) and that are meant to be used for testing. (These are those we
819 ;; used before the Mes-based reduced bootstrap.)
820 `(("libc" ,%bootstrap-glibc)
821 ("gcc" ,%bootstrap-gcc)
822 ("binutils" ,%bootstrap-binutils)
823 ("coreutils&co" ,%bootstrap-coreutils&co)
824 ("bash" ,%bootstrap-coreutils&co)))
825
826 ;;; bootstrap.scm ends here