[ostree/wip/libsysroot: 1/4] libostree: Add new OstreeSysroot class



commit af0f888057b5af2377f89e9602451ed8e61a5a80
Author: Colin Walters <walters verbum org>
Date:   Sun Sep 15 14:33:57 2013 -0400

    libostree: Add new OstreeSysroot class
    
    At the moment, just a container for a path, but we will start moving
    admin functionality here.

 Makefile-libostree.am                  |    2 +
 src/libostree/ostree-sysroot.c         |  176 ++++++++++++++++++++++++++++++++
 src/libostree/ostree-sysroot.h         |   42 ++++++++
 src/libostree/ostree-types.h           |    1 +
 src/libostree/ostree.h                 |    1 +
 src/ostree/ot-admin-builtin-cleanup.c  |    4 +-
 src/ostree/ot-admin-builtin-deploy.c   |   10 +-
 src/ostree/ot-admin-builtin-diff.c     |   10 +-
 src/ostree/ot-admin-builtin-init-fs.c  |    2 +-
 src/ostree/ot-admin-builtin-os-init.c  |    6 +-
 src/ostree/ot-admin-builtin-status.c   |    8 +-
 src/ostree/ot-admin-builtin-undeploy.c |   10 +-
 src/ostree/ot-admin-builtin-upgrade.c  |   14 ++--
 src/ostree/ot-admin-builtins.h         |   20 ++--
 src/ostree/ot-builtin-admin.c          |    8 +-
 15 files changed, 269 insertions(+), 45 deletions(-)
---
diff --git a/Makefile-libostree.am b/Makefile-libostree.am
index af74b75..c375527 100644
--- a/Makefile-libostree.am
+++ b/Makefile-libostree.am
@@ -43,6 +43,8 @@ libostree_1_la_SOURCES = \
        src/libostree/ostree-repo-file.c \
        src/libostree/ostree-repo-file-enumerator.c \
        src/libostree/ostree-repo-file-enumerator.h \
+       src/libostree/ostree-sysroot.c \
+       src/libostree/ostree-sysroot.h \
        $(NULL)
 if USE_LIBARCHIVE
 libostree_1_la_SOURCES += src/libostree/ostree-libarchive-input-stream.h \
diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c
new file mode 100644
index 0000000..4fa27af
--- /dev/null
+++ b/src/libostree/ostree-sysroot.c
@@ -0,0 +1,176 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2013 Colin Walters <walters verbum org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "otutil.h"
+#include "libgsystem.h"
+
+#include "ostree-sysroot.h"
+
+/**
+ * SECTION:libostree-sysroot
+ * @title: Root partition mount point
+ * @short_description: Manage physical root filesystem
+ *
+ * A #OstreeSysroot object represents a physical root filesystem,
+ * which in particular should contain a toplevel /ostree directory.
+ * Inside this directory is an #OstreeRepo in /ostree/repo, plus a set
+ * of deployments in /ostree/deploy.
+ */
+
+struct OstreeSysroot {
+  GObject parent;
+
+  GFile *path;
+  int sysroot_fd;
+};
+
+typedef struct {
+  GObjectClass parent_class;
+} OstreeSysrootClass;
+
+enum {
+  PROP_0,
+
+  PROP_PATH
+};
+
+G_DEFINE_TYPE (OstreeSysroot, ostree_sysroot, G_TYPE_OBJECT)
+
+static void
+ostree_sysroot_finalize (GObject *object)
+{
+  OstreeSysroot *self = OSTREE_SYSROOT (object);
+
+  g_clear_object (&self->path);
+
+  G_OBJECT_CLASS (ostree_sysroot_parent_class)->finalize (object);
+}
+
+static void
+ostree_sysroot_set_property(GObject         *object,
+                            guint            prop_id,
+                            const GValue    *value,
+                            GParamSpec      *pspec)
+{
+  OstreeSysroot *self = OSTREE_SYSROOT (object);
+
+  switch (prop_id)
+    {
+    case PROP_PATH:
+      /* Canonicalize */
+      self->path = g_file_new_for_path (gs_file_get_path_cached (g_value_get_object (value)));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+ostree_sysroot_get_property(GObject         *object,
+                            guint            prop_id,
+                            GValue          *value,
+                            GParamSpec      *pspec)
+{
+  OstreeSysroot *self = OSTREE_SYSROOT (object);
+
+  switch (prop_id)
+    {
+    case PROP_PATH:
+      g_value_set_object (value, self->path);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+ostree_sysroot_constructed (GObject *object)
+{
+  OstreeSysroot *self = OSTREE_SYSROOT (object);
+
+  g_assert (self->path != NULL);
+
+  G_OBJECT_CLASS (ostree_sysroot_parent_class)->constructed (object);
+}
+
+static void
+ostree_sysroot_class_init (OstreeSysrootClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->constructed = ostree_sysroot_constructed;
+  object_class->get_property = ostree_sysroot_get_property;
+  object_class->set_property = ostree_sysroot_set_property;
+  object_class->finalize = ostree_sysroot_finalize;
+
+  g_object_class_install_property (object_class,
+                                   PROP_PATH,
+                                   g_param_spec_object ("path",
+                                                        "",
+                                                        "",
+                                                        G_TYPE_FILE,
+                                                        G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+ostree_sysroot_init (OstreeSysroot *self)
+{
+  self->sysroot_fd = -1;
+}
+
+/**
+ * ostree_sysroot_new:
+ * @path: Path to a system root directory
+ *
+ * Returns: (transfer full): An accessor object for an system root located at @path
+ */
+OstreeSysroot*
+ostree_sysroot_new (GFile *path)
+{
+  return g_object_new (OSTREE_TYPE_SYSROOT, "path", path, NULL);
+}
+
+/**
+ * ostree_sysroot_new_default:
+ *
+ * Returns: (transfer full): An accessor for the current visible root / filesystem
+ */
+OstreeSysroot*
+ostree_sysroot_new_default (void)
+{
+  gs_unref_object GFile *rootfs = g_file_new_for_path ("/");
+  return ostree_sysroot_new (rootfs);
+}
+
+/**
+ * ostree_sysroot_get_path:
+ * @self:
+ *
+ * Returns: (transfer none): Path to rootfs
+ */
+GFile *
+ostree_sysroot_get_path (OstreeSysroot  *self)
+{
+  return self->path;
+}
diff --git a/src/libostree/ostree-sysroot.h b/src/libostree/ostree-sysroot.h
new file mode 100644
index 0000000..b983383
--- /dev/null
+++ b/src/libostree/ostree-sysroot.h
@@ -0,0 +1,42 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2013 Colin Walters <walters verbum org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#pragma once
+
+#include "ostree-repo.h"
+
+G_BEGIN_DECLS
+
+#define OSTREE_TYPE_SYSROOT ostree_sysroot_get_type()
+#define OSTREE_SYSROOT(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSTREE_TYPE_SYSROOT, OstreeSysroot))
+#define OSTREE_IS_SYSROOT(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSTREE_TYPE_SYSROOT))
+
+GType ostree_sysroot_get_type (void);
+
+OstreeSysroot* ostree_sysroot_new (GFile *path);
+
+OstreeSysroot* ostree_sysroot_new_default (void);
+
+GFile *ostree_sysroot_get_path (OstreeSysroot *self);
+
+G_END_DECLS
+
diff --git a/src/libostree/ostree-types.h b/src/libostree/ostree-types.h
index a0fff03..b15cbbc 100644
--- a/src/libostree/ostree-types.h
+++ b/src/libostree/ostree-types.h
@@ -27,6 +27,7 @@
 G_BEGIN_DECLS
 
 typedef struct OstreeRepo OstreeRepo;
+typedef struct OstreeSysroot OstreeSysroot;
 typedef struct OstreeMutableTree OstreeMutableTree;
 typedef struct OstreeRepoFile OstreeRepoFile;
 
diff --git a/src/libostree/ostree.h b/src/libostree/ostree.h
index efafe0d..aaaeb1b 100644
--- a/src/libostree/ostree.h
+++ b/src/libostree/ostree.h
@@ -26,4 +26,5 @@
 #include <ostree-repo.h>
 #include <ostree-mutable-tree.h>
 #include <ostree-repo-file.h>
+#include <ostree-sysroot.h>
 #include <ostree-diff.h>
diff --git a/src/ostree/ot-admin-builtin-cleanup.c b/src/ostree/ot-admin-builtin-cleanup.c
index 8b08ed2..929bf39 100644
--- a/src/ostree/ot-admin-builtin-cleanup.c
+++ b/src/ostree/ot-admin-builtin-cleanup.c
@@ -34,7 +34,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_cleanup (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_cleanup (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError 
**error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
@@ -46,7 +46,7 @@ ot_admin_builtin_cleanup (int argc, char **argv, GFile *sysroot, GCancellable *c
   if (!g_option_context_parse (context, &argc, &argv, error))
     goto out;
 
-  if (!ot_admin_cleanup (sysroot, cancellable, error))
+  if (!ot_admin_cleanup (ostree_sysroot_get_path (sysroot), cancellable, error))
     goto out;
 
   ret = TRUE;
diff --git a/src/ostree/ot-admin-builtin-deploy.c b/src/ostree/ot-admin-builtin-deploy.c
index 6652f56..7f49e4f 100644
--- a/src/ostree/ot-admin-builtin-deploy.c
+++ b/src/ostree/ot-admin-builtin-deploy.c
@@ -47,7 +47,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_deploy (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_deploy (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError 
**error)
 {
   gboolean ret = FALSE;
   const char *refspec;
@@ -77,10 +77,10 @@ ot_admin_builtin_deploy (int argc, char **argv, GFile *sysroot, GCancellable *ca
 
   refspec = argv[1];
 
-  if (!ot_admin_get_repo (sysroot, &repo, cancellable, error))
+  if (!ot_admin_get_repo (ostree_sysroot_get_path (sysroot), &repo, cancellable, error))
     goto out;
 
-  if (!ot_admin_list_deployments (sysroot, &current_bootversion, &current_deployments,
+  if (!ot_admin_list_deployments (ostree_sysroot_get_path (sysroot), &current_bootversion, 
&current_deployments,
                                   cancellable, error))
     {
       g_prefix_error (error, "While listing deployments: ");
@@ -90,7 +90,7 @@ ot_admin_builtin_deploy (int argc, char **argv, GFile *sysroot, GCancellable *ca
   /* Find the currently booted deployment, if any; we will ensure it
    * is present in the new deployment list.
    */
-  if (!ot_admin_require_deployment_or_osname (sysroot, current_deployments,
+  if (!ot_admin_require_deployment_or_osname (ostree_sysroot_get_path (sysroot), current_deployments,
                                               opt_osname,
                                               &booted_deployment,
                                               cancellable, error))
@@ -114,7 +114,7 @@ ot_admin_builtin_deploy (int argc, char **argv, GFile *sysroot, GCancellable *ca
   if (!ostree_repo_resolve_rev (repo, refspec, FALSE, &revision, error))
     goto out;
 
-  if (!ot_admin_deploy (sysroot, current_bootversion, current_deployments,
+  if (!ot_admin_deploy (ostree_sysroot_get_path (sysroot), current_bootversion, current_deployments,
                         opt_osname, revision, origin,
                         opt_kernel_argv, opt_retain,
                         booted_deployment, NULL,
diff --git a/src/ostree/ot-admin-builtin-diff.c b/src/ostree/ot-admin-builtin-diff.c
index 1758422..e64fe7e 100644
--- a/src/ostree/ot-admin-builtin-diff.c
+++ b/src/ostree/ot-admin-builtin-diff.c
@@ -37,7 +37,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_diff (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_diff (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError 
**error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
@@ -59,16 +59,16 @@ ot_admin_builtin_diff (int argc, char **argv, GFile *sysroot, GCancellable *canc
   if (!g_option_context_parse (context, &argc, &argv, error))
     goto out;
   
-  repo_path = g_file_resolve_relative_path (sysroot, "ostree/repo");
+  repo_path = g_file_resolve_relative_path (ostree_sysroot_get_path (sysroot), "ostree/repo");
 
-  if (!ot_admin_list_deployments (sysroot, &bootversion, &deployments,
+  if (!ot_admin_list_deployments (ostree_sysroot_get_path (sysroot), &bootversion, &deployments,
                                   cancellable, error))
     {
       g_prefix_error (error, "While listing deployments: ");
       goto out;
     }
 
-  if (!ot_admin_require_deployment_or_osname (sysroot, deployments,
+  if (!ot_admin_require_deployment_or_osname (ostree_sysroot_get_path (sysroot), deployments,
                                               opt_osname, &deployment,
                                               cancellable, error))
     goto out;
@@ -83,7 +83,7 @@ ot_admin_builtin_diff (int argc, char **argv, GFile *sysroot, GCancellable *canc
       goto out;
     }
 
-  deployment_dir = ot_admin_get_deployment_directory (sysroot, deployment);
+  deployment_dir = ot_admin_get_deployment_directory (ostree_sysroot_get_path (sysroot), deployment);
 
   orig_etc_path = g_file_resolve_relative_path (deployment_dir, "usr/etc");
   new_etc_path = g_file_resolve_relative_path (deployment_dir, "etc");
diff --git a/src/ostree/ot-admin-builtin-init-fs.c b/src/ostree/ot-admin-builtin-init-fs.c
index dbfd0ba..78872b7 100644
--- a/src/ostree/ot-admin-builtin-init-fs.c
+++ b/src/ostree/ot-admin-builtin-init-fs.c
@@ -34,7 +34,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_init_fs (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_init_fs (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError 
**error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
diff --git a/src/ostree/ot-admin-builtin-os-init.c b/src/ostree/ot-admin-builtin-os-init.c
index b9e8570..414662a 100644
--- a/src/ostree/ot-admin-builtin-os-init.c
+++ b/src/ostree/ot-admin-builtin-os-init.c
@@ -34,7 +34,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_os_init (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_os_init (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError 
**error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
@@ -48,7 +48,7 @@ ot_admin_builtin_os_init (int argc, char **argv, GFile *sysroot, GCancellable *c
   if (!g_option_context_parse (context, &argc, &argv, error))
     goto out;
 
-  if (!ot_admin_ensure_initialized (sysroot, cancellable, error))
+  if (!ot_admin_ensure_initialized (ostree_sysroot_get_path (sysroot), cancellable, error))
     goto out;
 
   if (argc < 2)
@@ -59,7 +59,7 @@ ot_admin_builtin_os_init (int argc, char **argv, GFile *sysroot, GCancellable *c
 
   osname = argv[1];
 
-  deploy_dir = ot_gfile_get_child_build_path (sysroot, "ostree", "deploy", osname, NULL);
+  deploy_dir = ot_gfile_get_child_build_path (ostree_sysroot_get_path (sysroot), "ostree", "deploy", osname, 
NULL);
 
   /* Ensure core subdirectories of /var exist, since we need them for
    * dracut generation, and the host will want them too.  Note that at
diff --git a/src/ostree/ot-admin-builtin-status.c b/src/ostree/ot-admin-builtin-status.c
index eb5b765..f29fd8b 100644
--- a/src/ostree/ot-admin-builtin-status.c
+++ b/src/ostree/ot-admin-builtin-status.c
@@ -34,7 +34,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_status (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_status (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError 
**error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
@@ -50,14 +50,14 @@ ot_admin_builtin_status (int argc, char **argv, GFile *sysroot, GCancellable *ca
   if (!g_option_context_parse (context, &argc, &argv, error))
     goto out;
 
-  if (!ot_admin_list_deployments (sysroot, &bootversion, &deployments,
+  if (!ot_admin_list_deployments (ostree_sysroot_get_path (sysroot), &bootversion, &deployments,
                                   cancellable, error))
     {
       g_prefix_error (error, "While listing deployments: ");
       goto out;
     }
 
-  if (!ot_admin_find_booted_deployment (sysroot, deployments,
+  if (!ot_admin_find_booted_deployment (ostree_sysroot_get_path (sysroot), deployments,
                                         &booted_deployment,
                                         cancellable, error))
     goto out;
@@ -70,7 +70,7 @@ ot_admin_builtin_status (int argc, char **argv, GFile *sysroot, GCancellable *ca
     {
       int subbootversion;
 
-      if (!ot_admin_read_current_subbootversion (sysroot, bootversion,
+      if (!ot_admin_read_current_subbootversion (ostree_sysroot_get_path (sysroot), bootversion,
                                                  &subbootversion,
                                                  cancellable, error))
         goto out;
diff --git a/src/ostree/ot-admin-builtin-undeploy.c b/src/ostree/ot-admin-builtin-undeploy.c
index 0386bba..5a6a279 100644
--- a/src/ostree/ot-admin-builtin-undeploy.c
+++ b/src/ostree/ot-admin-builtin-undeploy.c
@@ -34,7 +34,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_undeploy (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_undeploy (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError 
**error)
 {
   gboolean ret = FALSE;
   GOptionContext *context;
@@ -61,14 +61,14 @@ ot_admin_builtin_undeploy (int argc, char **argv, GFile *sysroot, GCancellable *
   deploy_index_str = argv[1];
   deploy_index = atoi (deploy_index_str);
 
-  if (!ot_admin_list_deployments (sysroot, &current_bootversion, &current_deployments,
+  if (!ot_admin_list_deployments (ostree_sysroot_get_path (sysroot), &current_bootversion, 
&current_deployments,
                                   cancellable, error))
     {
       g_prefix_error (error, "While listing deployments: ");
       goto out;
     }
 
-  if (!ot_admin_find_booted_deployment (sysroot, current_deployments, &booted_deployment,
+  if (!ot_admin_find_booted_deployment (ostree_sysroot_get_path (sysroot), current_deployments, 
&booted_deployment,
                                         cancellable, error))
     goto out;
 
@@ -95,7 +95,7 @@ ot_admin_builtin_undeploy (int argc, char **argv, GFile *sysroot, GCancellable *
   
   g_ptr_array_remove_index (current_deployments, deploy_index);
 
-  if (!ot_admin_write_deployments (sysroot, current_bootversion,
+  if (!ot_admin_write_deployments (ostree_sysroot_get_path (sysroot), current_bootversion,
                                    current_bootversion ? 0 : 1, current_deployments,
                                    cancellable, error))
     goto out;
@@ -103,7 +103,7 @@ ot_admin_builtin_undeploy (int argc, char **argv, GFile *sysroot, GCancellable *
   g_print ("Deleted deployment %s.%d\n", ot_deployment_get_csum (target_deployment),
            ot_deployment_get_deployserial (target_deployment));
   
-  if (!ot_admin_cleanup (sysroot, cancellable, error))
+  if (!ot_admin_cleanup (ostree_sysroot_get_path (sysroot), cancellable, error))
     {
       g_prefix_error (error, "Performing final cleanup: ");
       goto out;
diff --git a/src/ostree/ot-admin-builtin-upgrade.c b/src/ostree/ot-admin-builtin-upgrade.c
index 882c41a..269bcdd 100644
--- a/src/ostree/ot-admin-builtin-upgrade.c
+++ b/src/ostree/ot-admin-builtin-upgrade.c
@@ -43,7 +43,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError 
**error)
 {
   gboolean ret = FALSE;
   GOptionContext *context;
@@ -70,7 +70,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *c
   if (!g_option_context_parse (context, &argc, &argv, error))
     goto out;
 
-  if (!ot_admin_list_deployments (sysroot, &current_bootversion,
+  if (!ot_admin_list_deployments (ostree_sysroot_get_path (sysroot), &current_bootversion,
                                   &current_deployments,
                                   cancellable, error))
     {
@@ -78,7 +78,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *c
       goto out;
     }
 
-  if (!ot_admin_require_deployment_or_osname (sysroot, current_deployments,
+  if (!ot_admin_require_deployment_or_osname (ostree_sysroot_get_path (sysroot), current_deployments,
                                               opt_osname,
                                               &booted_deployment,
                                               cancellable, error))
@@ -88,10 +88,10 @@ ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *c
   merge_deployment = ot_admin_get_merge_deployment (current_deployments, opt_osname,
                                                     booted_deployment);
 
-  deployment_path = ot_admin_get_deployment_directory (sysroot, merge_deployment);
+  deployment_path = ot_admin_get_deployment_directory (ostree_sysroot_get_path (sysroot), merge_deployment);
   deployment_origin_path = ot_admin_get_deployment_origin_path (deployment_path);
 
-  repo_path = g_file_resolve_relative_path (sysroot, "ostree/repo");
+  repo_path = g_file_resolve_relative_path (ostree_sysroot_get_path (sysroot), "ostree/repo");
   repo = ostree_repo_new (repo_path);
   if (!ostree_repo_open (repo, cancellable, error))
     goto out;
@@ -135,7 +135,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *c
   else
     {
       gs_unref_object GFile *real_sysroot = g_file_new_for_path ("/");
-      if (!ot_admin_deploy (sysroot,
+      if (!ot_admin_deploy (ostree_sysroot_get_path (sysroot),
                             current_bootversion, current_deployments,
                             opt_osname, new_revision, origin,
                             NULL, FALSE,
@@ -144,7 +144,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *c
                             cancellable, error))
         goto out;
 
-      if (opt_reboot && g_file_equal (sysroot, real_sysroot))
+      if (opt_reboot && g_file_equal (ostree_sysroot_get_path (sysroot), real_sysroot))
         {
           gs_subprocess_simple_run_sync (NULL, GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
                                          cancellable, error,
diff --git a/src/ostree/ot-admin-builtins.h b/src/ostree/ot-admin-builtins.h
index bc7b8fc..eaea2af 100644
--- a/src/ostree/ot-admin-builtins.h
+++ b/src/ostree/ot-admin-builtins.h
@@ -22,19 +22,19 @@
 
 #pragma once
 
-#include <gio/gio.h>
+#include <ostree.h>
 
 G_BEGIN_DECLS
 
-gboolean ot_admin_builtin_os_init (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError 
**error);
-gboolean ot_admin_builtin_install (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError 
**error);
-gboolean ot_admin_builtin_init_fs (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError 
**error);
-gboolean ot_admin_builtin_undeploy (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError 
**error);
-gboolean ot_admin_builtin_deploy (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError 
**error);
-gboolean ot_admin_builtin_cleanup (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError 
**error);
-gboolean ot_admin_builtin_status (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError 
**error);
-gboolean ot_admin_builtin_diff (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError 
**error);
-gboolean ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError 
**error);
+gboolean ot_admin_builtin_os_init (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, 
GError **error);
+gboolean ot_admin_builtin_install (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, 
GError **error);
+gboolean ot_admin_builtin_init_fs (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, 
GError **error);
+gboolean ot_admin_builtin_undeploy (int argc, char **argv, OstreeSysroot *sysroot, GCancellable 
*cancellable, GError **error);
+gboolean ot_admin_builtin_deploy (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, 
GError **error);
+gboolean ot_admin_builtin_cleanup (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, 
GError **error);
+gboolean ot_admin_builtin_status (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, 
GError **error);
+gboolean ot_admin_builtin_diff (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, 
GError **error);
+gboolean ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, 
GError **error);
 
 G_END_DECLS
 
diff --git a/src/ostree/ot-builtin-admin.c b/src/ostree/ot-builtin-admin.c
index e6ea3e9..93d2efa 100644
--- a/src/ostree/ot-builtin-admin.c
+++ b/src/ostree/ot-builtin-admin.c
@@ -34,7 +34,7 @@
 
 typedef struct {
   const char *name;
-  gboolean (*fn) (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
+  gboolean (*fn) (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error);
 } OstreeAdminCommand;
 
 static OstreeAdminCommand admin_subcommands[] = {
@@ -56,7 +56,8 @@ ostree_builtin_admin (int argc, char **argv, OstreeRepo *repo, GCancellable *can
   const char *opt_sysroot = "/";
   const char *subcommand_name = NULL;
   OstreeAdminCommand *subcommand;
-  gs_unref_object GFile *sysroot = NULL;
+  gs_unref_object GFile *sysroot_path = NULL;
+  gs_unref_object OstreeSysroot *sysroot = NULL;
   gboolean want_help = FALSE;
   int in, out, i;
   gboolean skip;
@@ -170,7 +171,8 @@ ostree_builtin_admin (int argc, char **argv, OstreeRepo *repo, GCancellable *can
       goto out;
     }
 
-  sysroot = g_file_new_for_path (opt_sysroot);
+  sysroot_path = g_file_new_for_path (opt_sysroot);
+  sysroot = ostree_sysroot_new (sysroot_path);
   if (!subcommand->fn (argc, argv, sysroot, cancellable, error))
     goto out;
  


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