Copyright © 2022 SUSE LLC and contributors. All rights reserved.
Except where otherwise noted, this document is licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC-BY-SA 4.0): https://creativecommons.org/licenses/by-sa/4.0/legalcode.
For SUSE trademarks, see http://www.suse.com/company/legal/. All third-party trademarks are the property of their respective owners. Trademark symbols (®, ™ etc.) denote trademarks of SUSE and its affiliates. Asterisks (*) denote third-party trademarks.
All information found in this book has been compiled with utmost attention to detail. However, this does not guarantee complete accuracy. Neither SUSE LLC, its affiliates, the authors nor the translators shall be held liable for possible errors or the consequences thereof.
1 Conceptual overview #
Keg is a tool which helps to create and manage image descriptions for use with the KIWI appliance builder. A KIWI image description consists of a single XML document that specifies type, configuration, and content of the image to build. Optionally there can be configuration scripts and overlay archives added to an image description, which allow for further configuration and additional content.
Since KIWI image descriptions are monolithic, maintaining a number of image descriptions that have considerable overlap with respect to content and setup can be cumbersome and error-prone. Keg attempts to alleviate that by allowing image descriptions to be broken into modules. Those modules can be composed in different ways in so called image definitions, and modules can inherit from parent modules which allows for fine-tuning for specific image setups. Configuration scripts and overlay archives can also be generated in a modular fashion.
The collection of source data required for keg to produce image
descriptions is called recipes. Keg
recipes are typically kept in a git
repository, and Keg has support for producing change logs from
the git commit history, but this is not a requirement. A
recipes repository provides Keg with the
information how an image description is to be composed as well
as the content of the components.
The basic principle of operation is that when
keg is executed, it is pointed to a directory
within the recipes repository and it reads
any YAML files in that directory and any parent directories and
merges their contents into a dictionary. How the image
definition data is structured and composed is not relevant, as
long as the resulting dictionary represents a valid image
definition. This allows for a lot of flexibility in the layout
of a recipes repository. The SUSE
Public Cloud Keg Recipes repository provides an example
of a highly modular one with strong use of inheritance.
For more details on what constitutes a
recipes repository, see section Section 5, “Recipes basics” (ff).
2 Working with keg #
To create an image description, Keg needs to be installed, as well as KIWI, as the latter is used by Keg to validate the final image description. See Section 3, “Installation” for information about how to install Keg, and KIWI Installation about how to install KIWI.
Additionally, a recipes repository is
required. The following example uses the aforementioned SUSE
Public Cloud keg recipes:
> git clone https://github.com/SUSE-Enceladus/keg-recipes.git > mkdir sles15-sp4-byos > keg --recipes-root keg-recipes --dest-dir sles15-sp4-byos \ cross-cloud/sles/byos/15-sp4
After the keg command completes the
destination directory specified with
--dest-dir contains a description for a SUSE
Linux Enterprise Server 15 SP4 image for use in the Public
Clouds. It can be processed with KIWI to build an image. For
more details about KIWI image descriptions, see https://osinside.github.io/kiwi/image_description.html.
Recipes used to generate an image description
can be spread over multiple repositories. For that purpose, the
--recipes-root command line argument may be
given multiple times, with each one specifying a different
recipes repository. Repositories will be
searched in the order they are specified, and for any dictionary
key, config scriptlet, or overlay archive module that exists in
multiple repositories, the one that is read last will be used.
Using multiple repositories for recipes can
be useful in some situations. For example, if some parts of
recipes data are public and some private,
they can be kept in different repositories. It could also be
used to base recipes on an upstream
repository and only maintain additional image definitions or
modifications in a separate repository.
Keg also provides support for producing image descriptions for
use with the Open
Build Service (OBS). It can generate
_multibuild files that are required by OBS
for image descriptions with multiple profiles, and it comes with
an OBS Source Service plug-in for automating
generating image descriptions. See Section 9, “Keg OBS source service” for details.
3 Installation #
This section describes how to install Keg. Currently Keg is available from PyPi and from the openSUSE Build Service for several openSUSE distributions. It is included in openSUSE Tumbleweed.
3.1 Installation from the openSUSE Cloud:Tools repository #
Keg is available for various openSUSE distributions from the
Cloud:Tools
repository in the openSUSE Build Service. Package name
is pythonpy_version-kiwi-keg.
3.2 Installation from PyPI #
Keg can be obtained from the Python Package Index (PyPi) via Python’s package manager pip:
> pip install kiwi_keg
4 Command Line #
4.1 keg #
SYNOPSIS#
keg [options] <source>
DESCRIPTION#
Keg is a tool which helps to create and manage image descriptions suitable for the KIWI appliance builder. While Keg can be used to manage a single image definition the tool provides no considerable advantage in such a use case. The primary use case for Keg are situations where many image descriptions must be managed and the image descriptions have considerable overlap with respect to content and setup.
Keg requires source data called recipes
which provides all information necessary for Keg to create
KIWI image descriptions. See Section 5, “Recipes basics”
for more information about recipes.
The recipes used for generating SUSE Public
Cloud image descriptions can be found in the Public
Cloud Keg Recipes repository.
ARGUMENTS#
- source
Path to image source under
RECIPES_ROOT/images.
OPTIONS#
-
-r--recipes-root Root directory of keg recipes. Can be used more than once. Elements from later roots may overwrite earlier one.
-
-d--dest-dir Destination directory for generated description [default:
.]-
--disable-multibuild Option to disable creation of OBS _multibuild file (for image definitions with multiple profiles). [default:
false]-
--disable-root-tar Option to disable the creation of root.tar.gz in destination directory. If present, an overlay tree will be created instead. [default:
false]-
--dump-dict Dump generated data dictionary to stdout instead of generating an image description. Useful for debugging.
-
-l--list-recipes List available images that can be created with the current recipes.
-
-f--force Force mode (ignore errors, overwrite files).
-
--format-yaml Format/Update Keg written image description to installed KIWI schema and write the result description in YAML markup.
NoteCurrently no translation of comment blocks from the Keg generated KIWI description to the YAML markup will be performed.
-
--format-xml Format/Update Keg written image description to installed KIWI schema and write the result description in XML markup.
NoteCurrently only top-level header comments from the Keg written image description will be preserved into the formatted/updated KIWI XML file. Inline comments will not be preserved.
-
-i--image-version Set image version.
-
-a Generate image description for architecture ARCH (can be used multiple times).
-
-s--write-source-info Write a file per profile containing a list of all used source locations. The files can used to generate a change log from the recipes repository commit log.
-
-v--verbose Enable verbose output.
-
--version Print version.
EXAMPLE#
> git clone https://github.com/SUSE-Enceladus/keg-recipes.git > keg --recipes-root keg-recipes --dest-dir leap_description leap/jeos/15.2
4.2 generate_recipes_changelog #
SYNOPSIS#
generate_recipes_changelog [options] <logfile>
DESCRIPTION#
generate_recipes_changelog generates a
change log from the git commit history of one or more
keg-recipes repositories. The input file
is a source info log that is generated by Keg when run with
source tracking enabled (-s command line
switch).
The exit status is 0 in case a change log was generated successfully, 1 in case an error occurred, or 2 in case no error occurred but generated change log is empty.
ARGUMENTS#
- logfile
A source info log file produced by Keg.
OPTIONS#
-
-o Write output to OUTPUT_FILE (
stdoutif omitted)-
-rPATH:REV Set git revision range to REV for repo at PATH.
NoteThis limits the applicable set of commits to the given revision spec. This can be used to select only newer changes from a previous change log generator run. See the section called “EXAMPLE” below.
-
-f Output format,
textoryaml[default:yaml]-
-m Format spec for commit messages (see ‘format:<string>’ in
man git-log) [default:- %s] (only used with text format)-
-t Use ROOT_TAG for yaml output (e.g. image version)
EXAMPLE#
> generate_recipes_changelog -r /path/to/repo:12345678.. -t 1.1.8 log_sources
This will produce a YAML change log, namespaced with
1.1.8, intended as a version number, only
considering commits after hash 12345678. If
12345678 was the hash of the HEAD commit in
the checked out branch at /PATH/TO/REPO
at the previous run of
generate_recipes_changelog on the same data
set, this would limit the change log to only contain newer
changes. This method can be used to produce incremental change
logs.
The change log will have the following format:
1.1.8:
- change: git message subject
date: git commit UTC timestamp
details: |-
git message body
...5 Recipes basics #
To produce image descriptions, Keg must be provided with source
data, also called keg recipes. Unlike KIWI
descriptions, keg recipes can be composed of
an arbitrary number of files, which allows for creating building
blocks for image descriptions. Keg does not mandate a specific
structure of the recipes data, with the exception that it
expects certain types of source data in specific directories.
This document describes the fundamental keg recipes structure and how Keg
processes input data to generate an image definition.
5.1 Recipes data layout #
Essentially, a keg recipes repository conists of three top-level directories
which contain different types of configuration data. Those three are:
-
Image Definitions:
images The
imagesdirectory contains all image definitions. An image defintion specifies the properties and content of the image description to generate. Include statements in the image definition allow to reference chunks of content from the data modules. Image definitions are specifed in YAML format, can be modular and support data inheritence. See Section 6, “Image definition” for details.- Data Modules:
data The
datadirectory contains different bits of configuration and content data that can be used to compose an image description. See Section 7, “Data modules” for details on data modules. There are three different types of data modules:- Image Definition Modules
Any directory in
datathat is not file:scriptsor file:overlayfilesis considered a module, or module tree, for image definition data. Those modules can be referenced in the image definitions using_includestatements. The data is in YAML format and spports inheritence.- Image Configuration Scriptlets
Scriptlets can be used to compose optional configuration shell scripts that KIWI can run during the build process. The scriptlets are located in
data/scripts.- Overlay Files
Image description may include overlay files that get copied into the target image. Keg can create overlay archives from overlay data directories. Overlay files trees are located in
>data/overlayfiles.
- Schema Templates:
schemas Keg uses Jinja2 templates to produce the headers for
config.shandimages.sh. Both are optional and Keg will write a fallback header if they are missing. Additionally, a Jinja2 template can be used to generateconfig.kiwiinstead of using the internal XML generator.
5.2 Source data format and processing #
This section contains some general information about how Keg handles its source data.
An image description is internally represented by a data dictionary with a certain structure. This dictionary gets composed by parsing source image definition and data files referenced by the image definition and merging them into a dictionary.
Image definitions as well as data modules are used by
referencing a directory (under images or data respectively), which may be
several layers of directories under the root directory. When
parsing those, Keg will also read any
.yaml file that is in a directory above
the referenced one, and merge all source data into one
dictionary, with the lower (i.e. more specific) layers taking
precedence over upper (i.e. more generic) ones. This
inheritance mechanism is intended to reduce data duplication.
Keg uses namespaces in the image definition to group certain bits of information (for instance, a list of packages) which can be overwritten in derived modules, allowing for creating specialized versions of data modules for specific use case or different image description versions.
Once everything is merged, the resulting dictionary is
validated against the image definition schema, to ensure its
structure is correct and all required keys are present. If
that is the case, Keg runs the image dictionary through its
XML generator to produce a config.kiwi
file. In case the image definition contains configuration
scripts or overlay archives specifications, Keg will generate
those as well.
6 Image definition #
In Keg terminology, an image definition is the data set that
specifies the KIWI image description that should be
generated. Keg reads image definition from the images directory in the recipes root directory.
Keg considers all leaf directories in images to be image definitions.
This means by parsing any YAML file from those directories and
all YAML files in any parent directory and merging their data
into a dictionary, a complete image definition needs to be
available in the resulting dictionary. There is no specific
hierarchy required in images. Any level of sub
directories can be used to create multiple levels of
inheritance, or simply just to group image definitions. Example
directory layout:
images/
opensuse/
defaults.yaml
leap/
content.yaml
15.2/
image.yaml
15.3/
image.yaml
This example layout defines two images, opensuse/leap/15.2 and opensuse/leap/15.3. It uses
inheritance to define a common content definition for both image
definitions, and to set some opensuse specific defaults. Running
keg -d output_dir opensuse/leap/15.3 would
merge data from the files in the following order:
images/opensuse/defaults.yaml images/opensuse/leap/content.yaml images/opensuse/leap/15.3/image.yaml
All keys from the individual YAML files that are in the given tree will be merged into a dictionary that defines the image to be generated.
6.1 Image definition structure #
An image definition dictionary is composed of several parts that define different parts of the image. The actual image description, configuration scripts, overlay archives. All parts are defined under a top-level key in the dictionary. There are additional top-level keys that affect data parsing and generator selection.
The top-level keys are as follows:
6.1.1 image #
The image dictionary. This is the only mandatory top-level
key. It defines the content of the
config.kiwi file Keg should generate
and is essentially a YAML version of KIWI's image
description (typically in XML). It contains all image
configuration properties, package lists, and references to
overlay archives. There is a number of special keys that
influence how Keg constructs the dictionary and generates
the XML output. The basic structure is as follows:
image:
_attributes:
schemaversion: "SCHEMA_MAJ.SCHEMA_MIN"
name: IMAGE_NAME
displayname: IMAGE_BOOT_TITLE
description:
_attributes:
type: SYSTEM_TYPE
author: AUTHOR_NAME
contact: AUTHOR_EMAIL
preferences:
- version: VERSION_STRING
- _attributes:
profiles:
- PROFILE_NAME
...
type:
_attributes:
image: IMAGE_TYPE
kernelcmdline:
KERNEL_PARAM: KERNEL_PARAM_VALUE
...
...
size:
_attributes:
unit: SIZE_UNIT
_text: DISK_SIZE
...
users:
user:
- _attributes:
name: USER_NAME
groups: USER_GROUPS
home: USER_HOME
password: USER_PASSWORD
...
packages:
- _attributes:
type: image|bootstrap
profiles:
- PROFILE
...
archive:
_attributes:
name: ARCHIVE_FILENAME
NAMESPACE:
package:
- _attributes:
name: PACKAGE_NAME
arch: PACKAGE_ARCH
...
...
...
profiles:
profile:
- _attributes:
name: PROFILE_NAME
description: PROFILE_DESCRIPTION
...This only outlines the structure and includes some of the configuration keys that KIWI supports. See KIWI Image Description for full details.
For the purpose of generating the KIWI XML image
description, any key in the image dictionary that is not a
plain data type is converted to an XML element in the KIWI
image description, with the tag name being the key name. Any
key that starts with an _ has a special
meaning. The following keys are supported:
_attributesIf a key contains a sub key called
_attributes, it instructs the XML generator to produce an attribute for the XML element with the given key name and value as its name-value pair. If value is not a plain data type, it is converted to a string, which allows for complex attributes being split over different files and also for redefinition on lower levels. For example:type: _attributes: image: vmx kernelcmdline: console: ttyS0 debug: []Would generate the following XML element:
<type image="vmx" kernelcmdline="console=ttyS0 debug"/>
The empty list used as value for
debugmeans the attribute parameter is valueless (i.e. a flag)._textIf a key contains a key called
_text, its value is considered the element’s content string._namespace_nameAny key that start with
_namespacedoes not produce an XML element in the output. Namespaces are used to group data and allow for an inheritance and overwrite mechanism. Namespaces produce comments in the XML output that states which namespace the enclosed data was part of._map_attributeIf a key contains a key
_map_attribute, which needs to be a string type, any_attributekey under the key that is a simple list instead of the actually required mapping, is automatically converted to a mapping with the attribute key equal to_map_attributevalue. For example:packages: _map_attribute: name _namespace_some_pkgs: package: - pkg1 - pkg2Is automatically converted to:
packages: _namespace_some_pkgs: package: - _attribute: name: pkg1 - _attribute: name: pkg1 archive: - _attributes: name: archive1.tar.gzThis allows for making lists of elements that all have the same attribute (which package lists typically have) more compact and readable.
_comment_nameAny key that has a key that starts with
_commentwill have a comment above it in the XML output, reading the value of the_commentkey (needs to be a string).
6.1.2 config #
The config dictionary defines the content of the
config.sh file Keg should
generate. config.sh is a script that KIWI
runs during the image prepare step and can be used to modify
the image’s configuration. The config
dictionary structure is as follows:
config:
- profiles:
- PROFILE_NAME
...
files:
NAMESPACE:
- path: FILE
append: bool
content: string
...
...
scripts:
NAMESPACE:
- SCRIPT
...
...
services:
NAMESPACE:
- SERVICE_name
- name: SERVICE_name
enable: bool
...
...
sysconfig:
NAMESPACE:
- file: SYSCONFIG_FILE
name: SYSCONFIG_VARIABLE
value: string
...
...
...
Each list item in config produces a
section in config.sh, with the optional
profiles key defining for which image
profile that section should apply. Each item can have the
following keys (all are optional, but there has to be at
least one):
filesDefines files that should be created (or overwritten if existing) with the given
contentor havecontentappended to inconfig.sh(default onappendisfalse>).scriptsDefines which scriptlets should be included.
scriptrefers to a filedata/scripts/SCRIPT.shin the recipes tree.servicesDefines which systemd services and timers should be enabled or disabled in the image. The short version (just a string) means the string is the service name and it should be enabled
sysconfigDefines which existing sysconfig variables should the altered.
NAMESPACE defines a namespace
with the same purpose as in the image
dictionary, but config namespaces does
not have to start with _ (although this
would be allowed, too).
6.1.3 setup #
The config dictionary defines the content of the
images.sh file Keg should
generate. This script is run by KIWI during the image create
step. Its structure is identical to
config.
See User defined scripts in the KIWI documentation for more details on user scripts.
6.1.4 archive #
The archive dictionary defines the content of overlay tar
archives, that can be included in the image via the
archive sub-section of the
packages section of the
image dictionary. The structure is as
follows:
archive:
- name: archive_filename
namespace:
_include_overlays:
- overlay_module
...
...
When generating the image description, Keg will produce a
tar archive for each entry in archive
with the given file name, with its contents being composed
of all files that are in the listed overlay modules. Each
module references a directory in
data/overlayfiles.
Keg automatically compresses the archive based on the file
name extension. Supported are gz, ,
xz, or no extension for uncompressed
archive.
The archive name root.tar (regardless
of compression extension) is automatically included in all
profiles (if there are any) by KIWI. It is not necessary
to include it explicitly in the image definition.
6.2 The _include statement #
Keg supports importing parts of the image definition from
other directory trees within the recipes to allow for
modularization. For that purpose, a key in the image
dictionary may have a sub-key called
_include. Its value is a list of strings,
each of which points to a directory in the
data sub-directory of the recipes root. To
process the instruction, Keg generates another dictionary from
all YAML files in the referenced directory trees (the same
mechanism as when parsing the images tree
applies). It then looks up the key in that dictionary that is
equal to the parent key of the _include
key, and replaces the _include key with its
contents. That means, if the _include
statement is below a key called packages,
only data under packages in the include
dictionary will be copied into the image definition
dictionary. This allows for having different types of
configuration data in the same directory and including them in
different places in the image definition. See Section 7, “Data modules” for details on data modules.
6.3 Additional configuration directives #
There are three additional optional top-level image definition sections that affect how the image definition dictionary is composed and the image description is generated:
6.3.1 include-paths #
The include-paths key defines a list of
search paths that get appended when
_include statements are processed. This
allows for having different versions of data modules and
still share the most of an image definition between
different versions. See Section 7, “Data modules” for
details.
6.3.2 image-config-comments #
This section allows to add top-level comments in the produced KIWI file. The format is as follows:
image-config-comments:
COMMENT_NAME: string
...
COMMENT_NAME is just a name and
is not included in the generated output. Comments can be
used to include arbitrary information in the image
description. Some comments have a special meaning for
processing image descriptions by the Open Build Service, for
instance the OBS-Profiles directive that
is required to process multi-profile image descriptions. See
https://osinside.github.io/kiwi/working_with_images/build_in_buildservice.html
for details.
Keg generates some comments automatically. In case the
image definition has multiple profiles and the
--disable-multibuild command line
switch is not set, it will add an OBS-Profiles:
@BUILD_FLAVOR@ comment. In case the image
description is generated for one or more specific
architectures via the -a command line
option, the apprpriate
OBS-ExclusiveArch comment is
added.
6.3.3 xmlfiles #
This optional section allows generating additional custom XML files. The format is as follows:
xmlfiles:
- name: FILENAME
content:
CONTENT_DICTIONARY
...
For each list item in this section, an XML file named
FILENAME will be created, with
the content being generated from the
<content_dictionary>. For this
dictionary the same rules about formatting, including,
namespacing, etc., apply as for the image dictionary.
Custom XML files can be useful when generating image
descriptions for use in the Open Build Service, which
accepts build configuration directives via XML source files,
like the _constraints file. See
https://openbuildservice.org/help/manuals/obs-user-guide/cha.obs.build_job_constraints.html
for details.
6.3.4 schema #
Keg starting with version 2.0.0 has an internal XML generator to produce KIWI image descriptions. Previously, a Jinja2 template was used to convert the image dictionary that Keg constructed into a KIWI image description. Using a Jinja2 template is still supported and can be configured as follows in the image definition:
schema: TEMPLATE
In this case, instead of running the XML generator, Keg
would read the file
TEMPLATE.kiwi.templ
from the schemas
directory in the recipes root directory and run it trough
the Jinja2 engine.
While using a Jinja2 template would in theory allow to operate on different input data structures, the internal schema validator requires the image definition to comply with what Keg expects.
7 Data modules #
Data modules are essentially directories in the data tree. There are
three different kinds of data modules:
- Image Definition Modules
Any part of the image definition can be in a data module that is included by the
_includestatement from the main image definition.- Image Configuration Scriptlets
Configuration scriptlets are stored in
data/scripts. Those scriptlets can be used to compose an image configuration script or image setup scriptconfigandsetupkey in the image definition.- Overlay Files
Files that can be directly included in the image description and will be copied into the image’s file system by KIWI during the build process. Overlay files are stored under
data/overlayfiles.
7.1 Image definition modules #
Any directory under data that is not scripts or overlayfiles is considered an
image definition data module and may be included in the main
image definition using the _include
statement.
Inheritance rules apply similarly to the image definition tree, but additionally, Keg supports sub-versions of data modules. This can be used for instance to create slightly different versions of modules for use with different image versions while still sharing most of the image definition between those versions.
For this purpose, Keg supports the
include-paths directive in the image
definition. Include paths are paths that get appended to any
source path and those get scanned for input files as well. See
the following image definition as an example:
include-paths:
leap15/1
leap15/2
image:
preferences:
- _include:
- base/common
packages:
- _include:
- base/common
config:
- _include:
- base/common
This tells Keg, when adding data from directory data/base/common to the image
data dictionary, to also look into sub directories leap15/2, leap15/1, and leap15 (through
inheritance). This would lead to the following directories
being scanned:
data data/common data/common/base data/common/base/leap15 data/common/base/leap15/1 data/common/base/leap15/2
This allows for example to put generic configuration bits in
data/common/base, Leap
15 specific configuration in data/common/base/leap15, and
adjust the configuration for minor versions, if
necessary.
When merging the included dictionaries into the main
dictionary, Keg only copies the dictionary under the top level
key that matches the key under which the
_include statement is. That means, assuming
the YAML files collected from the above trees resulted in the
following data structure:
preferences:
locale: en_US
timezone: UTC
type:
_attributes:
firmware: efi
image: vmx
packages:
_namespace_base_packages:
package:
- bash
- glibc
- kernel-default
config:
_namespace_base_services:
services:
- sshdWould result in a data structure like this:
include-paths:
leap15/1
leap15/2
image:
preferences:
locale: en_US
timezone: UTC
type:
_attributes:
firmware: efi
image: vmx
packages:
_namespace_base_packages:
package:
- bash
- glibc
- kernel-default
config:
_namespace_base_services:
services:
- sshdMerging based on the parent key allows for grouping of different types of configuration data in one data module.
7.2 Image configuration scriptlets #
Configuration scriptlets are individual script snippets that can be used to generate image configuration scripts. KIWI runs those scripts at certain points in the image build process. They can be used to do changes to the system’s configuration.
The scriptlets are located in data/scripts and are required to have a
.sh suffix. These are referenced in the scripts lists of the config
or setup sections in the image definition (without the .sh suffix).
See Section 6.1.2, “config” for details on the config section.
7.3 Overlay files #
KIWI image descriptions can contain optional overlay archives, which will be
extracted into the system’s root directory before the image is created.
Overlay files are located in sub-directories in data/overlayfiles,
with each sub-directory representing an overlay files module. Any directory
structure under the module’s top directory is preserved.
Overlay files modules can be referenced in the archive section of the image
definition using the _include_overlays directive. See Section 6.1.4, “archive” for
details.
8 Generating change logs #
Keg comes with a separate tool that can be used to produce a
change log for a generated image description from the git commit
history of the used keg recipes tree(s). This
obviously requires these keg recipes to be
stored in git repositories.
To produce a change log for an image description, the
description needs to be generated with source info tracking
enabled in Keg (-s command line switch).
8.1 Source info tracking #
With source info tracking enabled, Keg will write one or more
source info files in addition to the image description in the
output directory. In case the image description at hand is
single-build, a single file log_sources is
written, in case it is multi-build, a file
log_sources_PROFILE is written for each
profile. This allows for generating individual change logs for
the resulting image binaries.
The source info logs contain detailed information about which
bits from the keg-recipes tree was used to
generate the image description. The source info log files will
contain several lines of the following format:
root:/path/to/repository
range:start:end:/path/to/repository/file
/path/to/repository/file_or_dir
The first line specifies the repository location. There will
be one for each keg-recipes directory given
to Keg. Lines starting with range: specify
a part of a file in a repository. This is used to track the
source location of each key that was in the final image
dictionary. The third line format simply specifies a file or a
directory in the repository that was used in the image
description, and is used for configuration script snippets and
overlay files.
This enables the change log generator to produce a change log using the git commit history, selecting only commits that apply to the generated image description.
8.2 Change log generator #
The generated source info log files, together with the
keg-recipes in the place and state they
were used to generate the image description, can be used to
generate change logs. The Keg distribution contains a tool
generate_recipes_changelog for that
purpose. When called with a source log file as argument,
generate_recipes_changelog will use the
source information to select matching git messages and produce
a change log in chronological order. There are parameters to
to narrow down the applicable commit range as well as some
formatting options. Refer to Section 4.2, “generate_recipes_changelog” command overview for
details.
8.3 Integration in OBS source service #
The Keg distribution contains a module for integrating with the Open Build Service, an implementation of a so-called OBS Source Service. It supports automatic handling of change log generation. See Section 9, “Keg OBS source service” for details.
9 Keg OBS source service #
The OBS Source Service for Keg provides a
mechanism to produce kiwi image descriptions
for use with the Open
Build Service in an automated fashion. The OBS
Source Service, named
compose_kiwi_description, checks out any
given keg-recipes repositories, runs
keg to produce the specified image
description, and optionally produces change log files and stores
the HEAD commit hashed of the keg-recipes
repositories to be used for the next source service run.
To set up an OBS package as a Keg source service package, simply
create a file named _service in your package
directory. The contents of the file should look like the
following:
<services>
<service name="compose_kiwi_description">
<param name="git-recipes">https://github.com/SUSE-Enceladus/keg-recipes.git</param>
<param name="git-branch">released</param>
<param name="image-source">cross-cloud/sles/byos/15-sp3</param>
</service>
</services>
In this example, the released branch of the
public keg-recipes repository for SUSE Linux
Enterprise images hosted on github is used as source and the
selected image source is
cross-cloud/sles/byos/15-sp3. Running the
source service will produce a description for a SUSE Linux
Enterprise Server 15 SP3 BYOS image for several cloud service
provider frameworks.
The parameters git-recipes and git-branch may be used multiple times if
the image description should be composed from more than one
repository.
There are a few additional optional parameters:
arch(string)Set build target architecture. Can be used multiple times.
image-version(string)Set image version. If no version is given, the version number of the existing image description will be used with the patch level increased by one.
version-bump(true|false)Whether the patch version number should be incremented. Ignored if
--image-versionis set. If set tofalseand--image-versionis not set, the image version defined in the recipes will be used. If no image version is defined, image description generation will fail. Default istrue.update-changelogs(true|false)Whether
changes.yamlfiles should be updated. Default istrue.update-revisions(true|false)Whether
_keg_revisions(used for storing current commit IDs) should be updated. Default istrue.force(true|false)If true, refresh image description even if there are no new commits. Default is
false.
The system the source service is running on needs to have Keg
and obs-service-keg installed. Refer to the
Using
Source Services section of the OBS manual about details
on how to run the source service and which operating modes are
available.