From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
To: 41350@debbugs.gnu.org, Mathieu Othacehe <othacehe@gnu.org>
Cc: "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#41350] [PATCH v2 3/3] system: vm: Build vm-image using native qemu, for the Hurd.
Date: Tue, 19 May 2020 09:23:02 +0200 [thread overview]
Message-ID: <20200519072302.9202-3-janneke@gnu.org> (raw)
In-Reply-To: <20200519072302.9202-1-janneke@gnu.org>
Cross-building a vm-image is usually done using a cross-qemu, e.g, qemu-ARM,
because, e.g., a native, x86_64 Grub cannot install an armhf-Grub. That
solution does not work for the Hurd, as there is no qemu-HURD.
This patch enables cross building vm-images for the Hurd using a native qemu
vm.
* gnu/system/vm.scm (expression->derivation-in-linux-vm): Run native
qemu-command; use native linux, initrd, bootloader-package and
bootloader-installer, for the Hurd.
[preserve-target]: New helper to install cross-packages into the native vm.
* gnu/bootloader/grub.scm (eye-candy): Use native font, for the Hurd.
Co-authored-by: Ludovic Courtès <ludo@gnu.org>
---
gnu/bootloader/grub.scm | 9 +++--
gnu/system/vm.scm | 78 +++++++++++++++++++++++++++++++----------
2 files changed, 66 insertions(+), 21 deletions(-)
diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 8c5b5eac0c..cee4c9f6c5 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -31,6 +31,7 @@
#:use-module (gnu system file-systems)
#:use-module (gnu system keyboard)
#:use-module (gnu packages bootloaders)
+ #:use-module (gnu packages hurd)
#:autoload (gnu packages gtk) (guile-cairo guile-rsvg)
#:autoload (gnu packages xorg) (xkeyboard-config)
#:use-module (ice-9 match)
@@ -211,8 +212,12 @@ else
set menu_color_highlight=white/blue
fi~%"
#$setup-gfxterm-body
- #$(grub-root-search store-device font-file)
- #$(setup-gfxterm config font-file)
+ #$(if (hurd-target?)
+ #~#+(grub-root-search store-device font-file)
+ (grub-root-search store-device font-file))
+ #$(if (hurd-target?)
+ #~#+(setup-gfxterm config font-file)
+ (setup-gfxterm config font-file))
#$(grub-setup-io config)
#$(strip-mount-point store-mount-point image)
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index b343141c18..527596421d 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2018 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -181,19 +182,36 @@ made available under the /xchg CIFS share.
SUBSTITUTABLE? determines whether the returned derivation should be marked as
substitutable."
(define user-builder
- (program-file "builder-in-linux-vm" exp))
+ (scheme-file "builder-in-linux-vm" exp))
+
+ (define (preserve-target obj)
+ (if target
+ (with-parameters ((%current-target-system target))
+ obj)
+ obj))
(define loader
- ;; Invoke USER-BUILDER instead using 'primitive-load'. The reason for
- ;; this is to allow USER-BUILDER to dlopen stuff by using a full-featured
- ;; Guile, which it couldn't do using the statically-linked guile used in
- ;; the initrd. See example at
+ ;; Instead of using 'primitive-load', evaluate USER-BUILDER in a
+ ;; full-featured Guile so it can use dlopen stuff, which it couldn't do
+ ;; using the statically-linked guile used in the initrd. See example at
;; <https://lists.gnu.org/archive/html/guix-devel/2017-10/msg00233.html>.
(program-file "linux-vm-loader"
- ;; Communicate USER-BUILDER's exit status via /xchg so that
- ;; the host can distinguish between success, failure, and
- ;; kernel panic.
- #~(let ((status (system* #$user-builder)))
+ ;; When cross-compiling, USER-BUILDER refers to the target
+ ;; (cross-compiled) system. Preserve that, even though
+ ;; LOADER itself is executed as a native program.
+ #~(let* ((guile #$(if (hurd-target?)
+ #~#+(file-append (default-guile)
+ "/bin/guile")
+ (file-append (default-guile)
+ "/bin/guile")))
+ (status (system* guile "--no-auto-compile"
+ #$(if (hurd-target?)
+ (preserve-target user-builder)
+ user-builder))))
+
+ ;; Communicate USER-BUILDER's exit status via /xchg so
+ ;; that the host can distinguish between success,
+ ;; failure, and kernel panic.
(call-with-output-file "/xchg/.exit-status"
(lambda (port)
(write status port)))
@@ -227,10 +245,16 @@ substitutable."
(let* ((native-inputs
'#+(list qemu (canonical-package coreutils)))
- (linux (string-append #$linux "/"
- #$(system-linux-image-file-name)))
- (initrd #$initrd)
- (loader #$loader)
+
+ (loader #$(if (hurd-target?) #~#+loader loader))
+ (linux #$(if (hurd-target?)
+ #~(string-append
+ #+linux "/"
+ #+(system-linux-image-file-name))
+ #~(string-append
+ #$linux "/"
+ #$(system-linux-image-file-name))))
+ (initrd #$(if (hurd-target?) #~#+initrd initrd))
(graphs '#$(match references-graphs
(((graph-files . _) ...) graph-files)
(_ #f)))
@@ -246,7 +270,9 @@ substitutable."
(load-in-linux-vm loader
#:output #$output
#:linux linux #:initrd initrd
- #:qemu (qemu-command target)
+ #:qemu #$(if (hurd-target?)
+ (qemu-command)
+ (qemu-command target))
#:memory-size #$memory-size
#:make-disk-image? #$make-disk-image?
#:single-file-output? #$single-file-output?
@@ -288,7 +314,9 @@ substitutable."
bootcfg-drv
bootloader
(register-closures? (and (has-guix-service-type? os)
- (not (hurd-target?))))
+ (not target)
+ ;(not (hurd-target?))
+ ))
(inputs '())
copy-inputs?
(substitutable? #t))
@@ -349,9 +377,17 @@ system that is passed to 'populate-root-file-system'."
(setlocale LC_ALL "en_US.utf8")
(let ((inputs
- '#$(append (list parted e2fsprogs dosfstools)
+ '#+(append (list parted e2fsprogs dosfstools)
(map canonical-package
- (list sed grep coreutils findutils gawk))))
+ (list sed grep coreutils findutils gawk)))
+ ;; (if #$(hurd-target?)
+ ;; '#+(append (list parted e2fsprogs dosfstools)
+ ;; (map canonical-package
+ ;; (list sed grep coreutils findutils gawk)))
+ ;; '#$(append (list parted e2fsprogs dosfstools)
+ ;; (map canonical-package
+ ;; (list sed grep coreutils findutils gawk))))
+ )
;; This variable is unused but allows us to add INPUTS-TO-COPY
;; as inputs.
@@ -426,12 +462,16 @@ system that is passed to 'populate-root-file-system'."
#:partitions partitions
#:grub-efi grub-efi
#:bootloader-package
- #$(bootloader-package bootloader)
+ (if #$(hurd-target?)
+ #+(bootloader-package bootloader)
+ #$(bootloader-package bootloader))
#:bootcfg #$bootcfg-drv
#:bootcfg-location
#$(bootloader-configuration-file bootloader)
#:bootloader-installer
- #$(bootloader-installer bootloader)))))))
+ (if #$(hurd-target?)
+ #+(bootloader-installer bootloader)
+ #$(bootloader-installer bootloader))))))))
#:system system
#:target target
#:make-disk-image? #t
--
2.26.2
next prev parent reply other threads:[~2020-05-19 7:24 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-17 10:01 [bug#41350] [PATCH 0/3] Use native qemu to build vm-image Jan Nieuwenhuizen
2020-05-17 10:03 ` [bug#41350] [PATCH 1/3] utils: Move 'reset-timestamps' out of database Jan (janneke) Nieuwenhuizen
2020-05-17 10:03 ` [bug#41350] [PATCH 2/3] system: vm: Do not register-closures when cross-building Jan (janneke) Nieuwenhuizen
2020-05-17 10:03 ` [bug#41350] [PATCH 3/3] system: vm: Build vm-image using native qemu Jan (janneke) Nieuwenhuizen
2020-05-18 9:10 ` [bug#41350] [PATCH 0/3] Use native qemu to build vm-image Mathieu Othacehe
2020-05-19 7:22 ` Jan Nieuwenhuizen
2020-05-19 10:02 ` Mathieu Othacehe
2020-05-20 14:03 ` Mathieu Othacehe
2020-05-20 15:09 ` Jan Nieuwenhuizen
2020-05-19 7:23 ` [bug#41350] [PATCH v2 1/3] utils: Move 'reset-timestamps' out of database Jan (janneke) Nieuwenhuizen
2020-05-19 7:23 ` [bug#41350] [PATCH v2 2/3] system: vm: Do not register-closures when cross-building to the Hurd Jan (janneke) Nieuwenhuizen
2020-05-19 7:23 ` Jan (janneke) Nieuwenhuizen [this message]
2020-05-19 9:14 ` [bug#41350] [PATCH v2 3/3] system: vm: Build vm-image using native qemu, for " Mathieu Othacehe
2020-05-20 21:49 ` Ludovic Courtès
2020-05-23 9:28 ` Jan Nieuwenhuizen
2020-05-23 17:45 ` Mathieu Othacehe
2020-05-23 19:07 ` Jan Nieuwenhuizen
2020-05-24 9:18 ` Mathieu Othacehe
2020-05-27 9:30 ` Ludovic Courtès
2020-05-28 7:00 ` Mathieu Othacehe
2020-05-24 11:19 ` Jan Nieuwenhuizen
2020-05-24 12:07 ` Mathieu Othacehe
2020-05-24 14:20 ` Jan Nieuwenhuizen
2020-05-24 16:36 ` Ludovic Courtès
2020-05-20 21:58 ` Ludovic Courtès
2020-05-22 19:24 ` Mathieu Othacehe
2020-05-27 22:54 ` Ludovic Courtès
2020-05-28 6:36 ` Mathieu Othacehe
2020-05-28 12:29 ` Jan Nieuwenhuizen
2020-05-28 15:39 ` Ludovic Courtès
2020-05-28 17:07 ` Jan Nieuwenhuizen
2020-05-28 17:10 ` Mathieu Othacehe
2020-05-28 18:19 ` Jan Nieuwenhuizen
2020-05-29 8:18 ` Ludovic Courtès
2020-05-29 9:06 ` Jan Nieuwenhuizen
2020-05-30 10:08 ` Jan Nieuwenhuizen
2020-05-30 13:54 ` Ludovic Courtès
2022-09-28 20:18 ` [bug#41350] [PATCH 0/3] Use native qemu to build vm-image Maxim Cournoyer
2022-09-29 14:17 ` bug#41350: " Mathieu Othacehe
2020-05-23 9:30 ` [bug#41350] [PATCH v3 1/3] utils: Move 'reset-timestamps' out of database Jan (janneke) Nieuwenhuizen
2020-05-23 9:30 ` [bug#41350] [PATCH v3 2/3] system: vm: Do not register-closures when cross-building to the Hurd Jan (janneke) Nieuwenhuizen
2020-05-27 8:45 ` Ludovic Courtès
2020-05-27 9:13 ` Jan Nieuwenhuizen
2020-05-23 9:30 ` [bug#41350] [PATCH v3 3/3] system: vm: Build vm-image using native qemu, for " Jan (janneke) Nieuwenhuizen
2020-05-27 8:43 ` [bug#41350] [PATCH v3 1/3] utils: Move 'reset-timestamps' out of database Ludovic Courtès
2020-05-27 8:59 ` Ludovic Courtès
2020-05-27 9:10 ` Jan Nieuwenhuizen
2020-05-24 18:11 ` [bug#41350] [PATCH v2 3/3] system: vm: Build vm-image using native qemu, for the Hurd Mathieu Othacehe
2020-05-24 18:40 ` Jan Nieuwenhuizen
2020-05-25 15:46 ` Jan Nieuwenhuizen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200519072302.9202-3-janneke@gnu.org \
--to=janneke@gnu.org \
--cc=41350@debbugs.gnu.org \
--cc=ludo@gnu.org \
--cc=othacehe@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).