[ostree/wip/libsysroot: 4/4] libostree: Move a lot more sysroot API here



commit 95f07d486adcb6bb12d8da0016066d8d8db205d6
Author: Colin Walters <walters verbum org>
Date:   Sun Sep 15 18:07:34 2013 -0400

    libostree: Move a lot more sysroot API here
    
    OstreeBootloader is temporarily public API.

 Makefile-libostree-defines.am                      |    4 +
 Makefile-libostree.am                              |   10 +-
 Makefile-ostree.am                                 |    7 -
 .../ostree-bootloader-syslinux.c}                  |   74 ++--
 .../ostree-bootloader-syslinux.h}                  |   14 +-
 .../ostree-bootloader-uboot.c}                     |   68 +-
 .../ostree-bootloader-uboot.h}                     |   14 +-
 .../ostree-bootloader.c}                           |   26 +-
 src/libostree/ostree-bootloader.h                  |   60 ++
 .../ostree-sysroot-cleanup.c}                      |   83 ++--
 src/libostree/ostree-sysroot-private.h             |   57 ++
 src/libostree/ostree-sysroot.c                     |  634 +++++++++++++++++++-
 src/libostree/ostree-sysroot.h                     |   31 +
 src/ostree/ot-admin-builtin-cleanup.c              |    2 +-
 src/ostree/ot-admin-builtin-deploy.c               |    6 +-
 src/ostree/ot-admin-builtin-diff.c                 |    6 +-
 src/ostree/ot-admin-builtin-status.c               |    6 +-
 src/ostree/ot-admin-builtin-undeploy.c             |    6 +-
 src/ostree/ot-admin-builtin-upgrade.c              |   10 +-
 src/ostree/ot-admin-deploy.c                       |   56 +-
 src/ostree/ot-admin-deploy.h                       |    1 -
 src/ostree/ot-admin-functions.c                    |  529 +----------------
 src/ostree/ot-admin-functions.h                    |   42 --
 src/ostree/ot-admin-util.c                         |   23 -
 src/ostree/ot-bootloader.h                         |   60 --
 25 files changed, 978 insertions(+), 851 deletions(-)
---
diff --git a/Makefile-libostree-defines.am b/Makefile-libostree-defines.am
index ee91cc1..da4507f 100644
--- a/Makefile-libostree-defines.am
+++ b/Makefile-libostree-defines.am
@@ -26,4 +26,8 @@ libostree_public_headers = \
        src/libostree/ostree-types.h \
        src/libostree/ostree-repo-file.h \
        src/libostree/ostree-diff.h \
+       src/libostree/ostree-sysroot.h \
+       src/libostree/ostree-bootloader.h \
+       src/libostree/ostree-deployment.h \
+       src/libostree/ostree-bootconfig-parser.h \
        $(NULL)
diff --git a/Makefile-libostree.am b/Makefile-libostree.am
index a24c542..3576b44 100644
--- a/Makefile-libostree.am
+++ b/Makefile-libostree.am
@@ -43,12 +43,16 @@ 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-private.h \
        src/libostree/ostree-sysroot.c \
-       src/libostree/ostree-sysroot.h \
-       src/libostree/ostree-bootconfig-parser.h \
+       src/libostree/ostree-sysroot-cleanup.c \
        src/libostree/ostree-bootconfig-parser.c \
-       src/libostree/ostree-deployment.h \
        src/libostree/ostree-deployment.c \
+       src/libostree/ostree-bootloader.c \
+       src/libostree/ostree-bootloader-syslinux.h \
+       src/libostree/ostree-bootloader-syslinux.c \
+       src/libostree/ostree-bootloader-uboot.h \
+       src/libostree/ostree-bootloader-uboot.c \
        $(NULL)
 if USE_LIBARCHIVE
 libostree_1_la_SOURCES += src/libostree/ostree-libarchive-input-stream.h \
diff --git a/Makefile-ostree.am b/Makefile-ostree.am
index 3fe1a05..df5c3a4 100644
--- a/Makefile-ostree.am
+++ b/Makefile-ostree.am
@@ -59,18 +59,11 @@ ostree_SOURCES += \
        src/ostree/ot-admin-builtin-status.c \
        src/ostree/ot-admin-builtin-upgrade.c \
        src/ostree/ot-admin-builtins.h \
-       src/ostree/ot-admin-cleanup.c \
        src/ostree/ot-admin-util.c \
        src/ostree/ot-admin-functions.h \
        src/ostree/ot-admin-functions.c \
        src/ostree/ot-admin-deploy.h \
        src/ostree/ot-admin-deploy.c \
-       src/ostree/ot-bootloader.h \
-       src/ostree/ot-bootloader.c \
-       src/ostree/ot-bootloader-syslinux.h \
-       src/ostree/ot-bootloader-syslinux.c \
-       src/ostree/ot-bootloader-uboot.h \
-       src/ostree/ot-bootloader-uboot.c \
        src/ostree/ot-ordered-hash.h \
        src/ostree/ot-ordered-hash.c \
        $(NULL)
diff --git a/src/ostree/ot-bootloader-syslinux.c b/src/libostree/ostree-bootloader-syslinux.c
similarity index 74%
rename from src/ostree/ot-bootloader-syslinux.c
rename to src/libostree/ostree-bootloader-syslinux.c
index 2d951f3..9c6b221 100644
--- a/src/ostree/ot-bootloader-syslinux.c
+++ b/src/libostree/ostree-bootloader-syslinux.c
@@ -20,43 +20,43 @@
 
 #include "config.h"
 
-#include "ot-bootloader-syslinux.h"
+#include "ostree-sysroot-private.h"
+#include "ostree-bootloader-syslinux.h"
 #include "otutil.h"
-#include "ot-admin-functions.h"
 #include "libgsystem.h"
 
 #include <string.h>
 
-struct _OtBootloaderSyslinux
+struct _OstreeBootloaderSyslinux
 {
   GObject       parent_instance;
 
-  GFile        *sysroot;
-  GFile        *config_path;
+  OstreeSysroot  *sysroot;
+  GFile          *config_path;
 };
 
-typedef GObjectClass OtBootloaderSyslinuxClass;
+typedef GObjectClass OstreeBootloaderSyslinuxClass;
 
-static void ot_bootloader_syslinux_bootloader_iface_init (OtBootloaderInterface *iface);
-G_DEFINE_TYPE_WITH_CODE (OtBootloaderSyslinux, ot_bootloader_syslinux, G_TYPE_OBJECT,
-                         G_IMPLEMENT_INTERFACE (OT_TYPE_BOOTLOADER, 
ot_bootloader_syslinux_bootloader_iface_init));
+static void ostree_bootloader_syslinux_bootloader_iface_init (OstreeBootloaderInterface *iface);
+G_DEFINE_TYPE_WITH_CODE (OstreeBootloaderSyslinux, ostree_bootloader_syslinux, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (OSTREE_TYPE_BOOTLOADER, 
ostree_bootloader_syslinux_bootloader_iface_init));
 
 static gboolean
-ot_bootloader_syslinux_query (OtBootloader *bootloader)
+ostree_bootloader_syslinux_query (OstreeBootloader *bootloader)
 {
-  OtBootloaderSyslinux *self = OT_BOOTLOADER_SYSLINUX (bootloader);
+  OstreeBootloaderSyslinux *self = OSTREE_BOOTLOADER_SYSLINUX (bootloader);
 
   return g_file_query_file_type (self->config_path, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL) == 
G_FILE_TYPE_SYMBOLIC_LINK;
 }
 
 static const char *
-ot_bootloader_syslinux_get_name (OtBootloader *bootloader)
+ostree_bootloader_syslinux_get_name (OstreeBootloader *bootloader)
 {
   return "syslinux";
 }
 
 static gboolean
-append_config_from_boot_loader_entries (OtBootloaderSyslinux  *self,
+append_config_from_boostree_loader_entries (OstreeBootloaderSyslinux  *self,
                                         gboolean               regenerate_default,
                                         int                    bootversion,
                                         GPtrArray             *new_lines,
@@ -64,16 +64,16 @@ append_config_from_boot_loader_entries (OtBootloaderSyslinux  *self,
                                         GError               **error)
 {
   gboolean ret = FALSE;
-  gs_unref_ptrarray GPtrArray *boot_loader_configs = NULL;
+  gs_unref_ptrarray GPtrArray *boostree_loader_configs = NULL;
   guint i;
 
-  if (!ot_admin_read_boot_loader_configs (self->sysroot, bootversion, &boot_loader_configs,
-                                          cancellable, error))
+  if (!_ostree_sysroot_read_boot_loader_configs (self->sysroot, bootversion, &boostree_loader_configs,
+                                                 cancellable, error))
     goto out;
 
-  for (i = 0; i < boot_loader_configs->len; i++)
+  for (i = 0; i < boostree_loader_configs->len; i++)
     {
-      OstreeBootconfigParser *config = boot_loader_configs->pdata[i];
+      OstreeBootconfigParser *config = boostree_loader_configs->pdata[i];
       const char *val;
 
       val = ostree_bootconfig_parser_get (config, "title");
@@ -111,13 +111,13 @@ append_config_from_boot_loader_entries (OtBootloaderSyslinux  *self,
 }
 
 static gboolean
-ot_bootloader_syslinux_write_config (OtBootloader          *bootloader,
+ostree_bootloader_syslinux_write_config (OstreeBootloader          *bootloader,
                                      int                    bootversion,
                                      GCancellable          *cancellable,
                                      GError               **error)
 {
   gboolean ret = FALSE;
-  OtBootloaderSyslinux *self = OT_BOOTLOADER_SYSLINUX (bootloader);
+  OstreeBootloaderSyslinux *self = OSTREE_BOOTLOADER_SYSLINUX (bootloader);
   gs_unref_object GFile *new_config_path = NULL;
   gs_free char *config_contents = NULL;
   gs_free char *new_config_contents = NULL;
@@ -131,7 +131,7 @@ ot_bootloader_syslinux_write_config (OtBootloader          *bootloader,
   char **iter;
   guint i;
 
-  new_config_path = ot_gfile_resolve_path_printf (self->sysroot, "boot/loader.%d/syslinux.cfg",
+  new_config_path = ot_gfile_resolve_path_printf (self->sysroot->path, "boot/loader.%d/syslinux.cfg",
                                                   bootversion);
 
   /* This should follow the symbolic link to the current bootversion. */
@@ -230,12 +230,12 @@ ot_bootloader_syslinux_write_config (OtBootloader          *bootloader,
   if (!saw_default)
     regenerate_default = TRUE;
 
-  if (!append_config_from_boot_loader_entries (self, regenerate_default,
+  if (!append_config_from_boostree_loader_entries (self, regenerate_default,
                                                bootversion, new_lines,
                                                cancellable, error))
     goto out;
 
-  new_config_contents = ot_admin_join_lines (new_lines);
+  new_config_contents = _ostree_sysroot_join_lines (new_lines);
 
   if (strcmp (new_config_contents, config_contents) != 0)
     {
@@ -254,42 +254,42 @@ ot_bootloader_syslinux_write_config (OtBootloader          *bootloader,
 }
 
 static void
-ot_bootloader_syslinux_finalize (GObject *object)
+ostree_bootloader_syslinux_finalize (GObject *object)
 {
-  OtBootloaderSyslinux *self = OT_BOOTLOADER_SYSLINUX (object);
+  OstreeBootloaderSyslinux *self = OSTREE_BOOTLOADER_SYSLINUX (object);
 
   g_clear_object (&self->sysroot);
   g_clear_object (&self->config_path);
 
-  G_OBJECT_CLASS (ot_bootloader_syslinux_parent_class)->finalize (object);
+  G_OBJECT_CLASS (ostree_bootloader_syslinux_parent_class)->finalize (object);
 }
 
 void
-ot_bootloader_syslinux_init (OtBootloaderSyslinux *self)
+ostree_bootloader_syslinux_init (OstreeBootloaderSyslinux *self)
 {
 }
 
 static void
-ot_bootloader_syslinux_bootloader_iface_init (OtBootloaderInterface *iface)
+ostree_bootloader_syslinux_bootloader_iface_init (OstreeBootloaderInterface *iface)
 {
-  iface->query = ot_bootloader_syslinux_query;
-  iface->get_name = ot_bootloader_syslinux_get_name;
-  iface->write_config = ot_bootloader_syslinux_write_config;
+  iface->query = ostree_bootloader_syslinux_query;
+  iface->get_name = ostree_bootloader_syslinux_get_name;
+  iface->write_config = ostree_bootloader_syslinux_write_config;
 }
 
 void
-ot_bootloader_syslinux_class_init (OtBootloaderSyslinuxClass *class)
+ostree_bootloader_syslinux_class_init (OstreeBootloaderSyslinuxClass *class)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (class);
 
-  object_class->finalize = ot_bootloader_syslinux_finalize;
+  object_class->finalize = ostree_bootloader_syslinux_finalize;
 }
 
-OtBootloaderSyslinux *
-ot_bootloader_syslinux_new (GFile *sysroot)
+OstreeBootloaderSyslinux *
+ostree_bootloader_syslinux_new (OstreeSysroot *sysroot)
 {
-  OtBootloaderSyslinux *self = g_object_new (OT_TYPE_BOOTLOADER_SYSLINUX, NULL);
+  OstreeBootloaderSyslinux *self = g_object_new (OSTREE_TYPE_BOOTLOADER_SYSLINUX, NULL);
   self->sysroot = g_object_ref (sysroot);
-  self->config_path = g_file_resolve_relative_path (self->sysroot, "boot/syslinux/syslinux.cfg");
+  self->config_path = g_file_resolve_relative_path (self->sysroot->path, "boot/syslinux/syslinux.cfg");
   return self;
 }
diff --git a/src/ostree/ot-bootloader-syslinux.h b/src/libostree/ostree-bootloader-syslinux.h
similarity index 61%
rename from src/ostree/ot-bootloader-syslinux.h
rename to src/libostree/ostree-bootloader-syslinux.h
index 3324b78..7f44816 100644
--- a/src/ostree/ot-bootloader-syslinux.h
+++ b/src/libostree/ostree-bootloader-syslinux.h
@@ -20,19 +20,19 @@
 
 #pragma once
 
-#include "ot-bootloader.h"
+#include "ostree-bootloader.h"
 
 G_BEGIN_DECLS
 
-#define OT_TYPE_BOOTLOADER_SYSLINUX (ot_bootloader_syslinux_get_type ())
-#define OT_BOOTLOADER_SYSLINUX(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), OT_TYPE_BOOTLOADER_SYSLINUX, 
OtBootloaderSyslinux))
-#define OT_IS_BOOTLOADER_SYSLINUX(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), OT_TYPE_BOOTLOADER_SYSLINUX))
+#define OSTREE_TYPE_BOOTLOADER_SYSLINUX (ostree_bootloader_syslinux_get_type ())
+#define OSTREE_BOOTLOADER_SYSLINUX(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), 
OSTREE_TYPE_BOOTLOADER_SYSLINUX, OstreeBootloaderSyslinux))
+#define OSTREE_IS_BOOTLOADER_SYSLINUX(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), 
OSTREE_TYPE_BOOTLOADER_SYSLINUX))
 
-typedef struct _OtBootloaderSyslinux OtBootloaderSyslinux;
+typedef struct _OstreeBootloaderSyslinux OstreeBootloaderSyslinux;
 
-GType ot_bootloader_syslinux_get_type (void) G_GNUC_CONST;
+GType ostree_bootloader_syslinux_get_type (void) G_GNUC_CONST;
 
-OtBootloaderSyslinux * ot_bootloader_syslinux_new (GFile *sysroot);
+OstreeBootloaderSyslinux * ostree_bootloader_syslinux_new (OstreeSysroot *sysroot);
 
 G_END_DECLS
 
diff --git a/src/ostree/ot-bootloader-uboot.c b/src/libostree/ostree-bootloader-uboot.c
similarity index 65%
rename from src/ostree/ot-bootloader-uboot.c
rename to src/libostree/ostree-bootloader-uboot.c
index 691d2a5..5d711ef 100644
--- a/src/ostree/ot-bootloader-uboot.c
+++ b/src/libostree/ostree-bootloader-uboot.c
@@ -24,43 +24,43 @@
 
 #include "config.h"
 
-#include "ot-bootloader-uboot.h"
+#include "ostree-sysroot-private.h"
+#include "ostree-bootloader-uboot.h"
 #include "otutil.h"
-#include "ot-admin-functions.h"
 #include "libgsystem.h"
 
 #include <string.h>
 
-struct _OtBootloaderUboot
+struct _OstreeBootloaderUboot
 {
   GObject       parent_instance;
 
-  GFile        *sysroot;
-  GFile        *config_path;
+  OstreeSysroot  *sysroot;
+  GFile          *config_path;
 };
 
-typedef GObjectClass OtBootloaderUbootClass;
+typedef GObjectClass OstreeBootloaderUbootClass;
 
-static void ot_bootloader_uboot_bootloader_iface_init (OtBootloaderInterface *iface);
-G_DEFINE_TYPE_WITH_CODE (OtBootloaderUboot, ot_bootloader_uboot, G_TYPE_OBJECT,
-                         G_IMPLEMENT_INTERFACE (OT_TYPE_BOOTLOADER, 
ot_bootloader_uboot_bootloader_iface_init));
+static void ostree_bootloader_uboot_bootloader_iface_init (OstreeBootloaderInterface *iface);
+G_DEFINE_TYPE_WITH_CODE (OstreeBootloaderUboot, ostree_bootloader_uboot, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (OSTREE_TYPE_BOOTLOADER, 
ostree_bootloader_uboot_bootloader_iface_init));
 
 static gboolean
-ot_bootloader_uboot_query (OtBootloader *bootloader)
+ostree_bootloader_uboot_query (OstreeBootloader *bootloader)
 {
-  OtBootloaderUboot *self = OT_BOOTLOADER_UBOOT (bootloader);
+  OstreeBootloaderUboot *self = OSTREE_BOOTLOADER_UBOOT (bootloader);
 
   return g_file_query_file_type (self->config_path, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL) == 
G_FILE_TYPE_SYMBOLIC_LINK;
 }
 
 static const char *
-ot_bootloader_uboot_get_name (OtBootloader *bootloader)
+ostree_bootloader_uboot_get_name (OstreeBootloader *bootloader)
 {
   return "U-Boot";
 }
 
 static gboolean
-create_config_from_boot_loader_entries (OtBootloaderUboot     *self,
+create_config_from_boot_loader_entries (OstreeBootloaderUboot     *self,
                                         int                    bootversion,
                                         GPtrArray             *new_lines,
                                         GCancellable          *cancellable,
@@ -70,8 +70,8 @@ create_config_from_boot_loader_entries (OtBootloaderUboot     *self,
   OstreeBootconfigParser *config;
   const char *val;
 
-  if (!ot_admin_read_boot_loader_configs (self->sysroot, bootversion, &boot_loader_configs,
-                                          cancellable, error))
+  if (!_ostree_sysroot_read_boot_loader_configs (self->sysroot, bootversion, &boot_loader_configs,
+                                                 cancellable, error))
     return FALSE;
 
   /* U-Boot doesn't support a menu so just pick the first one since the list is ordered */
@@ -98,12 +98,12 @@ create_config_from_boot_loader_entries (OtBootloaderUboot     *self,
 }
 
 static gboolean
-ot_bootloader_uboot_write_config (OtBootloader          *bootloader,
+ostree_bootloader_uboot_write_config (OstreeBootloader          *bootloader,
                                   int                    bootversion,
                                   GCancellable          *cancellable,
                                   GError               **error)
 {
-  OtBootloaderUboot *self = OT_BOOTLOADER_UBOOT (bootloader);
+  OstreeBootloaderUboot *self = OSTREE_BOOTLOADER_UBOOT (bootloader);
   gs_unref_object GFile *new_config_path = NULL;
   gs_free char *config_contents = NULL;
   gs_free char *new_config_contents = NULL;
@@ -114,8 +114,8 @@ ot_bootloader_uboot_write_config (OtBootloader          *bootloader,
   if (!config_contents)
     return FALSE;
 
-  new_config_path = ot_gfile_resolve_path_printf (self->sysroot, "boot/loader.%d/uEnv.txt",
-                                                  bootversion);
+  new_config_path = ot_gfile_resolve_path_printf (self->sysroot->path, "boot/loader.%d/uEnv.txt",
+                                                      bootversion);
 
   new_lines = g_ptr_array_new_with_free_func (g_free);
 
@@ -123,7 +123,7 @@ ot_bootloader_uboot_write_config (OtBootloader          *bootloader,
                                                cancellable, error))
     return FALSE;
 
-  new_config_contents = ot_admin_join_lines (new_lines);
+  new_config_contents = _ostree_sysroot_join_lines (new_lines);
 
   if (strcmp (new_config_contents, config_contents) != 0)
     {
@@ -139,42 +139,42 @@ ot_bootloader_uboot_write_config (OtBootloader          *bootloader,
 }
 
 static void
-ot_bootloader_uboot_finalize (GObject *object)
+ostree_bootloader_uboot_finalize (GObject *object)
 {
-  OtBootloaderUboot *self = OT_BOOTLOADER_UBOOT (object);
+  OstreeBootloaderUboot *self = OSTREE_BOOTLOADER_UBOOT (object);
 
   g_clear_object (&self->sysroot);
   g_clear_object (&self->config_path);
 
-  G_OBJECT_CLASS (ot_bootloader_uboot_parent_class)->finalize (object);
+  G_OBJECT_CLASS (ostree_bootloader_uboot_parent_class)->finalize (object);
 }
 
 void
-ot_bootloader_uboot_init (OtBootloaderUboot *self)
+ostree_bootloader_uboot_init (OstreeBootloaderUboot *self)
 {
 }
 
 static void
-ot_bootloader_uboot_bootloader_iface_init (OtBootloaderInterface *iface)
+ostree_bootloader_uboot_bootloader_iface_init (OstreeBootloaderInterface *iface)
 {
-  iface->query = ot_bootloader_uboot_query;
-  iface->get_name = ot_bootloader_uboot_get_name;
-  iface->write_config = ot_bootloader_uboot_write_config;
+  iface->query = ostree_bootloader_uboot_query;
+  iface->get_name = ostree_bootloader_uboot_get_name;
+  iface->write_config = ostree_bootloader_uboot_write_config;
 }
 
 void
-ot_bootloader_uboot_class_init (OtBootloaderUbootClass *class)
+ostree_bootloader_uboot_class_init (OstreeBootloaderUbootClass *class)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (class);
 
-  object_class->finalize = ot_bootloader_uboot_finalize;
+  object_class->finalize = ostree_bootloader_uboot_finalize;
 }
 
-OtBootloaderUboot *
-ot_bootloader_uboot_new (GFile *sysroot)
+OstreeBootloaderUboot *
+ostree_bootloader_uboot_new (OstreeSysroot *sysroot)
 {
-  OtBootloaderUboot *self = g_object_new (OT_TYPE_BOOTLOADER_UBOOT, NULL);
+  OstreeBootloaderUboot *self = g_object_new (OSTREE_TYPE_BOOTLOADER_UBOOT, NULL);
   self->sysroot = g_object_ref (sysroot);
-  self->config_path = g_file_resolve_relative_path (self->sysroot, "boot/uEnv.txt");
+  self->config_path = g_file_resolve_relative_path (self->sysroot->path, "boot/uEnv.txt");
   return self;
 }
diff --git a/src/ostree/ot-bootloader-uboot.h b/src/libostree/ostree-bootloader-uboot.h
similarity index 65%
rename from src/ostree/ot-bootloader-uboot.h
rename to src/libostree/ostree-bootloader-uboot.h
index 1286041..4b19608 100644
--- a/src/ostree/ot-bootloader-uboot.h
+++ b/src/libostree/ostree-bootloader-uboot.h
@@ -24,18 +24,18 @@
 
 #pragma once
 
-#include "ot-bootloader.h"
+#include "ostree-bootloader.h"
 
 G_BEGIN_DECLS
 
-#define OT_TYPE_BOOTLOADER_UBOOT (ot_bootloader_uboot_get_type ())
-#define OT_BOOTLOADER_UBOOT(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), OT_TYPE_BOOTLOADER_UBOOT, 
OtBootloaderUboot))
-#define OT_IS_BOOTLOADER_UBOOT(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), OT_TYPE_BOOTLOADER_UBOOT))
+#define OSTREE_TYPE_BOOTLOADER_UBOOT (ostree_bootloader_uboot_get_type ())
+#define OSTREE_BOOTLOADER_UBOOT(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), OSTREE_TYPE_BOOTLOADER_UBOOT, 
OstreeBootloaderUboot))
+#define OSTREE_IS_BOOTLOADER_UBOOT(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), OSTREE_TYPE_BOOTLOADER_UBOOT))
 
-typedef struct _OtBootloaderUboot OtBootloaderUboot;
+typedef struct _OstreeBootloaderUboot OstreeBootloaderUboot;
 
-GType ot_bootloader_uboot_get_type (void) G_GNUC_CONST;
+GType ostree_bootloader_uboot_get_type (void) G_GNUC_CONST;
 
-OtBootloaderUboot * ot_bootloader_uboot_new (GFile *sysroot);
+OstreeBootloaderUboot * ostree_bootloader_uboot_new (OstreeSysroot *sysroot);
 
 G_END_DECLS
diff --git a/src/ostree/ot-bootloader.c b/src/libostree/ostree-bootloader.c
similarity index 63%
rename from src/ostree/ot-bootloader.c
rename to src/libostree/ostree-bootloader.c
index b74b3ab..2438013 100644
--- a/src/ostree/ot-bootloader.c
+++ b/src/libostree/ostree-bootloader.c
@@ -19,45 +19,45 @@
  */
 
 #include "config.h"
-#include "ot-bootloader.h"
+#include "ostree-bootloader.h"
 #include "libgsystem.h"
 
-G_DEFINE_INTERFACE (OtBootloader, ot_bootloader, G_TYPE_OBJECT)
+G_DEFINE_INTERFACE (OstreeBootloader, ostree_bootloader, G_TYPE_OBJECT)
 
 static void
-ot_bootloader_default_init (OtBootloaderInterface *iface)
+ostree_bootloader_default_init (OstreeBootloaderInterface *iface)
 {
 }
 
 gboolean
-ot_bootloader_query (OtBootloader  *self)
+ostree_bootloader_query (OstreeBootloader  *self)
 {
-  g_return_val_if_fail (OT_IS_BOOTLOADER (self), FALSE);
+  g_return_val_if_fail (OSTREE_IS_BOOTLOADER (self), FALSE);
 
-  return OT_BOOTLOADER_GET_IFACE (self)->query (self);
+  return OSTREE_BOOTLOADER_GET_IFACE (self)->query (self);
 }
 
 /**
- * ot_bootloader_get_name:
+ * ostree_bootloader_get_name:
  *
  * Returns: (transfer none): Name of this bootloader
  */
 const char *
-ot_bootloader_get_name (OtBootloader  *self)
+ostree_bootloader_get_name (OstreeBootloader  *self)
 {
-  g_return_val_if_fail (OT_IS_BOOTLOADER (self), NULL);
+  g_return_val_if_fail (OSTREE_IS_BOOTLOADER (self), NULL);
 
-  return OT_BOOTLOADER_GET_IFACE (self)->get_name (self);
+  return OSTREE_BOOTLOADER_GET_IFACE (self)->get_name (self);
 }
 
 gboolean
-ot_bootloader_write_config (OtBootloader  *self,
+ostree_bootloader_write_config (OstreeBootloader  *self,
                             int            bootversion,
                             GCancellable  *cancellable,
                             GError       **error)
 {
-  g_return_val_if_fail (OT_IS_BOOTLOADER (self), FALSE);
+  g_return_val_if_fail (OSTREE_IS_BOOTLOADER (self), FALSE);
 
-  return OT_BOOTLOADER_GET_IFACE (self)->write_config (self, bootversion, 
+  return OSTREE_BOOTLOADER_GET_IFACE (self)->write_config (self, bootversion, 
                                                        cancellable, error);
 }
diff --git a/src/libostree/ostree-bootloader.h b/src/libostree/ostree-bootloader.h
new file mode 100644
index 0000000..6784409
--- /dev/null
+++ b/src/libostree/ostree-bootloader.h
@@ -0,0 +1,60 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2013 Colin Walters <walters verbum org>
+ *
+ * This program 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 licence 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 <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define OSTREE_TYPE_BOOTLOADER (ostree_bootloader_get_type ())
+#define OSTREE_BOOTLOADER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), OSTREE_TYPE_BOOTLOADER, 
OstreeBootloader))
+#define OSTREE_IS_BOOTLOADER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), OSTREE_TYPE_BOOTLOADER))
+#define OSTREE_BOOTLOADER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), OSTREE_TYPE_BOOTLOADER, 
OstreeBootloaderInterface))
+
+typedef struct _OstreeBootloader OstreeBootloader;
+typedef struct _OstreeBootloaderInterface                            OstreeBootloaderInterface;
+
+struct _OstreeBootloaderInterface
+{
+  GTypeInterface g_iface;
+
+  /* virtual functions */
+  gboolean             (* query)                  (OstreeBootloader  *self);
+  const char *         (* get_name)               (OstreeBootloader  *self);
+  gboolean             (* write_config)           (OstreeBootloader  *self,
+                                                   int            bootversion,
+                                                   GCancellable  *cancellable,
+                                                   GError       **error);
+};
+
+GType ostree_bootloader_get_type (void) G_GNUC_CONST;
+
+gboolean ostree_bootloader_query (OstreeBootloader *self);
+
+const char *ostree_bootloader_get_name (OstreeBootloader  *self);
+
+gboolean ostree_bootloader_write_config (OstreeBootloader  *self,
+                                         int            bootversion,
+                                         GCancellable  *cancellable,
+                                         GError       **error);
+
+G_END_DECLS
+
diff --git a/src/ostree/ot-admin-cleanup.c b/src/libostree/ostree-sysroot-cleanup.c
similarity index 84%
rename from src/ostree/ot-admin-cleanup.c
rename to src/libostree/ostree-sysroot-cleanup.c
index 216cd6e..fbad0b2 100644
--- a/src/ostree/ot-admin-cleanup.c
+++ b/src/libostree/ostree-sysroot-cleanup.c
@@ -1,6 +1,6 @@
 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  *
- * Copyright (C) 2012 Colin Walters <walters verbum org>
+ * 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
@@ -16,17 +16,15 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
- *
- * Author: Colin Walters <walters verbum org>
  */
 
 #include "config.h"
 
-#include "ot-admin-functions.h"
 #include "otutil.h"
-#include "ostree.h"
 #include "libgsystem.h"
 
+#include "ostree-sysroot-private.h"
+
 static gboolean
 list_deployment_dirs_for_os (GFile               *osdir,
                              GPtrArray           *inout_deployments,
@@ -78,7 +76,7 @@ list_deployment_dirs_for_os (GFile               *osdir,
       if (g_file_info_get_file_type (file_info) != G_FILE_TYPE_DIRECTORY)
         continue;
 
-      if (!ot_admin_parse_deploy_path_name (name, &csum, &deployserial, error))
+      if (!_ostree_sysroot_parse_deploy_path_name (name, &csum, &deployserial, error))
         goto out;
       
       deployment = ostree_deployment_new (-1, osname, csum, deployserial, NULL, -1);
@@ -92,7 +90,7 @@ list_deployment_dirs_for_os (GFile               *osdir,
 }
 
 static gboolean
-list_all_deployment_directories (GFile               *sysroot,
+list_all_deployment_directories (OstreeSysroot       *self,
                                  GPtrArray          **out_deployments,
                                  GCancellable        *cancellable,
                                  GError             **error)
@@ -103,7 +101,7 @@ list_all_deployment_directories (GFile               *sysroot,
   gs_unref_ptrarray GPtrArray *ret_deployments = NULL;
   GError *temp_error = NULL;
 
-  deploydir = g_file_resolve_relative_path (sysroot, "ostree/deploy");
+  deploydir = g_file_resolve_relative_path (self->path, "ostree/deploy");
 
   ret_deployments = g_ptr_array_new_with_free_func (g_object_unref);
 
@@ -178,7 +176,7 @@ parse_bootdir_name (const char *name,
 }
 
 static gboolean
-list_all_boot_directories (GFile               *sysroot,
+list_all_boot_directories (OstreeSysroot       *self,
                            GPtrArray          **out_bootdirs,
                            GCancellable        *cancellable,
                            GError             **error)
@@ -189,7 +187,7 @@ list_all_boot_directories (GFile               *sysroot,
   gs_unref_ptrarray GPtrArray *ret_bootdirs = NULL;
   GError *temp_error = NULL;
 
-  boot_ostree = g_file_resolve_relative_path (sysroot, "boot/ostree");
+  boot_ostree = g_file_resolve_relative_path (self->path, "boot/ostree");
 
   ret_bootdirs = g_ptr_array_new_with_free_func (g_object_unref);
 
@@ -243,7 +241,7 @@ list_all_boot_directories (GFile               *sysroot,
 }
 
 static gboolean
-cleanup_other_bootversions (GFile               *sysroot,
+cleanup_other_bootversions (OstreeSysroot       *self,
                             int                  bootversion,
                             int                  subbootversion,
                             GCancellable        *cancellable,
@@ -257,27 +255,27 @@ cleanup_other_bootversions (GFile               *sysroot,
   cleanup_bootversion = bootversion == 0 ? 1 : 0;
   cleanup_subbootversion = subbootversion == 0 ? 1 : 0;
 
-  cleanup_boot_dir = ot_gfile_resolve_path_printf (sysroot, "boot/loader.%d", cleanup_bootversion);
+  cleanup_boot_dir = ot_gfile_resolve_path_printf (self->path, "boot/loader.%d", cleanup_bootversion);
   if (!gs_shutil_rm_rf (cleanup_boot_dir, cancellable, error))
     goto out;
   g_clear_object (&cleanup_boot_dir);
 
-  cleanup_boot_dir = ot_gfile_resolve_path_printf (sysroot, "ostree/boot.%d", cleanup_bootversion);
+  cleanup_boot_dir = ot_gfile_resolve_path_printf (self->path, "ostree/boot.%d", cleanup_bootversion);
   if (!gs_shutil_rm_rf (cleanup_boot_dir, cancellable, error))
     goto out;
   g_clear_object (&cleanup_boot_dir);
 
-  cleanup_boot_dir = ot_gfile_resolve_path_printf (sysroot, "ostree/boot.%d.0", cleanup_bootversion);
+  cleanup_boot_dir = ot_gfile_resolve_path_printf (self->path, "ostree/boot.%d.0", cleanup_bootversion);
   if (!gs_shutil_rm_rf (cleanup_boot_dir, cancellable, error))
     goto out;
   g_clear_object (&cleanup_boot_dir);
 
-  cleanup_boot_dir = ot_gfile_resolve_path_printf (sysroot, "ostree/boot.%d.1", cleanup_bootversion);
+  cleanup_boot_dir = ot_gfile_resolve_path_printf (self->path, "ostree/boot.%d.1", cleanup_bootversion);
   if (!gs_shutil_rm_rf (cleanup_boot_dir, cancellable, error))
     goto out;
   g_clear_object (&cleanup_boot_dir);
 
-  cleanup_boot_dir = ot_gfile_resolve_path_printf (sysroot, "ostree/boot.%d.%d", bootversion,
+  cleanup_boot_dir = ot_gfile_resolve_path_printf (self->path, "ostree/boot.%d.%d", bootversion,
                                                    cleanup_subbootversion);
   if (!gs_shutil_rm_rf (cleanup_boot_dir, cancellable, error))
     goto out;
@@ -289,7 +287,7 @@ cleanup_other_bootversions (GFile               *sysroot,
 }
 
 static gboolean
-cleanup_old_deployments (GFile               *sysroot,
+cleanup_old_deployments (OstreeSysroot       *self,
                          GPtrArray           *deployments,
                          GCancellable        *cancellable,
                          GError             **error)
@@ -304,8 +302,8 @@ cleanup_old_deployments (GFile               *sysroot,
   gs_unref_ptrarray GPtrArray *all_deployment_dirs = NULL;
   gs_unref_ptrarray GPtrArray *all_boot_dirs = NULL;
 
-  if (!ot_admin_util_get_devino (active_root, &root_device, &root_inode,
-                                 cancellable, error))
+  if (!_ostree_sysroot_get_devino (active_root, &root_device, &root_inode,
+                                   cancellable, error))
     goto out;
 
   active_deployment_dirs = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, NULL, 
g_object_unref);
@@ -314,29 +312,29 @@ cleanup_old_deployments (GFile               *sysroot,
   for (i = 0; i < deployments->len; i++)
     {
       OstreeDeployment *deployment = deployments->pdata[i];
-      GFile *deployment_path = ot_admin_get_deployment_directory (sysroot, deployment);
+      GFile *deployment_path = ostree_sysroot_get_deployment_directory (self, deployment);
       char *bootcsum = g_strdup (ostree_deployment_get_bootcsum (deployment));
       /* Transfer ownership */
       g_hash_table_insert (active_deployment_dirs, deployment_path, deployment_path);
       g_hash_table_insert (active_boot_checksums, bootcsum, bootcsum);
     }
 
-  if (!list_all_deployment_directories (sysroot, &all_deployment_dirs,
+  if (!list_all_deployment_directories (self, &all_deployment_dirs,
                                         cancellable, error))
     goto out;
   
   for (i = 0; i < all_deployment_dirs->len; i++)
     {
       OstreeDeployment *deployment = all_deployment_dirs->pdata[i];
-      gs_unref_object GFile *deployment_path = ot_admin_get_deployment_directory (sysroot, deployment);
-      gs_unref_object GFile *origin_path = ot_admin_get_deployment_origin_path (deployment_path);
+      gs_unref_object GFile *deployment_path = ostree_sysroot_get_deployment_directory (self, deployment);
+      gs_unref_object GFile *origin_path = ostree_sysroot_get_deployment_origin_path (deployment_path);
       if (!g_hash_table_lookup (active_deployment_dirs, deployment_path))
         {
           guint32 device;
           guint64 inode;
 
-          if (!ot_admin_util_get_devino (deployment_path, &device, &inode,
-                                         cancellable, error))
+          if (!_ostree_sysroot_get_devino (deployment_path, &device, &inode,
+                                           cancellable, error))
             goto out;
 
           /* This shouldn't happen, because higher levels should
@@ -353,7 +351,7 @@ cleanup_old_deployments (GFile               *sysroot,
         }
     }
 
-  if (!list_all_boot_directories (sysroot, &all_boot_dirs,
+  if (!list_all_boot_directories (self, &all_boot_dirs,
                                   cancellable, error))
     goto out;
   
@@ -419,7 +417,7 @@ cleanup_ref_prefix (OstreeRepo         *repo,
 }
 
 static gboolean
-generate_deployment_refs_and_prune (GFile               *sysroot,
+generate_deployment_refs_and_prune (OstreeSysroot       *self,
                                     OstreeRepo          *repo,
                                     int                  bootversion,
                                     int                  subbootversion,
@@ -481,10 +479,19 @@ generate_deployment_refs_and_prune (GFile               *sysroot,
   return ret;
 }
   
+/**
+ * ostree_sysroot_cleanup:
+ * @self: Sysroot
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * Delete any state that resulted from a partially completed
+ * transaction, such as incomplete deployments.
+ */
 gboolean
-ot_admin_cleanup (GFile               *sysroot,
-                  GCancellable        *cancellable,
-                  GError             **error)
+ostree_sysroot_cleanup (OstreeSysroot       *self,
+                        GCancellable        *cancellable,
+                        GError             **error)
 {
   gboolean ret = FALSE;
   gs_unref_ptrarray GPtrArray *deployments = NULL;
@@ -492,28 +499,28 @@ ot_admin_cleanup (GFile               *sysroot,
   int bootversion;
   int subbootversion;
 
-  if (!ot_admin_list_deployments (sysroot, &bootversion, &deployments,
-                                  cancellable, error))
+  if (!ostree_sysroot_list_deployments (self, &bootversion, &deployments,
+                                        cancellable, error))
     goto out;
 
-  if (!ot_admin_read_current_subbootversion (sysroot, bootversion, &subbootversion,
-                                             cancellable, error))
+  if (!ostree_sysroot_read_current_subbootversion (self, bootversion, &subbootversion,
+                                                   cancellable, error))
     goto out;
 
-  if (!cleanup_other_bootversions (sysroot, bootversion, subbootversion,
+  if (!cleanup_other_bootversions (self, bootversion, subbootversion,
                                    cancellable, error))
     goto out;
 
-  if (!cleanup_old_deployments (sysroot, deployments,
+  if (!cleanup_old_deployments (self, deployments,
                                 cancellable, error))
     goto out;
 
   if (deployments->len > 0)
     {
-      if (!ot_admin_get_repo (sysroot, &repo, cancellable, error))
+      if (!ostree_sysroot_get_repo (self, &repo, cancellable, error))
         goto out;
 
-      if (!generate_deployment_refs_and_prune (sysroot, repo, bootversion,
+      if (!generate_deployment_refs_and_prune (self, repo, bootversion,
                                                subbootversion, deployments,
                                                cancellable, error))
         goto out;
diff --git a/src/libostree/ostree-sysroot-private.h b/src/libostree/ostree-sysroot-private.h
new file mode 100644
index 0000000..7da6507
--- /dev/null
+++ b/src/libostree/ostree-sysroot-private.h
@@ -0,0 +1,57 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2012,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.h"
+
+G_BEGIN_DECLS
+
+struct OstreeSysroot {
+  GObject parent;
+
+  GFile *path;
+  int sysroot_fd;
+};
+
+gboolean
+_ostree_sysroot_read_boot_loader_configs (OstreeSysroot *self,
+                                          int            bootversion,
+                                          GPtrArray    **out_loader_configs,
+                                          GCancellable  *cancellable,
+                                          GError       **error);
+
+gboolean
+_ostree_sysroot_parse_deploy_path_name (const char *name,
+                                        char      **out_csum,
+                                        int        *out_serial,
+                                        GError    **error);
+
+gboolean
+_ostree_sysroot_get_devino (GFile         *path,
+                            guint32       *out_device,
+                            guint64       *out_inode,
+                            GCancellable  *cancellable,
+                            GError       **error);
+
+char *_ostree_sysroot_join_lines (GPtrArray  *lines);
+
+G_END_DECLS
+
diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c
index 3f1fa37..71774de 100644
--- a/src/libostree/ostree-sysroot.c
+++ b/src/libostree/ostree-sysroot.c
@@ -23,7 +23,9 @@
 #include "otutil.h"
 #include "libgsystem.h"
 
-#include "ostree-sysroot.h"
+#include "ostree-sysroot-private.h"
+#include "ostree-bootloader-uboot.h"
+#include "ostree-bootloader-syslinux.h"
 
 /**
  * SECTION:libostree-sysroot
@@ -35,14 +37,6 @@
  * 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;
@@ -175,6 +169,28 @@ ostree_sysroot_get_path (OstreeSysroot  *self)
   return self->path;
 }
 
+gboolean
+_ostree_sysroot_get_devino (GFile         *path,
+                            guint32       *out_device,
+                            guint64       *out_inode,
+                            GCancellable  *cancellable,
+                            GError       **error)
+{
+  gboolean ret = FALSE;
+  gs_unref_object GFileInfo *finfo = g_file_query_info (path, "unix::device,unix::inode",
+                                                        G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+                                                        cancellable, error);
+
+  if (!finfo)
+    goto out;
+
+  ret = TRUE;
+  *out_device = g_file_info_get_attribute_uint32 (finfo, "unix::device");
+  *out_inode = g_file_info_get_attribute_uint64 (finfo, "unix::inode");
+ out:
+  return ret;
+}
+
 /**
  * ostree_sysroot_ensure_initialized:
  * @self:
@@ -223,3 +239,603 @@ ostree_sysroot_ensure_initialized (OstreeSysroot  *self,
  out:
   return ret;
 }
+
+static void
+match_info_cleanup (void *loc)
+{
+  GMatchInfo **match = (GMatchInfo**)loc;
+  if (*match) g_match_info_unref (*match);
+}
+
+gboolean
+_ostree_sysroot_parse_deploy_path_name (const char *name,
+                                        char      **out_csum,
+                                        int        *out_serial,
+                                        GError    **error)
+{
+  gboolean ret = FALSE;
+  __attribute__((cleanup(match_info_cleanup))) GMatchInfo *match = NULL;
+  gs_free char *serial_str = NULL;
+
+  static gsize regex_initialized;
+  static GRegex *regex;
+
+  if (g_once_init_enter (&regex_initialized))
+    {
+      regex = g_regex_new ("^([0-9a-f]+)\\.([0-9]+)$", 0, 0, NULL);
+      g_assert (regex);
+      g_once_init_leave (&regex_initialized, 1);
+    }
+
+  if (!g_regex_match (regex, name, 0, &match))
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "Invalid deploy name '%s', expected CHECKSUM.TREESERIAL", name);
+      goto out;
+    }
+
+  *out_csum = g_match_info_fetch (match, 1);
+  serial_str = g_match_info_fetch (match, 2);
+  *out_serial = (int)g_ascii_strtoll (serial_str, NULL, 10);
+
+  ret = TRUE;
+ out:
+  return ret;
+}
+
+
+/**
+ * ostree_sysroot_read_current_subbootversion:
+ * @self: Sysroot
+ * @bootversion: Current boot version
+ * @out_subbootversion: (out): The active subbootversion
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * Determine the active subbootversion.
+ */
+gboolean
+ostree_sysroot_read_current_subbootversion (OstreeSysroot *self,
+                                            int            bootversion,
+                                            int           *out_subbootversion,
+                                            GCancellable  *cancellable,
+                                            GError       **error)
+{
+  gboolean ret = FALSE;
+  gs_unref_object GFile *ostree_dir = g_file_get_child (self->path, "ostree");
+  gs_free char *ostree_bootdir_name = g_strdup_printf ("boot.%d", bootversion);
+  gs_unref_object GFile *ostree_bootdir = g_file_resolve_relative_path (ostree_dir, ostree_bootdir_name);
+  gs_unref_object GFile *ostree_subbootdir = NULL;
+
+  if (!ot_gfile_query_symlink_target_allow_noent (ostree_bootdir, &ostree_subbootdir,
+                                                  cancellable, error))
+    goto out;
+
+  if (ostree_subbootdir == NULL)
+    {
+      *out_subbootversion = 0;
+    }
+  else
+    {
+      const char *current_subbootdir_name = gs_file_get_basename_cached (ostree_subbootdir);
+      if (g_str_has_suffix (current_subbootdir_name, ".0"))
+        *out_subbootversion = 0;
+      else if (g_str_has_suffix (current_subbootdir_name, ".1"))
+        *out_subbootversion = 1;
+      else
+        {
+          g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                       "Invalid target '%s' in %s",
+                       gs_file_get_path_cached (ostree_subbootdir),
+                       gs_file_get_path_cached (ostree_bootdir));
+          goto out;
+        }
+    }
+
+  ret = TRUE;
+ out:
+  return ret;
+}
+
+gboolean
+_ostree_sysroot_read_boot_loader_configs (OstreeSysroot *self,
+                                          int            bootversion,
+                                          GPtrArray    **out_loader_configs,
+                                          GCancellable  *cancellable,
+                                          GError       **error)
+{
+  gboolean ret = FALSE;
+  gs_unref_object GFileEnumerator *dir_enum = NULL;
+  gs_unref_object GFile *loader_entries_dir = NULL;
+  gs_unref_ptrarray GPtrArray *ret_loader_configs = NULL;
+  GError *temp_error = NULL;
+
+  loader_entries_dir = ot_gfile_resolve_path_printf (self->path, "boot/loader.%d/entries",
+                                                     bootversion);
+  ret_loader_configs = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
+
+  dir_enum = g_file_enumerate_children (loader_entries_dir, OSTREE_GIO_FAST_QUERYINFO,
+                                        0, NULL, &temp_error);
+  if (!dir_enum)
+    {
+      if (g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+        {
+          g_clear_error (&temp_error);
+          goto done;
+        } 
+      else
+        {
+          g_propagate_error (error, temp_error);
+          goto out;
+        }
+    }
+
+  while (TRUE)
+    {
+      GFileInfo *file_info;
+      GFile *child;
+      const char *name;
+
+      if (!gs_file_enumerator_iterate (dir_enum, &file_info, &child,
+                                       cancellable, error))
+        goto out;
+      if (file_info == NULL)
+        break;
+
+      name = g_file_info_get_name (file_info);
+
+      if (g_str_has_prefix (name, "ostree-") &&
+          g_str_has_suffix (name, ".conf") &&
+          g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR)
+        {
+          gs_unref_object OstreeBootconfigParser *config = ostree_bootconfig_parser_new ();
+  
+          if (!ostree_bootconfig_parser_parse (config, child, cancellable, error))
+            {
+              g_prefix_error (error, "Parsing %s: ", gs_file_get_path_cached (child));
+              goto out;
+            }
+
+          g_ptr_array_add (ret_loader_configs, g_object_ref (config));
+        }
+    }
+
+ done:
+  gs_transfer_out_value (out_loader_configs, &ret_loader_configs);
+  ret = TRUE;
+ out:
+  return ret;
+}
+
+
+static gboolean
+read_current_bootversion (OstreeSysroot *self,
+                          int           *out_bootversion,
+                          GCancellable  *cancellable,
+                          GError       **error)
+{
+  gboolean ret = FALSE;
+  gs_unref_object GFile *boot_loader_path = g_file_resolve_relative_path (self->path, "boot/loader");
+  gs_unref_object GFileInfo *info = NULL;
+  const char *target;
+  int ret_bootversion;
+
+  if (!ot_gfile_query_info_allow_noent (boot_loader_path, OSTREE_GIO_FAST_QUERYINFO,
+                                        G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+                                        &info,
+                                        cancellable, error))
+    goto out;
+
+  if (info == NULL)
+    ret_bootversion = 0;
+  else
+    {
+      if (g_file_info_get_file_type (info) != G_FILE_TYPE_SYMBOLIC_LINK)
+        {
+          g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                       "Not a symbolic link: %s", gs_file_get_path_cached (boot_loader_path));
+          goto out;
+        }
+
+      target = g_file_info_get_symlink_target (info);
+      if (g_strcmp0 (target, "loader.0") == 0)
+        ret_bootversion = 0;
+      else if (g_strcmp0 (target, "loader.1") == 0)
+        ret_bootversion = 1;
+      else
+        {
+          g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                       "Invalid target '%s' in %s", target, gs_file_get_path_cached (boot_loader_path));
+          goto out;
+        }
+    }
+
+  ret = TRUE;
+  *out_bootversion = ret_bootversion;
+ out:
+  return ret;
+}
+
+static gboolean
+parse_origin (OstreeSysroot   *self,
+              GFile           *deployment_path,
+              GKeyFile       **out_origin,
+              GCancellable    *cancellable,
+              GError         **error)
+{
+  gboolean ret = FALSE;
+  GKeyFile *ret_origin = NULL;
+  gs_unref_object GFile *origin_path = ostree_sysroot_get_deployment_origin_path (deployment_path);
+  gs_free char *origin_contents = NULL;
+  
+  if (!ot_gfile_load_contents_utf8_allow_noent (origin_path, &origin_contents,
+                                                cancellable, error))
+    goto out;
+
+  if (origin_contents)
+    {
+      ret_origin = g_key_file_new ();
+      if (!g_key_file_load_from_data (ret_origin, origin_contents, -1, 0, error))
+        goto out;
+    }
+
+  ret = TRUE;
+  gs_transfer_out_value (out_origin, &ret_origin);
+ out:
+  if (error)
+    g_prefix_error (error, "Parsing %s: ", gs_file_get_path_cached (origin_path));
+  if (ret_origin)
+    g_key_file_unref (ret_origin);
+  return ret;
+}
+
+static gboolean
+parse_bootlink (const char    *bootlink,
+                int           *out_entry_bootversion,
+                char         **out_osname,
+                char         **out_bootcsum,
+                int           *out_treebootserial,
+                GError       **error)
+{
+  gboolean ret = FALSE;
+  __attribute__((cleanup(match_info_cleanup))) GMatchInfo *match = NULL;
+  gs_free char *bootversion_str = NULL;
+  gs_free char *treebootserial_str = NULL;
+
+  static gsize regex_initialized;
+  static GRegex *regex;
+
+  if (g_once_init_enter (&regex_initialized))
+    {
+      regex = g_regex_new ("^/ostree/boot.([01])/([^/]+)/([^/]+)/([0-9]+)$", 0, 0, NULL);
+      g_assert (regex);
+      g_once_init_leave (&regex_initialized, 1);
+    }
+
+  if (!g_regex_match (regex, bootlink, 0, &match))
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "Invalid ostree= argument '%s', expected 
ostree=/ostree/boot.BOOTVERSION/OSNAME/BOOTCSUM/TREESERIAL", bootlink);
+      goto out;
+    }
+    
+  bootversion_str = g_match_info_fetch (match, 1);
+  *out_entry_bootversion = (int)g_ascii_strtoll (bootversion_str, NULL, 10);
+  *out_osname = g_match_info_fetch (match, 2);
+  *out_bootcsum = g_match_info_fetch (match, 3);
+  treebootserial_str = g_match_info_fetch (match, 4);
+  *out_treebootserial = (int)g_ascii_strtoll (treebootserial_str, NULL, 10);
+  
+  ret = TRUE;
+ out:
+  return ret;
+}
+
+static gboolean
+parse_deployment (OstreeSysroot       *self,
+                  const char          *boot_link,
+                  OstreeDeployment   **out_deployment,
+                  GCancellable        *cancellable,
+                  GError             **error)
+{
+  gboolean ret = FALSE;
+  const char *relative_boot_link;
+  gs_unref_object OstreeDeployment *ret_deployment = NULL;
+  int entry_boot_version;
+  int treebootserial = -1;
+  int deployserial = -1;
+  gs_free char *osname = NULL;
+  gs_free char *bootcsum = NULL;
+  gs_free char *treecsum = NULL;
+  gs_unref_object GFile *treebootserial_link = NULL;
+  gs_unref_object GFileInfo *treebootserial_info = NULL;
+  gs_unref_object GFile *treebootserial_target = NULL;
+  GKeyFile *origin = NULL;
+      
+  if (!parse_bootlink (boot_link, &entry_boot_version,
+                       &osname, &bootcsum, &treebootserial,
+                       error))
+    goto out;
+
+  relative_boot_link = boot_link;
+  if (*relative_boot_link == '/')
+    relative_boot_link++;
+  treebootserial_link = g_file_resolve_relative_path (self->path, relative_boot_link);
+  treebootserial_info = g_file_query_info (treebootserial_link, OSTREE_GIO_FAST_QUERYINFO,
+                                           G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+                                           cancellable, error);
+  if (!treebootserial_info)
+    goto out;
+
+  if (!ot_gfile_get_symlink_target_from_info (treebootserial_link, treebootserial_info,
+                                              &treebootserial_target, cancellable, error))
+    goto out;
+
+  if (!_ostree_sysroot_parse_deploy_path_name (gs_file_get_basename_cached (treebootserial_target),
+                                               &treecsum, &deployserial, error))
+    goto out;
+
+  if (!parse_origin (self, treebootserial_target, &origin,
+                     cancellable, error))
+    goto out;
+
+  ret_deployment = ostree_deployment_new (-1, osname, treecsum, deployserial,
+                                      bootcsum, treebootserial);
+  if (origin)
+    ostree_deployment_set_origin (ret_deployment, origin);
+
+  ret = TRUE;
+  gs_transfer_out_value (out_deployment, &ret_deployment);
+ out:
+  if (origin)
+    g_key_file_unref (origin);
+  return ret;
+}
+
+static char *
+get_ostree_kernel_arg_from_config (OstreeBootconfigParser  *config)
+{
+  const char *options;
+  char *ret = NULL;
+  char **opts, **iter;
+
+  options = ostree_bootconfig_parser_get (config, "options");
+  if (!options)
+    return NULL;
+
+  opts = g_strsplit (options, " ", -1);
+  for (iter = opts; *iter; iter++)
+    {
+      const char *opt = *iter;
+      if (g_str_has_prefix (opt, "ostree="))
+        {
+          ret = g_strdup (opt + strlen ("ostree="));
+          break;
+        }
+    }
+  g_strfreev (opts);
+
+  return ret;
+}
+
+static gboolean
+list_deployments_process_one_boot_entry (OstreeSysroot               *self,
+                                         OstreeBootconfigParser      *config,
+                                         GPtrArray                   *inout_deployments,
+                                         GCancellable                *cancellable,
+                                         GError                     **error)
+{
+  gboolean ret = FALSE;
+  gs_free char *ostree_arg = NULL;
+  gs_unref_object OstreeDeployment *deployment = NULL;
+
+  ostree_arg = get_ostree_kernel_arg_from_config (config);
+  if (ostree_arg == NULL)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "No ostree= kernel argument found");
+      goto out;
+    }
+  
+  if (!parse_deployment (self, ostree_arg, &deployment,
+                         cancellable, error))
+    goto out;
+  
+  ostree_deployment_set_bootconfig (deployment, config);
+
+  g_ptr_array_add (inout_deployments, g_object_ref (deployment));
+  
+  ret = TRUE;
+ out:
+  return ret;
+}
+
+static gint
+compare_deployments_by_boot_loader_version_reversed (gconstpointer     a_pp,
+                                                     gconstpointer     b_pp)
+{
+  OstreeDeployment *a = *((OstreeDeployment**)a_pp);
+  OstreeDeployment *b = *((OstreeDeployment**)b_pp);
+  OstreeBootconfigParser *a_bootconfig = ostree_deployment_get_bootconfig (a);
+  OstreeBootconfigParser *b_bootconfig = ostree_deployment_get_bootconfig (b);
+  const char *a_version = ostree_bootconfig_parser_get (a_bootconfig, "version");
+  const char *b_version = ostree_bootconfig_parser_get (b_bootconfig, "version");
+  
+  if (a_version && b_version)
+    {
+      int r = strverscmp (a_version, b_version);
+      /* Reverse */
+      return -r;
+    }
+  else if (a_version)
+    return -1;
+  else
+    return 1;
+}
+/**
+ * ostree_sysroot_list_deployments:
+ * @sysroot: Sysroot
+ * @out_current_bootversion: (out): Current bootversion
+ * @out_deployments: (out) (element-type OstreeDeployment): Deployment list
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * Enumerate all deployments, in the boot order.  Also returns the
+ * active bootversion.
+ */
+gboolean
+ostree_sysroot_list_deployments (OstreeSysroot       *self,
+                                 int                 *out_current_bootversion,
+                                 GPtrArray          **out_deployments,
+                                 GCancellable        *cancellable,
+                                 GError             **error)
+{
+  gboolean ret = FALSE;
+  gs_unref_ptrarray GPtrArray *boot_loader_configs = NULL;
+  gs_unref_ptrarray GPtrArray *ret_deployments = NULL;
+  guint i;
+  int bootversion = -1;
+
+  if (!read_current_bootversion (self, &bootversion, cancellable, error))
+    goto out;
+
+  if (!_ostree_sysroot_read_boot_loader_configs (self, bootversion, &boot_loader_configs,
+                                                 cancellable, error))
+    goto out;
+
+  ret_deployments = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
+
+  for (i = 0; i < boot_loader_configs->len; i++)
+    {
+      OstreeBootconfigParser *config = boot_loader_configs->pdata[i];
+
+      if (!list_deployments_process_one_boot_entry (self, config, ret_deployments,
+                                                    cancellable, error))
+        goto out;
+    }
+
+  g_ptr_array_sort (ret_deployments, compare_deployments_by_boot_loader_version_reversed);
+  for (i = 0; i < ret_deployments->len; i++)
+    {
+      OstreeDeployment *deployment = ret_deployments->pdata[i];
+      ostree_deployment_set_index (deployment, i);
+    }
+
+  ret = TRUE;
+  *out_current_bootversion = bootversion;
+  gs_transfer_out_value (out_deployments, &ret_deployments);
+ out:
+  return ret;
+}
+
+/**
+ * ostree_sysroot_get_deployment_directory:
+ * @self: Sysroot
+ * @deployment: A deployment
+ *
+ * Returns: (transfer full): Path to deployment root directory
+ */
+GFile *
+ostree_sysroot_get_deployment_directory (OstreeSysroot    *self,
+                                         OstreeDeployment *deployment)
+{
+  gs_free char *path = g_strdup_printf ("ostree/deploy/%s/deploy/%s.%d",
+                                        ostree_deployment_get_osname (deployment),
+                                        ostree_deployment_get_csum (deployment),
+                                        ostree_deployment_get_deployserial (deployment));
+  return g_file_resolve_relative_path (self->path, path);
+}
+
+/**
+ * ostree_sysroot_get_deployment_origin_path:
+ * @self: Sysroot
+ * @deployment: A deployment
+ *
+ * Returns: (transfer full): Path to deployment origin file
+ */
+GFile *
+ostree_sysroot_get_deployment_origin_path (GFile   *deployment_path)
+{
+  gs_unref_object GFile *deployment_parent = g_file_get_parent (deployment_path);
+  return ot_gfile_resolve_path_printf (deployment_parent,
+                                       "%s.origin",
+                                       gs_file_get_path_cached (deployment_path));
+}
+
+
+/**
+ * ostree_sysroot_get_repo:
+ * @self: Sysroot
+ * @out_repo: (out): Repository in sysroot @self
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * Retrieve the OSTree repository in sysroot @self.
+ */
+gboolean
+ostree_sysroot_get_repo (OstreeSysroot         *self,
+                         OstreeRepo   **out_repo,
+                         GCancellable  *cancellable,
+                         GError       **error)
+{
+  gboolean ret = FALSE;
+  gs_unref_object OstreeRepo *ret_repo = NULL;
+  gs_unref_object GFile *repo_path = g_file_resolve_relative_path (self->path, "ostree/repo");
+
+  ret_repo = ostree_repo_new (repo_path);
+  if (!ostree_repo_open (ret_repo, cancellable, error))
+    goto out;
+    
+  ret = TRUE;
+  ot_transfer_out_value (out_repo, &ret_repo);
+ out:
+  return ret;
+}
+
+
+/**
+ * ostree_sysroot_query_bootloader:
+ * @sysroot: Sysroot
+ *
+ * Returns: (transfer full): Currently active bootloader in @sysroot
+ */
+OstreeBootloader *
+ostree_sysroot_query_bootloader (OstreeSysroot *self)
+{
+  OstreeBootloaderSyslinux *syslinux;
+  OstreeBootloaderUboot    *uboot;
+
+  syslinux = ostree_bootloader_syslinux_new (self);
+  if (ostree_bootloader_query ((OstreeBootloader*)syslinux))
+    return (OstreeBootloader*) (syslinux);
+
+  uboot = ostree_bootloader_uboot_new (self);
+  if (ostree_bootloader_query ((OstreeBootloader*)uboot))
+    return (OstreeBootloader*) (uboot);
+
+  return NULL;
+}
+
+char *
+_ostree_sysroot_join_lines (GPtrArray  *lines)
+{
+  GString *buf = g_string_new ("");
+  guint i;
+  gboolean prev_was_empty = FALSE;
+
+  for (i = 0; i < lines->len; i++)
+    {
+      const char *line = lines->pdata[i];
+      /* Special bit to remove extraneous empty lines */
+      if (*line == '\0')
+        {
+          if (prev_was_empty || i == 0)
+            continue;
+          else
+            prev_was_empty = TRUE;
+        }
+      g_string_append (buf, line);
+      g_string_append_c (buf, '\n');
+    }
+  return g_string_free (buf, FALSE);
+}
diff --git a/src/libostree/ostree-sysroot.h b/src/libostree/ostree-sysroot.h
index 490d5d2..5df0ae7 100644
--- a/src/libostree/ostree-sysroot.h
+++ b/src/libostree/ostree-sysroot.h
@@ -21,6 +21,8 @@
 #pragma once
 
 #include "ostree-repo.h"
+#include "ostree-deployment.h"
+#include "ostree-bootloader.h"
 
 G_BEGIN_DECLS
 
@@ -42,5 +44,34 @@ gboolean ostree_sysroot_ensure_initialized (OstreeSysroot  *self,
                                             GCancellable   *cancellable,
                                             GError        **error);
 
+gboolean ostree_sysroot_read_current_subbootversion (OstreeSysroot *self,
+                                                     int            bootversion,
+                                                     int           *out_subbootversion,
+                                                     GCancellable  *cancellable,
+                                                     GError       **error);
+
+gboolean ostree_sysroot_list_deployments (OstreeSysroot       *self,
+                                          int                 *out_bootversion,
+                                          GPtrArray          **out_deployments,
+                                          GCancellable        *cancellable,
+                                          GError             **error);
+
+GFile *ostree_sysroot_get_deployment_directory (OstreeSysroot    *self,
+                                                OstreeDeployment *deployment);
+
+GFile * ostree_sysroot_get_deployment_origin_path (GFile   *deployment_path);
+
+gboolean ostree_sysroot_cleanup (OstreeSysroot       *self,
+                                 GCancellable        *cancellable,
+                                 GError             **error);
+
+gboolean ostree_sysroot_get_repo (OstreeSysroot         *self,
+                                  OstreeRepo           **out_repo,
+                                  GCancellable          *cancellable,
+                                  GError               **error);
+
+OstreeBootloader *ostree_sysroot_query_bootloader (OstreeSysroot         *sysroot);
+
+
 G_END_DECLS
 
diff --git a/src/ostree/ot-admin-builtin-cleanup.c b/src/ostree/ot-admin-builtin-cleanup.c
index 929bf39..db9c667 100644
--- a/src/ostree/ot-admin-builtin-cleanup.c
+++ b/src/ostree/ot-admin-builtin-cleanup.c
@@ -46,7 +46,7 @@ ot_admin_builtin_cleanup (int argc, char **argv, OstreeSysroot *sysroot, GCancel
   if (!g_option_context_parse (context, &argc, &argv, error))
     goto out;
 
-  if (!ot_admin_cleanup (ostree_sysroot_get_path (sysroot), cancellable, error))
+  if (!ostree_sysroot_cleanup (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 66b868e..883f77a 100644
--- a/src/ostree/ot-admin-builtin-deploy.c
+++ b/src/ostree/ot-admin-builtin-deploy.c
@@ -77,11 +77,11 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeSysroot *sysroot, GCancell
 
   refspec = argv[1];
 
-  if (!ot_admin_get_repo (ostree_sysroot_get_path (sysroot), &repo, cancellable, error))
+  if (!ostree_sysroot_get_repo (sysroot, &repo, cancellable, error))
     goto out;
 
-  if (!ot_admin_list_deployments (ostree_sysroot_get_path (sysroot), &current_bootversion, 
&current_deployments,
-                                  cancellable, error))
+  if (!ostree_sysroot_list_deployments (sysroot, &current_bootversion, &current_deployments,
+                                        cancellable, error))
     {
       g_prefix_error (error, "While listing deployments: ");
       goto out;
diff --git a/src/ostree/ot-admin-builtin-diff.c b/src/ostree/ot-admin-builtin-diff.c
index c3f0e84..802fb17 100644
--- a/src/ostree/ot-admin-builtin-diff.c
+++ b/src/ostree/ot-admin-builtin-diff.c
@@ -61,8 +61,8 @@ ot_admin_builtin_diff (int argc, char **argv, OstreeSysroot *sysroot, GCancellab
   
   repo_path = g_file_resolve_relative_path (ostree_sysroot_get_path (sysroot), "ostree/repo");
 
-  if (!ot_admin_list_deployments (ostree_sysroot_get_path (sysroot), &bootversion, &deployments,
-                                  cancellable, error))
+  if (!ostree_sysroot_list_deployments (sysroot, &bootversion, &deployments,
+                                        cancellable, error))
     {
       g_prefix_error (error, "While listing deployments: ");
       goto out;
@@ -83,7 +83,7 @@ ot_admin_builtin_diff (int argc, char **argv, OstreeSysroot *sysroot, GCancellab
       goto out;
     }
 
-  deployment_dir = ot_admin_get_deployment_directory (ostree_sysroot_get_path (sysroot), deployment);
+  deployment_dir = ostree_sysroot_get_deployment_directory (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-status.c b/src/ostree/ot-admin-builtin-status.c
index 6de2d2d..cdddf11 100644
--- a/src/ostree/ot-admin-builtin-status.c
+++ b/src/ostree/ot-admin-builtin-status.c
@@ -50,8 +50,8 @@ ot_admin_builtin_status (int argc, char **argv, OstreeSysroot *sysroot, GCancell
   if (!g_option_context_parse (context, &argc, &argv, error))
     goto out;
 
-  if (!ot_admin_list_deployments (ostree_sysroot_get_path (sysroot), &bootversion, &deployments,
-                                  cancellable, error))
+  if (!ostree_sysroot_list_deployments (sysroot, &bootversion, &deployments,
+                                        cancellable, error))
     {
       g_prefix_error (error, "While listing deployments: ");
       goto out;
@@ -70,7 +70,7 @@ ot_admin_builtin_status (int argc, char **argv, OstreeSysroot *sysroot, GCancell
     {
       int subbootversion;
 
-      if (!ot_admin_read_current_subbootversion (ostree_sysroot_get_path (sysroot), bootversion,
+      if (!ostree_sysroot_read_current_subbootversion (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 c4427b3..e1535a5 100644
--- a/src/ostree/ot-admin-builtin-undeploy.c
+++ b/src/ostree/ot-admin-builtin-undeploy.c
@@ -61,8 +61,8 @@ ot_admin_builtin_undeploy (int argc, char **argv, OstreeSysroot *sysroot, GCance
   deploy_index_str = argv[1];
   deploy_index = atoi (deploy_index_str);
 
-  if (!ot_admin_list_deployments (ostree_sysroot_get_path (sysroot), &current_bootversion, 
&current_deployments,
-                                  cancellable, error))
+  if (!ostree_sysroot_list_deployments (sysroot, &current_bootversion, &current_deployments,
+                                        cancellable, error))
     {
       g_prefix_error (error, "While listing deployments: ");
       goto out;
@@ -103,7 +103,7 @@ ot_admin_builtin_undeploy (int argc, char **argv, OstreeSysroot *sysroot, GCance
   g_print ("Deleted deployment %s.%d\n", ostree_deployment_get_csum (target_deployment),
            ostree_deployment_get_deployserial (target_deployment));
   
-  if (!ot_admin_cleanup (ostree_sysroot_get_path (sysroot), cancellable, error))
+  if (!ostree_sysroot_cleanup (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 215f403..063703d 100644
--- a/src/ostree/ot-admin-builtin-upgrade.c
+++ b/src/ostree/ot-admin-builtin-upgrade.c
@@ -70,9 +70,9 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancel
   if (!g_option_context_parse (context, &argc, &argv, error))
     goto out;
 
-  if (!ot_admin_list_deployments (ostree_sysroot_get_path (sysroot), &current_bootversion,
-                                  &current_deployments,
-                                  cancellable, error))
+  if (!ostree_sysroot_list_deployments (sysroot, &current_bootversion,
+                                        &current_deployments,
+                                        cancellable, error))
     {
       g_prefix_error (error, "While listing deployments: ");
       goto out;
@@ -88,8 +88,8 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancel
   merge_deployment = ot_admin_get_merge_deployment (current_deployments, opt_osname,
                                                     booted_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);
+  deployment_path = ostree_sysroot_get_deployment_directory (sysroot, merge_deployment);
+  deployment_origin_path = ostree_sysroot_get_deployment_origin_path (deployment_path);
 
   repo_path = g_file_resolve_relative_path (ostree_sysroot_get_path (sysroot), "ostree/repo");
   repo = ostree_repo_new (repo_path);
diff --git a/src/ostree/ot-admin-deploy.c b/src/ostree/ot-admin-deploy.c
index c5cc588..32d0d95 100644
--- a/src/ostree/ot-admin-deploy.c
+++ b/src/ostree/ot-admin-deploy.c
@@ -24,7 +24,6 @@
 
 #include "ot-admin-functions.h"
 #include "ot-admin-deploy.h"
-#include "ot-bootloader-syslinux.h"
 #include "otutil.h"
 #include "ostree-core.h"
 #include "libgsystem.h"
@@ -247,7 +246,7 @@ checkout_deployment_tree (GFile             *sysroot,
 }
 
 static gboolean
-merge_configuration (GFile             *sysroot,
+merge_configuration (OstreeSysroot         *sysroot_obj,
                      OstreeDeployment      *previous_deployment,
                      OstreeDeployment      *deployment,
                      GFile             *deployment_path,
@@ -267,7 +266,7 @@ merge_configuration (GFile             *sysroot,
       gs_unref_object GFile *previous_path = NULL;
       OstreeBootconfigParser *previous_bootconfig;
 
-      previous_path = ot_admin_get_deployment_directory (sysroot, previous_deployment);
+      previous_path = ostree_sysroot_get_deployment_directory (sysroot_obj, previous_deployment);
       source_etc_path = g_file_resolve_relative_path (previous_path, "etc");
       source_etc_pristine_path = g_file_resolve_relative_path (previous_path, "usr/etc");
 
@@ -279,7 +278,7 @@ merge_configuration (GFile             *sysroot,
            * them later.
            */
           ostree_bootconfig_parser_set (ostree_deployment_get_bootconfig (deployment), "options",
-                                previous_options);
+                                        previous_options);
         }
     }
 
@@ -337,12 +336,15 @@ write_origin_file (GFile             *sysroot,
                    GError           **error)
 {
   gboolean ret = FALSE;
+  gs_unref_object OstreeSysroot *sysroot_obj = NULL;
   GKeyFile *origin = ostree_deployment_get_origin (deployment);
 
+  sysroot_obj = ostree_sysroot_new (sysroot);
+
   if (origin)
     {
-      gs_unref_object GFile *deployment_path = ot_admin_get_deployment_directory (sysroot, deployment);
-      gs_unref_object GFile *origin_path = ot_admin_get_deployment_origin_path (deployment_path);
+      gs_unref_object GFile *deployment_path = ostree_sysroot_get_deployment_directory (sysroot_obj, 
deployment);
+      gs_unref_object GFile *origin_path = ostree_sysroot_get_deployment_origin_path (deployment_path);
       gs_free char *contents = NULL;
       gsize len;
 
@@ -711,7 +713,7 @@ full_system_sync (GCancellable      *cancellable,
 }
 
 static gboolean
-swap_bootlinks (GFile        *sysroot,
+swap_bootlinks (OstreeSysroot *sysroot,
                 int           current_bootversion,
                 GPtrArray    *new_deployments,
                 GCancellable *cancellable,
@@ -720,15 +722,15 @@ swap_bootlinks (GFile        *sysroot,
   gboolean ret = FALSE;
   guint i;
   int old_subbootversion, new_subbootversion;
-  gs_unref_object GFile *ostree_dir = g_file_get_child (sysroot, "ostree");
+  gs_unref_object GFile *ostree_dir = g_file_get_child (ostree_sysroot_get_path (sysroot), "ostree");
   gs_free char *ostree_bootdir_name = g_strdup_printf ("boot.%d", current_bootversion);
   gs_unref_object GFile *ostree_bootdir = g_file_resolve_relative_path (ostree_dir, ostree_bootdir_name);
   gs_free char *ostree_subbootdir_name = NULL;
   gs_unref_object GFile *ostree_subbootdir = NULL;
 
-  if (!ot_admin_read_current_subbootversion (sysroot, current_bootversion,
-                                             &old_subbootversion,
-                                             cancellable, error))
+  if (!ostree_sysroot_read_current_subbootversion (sysroot, current_bootversion,
+                                                   &old_subbootversion,
+                                                   cancellable, error))
     goto out;
 
   new_subbootversion = old_subbootversion == 0 ? 1 : 0;
@@ -818,7 +820,7 @@ parse_os_release (const char *contents,
  * Write out an entry in /boot/loader/entries for @deployment.
  */
 static gboolean
-install_deployment_kernel (GFile          *sysroot,
+install_deployment_kernel (OstreeSysroot   *sysroot,
                            int             new_bootversion,
                            OstreeDeployment   *deployment,
                            guint           n_deployments,
@@ -856,13 +858,13 @@ install_deployment_kernel (GFile          *sysroot,
   gsize len;
 
   bootconfig = ostree_deployment_get_bootconfig (deployment);
-  deployment_dir = ot_admin_get_deployment_directory (sysroot, deployment);
+  deployment_dir = ostree_sysroot_get_deployment_directory (sysroot, deployment);
 
   if (!get_kernel_from_tree (deployment_dir, &tree_kernel_path, &tree_initramfs_path,
                              cancellable, error))
     goto out;
 
-  bootdir = g_file_get_child (sysroot, "boot");
+  bootdir = g_file_get_child (ostree_sysroot_get_path (sysroot), "boot");
   bootcsumdir = ot_gfile_resolve_path_printf (bootdir, "ostree/%s-%s",
                                               osname,
                                               bootcsum);
@@ -996,10 +998,11 @@ ot_admin_write_deployments (GFile             *sysroot,
 {
   gboolean ret = FALSE;
   guint i;
-  gs_unref_object OtBootloader *bootloader = ot_admin_query_bootloader (sysroot);
+  gs_unref_object OstreeSysroot *sysroot_obj = ostree_sysroot_new (sysroot);
+  gs_unref_object OstreeBootloader *bootloader = ostree_sysroot_query_bootloader (sysroot_obj);
 
   if (bootloader)
-    g_print ("Detected bootloader: %s\n", ot_bootloader_get_name (bootloader));
+    g_print ("Detected bootloader: %s\n", ostree_bootloader_get_name (bootloader));
   else
     g_print ("Detected bootloader: (unknown)\n");
 
@@ -1011,7 +1014,7 @@ ot_admin_write_deployments (GFile             *sysroot,
           goto out;
         }
 
-      if (!swap_bootlinks (sysroot, current_bootversion,
+      if (!swap_bootlinks (sysroot_obj, current_bootversion,
                            new_deployments,
                            cancellable, error))
         {
@@ -1024,7 +1027,7 @@ ot_admin_write_deployments (GFile             *sysroot,
       for (i = 0; i < new_deployments->len; i++)
         {
           OstreeDeployment *deployment = new_deployments->pdata[i];
-          if (!install_deployment_kernel (sysroot, new_bootversion,
+          if (!install_deployment_kernel (sysroot_obj, new_bootversion,
                                           deployment, new_deployments->len,
                                           cancellable, error))
             {
@@ -1034,7 +1037,7 @@ ot_admin_write_deployments (GFile             *sysroot,
         }
 
       /* Swap bootlinks for *new* version */
-      if (!swap_bootlinks (sysroot, new_bootversion, new_deployments,
+      if (!swap_bootlinks (sysroot_obj, new_bootversion, new_deployments,
                            cancellable, error))
         {
           g_prefix_error (error, "Generating new bootlinks: ");
@@ -1047,8 +1050,8 @@ ot_admin_write_deployments (GFile             *sysroot,
           goto out;
         }
 
-      if (bootloader && !ot_bootloader_write_config (bootloader, new_bootversion,
-                                                     cancellable, error))
+      if (bootloader && !ostree_bootloader_write_config (bootloader, new_bootversion,
+                                                         cancellable, error))
           {
             g_prefix_error (error, "Bootloader write config: ");
             goto out;
@@ -1086,6 +1089,7 @@ ot_admin_deploy (GFile             *sysroot,
 {
   gboolean ret = FALSE;
   OstreeDeployment *new_deployment;
+  gs_unref_object OstreeSysroot *sysroot_obj = NULL;
   gs_unref_object OstreeDeployment *merge_deployment = NULL;
   gs_unref_object OstreeRepo *repo = NULL;
   gs_unref_object GFile *commit_root = NULL;
@@ -1097,7 +1101,9 @@ ot_admin_deploy (GFile             *sysroot,
   gs_unref_ptrarray GPtrArray *new_deployments = NULL;
   int new_bootversion;
 
-  if (!ot_admin_get_repo (sysroot, &repo, cancellable, error))
+  sysroot_obj = ostree_sysroot_new (sysroot);
+
+  if (!ostree_sysroot_get_repo (sysroot_obj, &repo, cancellable, error))
     goto out;
 
   /* Here we perform cleanup of any leftover data from previous
@@ -1107,7 +1113,7 @@ ot_admin_deploy (GFile             *sysroot,
    * TODO: Add /ostree/transaction file, and only do this cleanup if
    * we find it.
    */
-  if (!ot_admin_cleanup (sysroot, cancellable, error))
+  if (!ostree_sysroot_cleanup (sysroot_obj, cancellable, error))
     {
       g_prefix_error (error, "Performing initial cleanup: ");
       goto out;
@@ -1173,7 +1179,7 @@ ot_admin_deploy (GFile             *sysroot,
   bootconfig = ostree_bootconfig_parser_new ();
   ostree_deployment_set_bootconfig (new_deployment, bootconfig);
 
-  if (!merge_configuration (sysroot, merge_deployment, new_deployment,
+  if (!merge_configuration (sysroot_obj, merge_deployment, new_deployment,
                             new_deployment_path,
                             cancellable, error))
     {
@@ -1231,7 +1237,7 @@ ot_admin_deploy (GFile             *sysroot,
 
   /* And finally, cleanup of any leftover data.
    */
-  if (!ot_admin_cleanup (sysroot, cancellable, error))
+  if (!ostree_sysroot_cleanup (sysroot_obj, cancellable, error))
     {
       g_prefix_error (error, "Performing final cleanup: ");
       goto out;
diff --git a/src/ostree/ot-admin-deploy.h b/src/ostree/ot-admin-deploy.h
index e076d00..6652201 100644
--- a/src/ostree/ot-admin-deploy.h
+++ b/src/ostree/ot-admin-deploy.h
@@ -24,7 +24,6 @@
 
 #include <gio/gio.h>
 #include <ostree.h>
-#include "ot-bootloader.h"
 #include "ot-ordered-hash.h"
 
 G_BEGIN_DECLS
diff --git a/src/ostree/ot-admin-functions.c b/src/ostree/ot-admin-functions.c
index 2cef98c..f497fcb 100644
--- a/src/ostree/ot-admin-functions.c
+++ b/src/ostree/ot-admin-functions.c
@@ -23,8 +23,6 @@
 #include "config.h"
 
 #include "ot-admin-functions.h"
-#include "ot-bootloader-syslinux.h"
-#include "ot-bootloader-uboot.h"
 #include "otutil.h"
 #include "ostree.h"
 #include "libgsystem.h"
@@ -84,14 +82,6 @@ ot_admin_kernel_arg_string_serialize (OtOrderedHash *ohash)
   return g_string_free (buf, FALSE);
 }
 
-
-static void
-match_info_cleanup (void *loc)
-{
-  GMatchInfo **match = (GMatchInfo**)loc;
-  if (*match) g_match_info_unref (*match);
-}
-
 gboolean
 ot_admin_check_os (GFile         *sysroot, 
                    const char    *osname,
@@ -115,187 +105,6 @@ ot_admin_check_os (GFile         *sysroot,
 }
 
 static gboolean
-parse_bootlink (const char    *bootlink,
-                int           *out_entry_bootversion,
-                char         **out_osname,
-                char         **out_bootcsum,
-                int           *out_treebootserial,
-                GError       **error)
-{
-  gboolean ret = FALSE;
-  __attribute__((cleanup(match_info_cleanup))) GMatchInfo *match = NULL;
-  gs_free char *bootversion_str = NULL;
-  gs_free char *treebootserial_str = NULL;
-
-  static gsize regex_initialized;
-  static GRegex *regex;
-
-  if (g_once_init_enter (&regex_initialized))
-    {
-      regex = g_regex_new ("^/ostree/boot.([01])/([^/]+)/([^/]+)/([0-9]+)$", 0, 0, NULL);
-      g_assert (regex);
-      g_once_init_leave (&regex_initialized, 1);
-    }
-
-  if (!g_regex_match (regex, bootlink, 0, &match))
-    {
-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                   "Invalid ostree= argument '%s', expected 
ostree=/ostree/boot.BOOTVERSION/OSNAME/BOOTCSUM/TREESERIAL", bootlink);
-      goto out;
-    }
-    
-  bootversion_str = g_match_info_fetch (match, 1);
-  *out_entry_bootversion = (int)g_ascii_strtoll (bootversion_str, NULL, 10);
-  *out_osname = g_match_info_fetch (match, 2);
-  *out_bootcsum = g_match_info_fetch (match, 3);
-  treebootserial_str = g_match_info_fetch (match, 4);
-  *out_treebootserial = (int)g_ascii_strtoll (treebootserial_str, NULL, 10);
-  
-  ret = TRUE;
- out:
-  return ret;
-}
-
-gboolean
-ot_admin_parse_deploy_path_name (const char *name,
-                                 char      **out_csum,
-                                 int        *out_serial,
-                                 GError    **error)
-{
-  gboolean ret = FALSE;
-  __attribute__((cleanup(match_info_cleanup))) GMatchInfo *match = NULL;
-  gs_free char *serial_str = NULL;
-
-  static gsize regex_initialized;
-  static GRegex *regex;
-
-  if (g_once_init_enter (&regex_initialized))
-    {
-      regex = g_regex_new ("^([0-9a-f]+)\\.([0-9]+)$", 0, 0, NULL);
-      g_assert (regex);
-      g_once_init_leave (&regex_initialized, 1);
-    }
-
-  if (!g_regex_match (regex, name, 0, &match))
-    {
-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                   "Invalid deploy name '%s', expected CHECKSUM.TREESERIAL", name);
-      goto out;
-    }
-
-  *out_csum = g_match_info_fetch (match, 1);
-  serial_str = g_match_info_fetch (match, 2);
-  *out_serial = (int)g_ascii_strtoll (serial_str, NULL, 10);
-
-  ret = TRUE;
- out:
-  return ret;
-}
-
-GFile *
-ot_admin_get_deployment_origin_path (GFile   *deployment_path)
-{
-  gs_unref_object GFile *deployment_parent = g_file_get_parent (deployment_path);
-  return ot_gfile_resolve_path_printf (deployment_parent,
-                                       "%s.origin",
-                                       gs_file_get_path_cached (deployment_path));
-}
-
-static gboolean
-parse_origin (GFile           *sysroot,
-              GFile           *deployment_path,
-              GKeyFile       **out_origin,
-              GCancellable    *cancellable,
-              GError         **error)
-{
-  gboolean ret = FALSE;
-  GKeyFile *ret_origin = NULL;
-  gs_unref_object GFile *origin_path = ot_admin_get_deployment_origin_path (deployment_path);
-  gs_free char *origin_contents = NULL;
-  
-  if (!ot_gfile_load_contents_utf8_allow_noent (origin_path, &origin_contents,
-                                                cancellable, error))
-    goto out;
-
-  if (origin_contents)
-    {
-      ret_origin = g_key_file_new ();
-      if (!g_key_file_load_from_data (ret_origin, origin_contents, -1, 0, error))
-        goto out;
-    }
-
-  ret = TRUE;
-  ot_transfer_out_value (out_origin, &ret_origin);
- out:
-  if (error)
-    g_prefix_error (error, "Parsing %s: ", gs_file_get_path_cached (origin_path));
-  if (ret_origin)
-    g_key_file_unref (ret_origin);
-  return ret;
-}
-
-static gboolean
-parse_deployment (GFile           *sysroot,
-                  const char      *boot_link,
-                  OstreeDeployment   **out_deployment,
-                  GCancellable    *cancellable,
-                  GError         **error)
-{
-  gboolean ret = FALSE;
-  const char *relative_boot_link;
-  gs_unref_object OstreeDeployment *ret_deployment = NULL;
-  int entry_boot_version;
-  int treebootserial = -1;
-  int deployserial = -1;
-  gs_free char *osname = NULL;
-  gs_free char *bootcsum = NULL;
-  gs_free char *treecsum = NULL;
-  gs_unref_object GFile *treebootserial_link = NULL;
-  gs_unref_object GFileInfo *treebootserial_info = NULL;
-  gs_unref_object GFile *treebootserial_target = NULL;
-  GKeyFile *origin = NULL;
-      
-  if (!parse_bootlink (boot_link, &entry_boot_version,
-                       &osname, &bootcsum, &treebootserial,
-                       error))
-    goto out;
-
-  relative_boot_link = boot_link;
-  if (*relative_boot_link == '/')
-    relative_boot_link++;
-  treebootserial_link = g_file_resolve_relative_path (sysroot, relative_boot_link);
-  treebootserial_info = g_file_query_info (treebootserial_link, OSTREE_GIO_FAST_QUERYINFO,
-                                           G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
-                                           cancellable, error);
-  if (!treebootserial_info)
-    goto out;
-
-  if (!ot_gfile_get_symlink_target_from_info (treebootserial_link, treebootserial_info,
-                                              &treebootserial_target, cancellable, error))
-    goto out;
-
-  if (!ot_admin_parse_deploy_path_name (gs_file_get_basename_cached (treebootserial_target),
-                                        &treecsum, &deployserial, error))
-    goto out;
-
-  if (!parse_origin (sysroot, treebootserial_target, &origin,
-                     cancellable, error))
-    goto out;
-
-  ret_deployment = ostree_deployment_new (-1, osname, treecsum, deployserial,
-                                      bootcsum, treebootserial);
-  if (origin)
-    ostree_deployment_set_origin (ret_deployment, origin);
-
-  ret = TRUE;
-  ot_transfer_out_value (out_deployment, &ret_deployment);
- out:
-  if (origin)
-    g_key_file_unref (origin);
-  return ret;
-}
-
-static gboolean
 parse_kernel_commandline (OtOrderedHash  **out_args,
                           GCancellable    *cancellable,
                           GError         **error)
@@ -336,6 +145,7 @@ ot_admin_find_booted_deployment (GFile               *target_sysroot,
 {
   gboolean ret = FALSE;
   gs_unref_object GFile *active_root = g_file_new_for_path ("/");
+  gs_unref_object OstreeSysroot *active_deployment_root = ostree_sysroot_new_default ();
   gs_unref_object OstreeDeployment *ret_deployment = NULL;
 
   if (g_file_equal (active_root, target_sysroot))
@@ -359,7 +169,7 @@ ot_admin_find_booted_deployment (GFile               *target_sysroot,
           for (i = 0; i < deployments->len; i++)
             {
               OstreeDeployment *deployment = deployments->pdata[i];
-              gs_unref_object GFile *deployment_path = ot_admin_get_deployment_directory (active_root, 
deployment);
+              gs_unref_object GFile *deployment_path = ostree_sysroot_get_deployment_directory 
(active_deployment_root, deployment);
               guint32 device;
               guint64 inode;
 
@@ -451,321 +261,6 @@ ot_admin_get_merge_deployment (GPtrArray         *deployments,
   return NULL;
 }
 
-static gboolean
-read_current_bootversion (GFile         *sysroot,
-                          int           *out_bootversion,
-                          GCancellable  *cancellable,
-                          GError       **error)
-{
-  gboolean ret = FALSE;
-  gs_unref_object GFile *boot_loader_path = g_file_resolve_relative_path (sysroot, "boot/loader");
-  gs_unref_object GFileInfo *info = NULL;
-  const char *target;
-  int ret_bootversion;
-
-  if (!ot_gfile_query_info_allow_noent (boot_loader_path, OSTREE_GIO_FAST_QUERYINFO,
-                                        G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
-                                        &info,
-                                        cancellable, error))
-    goto out;
-
-  if (info == NULL)
-    ret_bootversion = 0;
-  else
-    {
-      if (g_file_info_get_file_type (info) != G_FILE_TYPE_SYMBOLIC_LINK)
-        {
-          g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                       "Not a symbolic link: %s", gs_file_get_path_cached (boot_loader_path));
-          goto out;
-        }
-
-      target = g_file_info_get_symlink_target (info);
-      if (g_strcmp0 (target, "loader.0") == 0)
-        ret_bootversion = 0;
-      else if (g_strcmp0 (target, "loader.1") == 0)
-        ret_bootversion = 1;
-      else
-        {
-          g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                       "Invalid target '%s' in %s", target, gs_file_get_path_cached (boot_loader_path));
-          goto out;
-        }
-    }
-
-  ret = TRUE;
-  *out_bootversion = ret_bootversion;
- out:
-  return ret;
-}
-
-gboolean
-ot_admin_read_current_subbootversion (GFile         *sysroot,
-                                      int            bootversion,
-                                      int           *out_subbootversion,
-                                      GCancellable  *cancellable,
-                                      GError       **error)
-{
-  gboolean ret = FALSE;
-  gs_unref_object GFile *ostree_dir = g_file_get_child (sysroot, "ostree");
-  gs_free char *ostree_bootdir_name = g_strdup_printf ("boot.%d", bootversion);
-  gs_unref_object GFile *ostree_bootdir = g_file_resolve_relative_path (ostree_dir, ostree_bootdir_name);
-  gs_unref_object GFile *ostree_subbootdir = NULL;
-
-  if (!ot_gfile_query_symlink_target_allow_noent (ostree_bootdir, &ostree_subbootdir,
-                                                  cancellable, error))
-    goto out;
-
-  if (ostree_subbootdir == NULL)
-    {
-      *out_subbootversion = 0;
-    }
-  else
-    {
-      const char *current_subbootdir_name = gs_file_get_basename_cached (ostree_subbootdir);
-      if (g_str_has_suffix (current_subbootdir_name, ".0"))
-        *out_subbootversion = 0;
-      else if (g_str_has_suffix (current_subbootdir_name, ".1"))
-        *out_subbootversion = 1;
-      else
-        {
-          g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                       "Invalid target '%s' in %s",
-                       gs_file_get_path_cached (ostree_subbootdir),
-                       gs_file_get_path_cached (ostree_bootdir));
-          goto out;
-        }
-    }
-
-  ret = TRUE;
- out:
-  return ret;
-}
-
-gboolean
-ot_admin_read_boot_loader_configs (GFile         *sysroot,
-                                   int            bootversion,
-                                   GPtrArray    **out_loader_configs,
-                                   GCancellable  *cancellable,
-                                   GError       **error)
-{
-  gboolean ret = FALSE;
-  gs_unref_object GFileEnumerator *dir_enum = NULL;
-  gs_unref_object GFile *loader_entries_dir = NULL;
-  gs_unref_ptrarray GPtrArray *ret_loader_configs = NULL;
-  GError *temp_error = NULL;
-
-  loader_entries_dir = ot_gfile_resolve_path_printf (sysroot, "boot/loader.%d/entries",
-                                                     bootversion);
-  ret_loader_configs = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
-
-  dir_enum = g_file_enumerate_children (loader_entries_dir, OSTREE_GIO_FAST_QUERYINFO,
-                                        0, NULL, &temp_error);
-  if (!dir_enum)
-    {
-      if (g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
-        {
-          g_clear_error (&temp_error);
-          goto done;
-        } 
-      else
-        {
-          g_propagate_error (error, temp_error);
-          goto out;
-        }
-    }
-
-  while (TRUE)
-    {
-      GFileInfo *file_info;
-      GFile *child;
-      const char *name;
-
-      if (!gs_file_enumerator_iterate (dir_enum, &file_info, &child,
-                                       cancellable, error))
-        goto out;
-      if (file_info == NULL)
-        break;
-
-      name = g_file_info_get_name (file_info);
-
-      if (g_str_has_prefix (name, "ostree-") &&
-          g_str_has_suffix (name, ".conf") &&
-          g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR)
-        {
-          gs_unref_object OstreeBootconfigParser *config = ostree_bootconfig_parser_new ();
-  
-          if (!ostree_bootconfig_parser_parse (config, child, cancellable, error))
-            {
-              g_prefix_error (error, "Parsing %s: ", gs_file_get_path_cached (child));
-              goto out;
-            }
-
-          g_ptr_array_add (ret_loader_configs, g_object_ref (config));
-        }
-    }
-
- done:
-  ot_transfer_out_value (out_loader_configs, &ret_loader_configs);
-  ret = TRUE;
- out:
-  return ret;
-}
-
-static char *
-get_ostree_kernel_arg_from_config (OstreeBootconfigParser  *config)
-{
-  const char *options;
-  char *ret = NULL;
-  char **opts, **iter;
-
-  options = ostree_bootconfig_parser_get (config, "options");
-  if (!options)
-    return NULL;
-
-  opts = g_strsplit (options, " ", -1);
-  for (iter = opts; *iter; iter++)
-    {
-      const char *opt = *iter;
-      if (g_str_has_prefix (opt, "ostree="))
-        {
-          ret = g_strdup (opt + strlen ("ostree="));
-          break;
-        }
-    }
-  g_strfreev (opts);
-
-  return ret;
-}
-
-static gboolean
-list_deployments_process_one_boot_entry (GFile               *sysroot,
-                                         OstreeBootconfigParser      *config,
-                                         GPtrArray           *inout_deployments,
-                                         GCancellable        *cancellable,
-                                         GError             **error)
-{
-  gboolean ret = FALSE;
-  gs_free char *ostree_arg = NULL;
-  gs_unref_object OstreeDeployment *deployment = NULL;
-
-  ostree_arg = get_ostree_kernel_arg_from_config (config);
-  if (ostree_arg == NULL)
-    {
-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                   "No ostree= kernel argument found");
-      goto out;
-    }
-  
-  if (!parse_deployment (sysroot, ostree_arg, &deployment,
-                         cancellable, error))
-    goto out;
-  
-  ostree_deployment_set_bootconfig (deployment, config);
-
-  g_ptr_array_add (inout_deployments, g_object_ref (deployment));
-  
-  ret = TRUE;
- out:
-  return ret;
-}
-
-static gint
-compare_deployments_by_boot_loader_version_reversed (gconstpointer     a_pp,
-                                                     gconstpointer     b_pp)
-{
-  OstreeDeployment *a = *((OstreeDeployment**)a_pp);
-  OstreeDeployment *b = *((OstreeDeployment**)b_pp);
-  OstreeBootconfigParser *a_bootconfig = ostree_deployment_get_bootconfig (a);
-  OstreeBootconfigParser *b_bootconfig = ostree_deployment_get_bootconfig (b);
-  const char *a_version = ostree_bootconfig_parser_get (a_bootconfig, "version");
-  const char *b_version = ostree_bootconfig_parser_get (b_bootconfig, "version");
-  
-  if (a_version && b_version)
-    {
-      int r = strverscmp (a_version, b_version);
-      /* Reverse */
-      return -r;
-    }
-  else if (a_version)
-    return -1;
-  else
-    return 1;
-}
-
-gboolean
-ot_admin_list_deployments (GFile               *sysroot,
-                           int                 *out_current_bootversion,
-                           GPtrArray          **out_deployments,
-                           GCancellable        *cancellable,
-                           GError             **error)
-{
-  gboolean ret = FALSE;
-  gs_unref_ptrarray GPtrArray *boot_loader_configs = NULL;
-  gs_unref_ptrarray GPtrArray *ret_deployments = NULL;
-  guint i;
-  int bootversion = -1;
-
-  if (!read_current_bootversion (sysroot, &bootversion, cancellable, error))
-    goto out;
-
-  if (!ot_admin_read_boot_loader_configs (sysroot, bootversion, &boot_loader_configs,
-                                          cancellable, error))
-    goto out;
-
-  ret_deployments = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
-
-  for (i = 0; i < boot_loader_configs->len; i++)
-    {
-      OstreeBootconfigParser *config = boot_loader_configs->pdata[i];
-
-      if (!list_deployments_process_one_boot_entry (sysroot, config, ret_deployments,
-                                                    cancellable, error))
-        goto out;
-    }
-
-  g_ptr_array_sort (ret_deployments, compare_deployments_by_boot_loader_version_reversed);
-  for (i = 0; i < ret_deployments->len; i++)
-    {
-      OstreeDeployment *deployment = ret_deployments->pdata[i];
-      ostree_deployment_set_index (deployment, i);
-    }
-
-  ret = TRUE;
-  *out_current_bootversion = bootversion;
-  ot_transfer_out_value (out_deployments, &ret_deployments);
- out:
-  return ret;
-}
-
-GFile *
-ot_admin_get_deployment_directory (GFile        *sysroot,
-                                   OstreeDeployment *deployment)
-{
-  gs_free char *path = g_strdup_printf ("ostree/deploy/%s/deploy/%s.%d",
-                                        ostree_deployment_get_osname (deployment),
-                                        ostree_deployment_get_csum (deployment),
-                                        ostree_deployment_get_deployserial (deployment));
-  return g_file_resolve_relative_path (sysroot, path);
-}
-
-OtBootloader *
-ot_admin_query_bootloader (GFile         *sysroot)
-{
-  OtBootloaderSyslinux *syslinux;
-  OtBootloaderUboot    *uboot;
-
-  syslinux = ot_bootloader_syslinux_new (sysroot);
-  if (ot_bootloader_query ((OtBootloader*)syslinux))
-    return (OtBootloader*) (syslinux);
-
-  uboot = ot_bootloader_uboot_new (sysroot);
-  if (ot_bootloader_query ((OtBootloader*)uboot))
-    return (OtBootloader*) (uboot);
-
-  return NULL;
-}
-
 GKeyFile *
 ot_origin_new_from_refspec (const char *refspec)
 {
@@ -773,23 +268,3 @@ ot_origin_new_from_refspec (const char *refspec)
   g_key_file_set_string (ret, "origin", "refspec", refspec);
   return ret;
 }
-
-gboolean
-ot_admin_get_repo (GFile         *sysroot,
-                   OstreeRepo   **out_repo,
-                   GCancellable  *cancellable,
-                   GError       **error)
-{
-  gboolean ret = FALSE;
-  gs_unref_object OstreeRepo *ret_repo = NULL;
-  gs_unref_object GFile *repo_path = g_file_resolve_relative_path (sysroot, "ostree/repo");
-
-  ret_repo = ostree_repo_new (repo_path);
-  if (!ostree_repo_open (ret_repo, cancellable, error))
-    goto out;
-    
-  ret = TRUE;
-  ot_transfer_out_value (out_repo, &ret_repo);
- out:
-  return ret;
-}
diff --git a/src/ostree/ot-admin-functions.h b/src/ostree/ot-admin-functions.h
index f48912a..4b7a6a6 100644
--- a/src/ostree/ot-admin-functions.h
+++ b/src/ostree/ot-admin-functions.h
@@ -24,7 +24,6 @@
 
 #include <gio/gio.h>
 #include <ostree.h>
-#include "ot-bootloader.h"
 #include "ot-ordered-hash.h"
 
 G_BEGIN_DECLS
@@ -37,13 +36,6 @@ gboolean ot_admin_util_get_devino (GFile         *path,
                                    GCancellable  *cancellable,
                                    GError       **error);
 
-char *ot_admin_join_lines (GPtrArray  *lines);
-
-gboolean ot_admin_parse_deploy_path_name (const char *name,
-                                          char      **out_csum,
-                                          int        *out_serial,
-                                          GError    **error);
-
 gboolean ot_admin_ensure_initialized (GFile         *ostree_dir, 
                                      GCancellable  *cancellable,
                                      GError       **error);
@@ -56,26 +48,6 @@ gboolean ot_admin_check_os (GFile         *sysroot,
 OtOrderedHash *ot_admin_parse_kernel_args (const char *options);
 char * ot_admin_kernel_arg_string_serialize (OtOrderedHash *ohash);
 
-OtBootloader *ot_admin_query_bootloader (GFile         *sysroot);
-
-gboolean ot_admin_read_current_subbootversion (GFile         *sysroot,
-                                               int            bootversion,
-                                               int           *out_subbootversion,
-                                               GCancellable  *cancellable,
-                                               GError       **error);
-
-gboolean ot_admin_read_boot_loader_configs (GFile         *boot_dir,
-                                            int            bootversion,
-                                            GPtrArray    **out_loader_configs,
-                                            GCancellable  *cancellable,
-                                            GError       **error);
-
-gboolean ot_admin_list_deployments (GFile               *sysroot,
-                                    int                 *out_bootversion,
-                                    GPtrArray          **out_deployments,
-                                    GCancellable        *cancellable,
-                                    GError             **error);
-
 gboolean ot_admin_find_booted_deployment (GFile               *sysroot,
                                           GPtrArray           *deployments,
                                           OstreeDeployment       **out_deployment,
@@ -98,20 +70,6 @@ OstreeDeployment *ot_admin_get_merge_deployment (GPtrArray         *deployment_l
                                              const char        *osname,
                                              OstreeDeployment      *booted_deployment);
 
-GFile *ot_admin_get_deployment_origin_path (GFile   *deployment_path);
-
-GFile *ot_admin_get_deployment_directory (GFile        *sysroot,
-                                          OstreeDeployment *deployment);
-
-gboolean ot_admin_get_repo (GFile         *sysroot,
-                            OstreeRepo   **out_repo,
-                            GCancellable  *cancellable,
-                            GError       **error);
-
-gboolean ot_admin_cleanup (GFile               *sysroot,
-                           GCancellable        *cancellable,
-                           GError             **error);
-
 gboolean ot_admin_get_default_ostree_dir (GFile        **out_ostree_dir,
                                           GCancellable  *cancellable,
                                           GError       **error);
diff --git a/src/ostree/ot-admin-util.c b/src/ostree/ot-admin-util.c
index 4a05578..5e82261 100644
--- a/src/ostree/ot-admin-util.c
+++ b/src/ostree/ot-admin-util.c
@@ -76,26 +76,3 @@ ot_admin_util_get_devino (GFile         *path,
   return ret;
 }
 
-char *
-ot_admin_join_lines (GPtrArray  *lines)
-{
-  GString *buf = g_string_new ("");
-  guint i;
-  gboolean prev_was_empty = FALSE;
-
-  for (i = 0; i < lines->len; i++)
-    {
-      const char *line = lines->pdata[i];
-      /* Special bit to remove extraneous empty lines */
-      if (*line == '\0')
-        {
-          if (prev_was_empty || i == 0)
-            continue;
-          else
-            prev_was_empty = TRUE;
-        }
-      g_string_append (buf, line);
-      g_string_append_c (buf, '\n');
-    }
-  return g_string_free (buf, FALSE);
-}


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