diff options
author | Bruce Ashfield <bruce.ashfield@gmail.com> | 2022-12-09 18:21:01 -0500 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2023-02-10 12:36:11 -0500 |
commit | 16c89216dc24021f574e7740b9f8a6e4ed112b9c (patch) | |
tree | d2ed5f15dcf2b79d2c420f4b12ffbfd13af90111 /classes | |
parent | 202f388855a8fa3238d2c7dc532c4e19f70022cb (diff) | |
download | meta-virtualization-16c89216dc24021f574e7740b9f8a6e4ed112b9c.tar.gz |
oci-image: create two different tar outputs
The original tar output of the oci image followed the sloci-image
convention of putting the oci contents into a subdirectory in the
tarball. This allows it to work directly with skopeo, etc, but it
isn't the format that tools like podman expect in an oci-image
tarball.
We move the original format to have "-dir" in the name, and let
the more simply named one be the oci-image format as expcted by
various 3rd party tools
1) image_name.tar: compatible with oci tar format, blobs and
rootfs are at the top level. Can load directly from something like podman
2) image_name-dir.tar: original format from meta-virt, is just a
tar'd up oci image directory (compatible with skopeo :dir format)
We also fix a bug in the sloci-image backend, where the sloci tar
was removing the raw oci image directory leaving a dangling symlink.
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'classes')
-rw-r--r-- | classes/image-oci-sloci-image.inc | 17 | ||||
-rw-r--r-- | classes/image-oci-umoci.inc | 13 |
2 files changed, 28 insertions, 2 deletions
diff --git a/classes/image-oci-sloci-image.inc b/classes/image-oci-sloci-image.inc index 379f6fe0..9248489f 100644 --- a/classes/image-oci-sloci-image.inc +++ b/classes/image-oci-sloci-image.inc | |||
@@ -65,10 +65,25 @@ IMAGE_CMD:oci() { | |||
65 | ${oci_image_port_options} \ | 65 | ${oci_image_port_options} \ |
66 | ${IMAGE_ROOTFS} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci:${OCI_IMAGE_TAG} | 66 | ${IMAGE_ROOTFS} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci:${OCI_IMAGE_TAG} |
67 | 67 | ||
68 | if [ -n "${OCI_IMAGE_TAR_OUTPUT}" ]; then | ||
69 | # if tar is specified, sloci-image is removing the directory that we need for a secondary | ||
70 | # tar format, so we need to restore it. | ||
71 | tar xf ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci-${OCI_IMAGE_TAG}-${OCI_IMAGE_ARCH}-linux.oci-image.tar | ||
72 | fi | ||
73 | |||
68 | # create a convenience symlink | 74 | # create a convenience symlink |
69 | ln -sf ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci ${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci | 75 | ln -sf ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci ${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci |
70 | 76 | ||
71 | if [ -n "${OCI_IMAGE_TAR_OUTPUT}" ]; then | 77 | if [ -n "${OCI_IMAGE_TAR_OUTPUT}" ]; then |
72 | ln -sf ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci-${OCI_IMAGE_TAG}-${OCI_IMAGE_ARCH}-linux.oci-image.tar ${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci.tar | 78 | # move the sloci output to a naming convention that matches what we do with umoci, thie |
79 | # default creates a subdirectory, so it get the "-dir" in the name | ||
80 | mv ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci-${OCI_IMAGE_TAG}-${OCI_IMAGE_ARCH}-linux.oci-image.tar ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci-${OCI_IMAGE_TAG}-${OCI_IMAGE_ARCH}-linux.oci-dir.tar | ||
81 | ln -sf ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci-${OCI_IMAGE_TAG}-${OCI_IMAGE_ARCH}-linux.oci-dir.tar ${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci-dir.tar | ||
82 | |||
83 | ( | ||
84 | cd "${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci" | ||
85 | tar -cf ../"${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci-${OCI_IMAGE_TAG}-${OCI_IMAGE_ARCH}-linux.oci-image.tar" "." | ||
86 | ) | ||
87 | ln -sf "${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci-${OCI_IMAGE_TAG}-${OCI_IMAGE_ARCH}-linux.oci-image.tar" ${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci.tar | ||
73 | fi | 88 | fi |
74 | } | 89 | } |
diff --git a/classes/image-oci-umoci.inc b/classes/image-oci-umoci.inc index 38917d4f..58e46681 100644 --- a/classes/image-oci-umoci.inc +++ b/classes/image-oci-umoci.inc | |||
@@ -106,14 +106,25 @@ IMAGE_CMD:oci() { | |||
106 | umoci config --image $image_name:${OCI_IMAGE_TAG} --author ${OCI_IMAGE_AUTHOR_EMAIL} | 106 | umoci config --image $image_name:${OCI_IMAGE_TAG} --author ${OCI_IMAGE_AUTHOR_EMAIL} |
107 | 107 | ||
108 | # make a tar version of the image direcotry | 108 | # make a tar version of the image direcotry |
109 | # 1) image_name.tar: compatible with oci tar format, blobs and rootfs | ||
110 | # are at the top level. Can load directly from something like podman | ||
111 | # 2) image_name-dir.tar: original format from meta-virt, is just a tar'd | ||
112 | # up oci image directory (compatible with skopeo :dir format) | ||
109 | if [ -n "${OCI_IMAGE_TAR_OUTPUT}" ]; then | 113 | if [ -n "${OCI_IMAGE_TAR_OUTPUT}" ]; then |
110 | tar -cf "$image_name.tar" "$image_name" | 114 | ( |
115 | cd "$image_name" | ||
116 | tar -cf ../"$image_name.tar" "." | ||
117 | ) | ||
118 | tar -cf "$image_name-dir.tar" "$image_name" | ||
119 | |||
111 | # create a convenience symlink | 120 | # create a convenience symlink |
112 | ln -sf "$image_name.tar" "${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci.tar" | 121 | ln -sf "$image_name.tar" "${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci.tar" |
122 | ln -sf "$image_name-dir.tar" "${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci-dir.tar" | ||
113 | fi | 123 | fi |
114 | 124 | ||
115 | # We could make this optional, since the bundle is directly runnable via runc | 125 | # We could make this optional, since the bundle is directly runnable via runc |
116 | rm -rf $image_bundle_name | 126 | rm -rf $image_bundle_name |
117 | 127 | ||
128 | # This is the OCI image directory, which is technically the "image" as specified | ||
118 | ln -sf $image_name ${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci | 129 | ln -sf $image_name ${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci |
119 | } | 130 | } |