[ostree] Add /ostree/current-etc symlink to current configuration



commit 8c9406637c60580ebd3d4feee66ab42b59877d2a
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sun Sep 16 23:56:13 2012 +0200

    Add /ostree/current-etc symlink to current configuration
    
    Configuration associated with a specific revision is stored in a folder
    named <revision>-etc. In a similar spirit, add /ostree/current-etc, pointing
    to the -etc folder for the revision named by current. This allows
    easy editing of configuration from the host distribution, and allows
    diffing current/etc and current-etc for configuration changes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684049

 src/ostree/ot-admin-builtin-deploy.c |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/src/ostree/ot-admin-builtin-deploy.c b/src/ostree/ot-admin-builtin-deploy.c
index 2041c5f..d6e5027 100644
--- a/src/ostree/ot-admin-builtin-deploy.c
+++ b/src/ostree/ot-admin-builtin-deploy.c
@@ -47,7 +47,8 @@ static GOptionEntry options[] = {
  *
  * Atomically swap the /ostree/current symbolic link to point to a new
  * path.  If successful, the old current will be saved as
- * /ostree/previous.
+ * /ostree/previous, and /ostree/current-etc will be a link to the
+ * current /etc subdirectory.
  *
  * Unless the new-current equals current, in which case, do nothing.
  */
@@ -60,18 +61,23 @@ update_current (OtAdminDeploy      *self,
 {
   gboolean ret = FALSE;
   ot_lobj GFile *current_path = NULL;
+  ot_lobj GFile *current_etc_path = NULL;
   ot_lobj GFile *previous_path = NULL;
   ot_lobj GFile *tmp_current_path = NULL;
+  ot_lobj GFile *tmp_current_etc_path = NULL;
   ot_lobj GFile *tmp_previous_path = NULL;
   ot_lobj GFileInfo *previous_info = NULL;
   ot_lfree char *relative_current = NULL;
+  ot_lfree char *relative_current_etc = NULL;
   ot_lfree char *relative_previous = NULL;
 
   current_path = g_file_get_child (self->ostree_dir, "current");
+  current_etc_path = g_file_get_child (self->ostree_dir, "current-etc");
   previous_path = g_file_get_child (self->ostree_dir, "previous");
 
   relative_current = g_file_get_relative_path (self->ostree_dir, deploy_target);
   g_assert (relative_current);
+  relative_current_etc = g_strconcat (relative_current, "-etc", NULL);
 
   if (current_deployment)
     {
@@ -105,9 +111,20 @@ update_current (OtAdminDeploy      *self,
       goto out;
     }
 
+  tmp_current_etc_path = g_file_get_child (self->ostree_dir, "tmp-current-etc");
+  (void) ot_gfile_unlink (tmp_current_etc_path, NULL, NULL);
+  if (symlink (relative_current_etc, ot_gfile_get_path_cached (tmp_current_etc_path)) < 0)
+    {
+      ot_util_set_error_from_errno (error, errno);
+      goto out;
+    }
+
   if (!ot_gfile_rename (tmp_current_path, current_path,
                         cancellable, error))
     goto out;
+  if (!ot_gfile_rename (tmp_current_etc_path, current_etc_path,
+                        cancellable, error))
+    goto out;
 
   if (tmp_previous_path)
     {
@@ -314,7 +331,7 @@ merge_etc_changes (OtAdminDeploy  *self,
  *
  * Merge configuration changes from the old deployment, if any.
  *
- * Update the OSTREE_DIR/current and OSTREE_DIR/previous symbolic
+ * Update the OSTREE_DIR/current{,-etc} and OSTREE_DIR/previous symbolic
  * links.
  */
 static gboolean



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]