From patchwork Sat May 23 09:30:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janneke Nieuwenhuizen X-Patchwork-Id: 22306 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 1FF6827BBE1; Sat, 23 May 2020 10:31:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 853A627BBE3 for ; Sat, 23 May 2020 10:31:10 +0100 (BST) Received: from localhost ([::1]:47080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcQUo-00027z-3p for patchwork@mira.cbaines.net; Sat, 23 May 2020 05:31:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcQUg-00027k-JI for guix-patches@gnu.org; Sat, 23 May 2020 05:31:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50128) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jcQUg-0000of-8v for guix-patches@gnu.org; Sat, 23 May 2020 05:31:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jcQUg-0004jj-6Z for guix-patches@gnu.org; Sat, 23 May 2020 05:31:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41350] [PATCH v3 1/3] utils: Move 'reset-timestamps' out of database. References: <87mu66q3rt.fsf@gnu.org> In-Reply-To: <87mu66q3rt.fsf@gnu.org> Resent-From: "Jan (janneke) Nieuwenhuizen" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 23 May 2020 09:31:02 +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 Received: via spool by 41350-submit@debbugs.gnu.org id=B41350.159022622818127 (code B ref 41350); Sat, 23 May 2020 09:31:02 +0000 Received: (at 41350) by debbugs.gnu.org; 23 May 2020 09:30:28 +0000 Received: from localhost ([127.0.0.1]:33435 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jcQU7-0004iI-N4 for submit@debbugs.gnu.org; Sat, 23 May 2020 05:30:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33174) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jcQU6-0004i2-81 for 41350@debbugs.gnu.org; Sat, 23 May 2020 05:30:26 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:41076) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcQU1-0000f1-0I; Sat, 23 May 2020 05:30:21 -0400 Received: from [2001:980:1b4f:1:42d2:832d:bb59:862] (port=51074 helo=dundal.fritz.box) by fencepost.gnu.org with esmtpa (Exim 4.82) (envelope-from ) id 1jcQTy-0000Rw-Dk; Sat, 23 May 2020 05:30:20 -0400 From: "Jan (janneke) Nieuwenhuizen" Date: Sat, 23 May 2020 11:30:15 +0200 Message-Id: <20200523093017.12149-1-janneke@gnu.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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 This supports calling reset-timestamps without loading sqlite3. * guix/store/database.scm (reset-timestamps): Move to... * guix/utils.scm (reset-timestamps): ... here. * gnu/build/vm.scm: Include it. --- gnu/build/vm.scm | 1 + guix/store/database.scm | 41 +++-------------------------------------- guix/utils.scm | 41 ++++++++++++++++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 41 deletions(-) diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index 433b5a7e8d..c751e6b0e2 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -26,6 +26,7 @@ #:use-module (guix build utils) #:use-module (guix build store-copy) #:use-module (guix build syscalls) + #:use-module ((guix utils) #:select (reset-timestamps)) #:use-module (guix store database) #:use-module (gnu build bootloader) #:use-module (gnu build linux-boot) diff --git a/guix/store/database.scm b/guix/store/database.scm index ef52036ede..b8fe313c3d 100644 --- a/guix/store/database.scm +++ b/guix/store/database.scm @@ -24,9 +24,8 @@ #:use-module (guix store deduplication) #:use-module (guix base16) #:use-module (guix progress) - #:use-module (guix build syscalls) - #:use-module ((guix build utils) - #:select (mkdir-p executable-file?)) + #:use-module ((guix build utils) #:select (mkdir-p)) + #:use-module ((guix utils) #:select (reset-timestamps)) #:use-module (guix build store-copy) #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) @@ -42,8 +41,7 @@ sqlite-register register-path register-items - %epoch - reset-timestamps)) + %epoch)) ;;; Code for working with the store database directly. @@ -227,39 +225,6 @@ Every store item in REFERENCES must already be registered." ;;; ;;; High-level interface. ;;; - -(define* (reset-timestamps file #:key preserve-permissions?) - "Reset the modification time on FILE and on all the files it contains, if -it's a directory. Canonicalize file permissions unless PRESERVE-PERMISSIONS? -is true." - ;; Note: We're resetting to one second after the Epoch like 'guix-daemon' - ;; has always done. - (let loop ((file file) - (type (stat:type (lstat file)))) - (case type - ((directory) - (unless preserve-permissions? - (chmod file #o555)) - (utime file 1 1 0 0) - (let ((parent file)) - (for-each (match-lambda - (("." . _) #f) - ((".." . _) #f) - ((file . properties) - (let ((file (string-append parent "/" file))) - (loop file - (match (assoc-ref properties 'type) - ((or 'unknown #f) - (stat:type (lstat file))) - (type type)))))) - (scandir* parent)))) - ((symlink) - (utime file 1 1 0 0 AT_SYMLINK_NOFOLLOW)) - (else - (unless preserve-permissions? - (chmod file (if (executable-file? file) #o555 #o444))) - (utime file 1 1 0 0))))) - (define* (register-path path #:key (references '()) deriver prefix state-directory (deduplicate? #t) diff --git a/guix/utils.scm b/guix/utils.scm index d7b197fa44..812617dd61 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -35,8 +35,10 @@ #:use-module (rnrs io ports) ;need 'port-position' etc. #:use-module ((rnrs bytevectors) #:select (bytevector-u8-set!)) #:use-module (guix memoization) - #:use-module ((guix build utils) #:select (dump-port mkdir-p delete-file-recursively)) - #:use-module ((guix build syscalls) #:select (mkdtemp! fdatasync)) + #:use-module ((guix build utils) + #:select (dump-port mkdir-p delete-file-recursively + executable-file?)) + #:use-module ((guix build syscalls) #:select (mkdtemp! fdatasync scandir*)) #:use-module (ice-9 format) #:use-module (ice-9 regex) #:use-module (ice-9 match) @@ -109,7 +111,8 @@ call-with-decompressed-port compressed-output-port call-with-compressed-output-port - canonical-newline-port)) + canonical-newline-port + reset-timestamps)) ;;; @@ -843,6 +846,38 @@ a location object." fix-hint? (hint condition-fix-hint)) ;string +(define* (reset-timestamps file #:key preserve-permissions?) + "Reset the modification time on FILE and on all the files it contains, if +it's a directory. Canonicalize file permissions unless PRESERVE-PERMISSIONS? +is true." + ;; Note: We're resetting to one second after the Epoch like 'guix-daemon' + ;; has always done. + (let loop ((file file) + (type (stat:type (lstat file)))) + (case type + ((directory) + (unless preserve-permissions? + (chmod file #o555)) + (utime file 1 1 0 0) + (let ((parent file)) + (for-each (match-lambda + (("." . _) #f) + ((".." . _) #f) + ((file . properties) + (let ((file (string-append parent "/" file))) + (loop file + (match (assoc-ref properties 'type) + ((or 'unknown #f) + (stat:type (lstat file))) + (type type)))))) + (scandir* parent)))) + ((symlink) + (utime file 1 1 0 0 AT_SYMLINK_NOFOLLOW)) + (else + (unless preserve-permissions? + (chmod file (if (executable-file? file) #o555 #o444))) + (utime file 1 1 0 0))))) + ;;; Local Variables: ;;; eval: (put 'call-with-progress-reporter 'scheme-indent-function 1) ;;; End: From patchwork Sat May 23 09:30:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janneke Nieuwenhuizen X-Patchwork-Id: 22307 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 2A7DA27BBE3; Sat, 23 May 2020 10:31:12 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id EE04527BBE1 for ; Sat, 23 May 2020 10:31:11 +0100 (BST) Received: from localhost ([::1]:47112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcQUp-000294-Gs for patchwork@mira.cbaines.net; Sat, 23 May 2020 05:31:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcQUg-00027q-To for guix-patches@gnu.org; Sat, 23 May 2020 05:31:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50129) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jcQUg-0000oj-Kg for guix-patches@gnu.org; Sat, 23 May 2020 05:31:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jcQUg-0004jr-IV for guix-patches@gnu.org; Sat, 23 May 2020 05:31:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41350] [PATCH v3 2/3] system: vm: Do not register-closures when cross-building to the Hurd. Resent-From: "Jan (janneke) Nieuwenhuizen" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 23 May 2020 09:31:02 +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 Received: via spool by 41350-submit@debbugs.gnu.org id=B41350.159022623118149 (code B ref 41350); Sat, 23 May 2020 09:31:02 +0000 Received: (at 41350) by debbugs.gnu.org; 23 May 2020 09:30:31 +0000 Received: from localhost ([127.0.0.1]:33439 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jcQUB-0004ie-21 for submit@debbugs.gnu.org; Sat, 23 May 2020 05:30:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33182) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jcQU8-0004i8-Pu for 41350@debbugs.gnu.org; Sat, 23 May 2020 05:30:28 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:41078) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcQU3-0000fD-Il; Sat, 23 May 2020 05:30:23 -0400 Received: from [2001:980:1b4f:1:42d2:832d:bb59:862] (port=51074 helo=dundal.fritz.box) by fencepost.gnu.org with esmtpa (Exim 4.82) (envelope-from ) id 1jcQU1-0000Rw-By; Sat, 23 May 2020 05:30:22 -0400 From: "Jan (janneke) Nieuwenhuizen" Date: Sat, 23 May 2020 11:30:16 +0200 Message-Id: <20200523093017.12149-2-janneke@gnu.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200523093017.12149-1-janneke@gnu.org> References: <20200523093017.12149-1-janneke@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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 This supports cross-building building a vm-image for the Hurd, running a native qemu. * gnu/system/vm.scm (qemu-image)[register-closures?]: Default to #f when cross-compiling to the Hurd. Only create sql-schema when actually registering closures. --- gnu/build/vm.scm | 9 ++++++++- gnu/system/vm.scm | 9 ++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index c751e6b0e2..a1b193134a 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -27,7 +27,14 @@ #:use-module (guix build store-copy) #:use-module (guix build syscalls) #:use-module ((guix utils) #:select (reset-timestamps)) - #:use-module (guix store database) + #:autoload (guix store database) (sql-schema ;must list all exported symbols + %default-database-file + with-database + path-id + sqlite-register + register-path + register-items + %epoch) #:use-module (gnu build bootloader) #:use-module (gnu build linux-boot) #:use-module (gnu build install) diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index 3e483fd86c..b343141c18 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -51,6 +51,7 @@ #:use-module (gnu packages zile) #:use-module (gnu packages linux) #:use-module (gnu packages admin) + #:use-module (gnu packages hurd) #:use-module (gnu bootloader) #:use-module (gnu bootloader grub) @@ -286,7 +287,8 @@ substitutable." os bootcfg-drv bootloader - (register-closures? (has-guix-service-type? os)) + (register-closures? (and (has-guix-service-type? os) + (not (hurd-target?)))) (inputs '()) copy-inputs? (substitutable? #t)) @@ -333,12 +335,13 @@ system that is passed to 'populate-root-file-system'." ((gnu build linux-boot) #:select (make-essential-device-nodes make-hurd-device-nodes)) - (guix store database) (guix build utils) (srfi srfi-26) (ice-9 binary-ports)) - (sql-schema #$schema) + (when #$register-closures? + (use-modules (guix store database)) + (sql-schema #$schema)) ;; Allow non-ASCII file names--e.g., 'nss-certs'--to be decoded. (setenv "GUIX_LOCPATH" From patchwork Sat May 23 09:30:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janneke Nieuwenhuizen X-Patchwork-Id: 22308 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 685FE27BBE3; Sat, 23 May 2020 10:31:19 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id F06CB27BBE1 for ; Sat, 23 May 2020 10:31:18 +0100 (BST) Received: from localhost ([::1]:47492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcQUw-0002KC-Hp for patchwork@mira.cbaines.net; Sat, 23 May 2020 05:31:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcQUh-00027x-Ay for guix-patches@gnu.org; Sat, 23 May 2020 05:31:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50130) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jcQUh-0000on-1c for guix-patches@gnu.org; Sat, 23 May 2020 05:31:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jcQUg-0004jy-VU for guix-patches@gnu.org; Sat, 23 May 2020 05:31:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41350] [PATCH v3 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: Sat, 23 May 2020 09:31:02 +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 Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 41350-submit@debbugs.gnu.org id=B41350.159022623318159 (code B ref 41350); Sat, 23 May 2020 09:31:02 +0000 Received: (at 41350) by debbugs.gnu.org; 23 May 2020 09:30:33 +0000 Received: from localhost ([127.0.0.1]:33441 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jcQUD-0004in-AA for submit@debbugs.gnu.org; Sat, 23 May 2020 05:30:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33188) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jcQUA-0004iA-El for 41350@debbugs.gnu.org; Sat, 23 May 2020 05:30:30 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:41079) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcQU5-0000fM-6x; Sat, 23 May 2020 05:30:25 -0400 Received: from [2001:980:1b4f:1:42d2:832d:bb59:862] (port=51074 helo=dundal.fritz.box) by fencepost.gnu.org with esmtpa (Exim 4.82) (envelope-from ) id 1jcQU3-0000Rw-Pk; Sat, 23 May 2020 05:30:24 -0400 From: "Jan (janneke) Nieuwenhuizen" Date: Sat, 23 May 2020 11:30:17 +0200 Message-Id: <20200523093017.12149-3-janneke@gnu.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200523093017.12149-1-janneke@gnu.org> References: <20200523093017.12149-1-janneke@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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 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. Co-authored-by: Ludovic Courtès --- gnu/bootloader/grub.scm | 4 +- gnu/system/vm.scm | 81 +++++++++++++++++++++++++++++------------ 2 files changed, 60 insertions(+), 25 deletions(-) diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index bb40c551a7..ccf70b3785 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -207,8 +207,8 @@ else set menu_color_highlight=white/blue fi~%" #$setup-gfxterm-body - #$(grub-root-search store-device font-file) - #$(setup-gfxterm config font-file) + #+(grub-root-search store-device font-file) + #+(setup-gfxterm config font-file) #$(grub-setup-io config) #$image diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index b343141c18..245ecc73b3 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,29 +182,46 @@ 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-syntax-rule (check predicate) + (let-system (system target) + (predicate (or target system)))) (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 (check hurd-triplet?) + #~#+(file-append (default-guile) + "/bin/guile") + (file-append (default-guile) + "/bin/guile"))) + (status (system* guile "--no-auto-compile" + #$(if (check hurd-triplet?) + (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))) (sync) (reboot)))) - (define-syntax-rule (check predicate) - (let-system (system target) - (predicate (or target system)))) - (let ((initrd (or initrd (base-initrd file-systems #:on-error 'backtrace @@ -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 (check hurd-triplet?) #~#+loader loader)) + (linux #$(if (check hurd-triplet?) + #~(string-append + #+linux "/" + #+(system-linux-image-file-name)) + #~(string-append + #$linux "/" + #$(system-linux-image-file-name)))) + (initrd #$(if (check hurd-triplet?) #~#+initrd initrd)) (graphs '#$(match references-graphs (((graph-files . _) ...) graph-files) (_ #f))) @@ -246,7 +270,10 @@ substitutable." (load-in-linux-vm loader #:output #$output #:linux linux #:initrd initrd - #:qemu (qemu-command target) + #:qemu #$(if (or (not target) + (check hurd-triplet?)) + (qemu-command) + (qemu-command target)) #:memory-size #$memory-size #:make-disk-image? #$make-disk-image? #:single-file-output? #$single-file-output? @@ -349,9 +376,13 @@ system that is passed to 'populate-root-file-system'." (setlocale LC_ALL "en_US.utf8") (let ((inputs - '#$(append (list parted e2fsprogs dosfstools) - (map canonical-package - (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 +457,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