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