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.

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
Bruce Ashfield 2020-07-17 15:02:37 -04:00
parent cc25d8efd8
commit fd3d5ff379
2 changed files with 49 additions and 4 deletions

View File

@ -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
}

View File

@ -0,0 +1,42 @@
From 55aebd87ee81f851d088beea8688e3e599c2bced Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@gmail.com>
Date: Fri, 17 Jul 2020 14:40:12 -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.
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
---
sloci-image | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sloci-image b/sloci-image
index be8e79a..e0dc469 100755
--- a/sloci-image
+++ b/sloci-image
@@ -298,6 +298,7 @@ oci_image_config() {
# $1: digest of the image manifest json (must be in blobs directory)
oci_image_index() {
local manifest_digest="$1"
+ local variant_string=" \"variant\": $(json_string "$CFG_ARCH_VARIANT"),"
cat <<-EOF
{
@@ -309,7 +310,7 @@ oci_image_index() {
"digest": "$manifest_digest",
"platform": {
"architecture": "$(oci_arch $CFG_ARCH)",
- ${CFG_ARCH_VARIANT:+"\"variant\": $(json_string "$CFG_ARCH_VARIANT"),"}
+ ${CFG_ARCH_VARIANT:+$variant_string}
"os": "$CFG_OS"
},
"annotations": {
--
2.19.1