gnu: xorg: Disable not compiling xf86-video-geode.
[jackhill/guix/guix.git] / gnu / packages / bootstrap.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
4050e5d6 2;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
18633d4f 3;;;
233e7676 4;;; This file is part of GNU Guix.
18633d4f 5;;;
233e7676 6;;; GNU Guix is free software; you can redistribute it and/or modify it
18633d4f
LC
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
233e7676 11;;; GNU Guix is distributed in the hope that it will be useful, but
18633d4f
LC
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
233e7676 17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18633d4f 18
1ffa7090 19(define-module (gnu packages bootstrap)
4a44e743 20 #:use-module (guix licenses)
59a43334 21 #:use-module (gnu packages)
18633d4f 22 #:use-module (guix packages)
62cab99c 23 #:use-module (guix download)
18633d4f
LC
24 #:use-module (guix build-system)
25 #:use-module (guix build-system gnu)
26 #:use-module (guix build-system trivial)
27 #:use-module ((guix store) #:select (add-to-store add-text-to-store))
28 #:use-module ((guix derivations) #:select (derivation))
29 #:use-module (guix utils)
30 #:use-module (srfi srfi-1)
31 #:use-module (srfi srfi-26)
32 #:use-module (ice-9 match)
33 #:export (bootstrap-origin
34 package-with-bootstrap-guile
35 glibc-dynamic-linker
36
37 %bootstrap-guile
38 %bootstrap-coreutils&co
39 %bootstrap-binutils
40 %bootstrap-gcc
41 %bootstrap-glibc
42 %bootstrap-inputs))
43
44;;; Commentary:
45;;;
46;;; Pre-built packages that are used to bootstrap the
47;;; distribution--i.e., to build all the core packages from scratch.
48;;;
49;;; Code:
50
51
52\f
53;;;
54;;; Helper procedures.
55;;;
56
57(define (bootstrap-origin source)
58 "Return a variant of SOURCE, an <origin> instance, whose method uses
59%BOOTSTRAP-GUILE to do its job."
60 (define (boot fetch)
61 (lambda* (store url hash-algo hash
62 #:optional name #:key system)
63 (fetch store url hash-algo hash
64 #:guile %bootstrap-guile
65 #:system system)))
66
67 (let ((orig-method (origin-method source)))
68 (origin (inherit source)
87f5d366 69 (method (cond ((eq? orig-method url-fetch)
62cab99c 70 (boot url-fetch))
18633d4f
LC
71 (else orig-method))))))
72
73(define (package-from-tarball name* source* program-to-test description*)
74 "Return a package that correspond to the extraction of SOURCE*.
75PROGRAM-TO-TEST is a program to run after extraction of SOURCE*, to
76check whether everything is alright."
77 (package
78 (name name*)
79 (version "0")
80 (source #f)
81 (build-system trivial-build-system)
82 (arguments
83 `(#:guile ,%bootstrap-guile
84 #:modules ((guix build utils))
85 #:builder
86 (let ((out (assoc-ref %outputs "out"))
87 (tar (assoc-ref %build-inputs "tar"))
88 (xz (assoc-ref %build-inputs "xz"))
89 (tarball (assoc-ref %build-inputs "tarball")))
90 (use-modules (guix build utils))
91
92 (mkdir out)
93 (copy-file tarball "binaries.tar.xz")
94 (system* xz "-d" "binaries.tar.xz")
95 (let ((builddir (getcwd)))
96 (with-directory-excursion out
97 (and (zero? (system* tar "xvf"
98 (string-append builddir "/binaries.tar")))
99 (zero? (system* (string-append "bin/" ,program-to-test)
100 "--version"))))))))
101 (inputs
dd6b9a37
LC
102 `(("tar" ,(search-bootstrap-binary "tar" (%current-system)))
103 ("xz" ,(search-bootstrap-binary "xz" (%current-system)))
104 ("tarball" ,(bootstrap-origin (source* (%current-system))))))
18633d4f
LC
105 (synopsis description*)
106 (description #f)
107 (home-page #f)))
108
109(define package-with-bootstrap-guile
110 (memoize
111 (lambda (p)
112 "Return a variant of P such that all its origins are fetched with
113%BOOTSTRAP-GUILE."
114 (define rewritten-input
115 (match-lambda
116 ((name (? origin? o))
117 `(,name ,(bootstrap-origin o)))
118 ((name (? package? p) sub-drvs ...)
119 `(,name ,(package-with-bootstrap-guile p) ,@sub-drvs))
120 (x x)))
121
122 (package (inherit p)
123 (source (match (package-source p)
124 ((? origin? o) (bootstrap-origin o))
125 (s s)))
126 (inputs (map rewritten-input
127 (package-inputs p)))
128 (native-inputs (map rewritten-input
129 (package-native-inputs p)))
130 (propagated-inputs (map rewritten-input
131 (package-propagated-inputs p)))))))
132
21c203a5 133(define* (glibc-dynamic-linker #:optional (system (%current-system)))
18633d4f
LC
134 "Return the name of Glibc's dynamic linker for SYSTEM."
135 (cond ((string=? system "x86_64-linux") "/lib/ld-linux-x86-64.so.2")
136 ((string=? system "i686-linux") "/lib/ld-linux.so.2")
827d2891 137 ((string=? system "mips64el-linux") "/lib/ld.so.1")
18633d4f
LC
138 (else (error "dynamic linker name not known for this system"
139 system))))
140
141\f
142;;;
143;;; Bootstrap packages.
144;;;
145
146(define %bootstrap-guile
147 ;; The Guile used to run the build scripts of the initial derivations.
148 ;; It is just unpacked from a tarball containing a pre-built binary.
149 ;; This is typically built using %GUILE-BOOTSTRAP-TARBALL below.
150 ;;
151 ;; XXX: Would need libc's `libnss_files2.so' for proper `getaddrinfo'
152 ;; support (for /etc/services).
153 (let ((raw (build-system
154 (name "raw")
155 (description "Raw build system with direct store access")
156 (build (lambda* (store name source inputs #:key outputs system)
157 (define (->store file)
a9ebd9ef 158 (add-to-store store file #t "sha256"
18633d4f
LC
159 (or (search-bootstrap-binary file
160 system)
161 (error "bootstrap binary not found"
162 file system))))
163
164 (let* ((tar (->store "tar"))
165 (xz (->store "xz"))
166 (mkdir (->store "mkdir"))
167 (bash (->store "bash"))
0f099552 168 (guile (->store "guile-2.0.7.tar.xz"))
18633d4f
LC
169 (builder
170 (add-text-to-store store
171 "build-bootstrap-guile.sh"
172 (format #f "
173echo \"unpacking bootstrap Guile to '$out'...\"
174~a $out
175cd $out
176~a -dc < ~a | ~a xv
177
178# Sanity check.
179$out/bin/guile --version~%"
180 mkdir xz guile tar)
181 (list mkdir xz guile tar))))
182 (derivation store name system
183 bash `(,builder) '()
184 `((,bash) (,builder)))))))))
185 (package
186 (name "guile-bootstrap")
187 (version "2.0")
188 (source #f)
189 (build-system raw)
190 (synopsis "Bootstrap Guile")
191 (description "Pre-built Guile for bootstrapping purposes.")
192 (home-page #f)
4a44e743 193 (license lgpl3+))))
18633d4f 194
04732c37 195(define %bootstrap-base-urls
18633d4f 196 ;; This is where the initial binaries come from.
04732c37
LC
197 '("http://alpha.gnu.org/gnu/guix/bootstrap"
198 "http://www.fdn.fr/~lcourtes/software/guix/packages"))
18633d4f
LC
199
200(define %bootstrap-coreutils&co
201 (package-from-tarball "bootstrap-binaries"
202 (lambda (system)
203 (origin
87f5d366 204 (method url-fetch)
04732c37
LC
205 (uri (map (cut string-append <> "/" system
206 "/20130105/static-binaries.tar.xz")
207 %bootstrap-base-urls))
18633d4f
LC
208 (sha256
209 (match system
210 ("x86_64-linux"
211 (base32
79580eb6 212 "0md23alzy6nc5f16pric7mkagczdzr8xbh074sb3rjzrls06j1ls"))
18633d4f
LC
213 ("i686-linux"
214 (base32
79580eb6 215 "0nzj1lmm9b94g7k737cr4w1dv282w5nmhb53238ikax9r6pkc0yb"))))))
18633d4f
LC
216 "true" ; the program to test
217 "Bootstrap binaries of Coreutils, Awk, etc."))
218
219(define %bootstrap-binutils
220 (package-from-tarball "binutils-bootstrap"
221 (lambda (system)
222 (origin
87f5d366 223 (method url-fetch)
04732c37
LC
224 (uri (map (cut string-append <> "/" system
225 "/20130105/binutils-2.22.tar.xz")
226 %bootstrap-base-urls))
18633d4f
LC
227 (sha256
228 (match system
229 ("x86_64-linux"
230 (base32
79580eb6 231 "1ffmk2yy2pxvkqgzrkzp3s4jpn4qaaksyk3b5nsc5cjwfm7qkgzh"))
18633d4f
LC
232 ("i686-linux"
233 (base32
79580eb6 234 "1rafk6aq4sayvv3r3d2khn93nkyzf002xzh0xadlyci4mznr6b0a"))))))
18633d4f
LC
235 "ld" ; the program to test
236 "Bootstrap binaries of the GNU Binutils"))
237
238(define %bootstrap-glibc
239 ;; The initial libc.
240 (package
241 (name "glibc-bootstrap")
242 (version "0")
243 (source #f)
244 (build-system trivial-build-system)
245 (arguments
246 `(#:guile ,%bootstrap-guile
247 #:modules ((guix build utils))
248 #:builder
249 (let ((out (assoc-ref %outputs "out"))
250 (tar (assoc-ref %build-inputs "tar"))
251 (xz (assoc-ref %build-inputs "xz"))
252 (tarball (assoc-ref %build-inputs "tarball")))
253 (use-modules (guix build utils))
254
255 (mkdir out)
256 (copy-file tarball "binaries.tar.xz")
257 (system* xz "-d" "binaries.tar.xz")
258 (let ((builddir (getcwd)))
259 (with-directory-excursion out
260 (system* tar "xvf"
261 (string-append builddir
262 "/binaries.tar"))
263 (chmod "lib" #o755)
264
265 ;; Patch libc.so so it refers to the right path.
266 (substitute* "lib/libc.so"
267 (("/[^ ]+/lib/(libc|ld)" _ prefix)
268 (string-append out "/lib/" prefix))))))))
269 (inputs
dd6b9a37
LC
270 `(("tar" ,(search-bootstrap-binary "tar" (%current-system)))
271 ("xz" ,(search-bootstrap-binary "xz" (%current-system)))
272 ("tarball" ,(bootstrap-origin
273 (origin
274 (method url-fetch)
275 (uri (map (cut string-append <> "/" (%current-system)
276 "/20130105/glibc-2.17.tar.xz")
277 %bootstrap-base-urls))
278 (sha256
279 (match (%current-system)
280 ("x86_64-linux"
281 (base32
282 "18kv1z9d8dr1j3hm9w7663kchqw9p6rsx11n1m143jgba2jz6jy3"))
283 ("i686-linux"
284 (base32
285 "08hv8i0axwnihrcgbz19x0a7s6zyv3yx38x8r29liwl8h82x9g88")))))))))
18633d4f
LC
286 (synopsis "Bootstrap binaries and headers of the GNU C Library")
287 (description #f)
288 (home-page #f)))
289
290(define %bootstrap-gcc
291 ;; The initial GCC. Uses binaries from a tarball typically built by
292 ;; %GCC-BOOTSTRAP-TARBALL.
293 (package
294 (name "gcc-bootstrap")
295 (version "0")
296 (source #f)
297 (build-system trivial-build-system)
298 (arguments
21c203a5
LC
299 `(#:guile ,%bootstrap-guile
300 #:modules ((guix build utils))
301 #:builder
302 (let ((out (assoc-ref %outputs "out"))
303 (tar (assoc-ref %build-inputs "tar"))
304 (xz (assoc-ref %build-inputs "xz"))
305 (bash (assoc-ref %build-inputs "bash"))
306 (libc (assoc-ref %build-inputs "libc"))
307 (tarball (assoc-ref %build-inputs "tarball")))
308 (use-modules (guix build utils)
309 (ice-9 popen))
18633d4f 310
21c203a5
LC
311 (mkdir out)
312 (copy-file tarball "binaries.tar.xz")
313 (system* xz "-d" "binaries.tar.xz")
314 (let ((builddir (getcwd))
315 (bindir (string-append out "/bin")))
316 (with-directory-excursion out
317 (system* tar "xvf"
318 (string-append builddir "/binaries.tar")))
18633d4f 319
21c203a5
LC
320 (with-directory-excursion bindir
321 (chmod "." #o755)
322 (rename-file "gcc" ".gcc-wrapped")
323 (call-with-output-file "gcc"
324 (lambda (p)
325 (format p "#!~a
18633d4f
LC
326exec ~a/bin/.gcc-wrapped -B~a/lib \
327 -Wl,-rpath -Wl,~a/lib \
328 -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
21c203a5
LC
329 bash
330 out libc libc libc
331 ,(glibc-dynamic-linker))))
18633d4f 332
21c203a5 333 (chmod "gcc" #o555))))))
18633d4f 334 (inputs
dd6b9a37
LC
335 `(("tar" ,(search-bootstrap-binary "tar" (%current-system)))
336 ("xz" ,(search-bootstrap-binary "xz" (%current-system)))
337 ("bash" ,(search-bootstrap-binary "bash" (%current-system)))
18633d4f 338 ("libc" ,%bootstrap-glibc)
dd6b9a37
LC
339 ("tarball" ,(bootstrap-origin
340 (origin
341 (method url-fetch)
342 (uri (map (cut string-append <> "/" (%current-system)
343 "/20130105/gcc-4.7.2.tar.xz")
344 %bootstrap-base-urls))
345 (sha256
346 (match (%current-system)
347 ("x86_64-linux"
348 (base32
349 "1x1p7han5crnbw906iwdifykr6grzm0w27dy9gz75j0q1b32i4px"))
350 ("i686-linux"
351 (base32
352 "06wqs0xxnpw3hn0xjb4c9cs0899p1xwkcysa2rvzhvpra0c5vsg2")))))))))
18633d4f
LC
353 (synopsis "Bootstrap binaries of the GNU Compiler Collection")
354 (description #f)
355 (home-page #f)))
356
357(define %bootstrap-inputs
358 ;; The initial, pre-built inputs. From now on, we can start building our
359 ;; own packages.
360 `(("libc" ,%bootstrap-glibc)
361 ("gcc" ,%bootstrap-gcc)
362 ("binutils" ,%bootstrap-binutils)
9d1d434c
LC
363 ("coreutils&co" ,%bootstrap-coreutils&co)
364
365 ;; In gnu-build-system.scm, we rely on the availability of Bash.
366 ("bash" ,%bootstrap-coreutils&co)))
18633d4f
LC
367
368;;; bootstrap.scm ends here