Skip to contentSkip to conversation

classes/image-oci: Map x86_64 -> amd64

PATCH In review Joshua Watt 2 participants 6 messages Oct 16, 2023 – Nov 3, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 classes/image-oci: Map x86_64 -> amd64

OCI requires that the architecture [1] be a valid GOARCH [2]. "x86_64" is not a valid GOARCH so map it to the correct "amd64" value.

[1]: https://github.com/opencontainers/image-spec/blob/main/config.md#properties
[2]: https://go.dev/doc/install/source#environment

---
 classes/image-oci.bbclass | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
classes/image-oci.bbclass +8 -1
index 9ddb88b..3370f86 100644
@@ -52,7 +52,7 @@ OCI_IMAGE_AUTHOR_EMAIL ?= "${PATCH_GIT_USER_EMAIL}"
 OCI_IMAGE_TAG ?= "latest"
 OCI_IMAGE_RUNTIME_UID ?= ""
 
-OCI_IMAGE_ARCH ?= "${TARGET_ARCH}"
+OCI_IMAGE_ARCH ?= "${@oci_map_arch(d.getVar('TARGET_ARCH'))}"
 OCI_IMAGE_SUBARCH ?= "${@oci_map_subarch(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
 
 OCI_IMAGE_ENTRYPOINT ?= "sh"
@@ -74,6 +74,13 @@ OCI_IMAGE_ENV_VARS ?= ""
 # bundled into a tarball.
 OCI_IMAGE_TAR_OUTPUT ?= "true"
 
+# Map architectures to a valid container arch. Note that the container archs
+# should be a valid GOARCH
+def oci_map_arch(a):
+    if a == "x86_64":
+        return "amd64"
+    return a
+
 # Generate a subarch that is appropriate to OCI image
 # types. This is typically only ARM architectures at the
 # moment.
Signature · 1 line
2.34.1
#1 lore raw
Quoted 4 lines · Joshua Watt

OCI requires that the architecture [1] be a valid GOARCH [2]. "x86_64" is not a valid GOARCH so map it to the correct "amd64" value.

It may require it, but I've never had any issues with a container running.

Are you seeing a warning or something else ?

Quoted 24 lines

[1]: https://github.com/opencontainers/image-spec/blob/main/config.md#properties
[2]: https://go.dev/doc/install/source#environment

---
 classes/image-oci.bbclass | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
classes/image-oci.bbclass +1 -1
index 9ddb88b..3370f86 100644
@@ -52,7 +52,7 @@ OCI_IMAGE_AUTHOR_EMAIL ?= "${PATCH_GIT_USER_EMAIL}"
 OCI_IMAGE_TAG ?= "latest"
 OCI_IMAGE_RUNTIME_UID ?= ""
 
-OCI_IMAGE_ARCH ?= "${TARGET_ARCH}"
+OCI_IMAGE_ARCH ?= "${@oci_map_arch(d.getVar('TARGET_ARCH'))}"
 OCI_IMAGE_SUBARCH ?= "${@oci_map_subarch(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
 
 OCI_IMAGE_ENTRYPOINT ?= "sh"

classes/image-oci.bbclass OCI_IMAGE_ENV_VARS ?= "" · line 82

Quoted 9 lines
classes/image-oci.bbclass +6 -0
@@ -74,6 +74,13 @@ OCI_IMAGE_ENV_VARS ?= ""
 # bundled into a tarball.
 OCI_IMAGE_TAR_OUTPUT ?= "true"
 
+# Map architectures to a valid container arch. Note that the container archs
+# should be a valid GOARCH
+def oci_map_arch(a):
+    if a == "x86_64":
+        return "amd64"
+    return a

If it is supposed to match to the goarch, why wouldn't we just use the goarch.bbclass mapping ?

Bruce

Quoted 16 lines
classes/image-oci.bbclass +1 -1
+
 # Generate a subarch that is appropriate to OCI image
 # types. This is typically only ARM architectures at the
 # moment.
--

2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#8376): https://lists.yoctoproject.org/g/meta-virtualization/message/8376
Mute This Topic: https://lists.yoctoproject.org/mt/102006091/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
#2 lore raw
Quoted 10 lines · Bruce Ashfield
Quoted 4 lines · Joshua Watt

OCI requires that the architecture [1] be a valid GOARCH [2]. "x86_64" is not a valid GOARCH so map it to the correct "amd64" value.

It may require it, but I've never had any issues with a container running.

Are you seeing a warning or something else ?

I haven't, but I noticed it was wrong

Quoted 28 lines
Quoted 28 lines

[1]: https://github.com/opencontainers/image-spec/blob/main/config.md#properties
[2]: https://go.dev/doc/install/source#environment

---
 classes/image-oci.bbclass | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
classes/image-oci.bbclass +1 -1
index 9ddb88b..3370f86 100644
@@ -52,7 +52,7 @@ OCI_IMAGE_AUTHOR_EMAIL ?= "${PATCH_GIT_USER_EMAIL}"
 OCI_IMAGE_TAG ?= "latest"
 OCI_IMAGE_RUNTIME_UID ?= ""
 
-OCI_IMAGE_ARCH ?= "${TARGET_ARCH}"
+OCI_IMAGE_ARCH ?= "${@oci_map_arch(d.getVar('TARGET_ARCH'))}"
 OCI_IMAGE_SUBARCH ?= "${@oci_map_subarch(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
 
 OCI_IMAGE_ENTRYPOINT ?= "sh"
@@ -74,6 +74,13 @@ OCI_IMAGE_ENV_VARS ?= ""
 # bundled into a tarball.
 OCI_IMAGE_TAR_OUTPUT ?= "true"
 
Quoted 9 lines

classes/image-oci.bbclass OCI_IMAGE_ENV_VARS ?= "" · line 82

Quoted 6 lines
classes/image-oci.bbclass +6 -0
+# Map architectures to a valid container arch. Note that the container archs
+# should be a valid GOARCH
+def oci_map_arch(a):
+    if a == "x86_64":
+        return "amd64"
+    return a

If it is supposed to match to the goarch, why wouldn't we just use the goarch.bbclass mapping ?

Ah, that's a good idea. I think I'll move those functions to library code though so that they can be used without the bbclass.

Thanks

Quoted 28 lines

Bruce

Quoted 10 lines
classes/image-oci.bbclass +1 -1
+
 # Generate a subarch that is appropriate to OCI image
 # types. This is typically only ARM architectures at the
 # moment.
--

2.34.1

--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#8378): https://lists.yoctoproject.org/g/meta-virtualization/message/8378
Mute This Topic: https://lists.yoctoproject.org/mt/102006091/3616693
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/leave/12677403/3616693/1765413136/xyzzy [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw
Quoted 9 lines · Joshua Watt
Quoted 7 lines · Bruce Ashfield
Quoted 4 lines · Joshua Watt

OCI requires that the architecture [1] be a valid GOARCH [2]. "x86_64" is not a valid GOARCH so map it to the correct "amd64" value.

Quoted 5 lines
Quoted 3 lines

It may require it, but I've never had any issues with a container running.

Are you seeing a warning or something else ?

I haven't, but I noticed it was wrong

Fair enough. I just always want to document any runtime issues that were seen, since if for example, you weren't able to launch on x86-64 or were getting a runtime warning ... I wonder why I didn't pick it up in my testing.

Quoted 39 lines
Quoted 29 lines
Quoted 29 lines

[1]: https://github.com/opencontainers/image-spec/blob/main/config.md#properties
[2]: https://go.dev/doc/install/source#environment

---
 classes/image-oci.bbclass | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
classes/image-oci.bbclass +1 -1
index 9ddb88b..3370f86 100644
@@ -52,7 +52,7 @@ OCI_IMAGE_AUTHOR_EMAIL ?= "${PATCH_GIT_USER_EMAIL}"
 OCI_IMAGE_TAG ?= "latest"
 OCI_IMAGE_RUNTIME_UID ?= ""
 
-OCI_IMAGE_ARCH ?= "${TARGET_ARCH}"
+OCI_IMAGE_ARCH ?= "${@oci_map_arch(d.getVar('TARGET_ARCH'))}"
 OCI_IMAGE_SUBARCH ?= "${@oci_map_subarch(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
 
 OCI_IMAGE_ENTRYPOINT ?= "sh"
@@ -74,6 +74,13 @@ OCI_IMAGE_ENV_VARS ?= ""
 # bundled into a tarball.
 OCI_IMAGE_TAR_OUTPUT ?= "true"
 
Quoted 9 lines

classes/image-oci.bbclass OCI_IMAGE_ENV_VARS ?= "" · line 82

Quoted 6 lines
classes/image-oci.bbclass +6 -0
+# Map architectures to a valid container arch. Note that the container archs
+# should be a valid GOARCH
+def oci_map_arch(a):
+    if a == "x86_64":
+        return "amd64"
+    return a

If it is supposed to match to the goarch, why wouldn't we just use the goarch.bbclass mapping ?

Quoted 3 lines

Ah, that's a good idea. I think I'll move those functions to library code though so that they can be used without the bbclass.

perfect. I'll wait for v2, and ponder the other pending patches in the meantime.

Bruce

Quoted 30 lines

Thanks

Quoted 28 lines

Bruce

Quoted 10 lines
classes/image-oci.bbclass +1 -1
+
 # Generate a subarch that is appropriate to OCI image
 # types. This is typically only ARM architectures at the
 # moment.
--

2.34.1

--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#8378): https://lists.yoctoproject.org/g/meta-virtualization/message/8378
Mute This Topic: https://lists.yoctoproject.org/mt/102006091/3616693
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/leave/12677403/3616693/1765413136/xyzzy [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
#4 lore raw

PATCH v2 1/1 classes/image-oci: Map image architecture correctly

In reply to Joshua Watt

OCI requires that the architecture [1] be a valid GOARCH [2]. To correctly perform this mapping, use the go library code from OE core.

[1]: https://github.com/opencontainers/image-spec/blob/main/config.md#properties
[2]: https://go.dev/doc/install/source#environment

---
 classes/image-oci.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
classes/image-oci.bbclass +1 -1
index 9ddb88b..0ec5c48 100644
@@ -52,7 +52,7 @@ OCI_IMAGE_AUTHOR_EMAIL ?= "${PATCH_GIT_USER_EMAIL}"
 OCI_IMAGE_TAG ?= "latest"
 OCI_IMAGE_RUNTIME_UID ?= ""
 
-OCI_IMAGE_ARCH ?= "${TARGET_ARCH}"
+OCI_IMAGE_ARCH ?= "${@oe.go.map_arch(d.getVar('TARGET_ARCH'))}"
 OCI_IMAGE_SUBARCH ?= "${@oci_map_subarch(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
 
 OCI_IMAGE_ENTRYPOINT ?= "sh"
Signature · 1 line
2.34.1
#5 lore raw

Re: [meta-virtualization][PATCH v2] classes/image-oci: Map image architecture correctly

merged to master-next

With any luck, I'll complete my release testing and master-next will become master shortly

Bruce

In message: [meta-virtualization][PATCH v2] classes/image-oci: Map image architecture correctly

Quoted 37 lines · on 30/10/2023 Joshua Watt wrote:

OCI requires that the architecture [1] be a valid GOARCH [2]. To correctly perform this mapping, use the go library code from OE core.

[1]: https://github.com/opencontainers/image-spec/blob/main/config.md#properties
[2]: https://go.dev/doc/install/source#environment

---
 classes/image-oci.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
classes/image-oci.bbclass +1 -1
index 9ddb88b..0ec5c48 100644
@@ -52,7 +52,7 @@ OCI_IMAGE_AUTHOR_EMAIL ?= "${PATCH_GIT_USER_EMAIL}"
 OCI_IMAGE_TAG ?= "latest"
 OCI_IMAGE_RUNTIME_UID ?= ""
 
-OCI_IMAGE_ARCH ?= "${TARGET_ARCH}"
+OCI_IMAGE_ARCH ?= "${@oe.go.map_arch(d.getVar('TARGET_ARCH'))}"
 OCI_IMAGE_SUBARCH ?= "${@oci_map_subarch(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
 
 OCI_IMAGE_ENTRYPOINT ?= "sh"
Signature · 11 lines
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#8408): https://lists.yoctoproject.org/g/meta-virtualization/message/8408
Mute This Topic: https://lists.yoctoproject.org/mt/102282594/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-