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