gnu: Add setBfree.
[jackhill/guix/guix.git] / gnu / packages / bootstrap.scm
index ffe1ec6..1f0fe16 100644 (file)
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
   "Return a variant of SOURCE, an <origin> instance, whose method uses
 %BOOTSTRAP-GUILE to do its job."
   (define (boot fetch)
-    (lambda* (store url hash-algo hash
+    (lambda* (url hash-algo hash
               #:optional name #:key system)
-      (fetch store url hash-algo hash
+      (fetch url hash-algo hash
              #:guile %bootstrap-guile
              #:system system)))
 
+  (define %bootstrap-patch-inputs
+    ;; Packages used when an <origin> has a non-empty 'patches' field.
+    `(("tar"   ,%bootstrap-coreutils&co)
+      ("xz"    ,%bootstrap-coreutils&co)
+      ("bzip2" ,%bootstrap-coreutils&co)
+      ("gzip"  ,%bootstrap-coreutils&co)
+      ("patch" ,%bootstrap-coreutils&co)))
+
   (let ((orig-method (origin-method source)))
     (origin (inherit source)
       (method (cond ((eq? orig-method url-fetch)
                      (boot url-fetch))
-                    (else orig-method))))))
+                    (else orig-method)))
+      (patch-guile %bootstrap-guile)
+      (patch-inputs %bootstrap-patch-inputs)
+
+      ;; Patches can be origins as well, so process them.
+      (patches (map (match-lambda
+                     ((? origin? patch)
+                      (bootstrap-origin patch))
+                     (patch patch))
+                    (origin-patches source))))))
 
-(define (package-from-tarball name* source* program-to-test description*)
-  "Return a package that correspond to the extraction of SOURCE*.
-PROGRAM-TO-TEST is a program to run after extraction of SOURCE*, to
-check whether everything is alright."
+(define* (package-from-tarball name source program-to-test description
+                               #:key snippet)
+  "Return a package that correspond to the extraction of SOURCE.
+PROGRAM-TO-TEST is a program to run after extraction of SOURCE, to
+check whether everything is alright.  If SNIPPET is provided, it is
+evaluated after extracting SOURCE.  SNIPPET should return true if
+successful, or false to signal an error."
   (package
-    (name name*)
+    (name name)
     (version "0")
-    (source #f)
     (build-system trivial-build-system)
     (arguments
      `(#:guile ,%bootstrap-guile
@@ -96,13 +116,15 @@ check whether everything is alright."
            (with-directory-excursion out
              (and (zero? (system* tar "xvf"
                                   (string-append builddir "/binaries.tar")))
+                  ,@(if snippet (list snippet) '())
                   (zero? (system* (string-append "bin/" ,program-to-test)
                                   "--version"))))))))
     (inputs
      `(("tar" ,(search-bootstrap-binary "tar" (%current-system)))
        ("xz"  ,(search-bootstrap-binary "xz" (%current-system)))
-       ("tarball" ,(bootstrap-origin (source* (%current-system))))))
-    (synopsis description*)
+       ("tarball" ,(bootstrap-origin (source (%current-system))))))
+    (source #f)
+    (synopsis description)
     (description #f)
     (home-page #f)
     (license #f)))
@@ -129,12 +151,25 @@ check whether everything is alright."
       (native-inputs (map rewritten-input
                           (package-native-inputs p)))
       (propagated-inputs (map rewritten-input
-                              (package-propagated-inputs p)))))))
+                              (package-propagated-inputs p)))
+      (replacement (and=> (package-replacement p)
+                          package-with-bootstrap-guile))))))
 
-(define* (glibc-dynamic-linker #:optional (system (%current-system)))
+(define* (glibc-dynamic-linker
+          #:optional (system (or (and=> (%current-target-system)
+                                        gnu-triplet->nix-system)
+                                 (%current-system))))
   "Return the name of Glibc's dynamic linker for SYSTEM."
   (cond ((string=? system "x86_64-linux") "/lib/ld-linux-x86-64.so.2")
         ((string=? system "i686-linux") "/lib/ld-linux.so.2")
+        ((string=? system "armhf-linux") "/lib/ld-linux-armhf.so.3")
+        ((string=? system "mips64el-linux") "/lib/ld.so.1")
+
+        ;; XXX: This one is used bare-bones, without a libc, so add a case
+        ;; here just so we can keep going.
+        ((string=? system "xtensa-elf") "no-ld.so")
+        ((string=? system "avr") "no-ld.so")
+
         (else (error "dynamic linker name not known for this system"
                      system))))
 
@@ -143,6 +178,52 @@ check whether everything is alright."
 ;;; Bootstrap packages.
 ;;;
 
+(define* (raw-build store name inputs
+                    #:key outputs system search-paths
+                    #:allow-other-keys)
+  (define (->store file)
+    (add-to-store store file #t "sha256"
+                  (or (search-bootstrap-binary file
+                                               system)
+                      (error "bootstrap binary not found"
+                             file system))))
+
+  (let* ((tar   (->store "tar"))
+         (xz    (->store "xz"))
+         (mkdir (->store "mkdir"))
+         (bash  (->store "bash"))
+         (guile (->store (match system
+                           ("armhf-linux"
+                            "guile-2.0.11.tar.xz")
+                           (_
+                            "guile-2.0.9.tar.xz"))))
+         (builder
+          (add-text-to-store store
+                             "build-bootstrap-guile.sh"
+                             (format #f "
+echo \"unpacking bootstrap Guile to '$out'...\"
+~a $out
+cd $out
+~a -dc < ~a | ~a xv
+
+# Sanity check.
+$out/bin/guile --version~%"
+                                     mkdir xz guile tar)
+                             (list mkdir xz guile tar))))
+    (derivation store name
+                bash `(,builder)
+                #:system system
+                #:inputs `((,bash) (,builder)))))
+
+(define* (make-raw-bag name
+                       #:key source inputs native-inputs outputs
+                       system target)
+  (bag
+    (name name)
+    (system system)
+    (build-inputs inputs)
+    (build raw-build)))
+
 (define %bootstrap-guile
   ;; The Guile used to run the build scripts of the initial derivations.
   ;; It is just unpacked from a tarball containing a pre-built binary.
@@ -151,37 +232,9 @@ check whether everything is alright."
   ;; XXX: Would need libc's `libnss_files2.so' for proper `getaddrinfo'
   ;; support (for /etc/services).
   (let ((raw (build-system
-              (name "raw")
-              (description "Raw build system with direct store access")
-              (build (lambda* (store name source inputs #:key outputs system)
-                       (define (->store file)
-                         (add-to-store store file #t "sha256"
-                                       (or (search-bootstrap-binary file
-                                                                    system)
-                                           (error "bootstrap binary not found"
-                                                  file system))))
-
-                       (let* ((tar   (->store "tar"))
-                              (xz    (->store "xz"))
-                              (mkdir (->store "mkdir"))
-                              (bash  (->store "bash"))
-                              (guile (->store "guile-2.0.7.tar.xz"))
-                              (builder
-                               (add-text-to-store store
-                                                  "build-bootstrap-guile.sh"
-                                                  (format #f "
-echo \"unpacking bootstrap Guile to '$out'...\"
-~a $out
-cd $out
-~a -dc < ~a | ~a xv
-
-# Sanity check.
-$out/bin/guile --version~%"
-                                                          mkdir xz guile tar)
-                                                  (list mkdir xz guile tar))))
-                         (derivation store name system
-                                     bash `(,builder) '()
-                                     `((,bash) (,builder)))))))))
+               (name 'raw)
+               (description "Raw build system with direct store access")
+               (lower make-raw-bag))))
    (package
      (name "guile-bootstrap")
      (version "2.0")
@@ -203,18 +256,35 @@ $out/bin/guile --version~%"
                           (origin
                            (method url-fetch)
                            (uri (map (cut string-append <> "/" system
-                                          "/20130105/static-binaries.tar.xz")
+                                          (match system
+                                            ("armhf-linux"
+                                             "/20150101/static-binaries.tar.xz")
+                                            (_
+                                             "/20131110/static-binaries.tar.xz")))
                                      %bootstrap-base-urls))
                            (sha256
                             (match system
                               ("x86_64-linux"
                                (base32
-                                "0md23alzy6nc5f16pric7mkagczdzr8xbh074sb3rjzrls06j1ls"))
+                                "0c533p9dhczzcsa1117gmfq3pc8w362g4mx84ik36srpr7cx2bg4"))
                               ("i686-linux"
                                (base32
-                                "0nzj1lmm9b94g7k737cr4w1dv282w5nmhb53238ikax9r6pkc0yb"))))))
-                        "true"                    ; the program to test
-                        "Bootstrap binaries of Coreutils, Awk, etc."))
+                                "0s5b3jb315n13m1k8095l0a5hfrsz8g0fv1b6riyc5hnxqyphlak"))
+                              ("armhf-linux"
+                               (base32
+                                "0gf0fn2kbpxkjixkmx5f4z6hv6qpmgixl69zgg74dbsfdfj8jdv5"))
+                              ("mips64el-linux"
+                               (base32
+                                "072y4wyfsj1bs80r6vbybbafy8ya4vfy7qj25dklwk97m6g71753"))))))
+                        "fgrep"                    ; the program to test
+                        "Bootstrap binaries of Coreutils, Awk, etc."
+                        #:snippet
+                        '(let ((path (list (string-append (getcwd) "/bin"))))
+                           (chmod "bin" #o755)
+                           (patch-shebang "bin/egrep" path)
+                           (patch-shebang "bin/fgrep" path)
+                           (chmod "bin" #o555)
+                           #t)))
 
 (define %bootstrap-binutils
   (package-from-tarball "binutils-bootstrap"
@@ -222,16 +292,26 @@ $out/bin/guile --version~%"
                           (origin
                            (method url-fetch)
                            (uri (map (cut string-append <> "/" system
-                                          "/20130105/binutils-2.22.tar.xz")
+                                          (match system
+                                            ("armhf-linux"
+                                             "/20150101/binutils-2.25.tar.xz")
+                                            (_
+                                             "/20131110/binutils-2.23.2.tar.xz")))
                                      %bootstrap-base-urls))
                            (sha256
                             (match system
                               ("x86_64-linux"
                                (base32
-                                "1ffmk2yy2pxvkqgzrkzp3s4jpn4qaaksyk3b5nsc5cjwfm7qkgzh"))
+                                "1j5yivz7zkjqfsfmxzrrrffwyayjqyfxgpi89df0w4qziqs2dg20"))
                               ("i686-linux"
                                (base32
-                                "1rafk6aq4sayvv3r3d2khn93nkyzf002xzh0xadlyci4mznr6b0a"))))))
+                                "14jgwf9gscd7l2pnz610b1zia06dvcm2qyzvni31b8zpgmcai2v9"))
+                              ("armhf-linux"
+                               (base32
+                                "1v7dj6bzn6m36f20gw31l99xaabq4xrhrx3gwqkhhig0mdlmr69q"))
+                              ("mips64el-linux"
+                               (base32
+                                "1x8kkhcxmfyzg1ddpz2pxs6fbdl6412r7x0nzbmi5n7mj8zw2gy7"))))))
                         "ld"                      ; the program to test
                         "Bootstrap binaries of the GNU Binutils"))
 
@@ -273,16 +353,26 @@ $out/bin/guile --version~%"
                     (origin
                      (method url-fetch)
                      (uri (map (cut string-append <> "/" (%current-system)
-                                    "/20130105/glibc-2.17.tar.xz")
+                                    (match (%current-system)
+                                      ("armhf-linux"
+                                       "/20150101/glibc-2.20.tar.xz")
+                                      (_
+                                       "/20131110/glibc-2.18.tar.xz")))
                                %bootstrap-base-urls))
                      (sha256
                       (match (%current-system)
                         ("x86_64-linux"
                          (base32
-                          "18kv1z9d8dr1j3hm9w7663kchqw9p6rsx11n1m143jgba2jz6jy3"))
+                          "0jlqrgavvnplj1b083s20jj9iddr4lzfvwybw5xrcis9spbfzk7v"))
                         ("i686-linux"
                          (base32
-                          "08hv8i0axwnihrcgbz19x0a7s6zyv3yx38x8r29liwl8h82x9g88")))))))))
+                          "1hgrccw1zqdc7lvgivwa54d9l3zsim5pqm0dykxg0z522h6gr05w"))
+                        ("armhf-linux"
+                         (base32
+                          "18cmgvpllqfpn6khsmivqib7ys8ymnq0hdzi3qp24prik0ykz8gn"))
+                        ("mips64el-linux"
+                         (base32
+                          "0k97a3whzx3apsi9n2cbsrr79ad6lh00klxph9hw4fqyp1abkdsg")))))))))
     (synopsis "Bootstrap binaries and headers of the GNU C Library")
     (description #f)
     (home-page #f)
@@ -341,16 +431,33 @@ exec ~a/bin/.gcc-wrapped -B~a/lib \
                     (origin
                      (method url-fetch)
                      (uri (map (cut string-append <> "/" (%current-system)
-                                    "/20130105/gcc-4.7.2.tar.xz")
+                                    (match (%current-system)
+                                      ("armhf-linux"
+                                       "/20150101/gcc-4.8.4.tar.xz")
+                                      (_
+                                       "/20131110/gcc-4.8.2.tar.xz")))
                                %bootstrap-base-urls))
                      (sha256
                       (match (%current-system)
                         ("x86_64-linux"
                          (base32
-                          "1x1p7han5crnbw906iwdifykr6grzm0w27dy9gz75j0q1b32i4px"))
+                          "17ga4m6195n4fnbzdkmik834znkhs53nkypp6557pl1ps7dgqbls"))
                         ("i686-linux"
                          (base32
-                          "06wqs0xxnpw3hn0xjb4c9cs0899p1xwkcysa2rvzhvpra0c5vsg2")))))))))
+                          "150c1arrf2k8vfy6dpxh59vcgs4p1bgiz2av5m19dynpks7rjnyw"))
+                        ("armhf-linux"
+                         (base32
+                          "0ghz825yzp43fxw53kd6afm8nkz16f7dxi9xi40bfwc8x3nbbr8v"))
+                        ("mips64el-linux"
+                         (base32
+                          "1m5miqkyng45l745n0sfafdpjkqv9225xf44jqkygwsipj2cv9ks")))))))))
+    (native-search-paths
+     (list (search-path-specification
+            (variable "CPATH")
+            (files '("include")))
+           (search-path-specification
+            (variable "LIBRARY_PATH")
+            (files '("lib" "lib64")))))
     (synopsis "Bootstrap binaries of the GNU Compiler Collection")
     (description #f)
     (home-page #f)