summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2015-10-06 11:24:23 -0400
committerMatthew Barnes <mbarnes@redhat.com>2015-10-13 12:34:56 -0400
commit41ab26356c082e110c20e8e1601216584a46004b (patch)
treeff5608e952bebf5d11bd0efcda0fa6e29a33bc16
parent442dcec43be9ad50b4f9b24bbd527de58720c374 (diff)
downloadostree-41ab26356c082e110c20e8e1601216584a46004b.tar.gz
upgrader: Add ostree_sysroot_upgrader_dup_origin()
Convenience function returns a copy of the origin file, useful when modifying it.
-rw-r--r--doc/ostree-sections.txt1
-rw-r--r--src/libostree/ostree-sysroot-upgrader.c27
-rw-r--r--src/libostree/ostree-sysroot-upgrader.h1
3 files changed, 29 insertions, 0 deletions
diff --git a/doc/ostree-sections.txt b/doc/ostree-sections.txt
index 84ba417e..ff512e47 100644
--- a/doc/ostree-sections.txt
+++ b/doc/ostree-sections.txt
@@ -410,6 +410,7 @@ ostree_sysroot_upgrader_new_for_os
OstreeSysrootUpgraderFlags
ostree_sysroot_upgrader_new_for_os_with_flags
ostree_sysroot_upgrader_get_origin
+ostree_sysroot_upgrader_dup_origin
ostree_sysroot_upgrader_set_origin
ostree_sysroot_upgrader_get_origin_description
ostree_sysroot_upgrader_check_timestamps
diff --git a/src/libostree/ostree-sysroot-upgrader.c b/src/libostree/ostree-sysroot-upgrader.c
index 3012d31e..7ee19f63 100644
--- a/src/libostree/ostree-sysroot-upgrader.c
+++ b/src/libostree/ostree-sysroot-upgrader.c
@@ -342,6 +342,33 @@ ostree_sysroot_upgrader_get_origin (OstreeSysrootUpgrader *self)
}
/**
+ * ostree_sysroot_upgrader_dup_origin:
+ * @self: Sysroot
+ *
+ * Returns: (transfer full): A copy of the origin file, or %NULL if unknown
+ */
+GKeyFile *
+ostree_sysroot_upgrader_dup_origin (OstreeSysrootUpgrader *self)
+{
+ GKeyFile *copy = NULL;
+
+ g_return_val_if_fail (OSTREE_IS_SYSROOT_UPGRADER (self), NULL);
+
+ if (self->origin != NULL)
+ {
+ g_autofree char *data = NULL;
+ gsize length = 0;
+
+ copy = g_key_file_new ();
+ data = g_key_file_to_data (self->origin, &length, NULL);
+ g_key_file_load_from_data (copy, data, length,
+ G_KEY_FILE_KEEP_COMMENTS, NULL);
+ }
+
+ return copy;
+}
+
+/**
* ostree_sysroot_upgrader_set_origin:
* @self: Sysroot
* @origin: (allow-none): The new origin
diff --git a/src/libostree/ostree-sysroot-upgrader.h b/src/libostree/ostree-sysroot-upgrader.h
index edac5a3d..394e31a3 100644
--- a/src/libostree/ostree-sysroot-upgrader.h
+++ b/src/libostree/ostree-sysroot-upgrader.h
@@ -62,6 +62,7 @@ OstreeSysrootUpgrader *ostree_sysroot_upgrader_new_for_os_with_flags (OstreeSysr
GError **error);
GKeyFile *ostree_sysroot_upgrader_get_origin (OstreeSysrootUpgrader *self);
+GKeyFile *ostree_sysroot_upgrader_dup_origin (OstreeSysrootUpgrader *self);
gboolean ostree_sysroot_upgrader_set_origin (OstreeSysrootUpgrader *self, GKeyFile *origin,
GCancellable *cancellable, GError **error);