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