mirror of
git://git.yoctoproject.org/meta-virtualization.git
synced 2025-07-19 20:59:41 +02:00
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>
This commit is contained in:
parent
202f388855
commit
16c89216dc
|
@ -65,10 +65,25 @@ IMAGE_CMD:oci() {
|
||||||
${oci_image_port_options} \
|
${oci_image_port_options} \
|
||||||
${IMAGE_ROOTFS} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci:${OCI_IMAGE_TAG}
|
${IMAGE_ROOTFS} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci:${OCI_IMAGE_TAG}
|
||||||
|
|
||||||
|
if [ -n "${OCI_IMAGE_TAR_OUTPUT}" ]; then
|
||||||
|
# if tar is specified, sloci-image is removing the directory that we need for a secondary
|
||||||
|
# tar format, so we need to restore it.
|
||||||
|
tar xf ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci-${OCI_IMAGE_TAG}-${OCI_IMAGE_ARCH}-linux.oci-image.tar
|
||||||
|
fi
|
||||||
|
|
||||||
# create a convenience symlink
|
# create a convenience symlink
|
||||||
ln -sf ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci ${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci
|
ln -sf ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci ${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci
|
||||||
|
|
||||||
if [ -n "${OCI_IMAGE_TAR_OUTPUT}" ]; then
|
if [ -n "${OCI_IMAGE_TAR_OUTPUT}" ]; then
|
||||||
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
|
# move the sloci output to a naming convention that matches what we do with umoci, thie
|
||||||
|
# default creates a subdirectory, so it get the "-dir" in the name
|
||||||
|
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
|
||||||
|
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
|
||||||
|
|
||||||
|
(
|
||||||
|
cd "${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci"
|
||||||
|
tar -cf ../"${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci-${OCI_IMAGE_TAG}-${OCI_IMAGE_ARCH}-linux.oci-image.tar" "."
|
||||||
|
)
|
||||||
|
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
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,14 +106,25 @@ IMAGE_CMD:oci() {
|
||||||
umoci config --image $image_name:${OCI_IMAGE_TAG} --author ${OCI_IMAGE_AUTHOR_EMAIL}
|
umoci config --image $image_name:${OCI_IMAGE_TAG} --author ${OCI_IMAGE_AUTHOR_EMAIL}
|
||||||
|
|
||||||
# make a tar version of the image direcotry
|
# make a tar version of the image direcotry
|
||||||
|
# 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)
|
||||||
if [ -n "${OCI_IMAGE_TAR_OUTPUT}" ]; then
|
if [ -n "${OCI_IMAGE_TAR_OUTPUT}" ]; then
|
||||||
tar -cf "$image_name.tar" "$image_name"
|
(
|
||||||
|
cd "$image_name"
|
||||||
|
tar -cf ../"$image_name.tar" "."
|
||||||
|
)
|
||||||
|
tar -cf "$image_name-dir.tar" "$image_name"
|
||||||
|
|
||||||
# create a convenience symlink
|
# create a convenience symlink
|
||||||
ln -sf "$image_name.tar" "${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci.tar"
|
ln -sf "$image_name.tar" "${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci.tar"
|
||||||
|
ln -sf "$image_name-dir.tar" "${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci-dir.tar"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# We could make this optional, since the bundle is directly runnable via runc
|
# We could make this optional, since the bundle is directly runnable via runc
|
||||||
rm -rf $image_bundle_name
|
rm -rf $image_bundle_name
|
||||||
|
|
||||||
|
# This is the OCI image directory, which is technically the "image" as specified
|
||||||
ln -sf $image_name ${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci
|
ln -sf $image_name ${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user