Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions build-tests/x86/tumbleweed/test-image-disk-formats/appliance.kiwi
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>

<image schemaversion="7.5" name="kiwi-test-image-disk-formats" displayname="Disk Formats">
<description type="system">
<author>Marcus Schäfer</author>
<contact>marcus.schaefer@gmail.com</contact>
<specification>Build different disk formats</specification>
</description>
<preferences>
<version>1.42.1</version>
<packagemanager>zypper</packagemanager>
<locale>en_US</locale>
<keytable>us</keytable>
<timezone>Europe/Berlin</timezone>
<rpm-excludedocs>true</rpm-excludedocs>
<rpm-check-signatures>false</rpm-check-signatures>
<bootsplash-theme>breeze</bootsplash-theme>
<bootloader-theme>openSUSE</bootloader-theme>
<type image="oem" filesystem="ext3" kernelcmdline="console=ttyS0" firmware="uefi" eficsm="false" format="oci:raw:docker://alpine:latest">
<oemconfig>
<oem-resize>false</oem-resize>
</oemconfig>
<containerconfig name="alpine_baked_tw"/>
<machine memory="4096"/>
<bootloader name="grub2" console="serial" timeout="10"/>
</type>
</preferences>
<users>
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root" groups="root"/>
</users>
<repository type="rpm-md">
<source path="obsrepositories:/"/>
</repository>
<packages type="image">
<package name="patterns-base-minimal_base"/>
<package name="bind-utils"/>
<package name="systemd"/>
<package name="plymouth-theme-breeze"/>
<package name="plymouth-plugin-script"/>
<package name="grub2-branding-openSUSE"/>
<package name="iputils"/>
<package name="vim"/>
<package name="grub2"/>
<package name="grub2-x86_64-efi" arch="x86_64"/>
<package name="grub2-i386-pc"/>
<package name="lvm2"/>
<package name="plymouth"/>
<package name="fontconfig"/>
<package name="fonts-config"/>
<package name="tar"/>
<package name="parted"/>
<package name="openssh"/>
<package name="iproute2"/>
<package name="less"/>
<package name="bash-completion"/>
<package name="dhcp-client"/>
<package name="which"/>
<package name="kernel-default"/>
<package name="shim"/>
<package name="timezone"/>
</packages>
<packages type="bootstrap">
<package name="gawk"/>
<package name="grep"/>
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
<package name="ca-certificates"/>
<package name="ca-certificates-mozilla"/>
<package name="openSUSE-release"/>
</packages>
</image>
7 changes: 7 additions & 0 deletions build-tests/x86/tumbleweed/test-image-disk-formats/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -ex

#======================================
# Activate services
#--------------------------------------
systemctl enable sshd
31 changes: 27 additions & 4 deletions doc/source/image_description/elements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -931,10 +931,33 @@ flags="overlay|dmsquash":
system based on the capabilities of the upstream dracut
module.

format="gce|ova|qcow2|vagrant|vmdk|vdi|vhd|vhdx|vhd-fixed":
For disk image type oem, this specifies the format of
the virtual disk so that it can run on the desired target
virtualization platform.
format="format_name":
For disk image type `oem`, this specifies the format of the virtual disk
so that it can run on the desired target virtualization platform. The
supported formats_name's are:

* `gce`: Google Compute Engine image format.
* `ova`: Open Virtualization Format Archive.
* `qcow2`: QEMU Copy-On-Write version 2.
* `vagrant`: Vagrant box format (tar.gz).
* `vmdk`: VMware Virtual Machine Disk.
* `vdi`: VirtualBox Disk Image.
* `vhd`: Microsoft Virtual Hard Disk.
* `vhdx`: Microsoft Virtual Hard Disk version 2.
* `vhd-fixed`: Microsoft Virtual Hard Disk with fixed size.
* `oci:image_format:container_transport`: OCI image archive.

The `oci:...` format is a special case that allows you to create an
OCI-compliant container from a specified reference container. The
created container image has the actual disk image added as a new layer.
The specification of the `oci:image_format:container_transport` format
contains two parts separated by a colon. The first part specifies
one of the above disk formats or just `raw` if the disk should be
stored as raw disk inside of the container. The second part specifies
one of the supported `skopeo` container transport formats, for
details see the `skopeo` man page. This format is particularly useful
for building an image which bundles the actual disk image and its
runtime requirements into one artifact.

formatoptions="string":
Specifies additional format options passed on to `qemu-img`.
Expand Down
15 changes: 13 additions & 2 deletions kiwi/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -1528,8 +1528,19 @@ def get_disk_format_types():
:rtype: list
"""
return [
'gce', 'qcow2', 'vmdk', 'ova', 'meta', 'vmx', 'vhd', 'vhdx',
'vhdfixed', 'vdi', 'vagrant.libvirt.box', 'vagrant.virtualbox.box'
'gce',
'qcow2',
'vmdk',
'ova',
'meta',
'vmx',
'vhd',
'vhdx',
'vhdfixed',
'vdi',
'vagrant.libvirt.box',
'vagrant.virtualbox.box',
'oci'
]

@staticmethod
Expand Down
33 changes: 25 additions & 8 deletions kiwi/schema/kiwi.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ grub_console_input = xsd:token {pattern = "(none|console|serial|at_keyboard|usb_
fs_attributes = xsd:token {pattern = "(no-copy-on-write|synchronous-updates)(,(no-copy-on-write|synchronous-updates))*"}
package-version-type = xsd:token {pattern = "(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){3}"}
simple-uri-type = xsd:token {pattern = "(file:|https:|http:|ftp:).*"}
oci_format_type = xsd:token {pattern = "oci:(gce:|ova:|qcow2:|vmdk:|vdi:|vhd:|vhdx:|vhd-fixed:|raw:).*"}

#==========================================
# start with image description
Expand Down Expand Up @@ -1986,7 +1987,7 @@ div {
## Specifies the format of the virtual disk.
attribute format {
"gce" | "ova" | "qcow2" | "vagrant" | "vmdk" |
"vdi" | "vhd" | "vhdx" | "vhd-fixed"
"vdi" | "vhd" | "vhdx" | "vhd-fixed" | oci_format_type
}
>> sch:pattern [ id = "format" is-a = "image_type"
sch:param [ name = "attr" value = "format" ]
Expand Down Expand Up @@ -3090,14 +3091,30 @@ div {
]
]
]
sch:pattern [
abstract = "true"
id = "format_type"
sch:rule [
context = "containerconfig[@$attr]"
sch:assert [
test = "not(../@format) or starts-with(../@format, '$format')"
"containerconfig($attr) is only available for the following "~
"image @format values: $format"
]
]
]
k.containerconfig.name.attribute =
## Specifies a name for the container. This is usually the
## the repository name of the container as read if the container
## image is imported via the docker load command
attribute name { text }
>> sch:pattern [ id = "name" is-a = "container_type"
>> sch:pattern [ id = "image_name" is-a = "container_type"
sch:param [ name = "attr" value = "name" ]
sch:param [ name = "types" value = "oem docker oci appx" ]
]
>> sch:pattern [ id = "format_name" is-a = "format_type"
sch:param [ name = "attr" value = "name" ]
sch:param [ name = "types" value = "docker oci appx" ]
sch:param [ name = "format" value = "oci" ]
]
k.containerconfig.tag.attribute =
## Specifies a tag for the container. This is usually the
Expand All @@ -3106,7 +3123,7 @@ div {
attribute tag { text }
>> sch:pattern [ id = "tag" is-a = "container_type"
sch:param [ name = "attr" value = "tag" ]
sch:param [ name = "types" value = "docker oci" ]
sch:param [ name = "types" value = "oem docker oci" ]
]
k.containerconfig.additionalnames.attribute =
## Specifies additional names for the container using a comma
Expand All @@ -3117,28 +3134,28 @@ div {
attribute additionalnames { text }
>> sch:pattern [ id = "additionalnames" is-a = "container_type"
sch:param [ name = "attr" value = "additionalnames" ]
sch:param [ name = "types" value = "docker oci" ]
sch:param [ name = "types" value = "oem docker oci" ]
]
k.containerconfig.maintainer.attribute =
## Specifies a maintainer for the container.
attribute maintainer { text }
>> sch:pattern [ id = "maintainer" is-a = "container_type"
sch:param [ name = "attr" value = "maintainer" ]
sch:param [ name = "types" value = "docker oci" ]
sch:param [ name = "types" value = "oem docker oci" ]
]
k.containerconfig.user.attribute =
## Specifies a user for the container.
attribute user { text }
>> sch:pattern [ id = "user" is-a = "container_type"
sch:param [ name = "attr" value = "user" ]
sch:param [ name = "types" value = "docker oci" ]
sch:param [ name = "types" value = "oem docker oci" ]
]
k.containerconfig.workingdir.attribute =
## Specifies the default working directory of the container
attribute workingdir { text }
>> sch:pattern [ id = "workingdir" is-a = "container_type"
sch:param [ name = "attr" value = "workingdir" ]
sch:param [ name = "types" value = "docker oci" ]
sch:param [ name = "types" value = "oem docker oci" ]
]
k.containerconfig.attlist =
k.containerconfig.name.attribute &
Expand Down
29 changes: 22 additions & 7 deletions kiwi/schema/kiwi.rng
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@
<param name="pattern">(file:|https:|http:|ftp:).*</param>
</data>
</define>
<define name="oci_format_type">
<data type="token">
<param name="pattern">oci:(gce:|ova:|qcow2:|vmdk:|vdi:|vhd:|vhdx:|vhd-fixed:|raw:).*</param>
</data>
</define>
<!--
==========================================
start with image description
Expand Down Expand Up @@ -2914,6 +2919,7 @@ a different set of live features.</a:documentation>
<value>vhd</value>
<value>vhdx</value>
<value>vhd-fixed</value>
<ref name="oci_format_type"/>
</choice>
</attribute>
<sch:pattern id="format" is-a="image_type">
Expand Down Expand Up @@ -4700,15 +4706,24 @@ and to provide configuration parameters for it</a:documentation>
<sch:assert test="contains('$types', ../@image)">containerconfig($attr) is only available for the following image types: $types</sch:assert>
</sch:rule>
</sch:pattern>
<sch:pattern abstract="true" id="format_type">
<sch:rule context="containerconfig[@$attr]">
<sch:assert test="not(../@format) or starts-with(../@format, '$format')">containerconfig($attr) is only available for the following image @format values: $format</sch:assert>
</sch:rule>
</sch:pattern>
<define name="k.containerconfig.name.attribute">
<attribute name="name">
<a:documentation>Specifies a name for the container. This is usually the
the repository name of the container as read if the container
image is imported via the docker load command</a:documentation>
</attribute>
<sch:pattern id="name" is-a="container_type">
<sch:pattern id="image_name" is-a="container_type">
<sch:param name="attr" value="name"/>
<sch:param name="types" value="docker oci appx"/>
<sch:param name="types" value="oem docker oci appx"/>
</sch:pattern>
<sch:pattern id="format_name" is-a="format_type">
<sch:param name="attr" value="name"/>
<sch:param name="format" value="oci"/>
</sch:pattern>
</define>
<define name="k.containerconfig.tag.attribute">
Expand All @@ -4719,7 +4734,7 @@ image is imported via the docker load command</a:documentation>
</attribute>
<sch:pattern id="tag" is-a="container_type">
<sch:param name="attr" value="tag"/>
<sch:param name="types" value="docker oci"/>
<sch:param name="types" value="oem docker oci"/>
</sch:pattern>
</define>
<define name="k.containerconfig.additionalnames.attribute">
Expand All @@ -4732,7 +4747,7 @@ will be used to build a complete image referrence.</a:documentation>
</attribute>
<sch:pattern id="additionalnames" is-a="container_type">
<sch:param name="attr" value="additionalnames"/>
<sch:param name="types" value="docker oci"/>
<sch:param name="types" value="oem docker oci"/>
</sch:pattern>
</define>
<define name="k.containerconfig.maintainer.attribute">
Expand All @@ -4741,7 +4756,7 @@ will be used to build a complete image referrence.</a:documentation>
</attribute>
<sch:pattern id="maintainer" is-a="container_type">
<sch:param name="attr" value="maintainer"/>
<sch:param name="types" value="docker oci"/>
<sch:param name="types" value="oem docker oci"/>
</sch:pattern>
</define>
<define name="k.containerconfig.user.attribute">
Expand All @@ -4750,7 +4765,7 @@ will be used to build a complete image referrence.</a:documentation>
</attribute>
<sch:pattern id="user" is-a="container_type">
<sch:param name="attr" value="user"/>
<sch:param name="types" value="docker oci"/>
<sch:param name="types" value="oem docker oci"/>
</sch:pattern>
</define>
<define name="k.containerconfig.workingdir.attribute">
Expand All @@ -4759,7 +4774,7 @@ will be used to build a complete image referrence.</a:documentation>
</attribute>
<sch:pattern id="workingdir" is-a="container_type">
<sch:param name="attr" value="workingdir"/>
<sch:param name="types" value="docker oci"/>
<sch:param name="types" value="oem docker oci"/>
</sch:pattern>
</define>
<define name="k.containerconfig.attlist">
Expand Down
10 changes: 10 additions & 0 deletions kiwi/storage/subformat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def new(
name: str, xml_state: XMLState, root_dir: str, target_dir: str
) -> DiskFormatBase:
name_map = {
'oci': 'Oci',
'qcow2': 'Qcow2',
'vdi': 'Vdi',
'vhd': 'Vhd',
Expand Down Expand Up @@ -108,4 +109,13 @@ def _custom_args_for_format(name: str, xml_state: XMLState) -> Tuple[Dict, str]:
)
elif name == 'raw':
module_namespace = 'base'
elif name.startswith('oci:'):
module_namespace, base_format, base_container_uri = \
name.split(':', 2)
custom_args.update(
{
'base_container_uri': base_container_uri,
'base_format': base_format
}
)
return custom_args, module_namespace
Loading
Loading