From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id cFzlDKCJw14PIgAA0tVLHw (envelope-from ) for ; Tue, 19 May 2020 07:24:16 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id +IulCKCJw14wDQAAbx9fmQ (envelope-from ) for ; Tue, 19 May 2020 07:24:16 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 90897940B28 for ; Tue, 19 May 2020 07:24:15 +0000 (UTC) Received: from localhost ([::1]:55246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jawbm-0006Qu-Hd for larch@yhetil.org; Tue, 19 May 2020 03:24:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jawbb-0006Df-He for guix-patches@gnu.org; Tue, 19 May 2020 03:24:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:37497) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jawbb-0000hV-6r for guix-patches@gnu.org; Tue, 19 May 2020 03:24:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jawbb-0003s8-3h for guix-patches@gnu.org; Tue, 19 May 2020 03:24:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41350] [PATCH v2 3/3] system: vm: Build vm-image using native qemu, for the Hurd. Resent-From: "Jan (janneke) Nieuwenhuizen" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 19 May 2020 07:24:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41350 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 41350@debbugs.gnu.org, Mathieu Othacehe Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 41350-submit@debbugs.gnu.org id=B41350.158987300814822 (code B ref 41350); Tue, 19 May 2020 07:24:03 +0000 Received: (at 41350) by debbugs.gnu.org; 19 May 2020 07:23:28 +0000 Received: from localhost ([127.0.0.1]:49040 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jawb2-0003qv-2z for submit@debbugs.gnu.org; Tue, 19 May 2020 03:23:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36972) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jawan-0003q7-JN for 41350@debbugs.gnu.org; Tue, 19 May 2020 03:23:26 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:45781) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jawag-0000aM-Mx; Tue, 19 May 2020 03:23:06 -0400 Received: from [2001:980:1b4f:1:42d2:832d:bb59:862] (port=39336 helo=dundal.fritz.box) by fencepost.gnu.org with esmtpa (Exim 4.82) (envelope-from ) id 1jawaf-0002jm-S3; Tue, 19 May 2020 03:23:06 -0400 From: "Jan (janneke) Nieuwenhuizen" Date: Tue, 19 May 2020 09:23:02 +0200 Message-Id: <20200519072302.9202-3-janneke@gnu.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519072302.9202-1-janneke@gnu.org> References: <20200519072302.9202-1-janneke@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -0.01 X-TUID: eFiRvIks3yg5 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 --- 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 ;;; Copyright © 2017 Marius Bakke ;;; Copyright © 2018 Chris Marusich +;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; ;;; 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 ;; . (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