download: Add 'url-fetch/executable'.
[jackhill/guix/guix.git] / gnu / packages / bootstrap.scm
index d1b03eb..50786d9 100644 (file)
@@ -1,7 +1,8 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
-;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -31,7 +32,6 @@
   #:use-module ((guix derivations)
                 #:select (derivation derivation->output-path))
   #:use-module ((guix utils) #:select (gnu-triplet->nix-system))
-  #:use-module ((guix build utils) #:select (elf-file?))
   #:use-module (guix memoization)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
 
             %bootstrap-guile
             %bootstrap-coreutils&co
+            %bootstrap-linux-libre-headers
             %bootstrap-binutils
             %bootstrap-gcc
             %bootstrap-glibc
-            %bootstrap-inputs))
+            %bootstrap-inputs
+            %bootstrap-mescc-tools
+            %bootstrap-mes))
 
 ;;; Commentary:
 ;;;
 (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."
+PROGRAM-TO-TEST is #f or a string: the 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)
     (version "0")
@@ -110,22 +113,25 @@ successful, or false to signal an error."
      `(#:guile ,%bootstrap-guile
        #:modules ((guix build utils))
        #:builder
-       (let ((out     (assoc-ref %outputs "out"))
-             (tar     (assoc-ref %build-inputs "tar"))
-             (xz      (assoc-ref %build-inputs "xz"))
-             (tarball (assoc-ref %build-inputs "tarball")))
+       (begin
          (use-modules (guix build utils))
 
-         (mkdir out)
-         (copy-file tarball "binaries.tar.xz")
-         (system* xz "-d" "binaries.tar.xz")
-         (let ((builddir (getcwd)))
-           (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"))))))))
+         (let ((out     (assoc-ref %outputs "out"))
+              (tar     (assoc-ref %build-inputs "tar"))
+              (xz      (assoc-ref %build-inputs "xz"))
+              (tarball (assoc-ref %build-inputs "tarball")))
+
+          (mkdir out)
+          (copy-file tarball "binaries.tar.xz")
+          (invoke xz "-d" "binaries.tar.xz")
+          (let ((builddir (getcwd)))
+            (with-directory-excursion out
+              (invoke tar "xvf"
+                      (string-append builddir "/binaries.tar"))
+              ,@(if snippet (list snippet) '())
+              (or (not ,program-to-test)
+                  (invoke (string-append "bin/" ,program-to-test)
+                          "--version"))))))))
     (inputs
      `(("tar" ,(search-bootstrap-binary "tar" (%current-system)))
        ("xz"  ,(search-bootstrap-binary "xz" (%current-system)))
@@ -137,7 +143,7 @@ successful, or false to signal an error."
     (license gpl3+)))
 
 (define package-with-bootstrap-guile
-  (mlambda (p)
+  (mlambdaq (p)
     "Return a variant of P such that all its origins are fetched with
 %BOOTSTRAP-GUILE."
     (define rewritten-input
@@ -177,9 +183,12 @@ successful, or false to signal an error."
         ((string=? system "powerpc-linux") "/lib/ld.so.1")
         ((string=? system "powerpc64le-linux") "/lib/ld64.so.2")
         ((string=? system "alpha-linux") "/lib/ld-linux.so.2")
+        ((string=? system "s390x-linux") "/lib/ld64.so.1")
+        ((string=? system "riscv64-linux") "/lib/ld-linux-riscv64-lp64d.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 "arm-elf") "no-ld.so")
         ((string=? system "arm-eabi") "no-ld.so")
         ((string=? system "xtensa-elf") "no-ld.so")
         ((string=? system "avr") "no-ld.so")
@@ -389,8 +398,23 @@ $out/bin/guile --version~%"
                            (if (not (elf-file? "bin/egrep"))
                              (substitute* '("bin/egrep" "bin/fgrep")
                                (("^exec grep") (string-append (getcwd) "/bin/grep"))))
-                           (chmod "bin" #o555)
-                           #t)))
+                           (chmod "bin" #o555))))
+
+(define-public %bootstrap-linux-libre-headers
+  (package-from-tarball
+   "linux-libre-headers-bootstrap"
+   (lambda (system)
+     (origin
+       (method url-fetch)
+       (uri (map (cute string-append <>
+                       "/i686-linux/20181020/"
+                       "linux-libre-headers-stripped-4.14.67-i686-linux.tar.xz")
+                 %bootstrap-base-urls))
+       (sha256
+        (base32
+         "0sm2z9x4wk45bh6qfs94p0w1d6hsy6dqx9sw38qsqbvxwa1qzk8s"))))
+   #f                                   ; no program to test
+   "Bootstrap linux-libre-headers"))
 
 (define %bootstrap-binutils
   (package-from-tarball "binutils-bootstrap"
@@ -437,26 +461,30 @@ $out/bin/guile --version~%"
      `(#:guile ,%bootstrap-guile
        #:modules ((guix build utils))
        #:builder
-       (let ((out     (assoc-ref %outputs "out"))
-             (tar     (assoc-ref %build-inputs "tar"))
-             (xz      (assoc-ref %build-inputs "xz"))
-             (tarball (assoc-ref %build-inputs "tarball")))
+       (begin
          (use-modules (guix build utils))
 
-         (mkdir out)
-         (copy-file tarball "binaries.tar.xz")
-         (system* xz "-d" "binaries.tar.xz")
-         (let ((builddir (getcwd)))
-           (with-directory-excursion out
-             (system* tar "xvf"
+         (let ((out     (assoc-ref %outputs "out"))
+              (tar     (assoc-ref %build-inputs "tar"))
+              (xz      (assoc-ref %build-inputs "xz"))
+              (tarball (assoc-ref %build-inputs "tarball")))
+
+          (mkdir out)
+          (copy-file tarball "binaries.tar.xz")
+          (invoke xz "-d" "binaries.tar.xz")
+          (let ((builddir (getcwd)))
+            (with-directory-excursion out
+              (invoke tar "xvf"
                       (string-append builddir
                                      "/binaries.tar"))
-             (chmod "lib" #o755)
+              (chmod "lib" #o755)
 
-             ;; Patch libc.so so it refers to the right path.
-             (substitute* "lib/libc.so"
-               (("/[^ ]+/lib/(libc|ld)" _ prefix)
-                (string-append out "/lib/" prefix))))))))
+              ;; Patch libc.so so it refers to the right path.
+              (substitute* "lib/libc.so"
+                (("/[^ ]+/lib/(libc|ld)" _ prefix)
+                 (string-append out "/lib/" prefix)))
+
+              #t))))))
     (inputs
      `(("tar" ,(search-bootstrap-binary "tar" (%current-system)))
        ("xz"  ,(search-bootstrap-binary "xz" (%current-system)))
@@ -506,38 +534,41 @@ $out/bin/guile --version~%"
      `(#:guile ,%bootstrap-guile
        #:modules ((guix build utils))
        #:builder
-       (let ((out     (assoc-ref %outputs "out"))
-             (tar     (assoc-ref %build-inputs "tar"))
-             (xz      (assoc-ref %build-inputs "xz"))
-             (bash    (assoc-ref %build-inputs "bash"))
-             (libc    (assoc-ref %build-inputs "libc"))
-             (tarball (assoc-ref %build-inputs "tarball")))
+       (begin
          (use-modules (guix build utils)
                       (ice-9 popen))
 
-         (mkdir out)
-         (copy-file tarball "binaries.tar.xz")
-         (system* xz "-d" "binaries.tar.xz")
-         (let ((builddir (getcwd))
-               (bindir   (string-append out "/bin")))
-           (with-directory-excursion out
-             (system* tar "xvf"
-                      (string-append builddir "/binaries.tar")))
-
-           (with-directory-excursion bindir
-             (chmod "." #o755)
-             (rename-file "gcc" ".gcc-wrapped")
-             (call-with-output-file "gcc"
-               (lambda (p)
-                 (format p "#!~a
+         (let ((out     (assoc-ref %outputs "out"))
+               (tar     (assoc-ref %build-inputs "tar"))
+               (xz      (assoc-ref %build-inputs "xz"))
+               (bash    (assoc-ref %build-inputs "bash"))
+               (libc    (assoc-ref %build-inputs "libc"))
+               (tarball (assoc-ref %build-inputs "tarball")))
+
+           (mkdir out)
+           (copy-file tarball "binaries.tar.xz")
+           (invoke xz "-d" "binaries.tar.xz")
+           (let ((builddir (getcwd))
+                 (bindir   (string-append out "/bin")))
+             (with-directory-excursion out
+               (invoke tar "xvf"
+                       (string-append builddir "/binaries.tar")))
+
+             (with-directory-excursion bindir
+               (chmod "." #o755)
+               (rename-file "gcc" ".gcc-wrapped")
+               (call-with-output-file "gcc"
+                 (lambda (p)
+                   (format p "#!~a
 exec ~a/bin/.gcc-wrapped -B~a/lib \
      -Wl,-rpath -Wl,~a/lib \
      -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
-                         bash
-                         out libc libc libc
-                         ,(glibc-dynamic-linker))))
+                           bash
+                           out libc libc libc
+                           ,(glibc-dynamic-linker))))
 
-             (chmod "gcc" #o555))))))
+               (chmod "gcc" #o555)
+               #t))))))
     (inputs
      `(("tar" ,(search-bootstrap-binary "tar" (%current-system)))
        ("xz"  ,(search-bootstrap-binary "xz" (%current-system)))
@@ -545,33 +576,33 @@ exec ~a/bin/.gcc-wrapped -B~a/lib \
        ("libc" ,%bootstrap-glibc)
        ("tarball" ,(bootstrap-origin
                     (origin
-                     (method url-fetch)
-                     (uri (map (cut string-append <> "/" (%current-system)
-                                    (match (%current-system)
-                                      ("armhf-linux"
-                                       "/20150101/gcc-4.8.4.tar.xz")
-                                      ("aarch64-linux"
-                                       "/20170217/gcc-5.4.0.tar.xz")
-                                      (_
-                                       "/20131110/gcc-4.8.2.tar.xz")))
-                               %bootstrap-base-urls))
-                     (sha256
-                      (match (%current-system)
-                        ("x86_64-linux"
-                         (base32
-                          "17ga4m6195n4fnbzdkmik834znkhs53nkypp6557pl1ps7dgqbls"))
-                        ("i686-linux"
-                         (base32
-                          "150c1arrf2k8vfy6dpxh59vcgs4p1bgiz2av5m19dynpks7rjnyw"))
-                        ("armhf-linux"
-                         (base32
-                          "0ghz825yzp43fxw53kd6afm8nkz16f7dxi9xi40bfwc8x3nbbr8v"))
-                        ("aarch64-linux"
-                         (base32
-                          "1ar3vdzyqbfm0z36kmvazvfswxhcihlacl2dzdjgiq25cqnq9ih1"))
-                        ("mips64el-linux"
-                         (base32
-                          "1m5miqkyng45l745n0sfafdpjkqv9225xf44jqkygwsipj2cv9ks")))))))))
+                      (method url-fetch)
+                      (uri (map (cut string-append <> "/" (%current-system)
+                                     (match (%current-system)
+                                       ("armhf-linux"
+                                        "/20150101/gcc-4.8.4.tar.xz")
+                                       ("aarch64-linux"
+                                        "/20170217/gcc-5.4.0.tar.xz")
+                                       (_
+                                        "/20131110/gcc-4.8.2.tar.xz")))
+                                %bootstrap-base-urls))
+                      (sha256
+                       (match (%current-system)
+                         ("x86_64-linux"
+                          (base32
+                           "17ga4m6195n4fnbzdkmik834znkhs53nkypp6557pl1ps7dgqbls"))
+                         ("i686-linux"
+                          (base32
+                           "150c1arrf2k8vfy6dpxh59vcgs4p1bgiz2av5m19dynpks7rjnyw"))
+                         ("armhf-linux"
+                          (base32
+                           "0ghz825yzp43fxw53kd6afm8nkz16f7dxi9xi40bfwc8x3nbbr8v"))
+                         ("aarch64-linux"
+                          (base32
+                           "1ar3vdzyqbfm0z36kmvazvfswxhcihlacl2dzdjgiq25cqnq9ih1"))
+                         ("mips64el-linux"
+                          (base32
+                           "1m5miqkyng45l745n0sfafdpjkqv9225xf44jqkygwsipj2cv9ks")))))))))
     (native-search-paths
      (list (search-path-specification
             (variable "CPATH")
@@ -584,12 +615,116 @@ exec ~a/bin/.gcc-wrapped -B~a/lib \
     (home-page #f)
     (license gpl3+)))
 
-(define %bootstrap-inputs
+(define %bootstrap-mescc-tools
+  ;; The initial MesCC tools.  Uses binaries from a tarball typically built by
+  ;; %MESCC-TOOLS-BOOTSTRAP-TARBALL.
+  (package
+    (name "bootstrap-mescc-tools")
+    (version "0.5.2")
+    (source #f)
+    (build-system trivial-build-system)
+    (arguments
+     `(#:guile ,%bootstrap-guile
+       #:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils)
+                      (ice-9 popen))
+         (let ((out     (assoc-ref %outputs "out"))
+               (tar     (assoc-ref %build-inputs "tar"))
+               (xz      (assoc-ref %build-inputs "xz"))
+               (tarball (assoc-ref %build-inputs "tarball")))
+
+           (mkdir out)
+           (copy-file tarball "binaries.tar.xz")
+           (invoke xz "-d" "binaries.tar.xz")
+           (let ((builddir (getcwd))
+                 (bindir   (string-append out "/bin")))
+             (with-directory-excursion out
+               (invoke tar "xvf"
+                       (string-append builddir "/binaries.tar"))))))))
+    (inputs
+     `(("tar" ,(search-bootstrap-binary "tar" (%current-system)))
+       ("xz"  ,(search-bootstrap-binary "xz" (%current-system)))
+       ("tarball"
+        ,(bootstrap-origin
+          (origin
+            (method url-fetch)
+            (uri (map
+                  (cute string-append <>
+                        "/i686-linux/20181020/"
+                        "mescc-tools-static-0.5.2-0.bb062b0-i686-linux.tar.xz")
+                  %bootstrap-base-urls))
+            (sha256
+             (base32
+              "11lniw0vg61kmyhvnwkmcnkci9ym6hbmiksiqggd0hkipbq7hvlz")))))))
+    (synopsis "Bootstrap binaries of MesCC Tools")
+    (description synopsis)
+    (home-page #f)
+    (supported-systems '("i686-linux" "x86_64-linux"))
+    (license gpl3+)))
+
+(define %bootstrap-mes
+  ;; The initial Mes.  Uses binaries from a tarball typically built by
+  ;; %MES-BOOTSTRAP-TARBALL.
+  (package
+    (name "bootstrap-mes")
+    (version "0")
+    (source #f)
+    (build-system trivial-build-system)
+    (arguments
+     `(#:guile ,%bootstrap-guile
+       #:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils)
+                      (ice-9 popen))
+         (let ((out     (assoc-ref %outputs "out"))
+               (tar     (assoc-ref %build-inputs "tar"))
+               (xz      (assoc-ref %build-inputs "xz"))
+               (tarball (assoc-ref %build-inputs "tarball")))
+
+           (mkdir out)
+           (copy-file tarball "binaries.tar.xz")
+           (invoke xz "-d" "binaries.tar.xz")
+           (let ((builddir (getcwd))
+                 (bindir   (string-append out "/bin")))
+             (with-directory-excursion out
+               (invoke tar "xvf"
+                       (string-append builddir "/binaries.tar"))))))))
+    (inputs
+     `(("tar" ,(search-bootstrap-binary "tar" (%current-system)))
+       ("xz"  ,(search-bootstrap-binary "xz" (%current-system)))
+       ("tarball"
+        ,(bootstrap-origin
+          (origin
+            (method url-fetch)
+            (uri (map
+                  (cute string-append <>
+                        "/i686-linux/20181020/"
+                        "mes-minimal-stripped-0.19-i686-linux.tar.xz")
+                  %bootstrap-base-urls))
+            (sha256
+             (base32
+              "0k7kkl68a6xaadv47ij0nr9jm5ca1ffj38n7f2lg80y72wdkwr9h")))))))
+    (supported-systems '("i686-linux" "x86_64-linux"))
+    (synopsis "Bootstrap binaries of Mes")
+    (description synopsis)
+    (home-page #f)
+    (license gpl3+)))
+
+(define (%bootstrap-inputs)
   ;; The initial, pre-built inputs.  From now on, we can start building our
   ;; own packages.
-  `(("libc" ,%bootstrap-glibc)
-    ("gcc" ,%bootstrap-gcc)
-    ("binutils" ,%bootstrap-binutils)
+  `(,@(match (%current-system)
+        ((or "i686-linux" "x86_64-linux")
+         `(("linux-libre-headers" ,%bootstrap-linux-libre-headers)
+           ("bootstrap-mescc-tools" ,%bootstrap-mescc-tools)
+           ("mes" ,%bootstrap-mes)))
+        (_
+         `(("libc" ,%bootstrap-glibc)
+           ("gcc" ,%bootstrap-gcc)
+           ("binutils" ,%bootstrap-binutils))))
     ("coreutils&co" ,%bootstrap-coreutils&co)
 
     ;; In gnu-build-system.scm, we rely on the availability of Bash.