Debian Codegraph @

doc/source/image_description.rst

raw
1 .. _image-description:
2
3 Image Description
4 =================
5
6 KIWI builds images from a description directory. The directory describes what
7 packages to install, how to configure the target system, and which image types
8 should be created from the prepared root tree.
9
10 .. contents:: On this page
11 :local:
12 :depth: 2
13
14 Description Directory Layout
15 ----------------------------
16
17 A description directory usually contains these files:
18
19 :file:`config.xml` or :file:`*.kiwi`
20 The main image description. It defines metadata, repositories, packages,
21 users, image types, and optional profile-specific variants.
22
23 :file:`root/` or :file:`root.tar.gz`
24 Overlay content copied into the prepared root tree after package
25 installation.
26
27 :file:`config.sh`
28 An optional shell hook executed near the end of the prepare step.
29
30 :file:`images.sh`
31 An optional shell hook executed at the beginning of the create step.
32
33 :file:`config-cdroot.tar[.*]`
34 Optional additional files for ISO-style images, such as licenses or offline
35 documentation.
36
37 Referenced archives, drivers, certificate files, and include files
38 Additional resources referenced from the image description itself.
39
40 Minimal Example
41 ---------------
42
43 The following description is enough to prepare a root tree and create a simple
44 image from it:
45
46 .. code:: xml
47
48 <image schemaversion="{schema_version}" name="example">
49 <description type="system">
50 <author>Example Author</author>
51 <contact>[email protected]</contact>
52 <specification>Small example image</specification>
53 </description>
54
55 <preferences>
56 <version>1.0.0</version>
57 <packagemanager>zypper</packagemanager>
58 <type image="oem" filesystem="ext4"/>
59 </preferences>
60
61 <repository type="rpm-md">
62 <source path="{exc_repo_leap}"/>
63 </repository>
64
65 <packages type="image">
66 <package name="bash"/>
67 </packages>
68 </image>
69
70 Top-Level Schema Layout
71 -----------------------
72
73 The :file:`kiwi/schema/kiwi.rnc` schema organizes the document below the
74 :ref:`sec.image` root element in this order:
75
76 .. list-table:: Top-level sections
77 :widths: 18 34 32 16
78 :header-rows: 1
79
80 * - Section
81 - Purpose
82 - Main attributes and children
83 - Reference
84 * - ``<image>``
85 - Root node of the description.
86 - Required: ``name``, ``schemaversion``. Optional: ``displayname``, ``id``.
87 - :ref:`sec.image`
88 * - ``<include>``
89 - Insert the inner content of another XML description file.
90 - ``from`` URI attribute.
91 - :ref:`sec.include`
92 * - ``<certificates>``
93 - Import additional CA certificates during the build.
94 - ``target_distribution`` with one or more ``<certificate name="..."/>`` entries.
95 - :ref:`sec.certificates`
96 * - ``<description>``
97 - Define human-readable identity and ownership.
98 - ``type`` plus ``<author>``, ``<contact>``, ``<specification>``, and optional ``<license>``.
99 - :ref:`sec.description`
100 * - ``<preferences>``
101 - Define versions, package manager behavior, and one or more image types.
102 - Optional ``arch`` and ``profiles`` filters; includes ``<version>``, ``<packagemanager>``, ``<type>``, locale, timezone, themes, and release settings.
103 - :ref:`sec.preferences`
104 * - ``<profiles>``
105 - Group conditional variants of the same description.
106 - ``<profile>`` entries with ``name``, ``description``, ``arch``, ``import``, and optional ``<requires>``.
107 - :ref:`sec.profiles`
108 * - ``<users>``
109 - Create or adjust users and groups in the image.
110 - User records, group membership, home, shell, and password data.
111 - :ref:`sec.users`
112 * - ``<drivers>``
113 - Add driver files to the image description.
114 - File references with optional profile filters.
115 - :ref:`sec.drivers`
116 * - ``<strip>``
117 - Remove files, libraries, or toolchains from the prepared root tree.
118 - Required ``type`` (``delete``, ``tools``, or ``libs``) with one or more ``<file>`` entries.
119 - :ref:`sec.strip`
120 * - ``<repository>``
121 - Point KIWI to package sources.
122 - Repository type, source type, priority, GPG behavior, credentials, and source URLs.
123 - :ref:`sec.repository`
124 * - ``<containers>``
125 - Define containers to fetch from a registry into the image.
126 - Required ``source`` and ``backend`` with one or more ``<container>`` entries.
127 - :ref:`sec.registry`
128 * - ``<packages>``
129 - Define what KIWI installs, deletes, or imports.
130 - ``type``, optional ``profiles``, ``patternType``, ``bootstrap_package`` with package, collection, product, file, ignore, and archive entries.
131 - :ref:`sec.packages`
132 * - ``<extension>``
133 - Attach custom XML namespaces validated outside the built-in schema.
134 - Arbitrary namespaced content.
135 - :ref:`sec.extension`
136
137 What to Configure First
138 -----------------------
139
140 When you create or review an image description, work in this order:
141
142 #. Start with :ref:`sec.description` so the image has clear ownership and a
143 purpose.
144 #. Add at least one :ref:`sec.preferences` block with a version, package
145 manager, and one or more :ref:`type definitions <sec.preferences>`.
146 #. Add the :ref:`sec.repository` entries that provide the packages needed for
147 the build.
148 #. Add one or more :ref:`sec.packages` sections to populate the root tree.
149 #. Add optional sections such as :ref:`sec.users`, :ref:`sec.profiles`, or
150 :ref:`sec.certificates` only when the use case needs them.
151
152 Common Patterns
153 ---------------
154
155 Use profiles when one description should build multiple variants.
156
157 .. code:: xml
158
159 <profiles>
160 <profile name="VMX" description="VMware output"/>
161 <profile name="CLOUD" description="Cloud output"/>
162 </profiles>
163
164 <preferences profiles="VMX">
165 <version>1.0.0</version>
166 <packagemanager>zypper</packagemanager>
167 <type image="oem" format="vmdk" filesystem="ext4"/>
168 </preferences>
169
170 <preferences profiles="CLOUD">
171 <version>1.0.0</version>
172 <packagemanager>zypper</packagemanager>
173 <type image="oem" format="qcow2" filesystem="ext4"/>
174 </preferences>
175
176 Use multiple package sections to separate bootstrap packages from the final
177 image content.
178
179 .. code:: xml
180
181 <packages type="bootstrap">
182 <package name="filesystem"/>
183 <package name="glibc-locale"/>
184 </packages>
185
186 <packages type="image">
187 <package name="bash"/>
188 <package name="vim"/>
189 </packages>
190
191 Complete Schema Reference
192 -------------------------
193
194 The exhaustive element and attribute reference is documented in
195 :doc:`image_description/elements`. That reference follows the schema in
196 :file:`kiwi/schema/kiwi.rnc` and covers:
197
198 * every top-level section allowed below ``<image>``;
199 * all common and type-specific attributes of ``<preferences><type>``;
200 * repository, package, user, profile, bootloader, storage, and container
201 substructures; and
202 * examples for the most frequently used sections.
203
204 Use this page as the guide to the structure of a description directory and use
205 :doc:`image_description/elements` as the schema-backed lookup for every valid
206 section and attribute.
207
208 .. toctree::
209 :maxdepth: 1
210
211 image_description/elements.rst