unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Thiago Jung Bauermann via Guix-patches via <guix-patches@gnu.org>
To: 58576@debbugs.gnu.org
Cc: Mathieu Othacehe <othacehe@gnu.org>,
	Thiago Jung Bauermann <bauermann@kolabnow.com>
Subject: [bug#58576] [PATCH v2] system: image: Define correct docker image arch when cross building
Date: Thu,  3 Nov 2022 22:54:56 -0300	[thread overview]
Message-ID: <20221104015456.1059014-1-bauermann@kolabnow.com> (raw)
In-Reply-To: <87tu3qgmlg.fsf@kolabnow.com>

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




  reply	other threads:[~2022-11-04  2:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-17  1:28 [bug#58576] [PATCH] system: image: Define correct docker image arch when cross building Thiago Jung Bauermann via Guix-patches via
2022-10-17  7:54 ` Mathieu Othacehe
2022-10-26 23:47   ` Thiago Jung Bauermann via Guix-patches via
2022-11-04  1:54     ` Thiago Jung Bauermann via Guix-patches via [this message]
2022-11-04  7:46       ` bug#58576: [PATCH v2] " Mathieu Othacehe
2022-11-05  3:04         ` [bug#58576] " Thiago Jung Bauermann via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221104015456.1059014-1-bauermann@kolabnow.com \
    --to=guix-patches@gnu.org \
    --cc=58576@debbugs.gnu.org \
    --cc=bauermann@kolabnow.com \
    --cc=othacehe@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).