shared: add new IMAGE_VERSION=/IMAGE_ID= field to /etc/os-release

This specifes two new optional fields for /etc/os-release:
IMAGE_VERSION= and IMAGE_ID= that are supposed to identify the image of
the current booted system by name and version.

This is inspired by the versioning stuff in
https://github.com/systemd/mkosi/pull/683.

In environments where pre-built images are installed and updated as a
whole the existing os-release version/distro identifier are not
sufficient to describe the system's version, as they describe only the
distro an image is built from, but not the image itself, even if that
image is deployed many times on many systems, and even if that image
contains more resources than just the RPMs/DEBs.

In particular, "mkosi" is a tool for building disk images based on
distro RPMs with additional resources dropped in. The combination of all
of these together with their versions should also carry an identifier
and version, and that's what IMAGE_VERSION= and IMAGE_ID= is supposed to
be.
This commit is contained in:
Lennart Poettering
2021-03-31 10:46:22 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent e872679629
commit 9a515f0a55
9 changed files with 62 additions and 5 deletions
+8
View File
@@ -234,6 +234,14 @@ int specifier_os_variant_id(char specifier, const void *data, const void *userda
return specifier_os_release_common("VARIANT_ID", ret);
}
int specifier_os_image_id(char specifier, const void *data, const void *userdata, char **ret) {
return specifier_os_release_common("IMAGE_ID", ret);
}
int specifier_os_image_version(char specifier, const void *data, const void *userdata, char **ret) {
return specifier_os_release_common("IMAGE_VERSION", ret);
}
int specifier_group_name(char specifier, const void *data, const void *userdata, char **ret) {
char *t;
+7
View File
@@ -25,6 +25,8 @@ int specifier_os_id(char specifier, const void *data, const void *userdata, char
int specifier_os_version_id(char specifier, const void *data, const void *userdata, char **ret);
int specifier_os_build_id(char specifier, const void *data, const void *userdata, char **ret);
int specifier_os_variant_id(char specifier, const void *data, const void *userdata, char **ret);
int specifier_os_image_id(char specifier, const void *data, const void *userdata, char **ret);
int specifier_os_image_version(char specifier, const void *data, const void *userdata, char **ret);
int specifier_group_name(char specifier, const void *data, const void *userdata, char **ret);
int specifier_group_id(char specifier, const void *data, const void *userdata, char **ret);
@@ -41,11 +43,13 @@ int specifier_var_tmp_dir(char specifier, const void *data, const void *userdata
*
* COMMON_SYSTEM_SPECIFIERS:
* %a: the native userspace architecture
* %A: the OS image version, according to /etc/os-release
* %b: the boot ID of the running system
* %B: the OS build ID, according to /etc/os-release
* %H: the hostname of the running system
* %l: the short hostname of the running system
* %m: the machine ID of the running system
* %M: the OS image ID, according to /etc/os-release
* %o: the OS ID according to /etc/os-release
* %v: the kernel version
* %w: the OS version ID, according to /etc/os-release
@@ -64,16 +68,19 @@ int specifier_var_tmp_dir(char specifier, const void *data, const void *userdata
#define COMMON_SYSTEM_SPECIFIERS \
{ 'a', specifier_architecture, NULL }, \
{ 'A', specifier_os_image_version,NULL }, \
{ 'b', specifier_boot_id, NULL }, \
{ 'B', specifier_os_build_id, NULL }, \
{ 'H', specifier_host_name, NULL }, \
{ 'l', specifier_short_host_name, NULL }, \
{ 'm', specifier_machine_id, NULL }, \
{ 'M', specifier_os_image_id, NULL }, \
{ 'o', specifier_os_id, NULL }, \
{ 'v', specifier_kernel_release, NULL }, \
{ 'w', specifier_os_version_id, NULL }, \
{ 'W', specifier_os_variant_id, NULL }
#define COMMON_CREDS_SPECIFIERS \
{ 'g', specifier_group_name, NULL }, \
{ 'G', specifier_group_id, NULL }, \