[ostree] upgrade: Don't require specification of osname



commit 18af230e17fa2ff801863893fbc0175c5a608e9a
Author: Colin Walters <walters verbum org>
Date:   Wed May 15 08:18:53 2013 -0400

    upgrade: Don't require specification of osname
    
    Since this is a highly visible command, let's have a sane default and
    upgrade the currently running OS.

 src/libgsystem                        |    2 +-
 src/ostree/ot-admin-builtin-upgrade.c |   22 ++++++++++++++++------
 src/ostree/ot-admin-functions.c       |    2 +-
 3 files changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/src/libgsystem b/src/libgsystem
index 51736db..b2a65b2 160000
--- a/src/libgsystem
+++ b/src/libgsystem
@@ -1 +1 @@
-Subproject commit 51736db5f49b4b798fd2f9d0ccb8eff453105162
+Subproject commit b2a65b235600e340fada441de7e131de9d52d25e
diff --git a/src/ostree/ot-admin-builtin-upgrade.c b/src/ostree/ot-admin-builtin-upgrade.c
index f8ee8a0..60def83 100644
--- a/src/ostree/ot-admin-builtin-upgrade.c
+++ b/src/ostree/ot-admin-builtin-upgrade.c
@@ -40,23 +40,33 @@ ot_admin_builtin_upgrade (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
   GOptionContext *context;
   gboolean ret = FALSE;
   GFile *ostree_dir = admin_opts->ostree_dir;
+  gs_free char *booted_osname = NULL;
   const char *osname = NULL;
   gs_free char *ostree_dir_arg = NULL;
   __attribute__((unused)) GCancellable *cancellable = NULL;
 
-  context = g_option_context_new ("OSNAME - pull, deploy, and prune");
+  context = g_option_context_new ("[OSNAME] - pull, deploy, and prune");
   g_option_context_add_main_entries (context, options, NULL);
 
   if (!g_option_context_parse (context, &argc, &argv, error))
     goto out;
 
-  if (argc < 2)
+  if (argc > 1)
     {
-      ot_util_usage_error (context, "OSNAME must be specified", error);
-      goto out;
+      osname = argv[1];
+    }
+  else
+    {
+      if (!ot_admin_get_active_deployment (NULL, &booted_osname, NULL, cancellable, error))
+        goto out;
+      if (booted_osname == NULL)
+        {
+          g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                       "Not in an active OSTree system; must specify OSNAME");
+          goto out;
+        }
+      osname = booted_osname;
     }
-
-  osname = argv[1];
 
   ostree_dir_arg = g_strconcat ("--ostree-dir=",
                                 gs_file_get_path_cached (ostree_dir),
diff --git a/src/ostree/ot-admin-functions.c b/src/ostree/ot-admin-functions.c
index c0b71a5..cc0d3b3 100644
--- a/src/ostree/ot-admin-functions.c
+++ b/src/ostree/ot-admin-functions.c
@@ -377,7 +377,7 @@ ot_admin_get_active_deployment (GFile           *ostree_dir,
   if (!ot_admin_get_booted_os (&ret_osname, NULL, cancellable, error))
     goto out;
 
-  if (ret_osname != NULL)
+  if (ret_osname != NULL && out_deployment != NULL)
     {
       gs_unref_object GFile *rootfs_path = NULL;
       gs_unref_object GFileInfo *rootfs_info = NULL;


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