From patchwork Wed Aug 21 08:54:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Othacehe X-Patchwork-Id: 15093 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 AF0B717264; Wed, 21 Aug 2019 10:00:34 +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 5B9D71724B for ; Wed, 21 Aug 2019 10:00:34 +0100 (BST) Received: from localhost ([::1]:45722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0MTp-0003eD-EX for patchwork@mira.cbaines.net; Wed, 21 Aug 2019 05:00:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59415) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0MQf-0008Rt-C5 for guix-patches@gnu.org; Wed, 21 Aug 2019 04:57:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i0MQd-00064a-Pq for guix-patches@gnu.org; Wed, 21 Aug 2019 04:57:17 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:54189) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i0MQd-00064R-MU for guix-patches@gnu.org; Wed, 21 Aug 2019 04:57:15 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i0MQd-0006jD-Kd for guix-patches@gnu.org; Wed, 21 Aug 2019 04:57:15 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#36477] [PATCH v2 60/61] system: vm: Support cross-compilation. Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 21 Aug 2019 08:57:15 +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 Received: via spool by 36477-submit@debbugs.gnu.org id=B36477.156637780525646 (code B ref 36477); Wed, 21 Aug 2019 08:57:15 +0000 Received: (at 36477) by debbugs.gnu.org; 21 Aug 2019 08:56:45 +0000 Received: from localhost ([127.0.0.1]:34750 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i0MQ8-0006fT-UU for submit@debbugs.gnu.org; Wed, 21 Aug 2019 04:56:45 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40394) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i0MPP-0006VW-6U for 36477@debbugs.gnu.org; Wed, 21 Aug 2019 04:55:59 -0400 Received: by mail-wr1-f68.google.com with SMTP id c3so1228541wrd.7 for <36477@debbugs.gnu.org>; Wed, 21 Aug 2019 01:55:59 -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; bh=cCtQCncHylGJKH97u8Zs7Y6eJAkhgnHnM6y+HwkFZoY=; b=RNNzy+XXtL3hOvTjE097pT2jisJ5zbndK3sKUaLcIomzQNSk9BUyIMItFoDi6mUvYi whaSmMec7N2YzLqf66D4q9M+IoldgY+pLUs0Z3vgxmG8LCsH8IVkS1XNcUskD5ZvWhRf s4MQu7v/4RbS8X4rtcM+Kbce6ZBNyCowpYsPTaRDzwVhuSqoXXsygiq8SWWrfmhCNa8Z Zoa1MogFv1tXCx1xf+GFmehhKZeOUm66pdqQSaiKkbrhky8PC/EYX7BNd0CYUmTizubr IfiheyR1YGoxjpp7CCBxVZiP+MSPmHnBPe5FubF99hVgyoMSHYaIibdCKul7ikqNrKmv xwpA== 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; bh=cCtQCncHylGJKH97u8Zs7Y6eJAkhgnHnM6y+HwkFZoY=; b=dXzGttljQjBYN+OE55kD/vBCH03ssmnDu926/D4e/Yo+FmGmJJFnKoJRbBJ2Us8opm gdjpYAKjhsbFZDAWggPs/Xxq2JDSR5kMXn2A/cpPfeX24olEGQtc7kp0S53+ZTETR9Yt p7+cJGZLz7FYbYjsLAJL8BR8788a8TOxMTvKciMz+dLTfYAEq9Cs01MfEaliLNGU5oHp BKY/L3s1o9s+5Cs4x9E/hynUjz3H6xuK+v2o0euN1W2xx5g7XtxnaF5wz5kDYn/SVZO4 RUlxlSIA7j2dvXR/SWHE4tsDPsFEnLDZs4EPaLJek+1AVciCK5uQQiaUvPYhki1/QJQH xqwQ== X-Gm-Message-State: APjAAAWzbsQule34lG95WU5hz5Uxdsjk1/+qRjXofuGBXQpi5xXggDfD 7E4S5sDWPT8rBKIkdVQ2aAex1KEtZbY= X-Google-Smtp-Source: APXvYqyXd/rsgdTe+5yzHLoKhEqNfpOnkTp1cZvz9WwqOJZ+WCvw5DNNzbmvW6cvaFbooejjIrS6Gw== X-Received: by 2002:a5d:554a:: with SMTP id g10mr450171wrw.9.1566377753275; Wed, 21 Aug 2019 01:55:53 -0700 (PDT) Received: from fuji.Parrot.Biz (smtp.parrot.biz. [62.23.167.188]) by smtp.gmail.com with ESMTPSA id v3sm22110739wrq.34.2019.08.21.01.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2019 01:55:52 -0700 (PDT) From: Mathieu Othacehe Date: Wed, 21 Aug 2019 10:54:54 +0200 Message-Id: <20190821085455.18508-60-m.othacehe@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190821085455.18508-1-m.othacehe@gmail.com> References: <20190821085455.18508-1-m.othacehe@gmail.com> 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: , Cc: Mathieu Othacehe 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, move qemu from inputs list to a new native-inputs list and adapt set-path-environment-variable call accordingly. Pass target to qemu-command and gexp->derivation calls. (iso9660-image): Move qemu from inputs to a new native-inputs list and adapt set-path-environment-variable accordingly. (qemu-image): Add target argument, move qemu from inputs list to a new native-inputs list and adapt set-path-environment-variable call accordingly. Pass target argument to expression->derivation-in-linux-vm call. --- gnu/system.scm | 15 ++++++++------- gnu/system/vm.scm | 25 ++++++++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index 485896ba0a..85059119cc 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -439,20 +439,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 07cee2d4f5..759745c277 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* ((inputs '#$(list (canonical-package coreutils))) + (native-inputs '#+(list qemu)) (linux (string-append #$linux "/" #$(system-linux-image-file-name))) (initrd #$initrd) @@ -222,16 +223,19 @@ 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") + (append inputs 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 +252,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))) @@ -299,9 +304,10 @@ 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)))) + (native-inputs '#+(list qemu)) (graphs '#$(match inputs @@ -315,7 +321,8 @@ INPUTS is a list of inputs (as for packages)." ((name thing output) `(,thing ,output))) inputs))) - (set-path-environment-variable "PATH" '("bin" "sbin") inputs) + (set-path-environment-variable "PATH" '("bin" "sbin") + (append inputs native-inputs)) (make-iso9660-image #$xorriso '#$grub-mkrescue-environment #$(bootloader-package bootloader) @@ -346,6 +353,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,9 +412,10 @@ system." (setlocale LC_ALL "en_US.utf8") (let ((inputs - '#$(append (list qemu parted e2fsprogs dosfstools) + '#$(append (list util-linux parted e2fsprogs dosfstools) (map canonical-package (list sed grep coreutils findutils gawk)))) + (native-inputs '#+(list qemu)) ;; This variable is unused but allows us to add INPUTS-TO-COPY ;; as inputs. @@ -416,7 +425,8 @@ system." ((name thing output) `(,thing ,output))) inputs))) - (set-path-environment-variable "PATH" '("bin" "sbin") inputs) + (set-path-environment-variable "PATH" '("bin" "sbin") + (append inputs native-inputs)) (let* ((graphs '#$(match inputs (((names . _) ...) @@ -483,6 +493,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