summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-deployment.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2018-02-23 14:23:38 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-26 19:06:59 +0000
commitc40a47e965d139cf6e72192bd582098a635b72f4 (patch)
treea020e001e6f00a1aa1640514b4d8bda95f323474 /src/libostree/ostree-deployment.c
parent2f5a34bed98475b966de3c41bcd0275dc4bb4388 (diff)
downloadostree-c40a47e965d139cf6e72192bd582098a635b72f4.tar.gz
sysroot: Add API to clean up transient keys in origin files
The `origin/unlocked` and `origin/override-commit` keys are examples of state that's really transient; we don't want to maintain them across upgrades. Right now there are bits for this in both `ostree admin upgrade` as well as in rpm-ostree. This new API will slightly clean up both cases, but it's really prep for adding a concept of deployment "pinning" that will live in the new `libostree-transient` group. Closes: #1464 Approved by: jlebon
Diffstat (limited to 'src/libostree/ostree-deployment.c')
-rw-r--r--src/libostree/ostree-deployment.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/libostree/ostree-deployment.c b/src/libostree/ostree-deployment.c
index 6431aa96..2c479fdb 100644
--- a/src/libostree/ostree-deployment.c
+++ b/src/libostree/ostree-deployment.c
@@ -121,6 +121,35 @@ ostree_deployment_set_origin (OstreeDeployment *self, GKeyFile *origin)
self->origin = g_key_file_ref (origin);
}
+/**
+ * ostree_deployment_origin_remove_transient_state:
+ * @origin: An origin
+ *
+ * The intention of an origin file is primarily describe the "inputs" that
+ * resulted in a deployment, and it's commonly used to derive the new state. For
+ * example, a key value (in pure libostree mode) is the "refspec". However,
+ * libostree (or other applications) may want to store "transient" state that
+ * should not be carried across upgrades.
+ *
+ * This function just removes all members of the `libostree-transient` group.
+ * The name of that group is available to all libostree users; best practice
+ * would be to prefix values underneath there with a short identifier for your
+ * software.
+ *
+ * Additionally, this function will remove the `origin/unlocked` and
+ * `origin/override-commit` members; these should be considered transient state
+ * that should have been under an explicit group.
+ *
+ * Since: 2018.3
+ */
+void
+ostree_deployment_origin_remove_transient_state (GKeyFile *origin)
+{
+ g_key_file_remove_group (origin, OSTREE_ORIGIN_TRANSIENT_GROUP, NULL);
+ g_key_file_remove_key (origin, "origin", "override-commit", NULL);
+ g_key_file_remove_key (origin, "origin", "unlocked", NULL);
+}
+
void
_ostree_deployment_set_bootcsum (OstreeDeployment *self,
const char *bootcsum)