janneke pushed a commit to branch wip-bootstrap
in repository guix.
commit 6281e1de32f400672d0e7bd89847bc372a47918d
Author: Jan Nieuwenhuizen <[email protected]>
Date: Sun Dec 8 20:37:55 2019 +0100
bootstrap: Add %bootstrap-mes-rewired.
* gnu/packages/commencement.scm (%bootstrap-mes-rewired): New variable.
---
gnu/packages/commencement.scm | 77 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index f87c875..4dc3b60 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -396,6 +396,83 @@
("guile" ,%bootstrap-guile)
("guile+guild" ,%bootstrap-guile+guild)))
+(define %bootstrap-mes-rewired
+ (package
+ (inherit mes)
+ (name "bootstrap-mes-rewired")
+ (version "0.19")
+ (source #f)
+ (native-inputs `(("mes" ,(@ (gnu packages bootstrap) %bootstrap-mes))
+ ("gash" ,gash-boot)))
+ (inputs '())
+ (propagated-inputs '())
+ (outputs '("out"))
+ (build-system trivial-build-system)
+ (arguments
+ `(#:guile ,%bootstrap-guile
+ #:modules ((guix build utils)
+ (srfi srfi-26))
+ #:builder (begin
+ (use-modules (guix build utils)
+ (srfi srfi-26))
+ (let* ((mes (assoc-ref %build-inputs "mes"))
+ (gash (assoc-ref %build-inputs "gash"))
+ (mes-bin (string-append mes "/bin"))
+ (guile (string-append mes-bin "/mes"))
+ (mes-module (string-append mes "/share/mes/module"))
+ (out (assoc-ref %outputs "out"))
+ (bin (string-append out "/bin"))
+ (mescc (string-append bin "/mescc"))
+ (module (string-append out "/share/mes/module"))
+)
+ (define (rewire file)
+ (substitute* file
+ ((mes) out)
+ (("/gnu/store[^ ]+mes-minimal-[^/)}\"]*") out)
+ (("/gnu/store[^ ]+guile-[^/]*/bin/guile") guile)
+ (("/gnu/store[^ ]+bash-[^/)}\"]*") gash)))
+
+ (mkdir-p bin)
+ (for-each (lambda (file) (install-file file bin))
+ (find-files mes-bin))
+ (mkdir-p module)
+ (copy-recursively (string-append mes-module "/mes")
+ (string-append module "/mes"))
+ (copy-recursively (string-append mes-module "/srfi")
+ (string-append module "/srfi"))
+ (for-each rewire
+ ;; Cannot easily rewire "mes" because it
+ ;; contains NUL characters; would require
+ ;; remove-store-references alike trick
+ (filter (negate (cut string-suffix? "/mes" <>))
+ (find-files bin)))
+ (rewire (string-append module "/mes/boot-0.scm"))
+
+ (delete-file mescc)
+ (with-output-to-file mescc
+ (lambda _
+ (display (string-append
+ "\
+#! " gash "/bin/sh
+LANG=C
+LC_ALL=C
+export LANG LC_ALL
+
+#MES_PREFIX=${MES_REWIRED_PREFIX-$PWD}
+MES_PREFIX=${MES_REWIRED_PREFIX-" mes "/share/mes}
+MES=" bin "/mes
+export MES MES_PREFIX
+
+MES_ARENA=${MES_REWIRED_ARENA-10000000}
+MES_MAX_ARENA=${MES_REWIRED_ARENA-10000000}
+MES_STACK=${MES_REWIRED_STACK-1000000}
+export MES_ARENA MES_MAX_ARENA MES_STACK
+
+$MES -e '(mescc)' module/mescc.scm -- \"$@\"
+"))))
+ (chmod mescc #o555)
+ #t))))))
+
(define mes-boot
(package
(inherit mes)