diff --git a/src/daemon/rpmostree-sysroot-upgrader.c b/src/daemon/rpmostree-sysroot-upgrader.c index e5b83722..f6a48cc8 100644 --- a/src/daemon/rpmostree-sysroot-upgrader.c +++ b/src/daemon/rpmostree-sysroot-upgrader.c @@ -100,16 +100,22 @@ parse_origin_keyfile (RpmOstreeSysrootUpgrader *self, GCancellable *cancellable, GError **error) { - RpmOstreeOriginParseFlags origin_flags = 0; - g_clear_pointer (&self->origin, (GDestroyNotify)rpmostree_origin_unref); - if (self->flags & RPMOSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED) - origin_flags |= RPMOSTREE_ORIGIN_PARSE_FLAGS_IGNORE_UNCONFIGURED; - self->origin = rpmostree_origin_parse_keyfile (origin, origin_flags, error); + self->origin = rpmostree_origin_parse_keyfile (origin, error); if (!self->origin) return FALSE; + if (rpmostree_origin_get_unconfigured_state (self->origin) && + !(self->flags & RPMOSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED)) + { + /* explicit action is required OS creator to upgrade, print their text as an error */ + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "origin unconfigured-state: %s", + rpmostree_origin_get_unconfigured_state (self->origin)); + return FALSE; + } + return TRUE; } @@ -1219,8 +1225,7 @@ clean_pkgcache_orphans (OstreeSysroot *sysroot, OstreeDeployment *deployment = deployments->pdata[i]; g_autoptr(RpmOstreeOrigin) origin = NULL; - origin = rpmostree_origin_parse_deployment_ex (deployment, RPMOSTREE_ORIGIN_PARSE_FLAGS_IGNORE_UNCONFIGURED, - error); + origin = rpmostree_origin_parse_deployment (deployment, error); if (!origin) return FALSE; diff --git a/src/daemon/rpmostreed-deployment-utils.c b/src/daemon/rpmostreed-deployment-utils.c index 7f93f2e0..b6c3f046 100644 --- a/src/daemon/rpmostreed-deployment-utils.c +++ b/src/daemon/rpmostreed-deployment-utils.c @@ -191,8 +191,7 @@ rpmostreed_deployment_generate_variant (OstreeDeployment *deployment, id = rpmostreed_deployment_generate_id (deployment); - origin = rpmostree_origin_parse_deployment_ex (deployment, RPMOSTREE_ORIGIN_PARSE_FLAGS_IGNORE_UNCONFIGURED, - error); + origin = rpmostree_origin_parse_deployment (deployment, error); if (!origin) return NULL; @@ -282,8 +281,7 @@ rpmostreed_commit_generate_cached_details_variant (OstreeDeployment *deployment, { g_autoptr(RpmOstreeOrigin) origin = NULL; - origin = rpmostree_origin_parse_deployment_ex (deployment, RPMOSTREE_ORIGIN_PARSE_FLAGS_IGNORE_UNCONFIGURED, - error); + origin = rpmostree_origin_parse_deployment (deployment, error); if (!origin) return NULL; origin_refspec = g_strdup (rpmostree_origin_get_refspec (origin)); diff --git a/src/daemon/rpmostreed-os.c b/src/daemon/rpmostreed-os.c index 3d15353e..ccc8869e 100644 --- a/src/daemon/rpmostreed-os.c +++ b/src/daemon/rpmostreed-os.c @@ -1214,8 +1214,7 @@ rpmostreed_os_load_internals (RpmostreedOS *self, GError **error) g_autoptr(RpmOstreeOrigin) origin = NULL; /* Don't fail here for unknown origin types */ - origin = rpmostree_origin_parse_deployment_ex (merge_deployment, RPMOSTREE_ORIGIN_PARSE_FLAGS_IGNORE_UNCONFIGURED, - NULL); + origin = rpmostree_origin_parse_deployment (merge_deployment, NULL); if (origin) { cached_update = rpmostreed_commit_generate_cached_details_variant (merge_deployment, diff --git a/src/libpriv/rpmostree-origin.c b/src/libpriv/rpmostree-origin.c index 803e4b0d..fc056ff7 100644 --- a/src/libpriv/rpmostree-origin.c +++ b/src/libpriv/rpmostree-origin.c @@ -30,6 +30,7 @@ struct RpmOstreeOrigin { char *refspec; char **packages; char *override_commit; + char *unconfigured_state; }; static GKeyFile * @@ -45,7 +46,6 @@ keyfile_dup (GKeyFile *kf) RpmOstreeOrigin * rpmostree_origin_parse_keyfile (GKeyFile *origin, - RpmOstreeOriginParseFlags flags, GError **error) { g_autoptr(RpmOstreeOrigin) ret = NULL; @@ -57,19 +57,7 @@ rpmostree_origin_parse_keyfile (GKeyFile *origin, /* NOTE hack here - see https://github.com/ostreedev/ostree/pull/343 */ g_key_file_remove_key (ret->kf, "origin", "unlocked", NULL); - if ((flags & RPMOSTREE_ORIGIN_PARSE_FLAGS_IGNORE_UNCONFIGURED) == 0) - { - g_autofree char *unconfigured_state = NULL; - - /* If explicit action by the OS creator is requried to upgrade, print their text as an error */ - unconfigured_state = g_key_file_get_string (origin, "origin", "unconfigured-state", NULL); - if (unconfigured_state) - { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - "origin unconfigured-state: %s", unconfigured_state); - return NULL; - } - } + ret->unconfigured_state = g_key_file_get_string (ret->kf, "origin", "unconfigured-state", NULL); ret->refspec = g_key_file_get_string (ret->kf, "origin", "refspec", NULL); if (!ret->refspec) @@ -170,6 +158,7 @@ rpmostree_origin_unref (RpmOstreeOrigin *origin) return; g_key_file_unref (origin->kf); g_free (origin->refspec); + g_free (origin->unconfigured_state); g_strfreev (origin->packages); g_free (origin); } @@ -260,3 +249,9 @@ rpmostree_origin_set_rebase (RpmOstreeOrigin *origin, return TRUE; } + +const char* +rpmostree_origin_get_unconfigured_state (RpmOstreeOrigin *origin) +{ + return origin->unconfigured_state; +} diff --git a/src/libpriv/rpmostree-origin.h b/src/libpriv/rpmostree-origin.h index ad46c5c2..33628cdf 100644 --- a/src/libpriv/rpmostree-origin.h +++ b/src/libpriv/rpmostree-origin.h @@ -27,20 +27,14 @@ RpmOstreeOrigin *rpmostree_origin_ref (RpmOstreeOrigin *origin); void rpmostree_origin_unref (RpmOstreeOrigin *origin); G_DEFINE_AUTOPTR_CLEANUP_FUNC(RpmOstreeOrigin, rpmostree_origin_unref) -typedef enum { - RPMOSTREE_ORIGIN_PARSE_FLAGS_IGNORE_UNCONFIGURED = (1 << 0) -} RpmOstreeOriginParseFlags; - RpmOstreeOrigin * rpmostree_origin_parse_keyfile (GKeyFile *keyfile, - RpmOstreeOriginParseFlags flags, GError **error); static inline RpmOstreeOrigin * -rpmostree_origin_parse_deployment_ex (OstreeDeployment *deployment, - RpmOstreeOriginParseFlags flags, - GError **error) +rpmostree_origin_parse_deployment (OstreeDeployment *deployment, + GError **error) { GKeyFile *origin = ostree_deployment_get_origin (deployment); if (!origin) @@ -51,15 +45,7 @@ rpmostree_origin_parse_deployment_ex (OstreeDeployment *deployment, ostree_deployment_get_deployserial (deployment)); return NULL; } - return rpmostree_origin_parse_keyfile (origin, flags, error); -} - -static inline -RpmOstreeOrigin * -rpmostree_origin_parse_deployment (OstreeDeployment *deployment, - GError **error) -{ - return rpmostree_origin_parse_deployment_ex (deployment, 0, error); + return rpmostree_origin_parse_keyfile (origin, error); } RpmOstreeOrigin * @@ -105,3 +91,6 @@ gboolean rpmostree_origin_set_rebase (RpmOstreeOrigin *origin, const char *new_refspec, GError **error); + +const char * +rpmostree_origin_get_unconfigured_state (RpmOstreeOrigin *origin);