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