Skip to contentSkip to conversation

image-oci.bbclass creates faulty arm/variant entry in index.json

DISCUSSION Robert Berger 2 participants 4 messages Jul 17, 2020 – Jul 18, 2020 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

index.json looks like this:

{
"schemaVersion": 2,
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"size": 420,
"digest": "sha256:63f34b526be88da860b1ae7969430bc7d20f233a58e13fc0f3770e61e037ebba", "platform": {
"architecture": "arm",
\"variant\": "v7",
"os": "linux"
},
"annotations": {
"org.opencontainers.image.ref.name": "latest"
}
}
]
}

\"variant\": "v7" should be "variant": "v7"

I just hacked it like this in one of my custom scripts:

sed -i 's/\\"variant\\"/"variant"/g' ${OCI}/index.json

But this is not an appropriate fix.

The problem seems to be a combination of image-oci.bbclass and sloci-image.

Regards,

Robert

#1 lore raw
Quoted 24 lines · Robert Berger

index.json looks like this:

{
"schemaVersion": 2,
"manifests": [

    {
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "size": 420,
      "digest": "sha256:63f34b526be88da860b1ae7969430bc7d20f233a58e13fc0f3770e61e037ebba",
      "platform": {
        "architecture": "arm",
        \"variant\": "v7",
        "os": "linux"
      },
      "annotations": {
        "org.opencontainers.image.ref.name": "latest"
      }
    }

]
}

\"variant\": "v7" should be "variant": "v7"

Quoted 7 lines

I just hacked it like this in one of my custom scripts:

sed -i 's/\\"variant\\"/"variant"/g' ${OCI}/index.json

But this is not an appropriate fix.

The problem seems to be a combination of image-oci.bbclass and sloci-image.

It's sloci-image. I'll pull together a fix.

Bruce

Quoted 4 lines

Regards,

Robert

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Attached is the fix.

It is lightly tested and did the right thing in my unit testing. I'll push it early next week, if it works for you as well.

Bruce

Quoted 51 lines · Bruce Ashfield via lists.yoctoproject.org
Quoted 24 lines · Robert Berger

index.json looks like this:

{
"schemaVersion": 2,
"manifests": [

    {
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "size": 420,
      "digest": "sha256:63f34b526be88da860b1ae7969430bc7d20f233a58e13fc0f3770e61e037ebba",
      "platform": {
        "architecture": "arm",
        \"variant\": "v7",
        "os": "linux"
      },
      "annotations": {
        "org.opencontainers.image.ref.name": "latest"
      }
    }

]
}

\"variant\": "v7" should be "variant": "v7"

Quoted 7 lines

I just hacked it like this in one of my custom scripts:

sed -i 's/\\"variant\\"/"variant"/g' ${OCI}/index.json

But this is not an appropriate fix.

The problem seems to be a combination of image-oci.bbclass and sloci-image.

It's sloci-image. I'll pull together a fix.

Bruce

Quoted 4 lines

Regards,

Robert

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

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

From 2e4a5e5511fce537ab693ee5b9afa42553dee18c Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <[email protected]>
Date: Fri, 17 Jul 2020 15:02:37 -0400
Subject: [PATCH] sloci-image: fix variant quoting

Bash doesn't deal very well with the quoted "variant" in the output of the oci-image-index. We can calculate the string at the top of the function, and just use it as a whole to avoid needing to figure out the quote escaping.

No changes in the output, except a properly quoted "variant" when a variant is defined.

We also adjust the definition of "S", since it really wasn't correct before, and now that we have patches, it is more important.

---
 .../sloci-image/sloci-image-native_git.bb     | 11 +++--
 ...0001-sloci-image-fix-variant-quoting.patch | 42 +++++++++++++++++++
 2 files changed, 49 insertions(+), 4 deletions(-)
 create mode 100644 recipes-containers/sloci-image/sloci-image/0001-sloci-image-fix-variant-quoting.patch
recipes-containers/sloci-image/sloci-image-native_git.bb +7 -4
index 56e8e0f..b3b11bd 100644
@@ -1,7 +1,10 @@
 SUMMARY = "A simple CLI tool for packing rootfs into a single-layer OCI image"
 LICENSE = "MIT"
-LIC_FILES_CHKSUM = "file://git/LICENSE;md5=948cd8e59069fad992b0469af9ad7966"
-SRC_URI = "git://github.com/jirutka/sloci-image.git"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=948cd8e59069fad992b0469af9ad7966"
+SRC_URI = "git://github.com/jirutka/sloci-image.git \
+           file://0001-sloci-image-fix-variant-quoting.patch \
+          "
+
 
 DEPENDS = ""
 
@@ -10,13 +13,13 @@ PV = "v0.1.0+git${SRCPV}"
 
 inherit native
 
-S = "${WORKDIR}"
+S = "${WORKDIR}/git"
 
 do_compile() { 
 	:
 }
 
 do_install() {
-	cd ${S}/git
+	cd ${S}
         make PREFIX="${exec_prefix}" DESTDIR=${D} install
 }
recipes-containers/sloci-image/sloci-image/0001-sloci-image-fix-variant-quoting.patch new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.19.1
#4 lore raw

Hi,

Thanks!

Some space before "variant": "v7", to align with the character above would make it better readable, but this works for me as well.

{
"schemaVersion": 2,
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"size": 420,
"digest": "sha256:15324340cf7e067ee2e80c9409aee370a797d37dd14fe0cd62d68718fce1ed06", "platform": {
"architecture": "arm",
"variant": "v7",
"os": "linux"
},
"annotations": {
"org.opencontainers.image.ref.name": "latest"
}
}
]
}