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