all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#58576] [PATCH] system: image: Define correct docker image arch when cross building
@ 2022-10-17  1:28 Thiago Jung Bauermann via Guix-patches via
  2022-10-17  7:54 ` Mathieu Othacehe
  0 siblings, 1 reply; 6+ messages in thread
From: Thiago Jung Bauermann via Guix-patches via @ 2022-10-17  1:28 UTC (permalink / raw)
  To: 58576; +Cc: Thiago Jung Bauermann

From: Thiago Jung Bauermann <thiago.bauermann@linaro.org>

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’.
---
 gnu/system/image.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gnu/system/image.scm b/gnu/system/image.scm
index 5fc0d55d9a14..c6d7d13f6daf 100644
--- a/gnu/system/image.scm
+++ b/gnu/system/image.scm
@@ -652,6 +652,9 @@ (define shared-network?
                shared-network?)
               (list boot-program)))
          (substitutable? (image-substitutable? image))
+         (image-target (or (%current-target-system)
+                           (and=> (image-platform image) platform-target)
+                           (nix-system->gnu-triplet)))
          (register-closures? (has-guix-service-type? os))
          (schema (and register-closures?
                       (local-file (search-path %load-path
@@ -705,6 +708,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




^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-05  3:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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     ` [bug#58576] [PATCH v2] " Thiago Jung Bauermann via Guix-patches via
2022-11-04  7:46       ` bug#58576: " Mathieu Othacehe
2022-11-05  3:04         ` [bug#58576] " Thiago Jung Bauermann via Guix-patches via

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.