From patchwork Fri Nov 4 01:54:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 44289 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 E898427BBEA; Fri, 4 Nov 2022 02:04:32 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8275D27BBE9 for ; Fri, 4 Nov 2022 02:04:32 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oqm4E-0006kR-Dj; Thu, 03 Nov 2022 22:04:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oqlwD-0002n6-AB for guix-patches@gnu.org; Thu, 03 Nov 2022 21:56:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oqlwB-0000xm-3i for guix-patches@gnu.org; Thu, 03 Nov 2022 21:56:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oqlwA-0000M0-FM for guix-patches@gnu.org; Thu, 03 Nov 2022 21:56:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58576] [PATCH v2] system: image: Define correct docker image arch when cross building Resent-From: Thiago Jung Bauermann Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 04 Nov 2022 01:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58576 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: moreinfo patch To: 58576@debbugs.gnu.org Cc: Mathieu Othacehe , Thiago Jung Bauermann Received: via spool by 58576-submit@debbugs.gnu.org id=B58576.16675269221312 (code B ref 58576); Fri, 04 Nov 2022 01:56:02 +0000 Received: (at 58576) by debbugs.gnu.org; 4 Nov 2022 01:55:22 +0000 Received: from localhost ([127.0.0.1]:51137 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqlvW-0000L6-Gz for submit@debbugs.gnu.org; Thu, 03 Nov 2022 21:55:22 -0400 Received: from mx.kolabnow.com ([212.103.80.154]:36328) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqlvR-0000Km-QY for 58576@debbugs.gnu.org; Thu, 03 Nov 2022 21:55:21 -0400 Received: from localhost (unknown [127.0.0.1]) by mx.kolabnow.com (Postfix) with ESMTP id 41C042232; Fri, 4 Nov 2022 02:55:11 +0100 (CET) Authentication-Results: ext-mx-out001.mykolab.com (amavisd-new); dkim=pass (4096-bit key) reason="pass (just generated, assumed good)" header.d=kolabnow.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:date:date:subject:subject :from:from:received:received:received; s=dkim20160331; t= 1667526910; x=1669341311; bh=1+IJcU3xOls+/l+S7ze/Q96HxEH2gmr0pEl GIr31ezo=; b=OegGjUzvgPUPGC3RinF92UhbwlGs+2EicEHiQqRgMPQPR92cX4S 7WIxljElXzdJVnKz96J7vfIswk9olqRYZur6p1NXsoMZc+1jitIom1+JbrURKjFQ ohHVDZ/9+DGKO+FR9QVGFGuE49ShZ2rqMUHBb/DE9Kb8XvVYWdQ2niKPt33Ek3q9 lmS7Sn3OkHzssP/FlML+Rcrav8Eoj6XD/5RkDUujllDtshH77S3K0CC3zgRS/K0H XiGtdbMuL/mX2ve6NvsIjOB6vl8IsgbSOY6R99PpV/MEfkZfewexIS8JHMHIF6/c kS3SvaC40vTevPfzXibPm9D8AzeLqKvXlFZh1V4tlJrqjAGj0SSYV/Qa0nXZ+WyY LBv0pN6QHaaMWr6Qm5JNqeVi7b4PsGfJxSDV8CDgg+GFwRLPqSIJejHCl100UGdp nhT68+0vfLdrg6x9TLoYcOwmitI3A6cZ3TJJrEU2lwdBNVnaJ0lR0NkQIs1BPD5A X11vssQUZLEF8CLiiT+3E/HtdPYVyg7cch4CveXsYEKMD0bhP9CAX1qG9IgMJYnc UNbIRtekZhEcBEE+TBp+hUCgwmdgzMXf1lLguxDEqI65RXOeIetQ9pATFLqp1RJt Qm3/AqLamegWtNJpT5xUG2cU7dGm33KokG1m1CD4SUWrK+u/KTY97PnA= X-Virus-Scanned: amavisd-new at mykolab.com Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out001.mykolab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Hka-94rUrrkK; Fri, 4 Nov 2022 02:55:10 +0100 (CET) Received: from int-mx001.mykolab.com (unknown [10.9.13.1]) by mx.kolabnow.com (Postfix) with ESMTPS id ED52D213E; Fri, 4 Nov 2022 02:55:09 +0100 (CET) Received: from ext-subm002.mykolab.com (unknown [10.9.6.2]) by int-mx001.mykolab.com (Postfix) with ESMTPS id AE801BD2; Fri, 4 Nov 2022 02:55:09 +0100 (CET) Date: Thu, 3 Nov 2022 22:54:56 -0300 Message-Id: <20221104015456.1059014-1-bauermann@kolabnow.com> In-Reply-To: <87tu3qgmlg.fsf@kolabnow.com> References: <87tu3qgmlg.fsf@kolabnow.com> 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: , Sender: "Guix-patches" Reply-to: Thiago Jung Bauermann X-ACL-Warn: , Thiago Jung Bauermann via Guix-patches X-Patchwork-Original-From: Thiago Jung Bauermann via Guix-patches via From: Thiago Jung Bauermann Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Cross-building a docker image with: $ guix system image --image-type=docker --target=aarch64-linux-gnu os.scm results in an image where the architecture declared in its config.json is the host architecture rather than the target one. The binaries are correctly cross-compiled, so the image can be loaded and used despite the warning message shown by docker: $ docker load -i vcal7bvsqcijchifhqdvprpd1niqh8sk-docker-image.tar.gz Loaded image: guix:latest $ docker create guix:latest WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 40f06aa869ed690489c4a3824a7f7721bd4bf453b85f25ac7199266939fe2fba $ echo $? 0 This is fixed by passing the correct triplet to the build-docker-image function. * gnu/system/image.scm (system-docker-image) Add ‘image-target’ variable. [builder]: Pass ‘#:system’ argument to ‘build-docker-image’. --- Hello, This is v2 of the patch. The only difference is that the expression defining ‘image-target’ doesn't try to get the target from the image's platform field, since its caller ‘system-image’ already does that (thanks to Mathieu for pointing it out). gnu/system/image.scm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 5fc0d55d9a14..f07a4a52174f 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -652,6 +652,8 @@ (define shared-network? shared-network?) (list boot-program))) (substitutable? (image-substitutable? image)) + (image-target (or (%current-target-system) + (nix-system->gnu-triplet))) (register-closures? (has-guix-service-type? os)) (schema (and register-closures? (local-file (search-path %load-path @@ -705,6 +707,7 @@ (define builder #:entry-point '(#$boot-program #$os) #:compressor '(#+(file-append gzip "/bin/gzip") "-9n") #:creation-time (make-time time-utc 0 1) + #:system #$image-target #:transformations `((,image-root -> "")))))))) (computed-file name builder