[ostree/wip/libsysroot: 2/2] sysroot: Support more arbitrary deployment changes



commit b1d627fcea6f5bacb13dc48589c672330ef4a5d1
Author: Colin Walters <walters verbum org>
Date:   Mon Sep 30 18:44:32 2013 -0400

    sysroot: Support more arbitrary deployment changes
    
    This commit changes the sysroot API so that one can create arbitrary
    new deployment checkouts, then commit them as one step.  This is to
    enable things like an automatic bisection tool which say create 50
    deployments at once, then when done clean them up.

 src/libostree/ostree-sysroot-deploy.c |   33 ++++++++++-----------------------
 src/ostree/ot-admin-builtin-deploy.c  |   13 +++++++++++++
 src/ostree/ot-admin-builtin-upgrade.c |   14 ++++++++++++++
 tests/test-admin-deploy-1.sh          |   11 +++--------
 4 files changed, 40 insertions(+), 31 deletions(-)
---
diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c
index 2b32cf0..229bf15 100644
--- a/src/libostree/ostree-sysroot-deploy.c
+++ b/src/libostree/ostree-sysroot-deploy.c
@@ -881,7 +881,7 @@ ostree_sysroot_write_deployments (OstreeSysroot     *self,
       if (deployment == self->booted_deployment)
         found_booted_deployment = TRUE;
 
-      ostree_deployment_set_index (deployment, 0);
+      ostree_deployment_set_index (deployment, i);
     }
 
   if (self->booted_deployment && !found_booted_deployment)
@@ -959,14 +959,6 @@ ostree_sysroot_write_deployments (OstreeSysroot     *self,
 
   g_print ("Transaction complete, performing cleanup\n");
 
-  /* And finally, cleanup of any leftover data.
-   */
-  if (!ostree_sysroot_cleanup (self, cancellable, error))
-    {
-      g_prefix_error (error, "Performing final cleanup: ");
-      goto out;
-    }
-
   /* Now reload from disk */
   if (!ostree_sysroot_load (self, cancellable, error))
     {
@@ -977,6 +969,14 @@ ostree_sysroot_write_deployments (OstreeSysroot     *self,
   if (!create_current_symlinks (self, cancellable, error))
     goto out;
 
+  /* And finally, cleanup of any leftover data.
+   */
+  if (!ostree_sysroot_cleanup (self, cancellable, error))
+    {
+      g_prefix_error (error, "Performing final cleanup: ");
+      goto out;
+    }
+
   ret = TRUE;
  out:
   return ret;
@@ -1067,19 +1067,6 @@ ostree_sysroot_deploy_one_tree (OstreeSysroot     *self,
   if (!ostree_sysroot_get_repo (self, &repo, cancellable, error))
     goto out;
 
-  /* Here we perform cleanup of any leftover data from previous
-   * partial failures.  This avoids having to call gs_shutil_rm_rf()
-   * at random points throughout the process.
-   *
-   * TODO: Add /ostree/transaction file, and only do this cleanup if
-   * we find it.
-   */
-  if (!ostree_sysroot_cleanup (self, cancellable, error))
-    {
-      g_prefix_error (error, "Performing initial cleanup: ");
-      goto out;
-    }
-
   if (!ostree_repo_read_commit (repo, revision, &commit_root, NULL, cancellable, error))
     goto out;
 
@@ -1106,7 +1093,7 @@ ostree_sysroot_deploy_one_tree (OstreeSysroot     *self,
     goto out;
 
   new_deployment = ostree_deployment_new (0, osname, revision, new_deployserial,
-                                          new_bootcsum, 0);
+                                          new_bootcsum, -1);
   ostree_deployment_set_origin (new_deployment, origin);
 
   /* Check out the userspace tree onto the filesystem */
diff --git a/src/ostree/ot-admin-builtin-deploy.c b/src/ostree/ot-admin-builtin-deploy.c
index efe543b..5e94e90 100644
--- a/src/ostree/ot-admin-builtin-deploy.c
+++ b/src/ostree/ot-admin-builtin-deploy.c
@@ -105,6 +105,19 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeSysroot *sysroot, GCancell
 
   merge_deployment = ostree_sysroot_get_merge_deployment (sysroot, opt_osname);
 
+  /* Here we perform cleanup of any leftover data from previous
+   * partial failures.  This avoids having to call gs_shutil_rm_rf()
+   * at random points throughout the process.
+   *
+   * TODO: Add /ostree/transaction file, and only do this cleanup if
+   * we find it.
+   */
+  if (!ostree_sysroot_cleanup (sysroot, cancellable, error))
+    {
+      g_prefix_error (error, "Performing initial cleanup: ");
+      goto out;
+    }
+
   if (!ostree_sysroot_deploy_one_tree (sysroot,
                                        opt_osname, revision, origin,
                                        opt_kernel_argv, merge_deployment,
diff --git a/src/ostree/ot-admin-builtin-upgrade.c b/src/ostree/ot-admin-builtin-upgrade.c
index 8654e65..3beb7c9 100644
--- a/src/ostree/ot-admin-builtin-upgrade.c
+++ b/src/ostree/ot-admin-builtin-upgrade.c
@@ -125,6 +125,20 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancel
   else
     {
       gs_unref_object GFile *real_sysroot = g_file_new_for_path ("/");
+      
+      /* Here we perform cleanup of any leftover data from previous
+       * partial failures.  This avoids having to call gs_shutil_rm_rf()
+       * at random points throughout the process.
+       *
+       * TODO: Add /ostree/transaction file, and only do this cleanup if
+       * we find it.
+       */
+      if (!ostree_sysroot_cleanup (sysroot, cancellable, error))
+        {
+          g_prefix_error (error, "Performing initial cleanup: ");
+          goto out;
+        }
+
       if (!ostree_sysroot_deploy_one_tree (sysroot,
                                            opt_osname, new_revision, origin,
                                            NULL,
diff --git a/tests/test-admin-deploy-1.sh b/tests/test-admin-deploy-1.sh
index 66139d5..02f5b20 100755
--- a/tests/test-admin-deploy-1.sh
+++ b/tests/test-admin-deploy-1.sh
@@ -143,17 +143,12 @@ ostree admin --sysroot=sysroot status
 
 echo "ok upgrade"
 
+assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/etc/os-release 'NAME=TestOS'
 assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/os-release 'NAME=TestOS'
-assert_file_has_content sysroot/ostree/deploy/testos/deploy/${origrev}.4/etc/os-release 'NAME=TestOS'
-ostree admin --sysroot=sysroot undeploy 2
+ostree admin --sysroot=sysroot undeploy 1
 assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/os-release 'NAME=TestOS'
-assert_not_has_dir sysroot/ostree/deploy/testos/deploy/${origrev}.4
-
-assert_file_has_content sysroot/ostree/deploy/testos/deploy/${origrev}.3/etc/os-release 'NAME=TestOS'
-ostree admin --sysroot=sysroot undeploy 2
-assert_not_has_dir sysroot/ostree/deploy/testos/deploy/${origrev}.3
+assert_not_has_dir sysroot/ostree/deploy/testos/deploy/${rev}.0
 
-assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/os-release 'NAME=TestOS'
 ostree admin --sysroot=sysroot undeploy 0
 assert_not_has_dir sysroot/ostree/deploy/testos/deploy/${newrev}.0
 ostree admin --sysroot=sysroot status


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