assert(entry);
free(entry->id);
+ free(entry->id_old);
free(entry->path);
free(entry->root);
free(entry->title);
b = basename(path);
tmp.id = strdup(b);
- if (!tmp.id)
+ tmp.id_old = strndup(b, c - b);
+ if (!tmp.id || !tmp.id_old)
return log_oom();
if (!efi_loader_entry_name_valid(tmp.id))
const char *cmdline,
BootEntry *ret) {
- _cleanup_free_ char *os_pretty_name = NULL;
+ _cleanup_free_ char *os_pretty_name = NULL, *os_id = NULL, *version_id = NULL, *build_id = NULL;
_cleanup_(boot_entry_free) BootEntry tmp = {
.type = BOOT_ENTRY_UNIFIED,
};
if (!f)
return log_error_errno(errno, "Failed to open os-release buffer: %m");
- r = parse_env_file(f, "os-release", "PRETTY_NAME", &os_pretty_name);
+ r = parse_env_file(f, "os-release",
+ "PRETTY_NAME", &os_pretty_name,
+ "ID", &os_id,
+ "VERSION_ID", &version_id,
+ "BUILD_ID", &build_id);
if (r < 0)
return log_error_errno(r, "Failed to parse os-release data from unified kernel image %s: %m", path);
- if (!os_pretty_name)
+ if (!os_pretty_name || !os_id || !(version_id || build_id))
return log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "Missing fields in os-release data from unified kernel image %s, refusing.", path);
b = basename(path);
tmp.id = strdup(b);
- if (!tmp.id)
+ tmp.id_old = strjoin(os_id, "-", version_id ?: build_id);
+ if (!tmp.id || !tmp.id_old)
return log_oom();
if (!efi_loader_entry_name_valid(tmp.id))
typedef struct BootEntry {
BootEntryType type;
char *id; /* This is the file basename without extension */
+ char *id_old; /* Old-style ID, for deduplication purposes. */
char *path; /* This is the full path to the drop-in file */
char *root; /* The root path in which the drop-in was found, i.e. to which 'kernel', 'efi' and 'initrd' are relative */
char *title;
static inline bool boot_config_has_entry(BootConfig *config, const char *id) {
size_t j;
- for (j = 0; j < config->n_entries; j++)
- if (streq(config->entries[j].id, id))
+ for (j = 0; j < config->n_entries; j++) {
+ const char* entry_id_old = config->entries[j].id_old;
+ if (streq(config->entries[j].id, id) ||
+ (entry_id_old && streq(entry_id_old, id)))
return true;
+ }
return false;
}