Merge pull request #2666 from saqibali-2k/pr/bls-append
ostree-repo: bls-append-except-default followup
This commit is contained in:
commit
51ac63aa28
|
|
@ -224,6 +224,7 @@ struct OstreeRepo {
|
||||||
gint fs_support_reflink; /* The underlying filesystem has support for ioctl (FICLONE..) */
|
gint fs_support_reflink; /* The underlying filesystem has support for ioctl (FICLONE..) */
|
||||||
gchar **repo_finders;
|
gchar **repo_finders;
|
||||||
OstreeCfgSysrootBootloaderOpt bootloader; /* Configure which bootloader to use. */
|
OstreeCfgSysrootBootloaderOpt bootloader; /* Configure which bootloader to use. */
|
||||||
|
GHashTable *bls_append_values; /* Parsed key-values from bls-append-except-default key in config. */
|
||||||
|
|
||||||
OstreeRepo *parent_repo;
|
OstreeRepo *parent_repo;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1238,6 +1238,7 @@ ostree_repo_finalize (GObject *object)
|
||||||
g_mutex_clear (&self->txn_lock);
|
g_mutex_clear (&self->txn_lock);
|
||||||
g_free (self->collection_id);
|
g_free (self->collection_id);
|
||||||
g_strfreev (self->repo_finders);
|
g_strfreev (self->repo_finders);
|
||||||
|
g_clear_pointer (&self->bls_append_values, g_hash_table_unref);
|
||||||
|
|
||||||
g_clear_pointer (&self->remotes, g_hash_table_destroy);
|
g_clear_pointer (&self->remotes, g_hash_table_destroy);
|
||||||
g_mutex_clear (&self->remotes_lock);
|
g_mutex_clear (&self->remotes_lock);
|
||||||
|
|
@ -1412,6 +1413,9 @@ ostree_repo_init (OstreeRepo *self)
|
||||||
self->remotes = g_hash_table_new_full (g_str_hash, g_str_equal,
|
self->remotes = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||||
(GDestroyNotify) NULL,
|
(GDestroyNotify) NULL,
|
||||||
(GDestroyNotify) ostree_remote_unref);
|
(GDestroyNotify) ostree_remote_unref);
|
||||||
|
self->bls_append_values = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||||
|
(GDestroyNotify) g_free,
|
||||||
|
(GDestroyNotify) g_free);
|
||||||
g_mutex_init (&self->remotes_lock);
|
g_mutex_init (&self->remotes_lock);
|
||||||
|
|
||||||
self->repo_dir_fd = -1;
|
self->repo_dir_fd = -1;
|
||||||
|
|
@ -3510,16 +3514,42 @@ reload_sysroot_config (OstreeRepo *self,
|
||||||
* https://github.com/ostreedev/ostree/issues/1719
|
* https://github.com/ostreedev/ostree/issues/1719
|
||||||
* https://github.com/ostreedev/ostree/issues/1801
|
* https://github.com/ostreedev/ostree/issues/1801
|
||||||
*/
|
*/
|
||||||
|
gboolean valid_bootloader;
|
||||||
for (int i = 0; CFG_SYSROOT_BOOTLOADER_OPTS_STR[i]; i++)
|
for (int i = 0; CFG_SYSROOT_BOOTLOADER_OPTS_STR[i]; i++)
|
||||||
{
|
{
|
||||||
if (g_str_equal (bootloader, CFG_SYSROOT_BOOTLOADER_OPTS_STR[i]))
|
if (g_str_equal (bootloader, CFG_SYSROOT_BOOTLOADER_OPTS_STR[i]))
|
||||||
{
|
{
|
||||||
self->bootloader = (OstreeCfgSysrootBootloaderOpt) i;
|
self->bootloader = (OstreeCfgSysrootBootloaderOpt) i;
|
||||||
return TRUE;
|
valid_bootloader = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!valid_bootloader)
|
||||||
|
{
|
||||||
|
return glnx_throw (error, "Invalid bootloader configuration: '%s'", bootloader);
|
||||||
|
}
|
||||||
|
/* Parse bls-append-except-default string list. */
|
||||||
|
g_auto(GStrv) read_values = NULL;
|
||||||
|
if (!ot_keyfile_get_string_list_with_default (self->config, "sysroot", "bls-append-except-default",
|
||||||
|
';', NULL, &read_values, error))
|
||||||
|
return glnx_throw(error, "Unable to parse bls-append-except-default");
|
||||||
|
|
||||||
|
/* get all key value pairs in bls-append-except-default */
|
||||||
|
g_hash_table_remove_all (self->bls_append_values);
|
||||||
|
for (char **iter = read_values; iter && *iter; iter++)
|
||||||
|
{
|
||||||
|
const char *key_value = *iter;
|
||||||
|
const char *sep = strchr (key_value, '=');
|
||||||
|
if (sep == NULL)
|
||||||
|
{
|
||||||
|
glnx_throw (error, "bls-append-except-default key must be of the form \"key1=value1;key2=value2...\"");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
char *key = g_strndup (key_value, sep - key_value);
|
||||||
|
char *value = g_strdup (sep + 1);
|
||||||
|
g_hash_table_replace (self->bls_append_values, key, value);
|
||||||
|
}
|
||||||
|
|
||||||
return glnx_throw (error, "Invalid bootloader configuration: '%s'", bootloader);
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2083,25 +2083,6 @@ install_deployment_kernel (OstreeSysroot *sysroot,
|
||||||
g_autofree char *options_key = ostree_kernel_args_to_string (kargs);
|
g_autofree char *options_key = ostree_kernel_args_to_string (kargs);
|
||||||
ostree_bootconfig_parser_set (bootconfig, "options", options_key);
|
ostree_bootconfig_parser_set (bootconfig, "options", options_key);
|
||||||
|
|
||||||
g_autoptr(GError) local_error = NULL;
|
|
||||||
GKeyFile *config = ostree_repo_get_config (repo);
|
|
||||||
gchar **read_values = g_key_file_get_string_list (config, "sysroot", "bls-append-except-default", NULL, &local_error);
|
|
||||||
/* We can ignore not found errors */
|
|
||||||
if (!read_values)
|
|
||||||
{
|
|
||||||
gboolean not_found = g_error_matches (local_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND) || \
|
|
||||||
g_error_matches (local_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND);
|
|
||||||
if (not_found)
|
|
||||||
{
|
|
||||||
g_clear_error (&local_error);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_propagate_error (error, g_steal_pointer (&local_error));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only append to this BLS config if:
|
/* Only append to this BLS config if:
|
||||||
* - this is not the default deployment
|
* - this is not the default deployment
|
||||||
*/
|
*/
|
||||||
|
|
@ -2111,22 +2092,10 @@ install_deployment_kernel (OstreeSysroot *sysroot,
|
||||||
if (allow_append)
|
if (allow_append)
|
||||||
{
|
{
|
||||||
/* get all key value pairs in bls-append */
|
/* get all key value pairs in bls-append */
|
||||||
for (char **iter = read_values; iter && *iter; iter++)
|
GLNX_HASH_TABLE_FOREACH_KV (repo->bls_append_values, const char *, key, const char *, value)
|
||||||
{
|
|
||||||
const char *key_value = *iter;
|
|
||||||
const char *sep = strchr (key_value, '=');
|
|
||||||
if (sep == NULL)
|
|
||||||
{
|
|
||||||
glnx_throw (error, "bls-append-except-default key must be of the form \"key1=value1;key2=value2...\"");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
g_autofree char *key = g_strndup (key_value, sep - key_value);
|
|
||||||
g_autofree char *value = g_strdup (sep + 1);
|
|
||||||
ostree_bootconfig_parser_set (bootconfig, key, value);
|
ostree_bootconfig_parser_set (bootconfig, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
glnx_autofd int bootconf_dfd = -1;
|
glnx_autofd int bootconf_dfd = -1;
|
||||||
if (!glnx_opendirat (sysroot->boot_fd, bootconfdir, TRUE, &bootconf_dfd, error))
|
if (!glnx_opendirat (sysroot->boot_fd, bootconfdir, TRUE, &bootconf_dfd, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue