tree-wide: unify how we pick OS pretty name to display
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user