diff --git a/oci/private/tarball.sh.tpl b/oci/private/tarball.sh.tpl index 122fbf6a..365d49a3 100644 --- a/oci/private/tarball.sh.tpl +++ b/oci/private/tarball.sh.tpl @@ -18,7 +18,6 @@ cp_f_with_mkdir() { } MANIFEST_DIGEST=$(${YQ} eval '.manifests[0].digest | sub(":"; "/")' "${INDEX_FILE}" | tr -d '"') -REPOTAGS=($(cat "${TAGS_FILE}")) MANIFESTS_LENGTH=$("${YQ}" eval '.manifests | length' "${INDEX_FILE}") if [[ "${MANIFESTS_LENGTH}" != 1 ]]; then @@ -73,6 +72,7 @@ if [[ "${FORMAT}" == "oci" ]]; then # Fill in repo tags as per https://github.com/opencontainers/image-spec/issues/796 # If there's more than one repo tag, we need to duplicate the manifest entry, so we have one copy per repo tag. MANIFEST_COPIES=".manifests" + REPOTAGS=($(cat "${TAGS_FILE}")) if [[ "${#REPOTAGS[@]}" -gt 1 ]]; then for i in $(seq 2 "${#REPOTAGS[@]}"); do MANIFEST_COPIES="${MANIFEST_COPIES} + .manifests" @@ -130,11 +130,15 @@ for LAYER in $(${YQ} ".[]" <<< $LAYERS); do cp_f_with_mkdir "${IMAGE_DIR}/blobs/${LAYER}" "${BLOBS_DIR}/${LAYER}.tar.gz" done -repo_tags="${REPOTAGS[@]}" \ +# Replace newlines (unix or windows line endings) with % character. +# We can't pass newlines to yq due to https://github.com/mikefarah/yq/issues/1430 and +# we can't update YQ at the moment because structure_test depends on a specific version: +# see https://github.com/bazel-contrib/rules_oci/issues/212 +repo_tags="$(tr -d '\r' < "${TAGS_FILE}" | tr '\n' '%')" \ config="blobs/${CONFIG_DIGEST}" \ layers="${LAYERS}" \ "${YQ}" eval \ - --null-input '.[0] = {"Config": env(config), "RepoTags": "${repo_tags}" | envsubst | split(" ") | map(select(. != "")) , "Layers": env(layers) | map( "blobs/" + . + ".tar.gz") }' \ + --null-input '.[0] = {"Config": env(config), "RepoTags": "${repo_tags}" | envsubst | split("%") | map(select(. != "")) , "Layers": env(layers) | map( "blobs/" + . + ".tar.gz") }' \ --output-format json > "${STAGING_DIR}/manifest.json" # TODO: https://github.com/bazel-contrib/rules_oci/issues/217