Subject: [PATCH 2/2] bootstrap: Add m2-planet-boot0.

From: Jan Nieuwenhuizen <[email-masked]>
Date: Mon, 4 Nov 2019 23:42:43 +0100

* gnu/packages/commencement.scm (m2-planet-boot0): New variable.
---
 gnu/packages/commencement.scm | 103 +++++++++++++++++++++++++++++++++-
 1 file changed, 102 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index 54746151ce..31722b4cf3 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -5,7 +5,7 @@
 ;;; Copyright © 2014, 2015, 2017 Mark H Weaver <[email-masked]>
 ;;; Copyright © 2017, 2018, 2019 Efraim Flashner <[email-masked]>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <[email-masked]>
-;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <[email-masked]>
+;;; Copyright © 2018, 2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
 ;;; Copyright © 2019 Marius Bakke <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -84,6 +84,107 @@
 ;;;
 ;;; Code:
 
+(define-public m2-planet-boot0
+  ;; The soon-to-be initial bootstrap package: no binary inputs except for a
+  ;; ~500 byte binary seed: `x86/hex0-seed'.
+  (let* ((version "1.4.0")
+         (revision "0")
+         (commit "1fc2aeab483208bd2ba117b21df3894c182470ec")
+         (seed-version "Release_1.1")
+         (mescc-tools-version "Release_0.6.1")
+         (mes-m2-commit "f025a24b19e8447fb96ba1746bdad494ae63a514")
+         (mes-m2-version (string-append "0.19-" (string-take mes-m2-commit 7))))
+    (package
+      (inherit m2-planet)
+      (name "m2-planet-boot0")
+      (version (string-append version "-" revision "." (string-take commit 7)))
+      (source (origin
+                (method url-fetch)
+                (uri (string-append
+                      "https://github.com/oriansj/m2-planet"
+                      "/archive/" commit ".tar.gz"))
+                (file-name (string-append "mescc-tools-seed-" version ".tar.gz"))
+                (sha256
+                 (base32
+                  "09dfbhrkfq754lkk9qqsa95rgfp5crdwy8l4db97qwfclr0y914z"))))
+      (inputs `(("mescc-tools-seed"
+                 ,(bootstrap-origin
+                   (origin
+                     (method url-fetch)
+                     (uri (string-append
+                           "https://github.com/oriansj/mescc-tools-seed"
+                           "/archive/" seed-version ".tar.gz"))
+                     (file-name (string-append "mescc-tools-seed-" seed-version
+                                               ".tar.gz"))
+                     (sha256
+                      (base32
+                       "1ymkaanx3b9x8y3n4x0kpqxyjcql3gpv37hp1cbzvhwh89yqy6m4")))))
+                ("mescc-tools-source"
+                 ,(bootstrap-origin
+                   (origin
+                     (method url-fetch)
+                     (uri (string-append
+                           "https://github.com/oriansj/mescc-tools"
+                           "/archive/" mescc-tools-version ".tar.gz"))
+                     (file-name (string-append "mescc-tools-"
+                                               mescc-tools-version
+                                               ".tar.gz"))
+                     (sha256
+                      (base32
+                       "06jpvq6xfjzn2al6b4rdwd3zv3h4cvilc4n9gqcnjr9cr6wjpw2n")))))
+                ("mes-m2-source"
+                 ,(bootstrap-origin
+                   (origin
+                     (method url-fetch)
+                     (uri (string-append
+                           "https://github.com/oriansj/mes-m2"
+                           "/archive/" mes-m2-commit ".tar.gz"))
+                     (file-name (string-append "mes-m2-"
+                                               mes-m2-version
+                                               ".tar.gz"))
+                     (sha256
+                      (base32
+                       "092ydx21cms8rkgx5dfndxi4hrw9jqw9r266h4rsvycpv2lw6kp1")))))))
+      (native-inputs
+       `(("coreutils" , %bootstrap-coreutils&co)
+         ("guile" , %bootstrap-guile)))
+      (supported-systems '("i686-linux" "x86_64-linux"))
+      (build-system trivial-build-system)
+      (arguments
+       `(#:guile ,%bootstrap-guile
+         #:modules ((guix build utils))
+         #:builder (begin
+                     (use-modules (guix build utils))
+                     (let* ((mescc-tools-seed (assoc-ref %build-inputs "mescc-tools-seed"))
+                            (mescc-tools-source (assoc-ref %build-inputs "mescc-tools-source"))
+                            (mes-m2-source (assoc-ref %build-inputs "mes-m2-source"))
+                            (source (assoc-ref %build-inputs "source"))
+                            (dir (string-append "mescc-tools-seed-" ,seed-version))
+                            (coreutils (assoc-ref %build-inputs "coreutils"))
+                            (guile     (assoc-ref %build-inputs "guile"))
+                            (out       (assoc-ref %outputs "out"))
+                            (bindir    (string-append out "/bin")))
+                       (setenv "PATH" (string-append coreutils "/bin"))
+                       (invoke "tar" "--strip-components=1" "-xvf" mescc-tools-seed)
+                       (invoke "tar" "--strip-components=1" "-C" "mescc-tools" "-xvf" mescc-tools-source)
+                       (invoke "tar" "--strip-components=1" "-C" "M2-Planet" "-xvf" source)
+                       (invoke "tar" "--strip-components=1" "-C" "mes-m2" "-xvf" mes-m2-source)
+                       (mkdir-p bindir)
+                       (with-directory-excursion "x86"
+                         (invoke "../kaem-optional-seed" "--verbose" "--strict"))
+                       (with-directory-excursion "bin"
+                         (copy-file "mes-m2" "mes")
+                         (install-file "hex2" bindir)
+                         (install-file "M1" bindir)
+                         (install-file "blood-elf" bindir)
+                         (install-file "kaem" bindir)
+                         (install-file "get_machine" bindir)
+                         (install-file "get_machine" bindir)
+                         (install-file "M2-Planet" bindir)
+                         (install-file "mes" bindir)
+                         (install-file "mes-m2" bindir))
+                       #t)))))))
+
 (define mes-boot
   (package
     (inherit mes)
-- 
2.23.0