summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-sysroot-upgrader.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2014-09-30 18:12:08 -0400
committerColin Walters <walters@verbum.org>2014-10-03 14:03:55 -0400
commitb3ad113f788eaece9a4764ecafd3308154f59e8a (patch)
tree3e3c5e5331eba32d2502dbc1c5de1dbc39ea3c57 /src/libostree/ostree-sysroot-upgrader.c
parent63abc1b5134ac6fb100572a7cfd4b1c5021af859 (diff)
downloadostree-b3ad113f788eaece9a4764ecafd3308154f59e8a.tar.gz
Add "unconfigured-state" concept to origin files
Some operating systems may come with external tools for subscription management that drive access to the content. In that case, the origin file may not be useful (for example, it could refer to an installer ISO). This patch will allow OS installers to inject that state, with a useful error message, directing the system administrator to an external tool. See: https://github.com/projectatomic/rpm-ostree/issues/31 https://bugzilla.gnome.org/show_bug.cgi?id=737686
Diffstat (limited to 'src/libostree/ostree-sysroot-upgrader.c')
-rw-r--r--src/libostree/ostree-sysroot-upgrader.c68
1 files changed, 67 insertions, 1 deletions
diff --git a/src/libostree/ostree-sysroot-upgrader.c b/src/libostree/ostree-sysroot-upgrader.c
index 315b7cff..81f5ff2b 100644
--- a/src/libostree/ostree-sysroot-upgrader.c
+++ b/src/libostree/ostree-sysroot-upgrader.c
@@ -42,6 +42,7 @@ struct OstreeSysrootUpgrader {
OstreeSysroot *sysroot;
char *osname;
+ OstreeSysrootUpgraderFlags flags;
OstreeDeployment *merge_deployment;
GKeyFile *origin;
@@ -55,7 +56,8 @@ enum {
PROP_0,
PROP_SYSROOT,
- PROP_OSNAME
+ PROP_OSNAME,
+ PROP_FLAGS
};
static void ostree_sysroot_upgrader_initable_iface_init (GInitableIface *iface);
@@ -70,6 +72,19 @@ parse_refspec (OstreeSysrootUpgrader *self,
{
gboolean ret = FALSE;
gs_free char *origin_refspec = NULL;
+ gs_free char *unconfigured_state = NULL;
+
+ if ((self->flags & OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED) == 0)
+ {
+ /* If explicit action by the OS creator is requried to upgrade, print their text as an error */
+ unconfigured_state = g_key_file_get_string (self->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);
+ goto out;
+ }
+ }
origin_refspec = g_key_file_get_string (self->origin, "origin", "refspec", NULL);
if (!origin_refspec)
@@ -191,6 +206,9 @@ ostree_sysroot_upgrader_set_property (GObject *object,
case PROP_OSNAME:
self->osname = g_value_dup_string (value);
break;
+ case PROP_FLAGS:
+ self->flags = g_value_get_flags (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -213,6 +231,9 @@ ostree_sysroot_upgrader_get_property (GObject *object,
case PROP_OSNAME:
g_value_set_string (value, self->osname);
break;
+ case PROP_FLAGS:
+ g_value_set_flags (value, self->flags);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -249,6 +270,13 @@ ostree_sysroot_upgrader_class_init (OstreeSysrootUpgraderClass *klass)
PROP_OSNAME,
g_param_spec_string ("osname", "", "", NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_FLAGS,
+ g_param_spec_flags ("flags", "", "",
+ ostree_sysroot_upgrader_flags_get_type (),
+ 0,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
static void
@@ -289,6 +317,25 @@ ostree_sysroot_upgrader_new_for_os (OstreeSysroot *sysroot,
}
/**
+ * ostree_sysroot_upgrader_new_for_os_with_flags:
+ * @sysroot: An #OstreeSysroot
+ * @osname: (allow-none): Operating system name
+ * @flags: Flags
+ *
+ * Returns: (transfer full): An upgrader
+ */
+OstreeSysrootUpgrader *
+ostree_sysroot_upgrader_new_for_os_with_flags (OstreeSysroot *sysroot,
+ const char *osname,
+ OstreeSysrootUpgraderFlags flags,
+ GCancellable *cancellable,
+ GError **error)
+{
+ return g_initable_new (OSTREE_TYPE_SYSROOT_UPGRADER, cancellable, error,
+ "sysroot", sysroot, "osname", osname, "flags", flags, NULL);
+}
+
+/**
* ostree_sysroot_upgrader_get_origin:
* @self: Sysroot
*
@@ -544,3 +591,22 @@ ostree_sysroot_upgrader_deploy (OstreeSysrootUpgrader *self,
out:
return ret;
}
+
+GType
+ostree_sysroot_upgrader_flags_get_type (void)
+{
+ static volatile gsize g_define_type_id__volatile = 0;
+
+ if (g_once_init_enter (&g_define_type_id__volatile))
+ {
+ static const GFlagsValue values[] = {
+ { OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED, "OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED", "ignore-unconfigured" },
+ { 0, NULL, NULL }
+ };
+ GType g_define_type_id =
+ g_flags_register_static (g_intern_static_string ("OstreeSysrootUpgraderFlags"), values);
+ g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
+ }
+
+ return g_define_type_id__volatile;
+}