mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-21 09:33:57 +03:00
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:
parent
e872679629
commit
9a515f0a55
@ -346,6 +346,28 @@
|
||||
<literal>SYSEXT_LEVEL=15.14</literal>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>IMAGE_ID=</varname></term>
|
||||
|
||||
<listitem><para> A lower-case string (no spaces or other characters outside of 0–9, a–z, ".", "_" and
|
||||
"-"), identifying a specific image of the operating system. This is supposed to be used for
|
||||
environments where OS images are prepared, built, shipped and updated as comprehensive, consistent OS
|
||||
images. This field is optional and may not be implemented on all systems, in particulary not on those
|
||||
that are not managed via images but put together and updated from individual packages and on the
|
||||
local system. Examples: <literal>IMAGE_ID=vendorx-cashier-system</literal>,
|
||||
<literal>IMAGE_ID=netbook-image</literal> </para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>IMAGE_VERSION=</varname></term>
|
||||
|
||||
<listitem><para>A lower-case string (mostly numeric, no spaces or other characters outside of 0–9,
|
||||
a–z, ".", "_" and "-") identifying the OS image version. This is supposed to be used together with
|
||||
<varname>IMAGE_ID</varname> described above, to discern different versions of the same
|
||||
image. Examples: <literal>IMAGE_VERSION=33</literal>,
|
||||
<literal>IMAGE_VERSION=47.1rc1</literal> </para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
<para>If you are reading this file from C code or a shell script
|
||||
|
@ -543,11 +543,13 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="a"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="A"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="b"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="B"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="H"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="l"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="m"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="M"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="o"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="v"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="w"/>
|
||||
|
@ -4,16 +4,21 @@
|
||||
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
|
||||
|
||||
<tbody>
|
||||
<row id='b'>
|
||||
<entry><literal>%b</literal></entry>
|
||||
<entry>Boot ID</entry>
|
||||
<entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry>
|
||||
</row>
|
||||
<row id='a'>
|
||||
<entry><literal>%a</literal></entry>
|
||||
<entry>Architecture</entry>
|
||||
<entry>A short string identifying the architecture of the local system. A string such as <constant>x86</constant>, <constant>x86-64</constant> or <constant>arm64</constant>. See the architectures defined for <varname>ConditionArchitecture=</varname> in <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for a full list.</entry>
|
||||
</row>
|
||||
<row id='A'>
|
||||
<entry><literal>%A</literal></entry>
|
||||
<entry>Operating system image version</entry>
|
||||
<entry>The operating system image version identifier of the running system, as read from the <varname>IMAGE_VERSION=</varname> field of <filename>/etc/os-release</filename>. If not set, resolves to an empty string. See <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
|
||||
</row>
|
||||
<row id='b'>
|
||||
<entry><literal>%b</literal></entry>
|
||||
<entry>Boot ID</entry>
|
||||
<entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry>
|
||||
</row>
|
||||
<row id='B'>
|
||||
<entry><literal>%B</literal></entry>
|
||||
<entry>Operating system build ID</entry>
|
||||
@ -34,6 +39,11 @@
|
||||
<entry>Machine ID</entry>
|
||||
<entry>The machine ID of the running system, formatted as string. See <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
|
||||
</row>
|
||||
<row id='M'>
|
||||
<entry><literal>%M</literal></entry>
|
||||
<entry>Operating system image identifier</entry>
|
||||
<entry>The operating system image identifier of the running system, as read from the <varname>IMAGE_ID=</varname> field of <filename>/etc/os-release</filename>. If not set, resolves to an empty string. See <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
|
||||
</row>
|
||||
<row id='o'>
|
||||
<entry><literal>%o</literal></entry>
|
||||
<entry>Operating system ID</entry>
|
||||
|
@ -90,10 +90,12 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="a"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="A"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="b"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="B"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="H"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="m"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="M"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="o"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="v"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="w"/>
|
||||
|
@ -1872,6 +1872,7 @@
|
||||
<entry>Architecture</entry>
|
||||
<entry>A short string identifying the architecture of the local system. A string such as <constant>x86</constant>, <constant>x86-64</constant> or <constant>arm64</constant>. See the architectures defined for <varname>ConditionArchitecture=</varname> above for a full list.</entry>
|
||||
</row>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="A"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="b"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="B"/>
|
||||
<row>
|
||||
@ -1944,6 +1945,7 @@ Note that this setting is <emphasis>not</emphasis> influenced by the <varname>Us
|
||||
<entry>This is either <filename>/var/log</filename> (for the system manager) or the path <literal>$XDG_CONFIG_HOME</literal> resolves to with <filename index="false">/log</filename> appended (for user managers).</entry>
|
||||
</row>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="m"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="M"/>
|
||||
<row>
|
||||
<entry><literal>%n</literal></entry>
|
||||
<entry>Full unit name</entry>
|
||||
|
@ -259,11 +259,13 @@ r - 500-900
|
||||
</thead>
|
||||
<tbody>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="a"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="A"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="b"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="B"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="H"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="l"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="m"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="M"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="o"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="T"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="v"/>
|
||||
|
@ -635,6 +635,7 @@ w- /proc/sys/vm/swappiness - - - - 10</programlisting></para>
|
||||
</thead>
|
||||
<tbody>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="a"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="A"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="b"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="B"/>
|
||||
<row>
|
||||
@ -665,6 +666,7 @@ w- /proc/sys/vm/swappiness - - - - 10</programlisting></para>
|
||||
<entry>In <option>--user</option> mode, this is the same as <varname>$XDG_CONFIG_HOME</varname> with <filename index="false">/log</filename> appended, and <filename>/var/log</filename> otherwise.</entry>
|
||||
</row>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="m"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="M"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="o"/>
|
||||
<row>
|
||||
<entry><literal>%S</literal></entry>
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 }, \
|
||||
|
Loading…
Reference in New Issue
Block a user