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