From patchwork Wed Oct 2 09:59:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Othacehe X-Patchwork-Id: 15578 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 027161749F; Wed, 2 Oct 2019 11:02:47 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id A3EF31749D for ; Wed, 2 Oct 2019 11:02:46 +0100 (BST) Received: from localhost ([::1]:53198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFbT4-00066L-6T for patchwork@mira.cbaines.net; Wed, 02 Oct 2019 06:02:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51262) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFbQj-0003wr-Kk for guix-patches@gnu.org; Wed, 02 Oct 2019 06:00:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iFbQh-0000JI-GZ for guix-patches@gnu.org; Wed, 02 Oct 2019 06:00:21 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:54932) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iFbQh-0000IS-8f for guix-patches@gnu.org; Wed, 02 Oct 2019 06:00:19 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iFbQh-0000bY-5N for guix-patches@gnu.org; Wed, 02 Oct 2019 06:00:19 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#36477] [PATCH v4 22/23] system: vm: Support cross-compilation. Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 02 Oct 2019 10:00:19 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36477 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 36477@debbugs.gnu.org Cc: Mathieu Othacehe Received: via spool by 36477-submit@debbugs.gnu.org id=B36477.15700104062102 (code B ref 36477); Wed, 02 Oct 2019 10:00:19 +0000 Received: (at 36477) by debbugs.gnu.org; 2 Oct 2019 10:00:06 +0000 Received: from localhost ([127.0.0.1]:35496 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iFbQT-0000Xc-2W for submit@debbugs.gnu.org; Wed, 02 Oct 2019 06:00:06 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:46337) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iFbQH-0000VD-Su for 36477@debbugs.gnu.org; Wed, 02 Oct 2019 05:59:54 -0400 Received: by mail-wr1-f53.google.com with SMTP id o18so18863534wrv.13 for <36477@debbugs.gnu.org>; Wed, 02 Oct 2019 02:59:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bdKkVLt+BVm4Z+Syhu8bkVqQiKe+9G9Ke1m+3w5lg6E=; b=UYQmAcCLMml0HdHFLhuRsBeAz7U0zlqauyl501IIMRo41XTDgwtMFBYAHQ0wGkKKxt 9+IIl3lfacIomDQ4gwUXMuKI1WXQ+aJZGJfVhuDH+CZK5qopLIPEFPDIrfvmGEFwLiGo ptnDITKaiaAHntT40V77Io/JZ//U72KeqgZ6NCtimk98Zcb0652QF2i3eQoRISXDFXUW /wXNs8lANUK675Ba1ZVGz+x/eRz66zbiGssnb5Ja2a3e89LlcHunH7y+v2brjUG0ZLhj gPegSh8agwMBFoDV0vJGB+WPAld4l3Q3lukTQpMSbcaVwOyjMZE3l4Qsma1NBptVRcnR KEqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bdKkVLt+BVm4Z+Syhu8bkVqQiKe+9G9Ke1m+3w5lg6E=; b=dpnpobDJ64aNsg9hvxo7xt9UzwgELVL7DOen2/YKjdWmpEz9rEZYHPGAa1+JgJPshh uHaD/O3kY2z3jaTCO/cdu4nkGpRrKdNdotXDKEdcM9fyMmJuyZRU1l6Gf90I64IR+9iJ cPbB9A+u69NrQlNeIgHJ0w5FAwPdyu+N1u/xw43Onta5vM8eDJwgnRx+8X+50cMyAhi4 Go4p7k4XQbc5A0SKxHVERhlZeRqAbDnPdQsHRL+6f8iLfWgQ2+q9NZpfMG3gjU4/5RBU J4HyT+nnepKAlE0OkI4MIx8nbdaxCCjbcmyDo5RNPCgw9qO6oADD1+U+P1M2ckxaND/g gwzQ== X-Gm-Message-State: APjAAAUFI2U4oqGZbfbmnoM4wYiBY7GUmotedFGj75nPft9L77xls0Fh ElnIb4LhLWgAG6/Dq5zgkbxTMRtB X-Google-Smtp-Source: APXvYqxUhebwNiuQdlgNOZnpwtyOLjhkM5LdczPt2d+m5/FV5Z0RkNzAwSbf4Bohd73jATtR06VZvQ== X-Received: by 2002:adf:f649:: with SMTP id x9mr1941165wrp.163.1570010387884; Wed, 02 Oct 2019 02:59:47 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:fa:a50:21e:67ff:fe5b:4283]) by smtp.gmail.com with ESMTPSA id w12sm29621318wrg.47.2019.10.02.02.59.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Oct 2019 02:59:46 -0700 (PDT) From: Mathieu Othacehe Date: Wed, 2 Oct 2019 11:59:03 +0200 Message-Id: <20191002095904.6325-23-m.othacehe@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191002095904.6325-1-m.othacehe@gmail.com> References: <20191002095904.6325-1-m.othacehe@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/system.scm (system-linux-image-file-name): Add support for cross-built systems. Remove system argument that was ignored, (operating-system-kernel-file): adapt by removing ignored os argument. * gnu/system/vm.scm (expression->derivation-in-linux-vm): Add target argument and turn inputs into native-inputs. Pass target to qemu-command and gexp->derivation calls. (iso9660-image): Add target argument and pass it to expression->derivation-in-linux-vm. Remove qemu from inputs as it is not necessary. (qemu-image): Add target argument, also remove qemu from inputs. Pass target argument to expression->derivation-in-linux-vm call. --- gnu/system.scm | 15 ++++++++------- gnu/system/vm.scm | 18 +++++++++++++----- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index 37573fd153..fcd6203c70 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -447,20 +447,21 @@ from the initrd." "Return the list of swap services for OS." (map swap-service (operating-system-swap-devices os))) -(define* (system-linux-image-file-name #:optional (system (%current-system))) +(define* (system-linux-image-file-name) "Return the basename of the kernel image file for SYSTEM." ;; FIXME: Evaluate the conditional based on the actual current system. - (cond - ((string-prefix? "arm" (%current-system)) "zImage") - ((string-prefix? "mips" (%current-system)) "vmlinuz") - ((string-prefix? "aarch64" (%current-system)) "Image") - (else "bzImage"))) + (let ((target (or (%current-target-system) (%current-system)))) + (cond + ((string-prefix? "arm" target) "zImage") + ((string-prefix? "mips" target) "vmlinuz") + ((string-prefix? "aarch64" target) "Image") + (else "bzImage")))) (define (operating-system-kernel-file os) "Return an object representing the absolute file name of the kernel image of OS." (file-append (operating-system-kernel os) - "/" (system-linux-image-file-name os))) + "/" (system-linux-image-file-name))) (define* (operating-system-directory-base-entries os) "Return the basic entries of the 'system' directory of OS for use as the diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index de20030848..c900b2d435 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -143,7 +143,7 @@ (define* (expression->derivation-in-linux-vm name exp #:key - (system (%current-system)) + (system (%current-system)) target (linux linux-libre) initrd (qemu qemu-minimal) @@ -214,7 +214,8 @@ made available under the /xchg CIFS share." (use-modules (guix build utils) (gnu build vm)) - (let* ((inputs '#$(list qemu (canonical-package coreutils))) + (let* ((native-inputs + '#+(list qemu (canonical-package coreutils))) (linux (string-append #$linux "/" #$(system-linux-image-file-name))) (initrd #$initrd) @@ -222,16 +223,18 @@ made available under the /xchg CIFS share." (graphs '#$(match references-graphs (((graph-files . _) ...) graph-files) (_ #f))) + (target #$(or (%current-target-system) (%current-system))) (size #$(if (eq? 'guess disk-image-size) #~(+ (* 70 (expt 2 20)) ;ESP (estimated-partition-size graphs)) disk-image-size))) - (set-path-environment-variable "PATH" '("bin") inputs) + (set-path-environment-variable "PATH" '("bin") native-inputs) (load-in-linux-vm loader #:output #$output #:linux linux #:initrd initrd + #:qemu (qemu-command target) #:memory-size #$memory-size #:make-disk-image? #$make-disk-image? #:single-file-output? #$single-file-output? @@ -248,6 +251,7 @@ made available under the /xchg CIFS share." (gexp->derivation name builder ;; TODO: Require the "kvm" feature. #:system system + #:target target #:env-vars env-vars #:guile-for-build guile-for-build #:references-graphs references-graphs))) @@ -263,6 +267,7 @@ made available under the /xchg CIFS share." file-system-label file-system-uuid (system (%current-system)) + (target (%current-target-system)) (qemu qemu-minimal) os bootcfg-drv @@ -299,7 +304,7 @@ INPUTS is a list of inputs (as for packages)." (setlocale LC_ALL "en_US.utf8") (let ((inputs - '#$(append (list qemu parted e2fsprogs dosfstools xorriso) + '#$(append (list parted e2fsprogs dosfstools xorriso) (map canonical-package (list sed grep coreutils findutils gawk)))) @@ -328,6 +333,7 @@ INPUTS is a list of inputs (as for packages)." #:volume-uuid #$(and=> file-system-uuid uuid-bytevector)))))) #:system system + #:target target ;; Keep a local file system for /tmp so that we can populate it directly as ;; root and have files owned by root. See . @@ -346,6 +352,7 @@ INPUTS is a list of inputs (as for packages)." (define* (qemu-image #:key (name "qemu-image") (system (%current-system)) + (target (%current-target-system)) (qemu qemu-minimal) (disk-image-size 'guess) (disk-image-format "qcow2") @@ -404,7 +411,7 @@ system." (setlocale LC_ALL "en_US.utf8") (let ((inputs - '#$(append (list qemu parted e2fsprogs dosfstools) + '#$(append (list parted e2fsprogs dosfstools) (map canonical-package (list sed grep coreutils findutils gawk)))) @@ -481,6 +488,7 @@ system." #:bootloader-installer #$(bootloader-installer bootloader))))))) #:system system + #:target target #:make-disk-image? #t #:disk-image-size disk-image-size #:disk-image-format disk-image-format