tree-wide: unify how we pick OS pretty name to display

This commit is contained in:
Lennart Poettering
2023-01-24 15:32:42 +01:00
parent 31778abf95
commit 02b7005e38
7 changed files with 29 additions and 8 deletions
+9
View File
@@ -370,3 +370,12 @@ int os_release_support_ended(const char *support_end, bool quiet) {
usec_t ts = now(CLOCK_REALTIME);
return DIV_ROUND_UP(ts, USEC_PER_SEC) > (usec_t) eol;
}
const char *os_release_pretty_name(const char *pretty_name, const char *name) {
/* Distills a "pretty" name to show from os-release data. First argument is supposed to be the
* PRETTY_NAME= field, the second one the NAME= field. This function is trivial, of course, and
* exists mostly to ensure we use the same logic wherever possible. */
return empty_to_null(pretty_name) ?:
empty_to_null(name) ?: "Linux";
}
+2
View File
@@ -33,3 +33,5 @@ int load_os_release_pairs(const char *root, char ***ret);
int load_os_release_pairs_with_prefix(const char *root, const char *prefix, char ***ret);
int os_release_support_ended(const char *support_end, bool quiet);
const char *os_release_pretty_name(const char *pretty_name, const char *name);