mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
kernel-install: version sort listed kernels (#38983)
This commit is contained in:
@@ -1368,7 +1368,7 @@ static int verb_inspect(int argc, char *argv[], void *userdata) {
|
||||
TABLE_FIELD, "Entry Directory",
|
||||
TABLE_STRING, c->entry_dir,
|
||||
TABLE_FIELD, "Kernel Version",
|
||||
TABLE_STRING, c->version,
|
||||
TABLE_VERSION, c->version,
|
||||
TABLE_FIELD, "Kernel",
|
||||
TABLE_STRING, c->kernel,
|
||||
TABLE_FIELD, "Initrds",
|
||||
@@ -1430,6 +1430,7 @@ static int verb_list(int argc, char *argv[], void *userdata) {
|
||||
|
||||
table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
|
||||
table_set_align_percent(table, table_get_cell(table, 0, 1), 100);
|
||||
(void) table_set_sort(table, (size_t) 0);
|
||||
|
||||
FOREACH_ARRAY(d, de->entries, de->n_entries) {
|
||||
_cleanup_free_ char *j = path_join("/usr/lib/modules/", (*d)->d_name);
|
||||
@@ -1460,7 +1461,7 @@ static int verb_list(int argc, char *argv[], void *userdata) {
|
||||
exists = true;
|
||||
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, (*d)->d_name,
|
||||
TABLE_VERSION, (*d)->d_name,
|
||||
TABLE_BOOLEAN_CHECKMARK, exists,
|
||||
TABLE_SET_COLOR, ansi_highlight_green_red(exists),
|
||||
TABLE_PATH, j);
|
||||
|
||||
@@ -287,6 +287,7 @@ static size_t table_data_size(TableDataType type, const void *data) {
|
||||
case TABLE_PATH_BASENAME:
|
||||
case TABLE_FIELD:
|
||||
case TABLE_HEADER:
|
||||
case TABLE_VERSION:
|
||||
return strlen(data) + 1;
|
||||
|
||||
case TABLE_STRV:
|
||||
@@ -526,7 +527,7 @@ int table_add_cell_stringf_full(Table *t, TableCell **ret_cell, TableDataType dt
|
||||
int r;
|
||||
|
||||
assert(t);
|
||||
assert(IN_SET(dt, TABLE_STRING, TABLE_PATH, TABLE_PATH_BASENAME, TABLE_FIELD, TABLE_HEADER));
|
||||
assert(IN_SET(dt, TABLE_STRING, TABLE_PATH, TABLE_PATH_BASENAME, TABLE_FIELD, TABLE_HEADER, TABLE_VERSION));
|
||||
|
||||
va_start(ap, format);
|
||||
r = vasprintf(&buffer, format, ap);
|
||||
@@ -934,6 +935,7 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) {
|
||||
case TABLE_PATH_BASENAME:
|
||||
case TABLE_FIELD:
|
||||
case TABLE_HEADER:
|
||||
case TABLE_VERSION:
|
||||
data = va_arg(ap, const char *);
|
||||
break;
|
||||
|
||||
@@ -1395,6 +1397,9 @@ static int cell_data_compare(TableData *a, size_t index_a, TableData *b, size_t
|
||||
case TABLE_PATH_BASENAME:
|
||||
return path_compare(a->string, b->string);
|
||||
|
||||
case TABLE_VERSION:
|
||||
return strverscmp_improved(a->string, b->string);
|
||||
|
||||
case TABLE_STRV:
|
||||
case TABLE_STRV_WRAPPED:
|
||||
return strv_compare(a->strv, b->strv);
|
||||
@@ -1579,7 +1584,8 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
|
||||
case TABLE_PATH:
|
||||
case TABLE_PATH_BASENAME:
|
||||
case TABLE_FIELD:
|
||||
case TABLE_HEADER: {
|
||||
case TABLE_HEADER:
|
||||
case TABLE_VERSION: {
|
||||
_cleanup_free_ char *bn = NULL;
|
||||
const char *s;
|
||||
|
||||
@@ -2753,6 +2759,7 @@ static int table_data_to_json(TableData *d, sd_json_variant **ret) {
|
||||
case TABLE_PATH_BASENAME:
|
||||
case TABLE_FIELD:
|
||||
case TABLE_HEADER:
|
||||
case TABLE_VERSION:
|
||||
return sd_json_variant_new_string(ret, d->string);
|
||||
|
||||
case TABLE_STRV:
|
||||
|
||||
@@ -16,6 +16,7 @@ typedef enum TableDataType {
|
||||
TABLE_STRV_WRAPPED,
|
||||
TABLE_PATH,
|
||||
TABLE_PATH_BASENAME, /* like TABLE_PATH, but display only last path element (i.e. the "basename") in regular output */
|
||||
TABLE_VERSION, /* just like TABLE_STRING, but uses version comparison when sorting */
|
||||
TABLE_BOOLEAN,
|
||||
TABLE_BOOLEAN_CHECKMARK,
|
||||
TABLE_TIMESTAMP,
|
||||
|
||||
Reference in New Issue
Block a user