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