Move Deployment and BootconfigParser into libostree

As part of moving admin functionality there.  While we are doing this,
rename OtConfigParser to OstreeBootConfig parser since it's a better
name.
This commit is contained in:
Colin Walters 2013-09-15 15:06:31 -04:00
parent af0f888057
commit 35bab87691
21 changed files with 370 additions and 378 deletions

View File

@ -45,6 +45,10 @@ libostree_1_la_SOURCES = \
src/libostree/ostree-repo-file-enumerator.h \ src/libostree/ostree-repo-file-enumerator.h \
src/libostree/ostree-sysroot.c \ src/libostree/ostree-sysroot.c \
src/libostree/ostree-sysroot.h \ src/libostree/ostree-sysroot.h \
src/libostree/ostree-bootconfig-parser.h \
src/libostree/ostree-bootconfig-parser.c \
src/libostree/ostree-deployment.h \
src/libostree/ostree-deployment.c \
$(NULL) $(NULL)
if USE_LIBARCHIVE if USE_LIBARCHIVE
libostree_1_la_SOURCES += src/libostree/ostree-libarchive-input-stream.h \ libostree_1_la_SOURCES += src/libostree/ostree-libarchive-input-stream.h \

View File

@ -71,10 +71,6 @@ ostree_SOURCES += \
src/ostree/ot-bootloader-syslinux.c \ src/ostree/ot-bootloader-syslinux.c \
src/ostree/ot-bootloader-uboot.h \ src/ostree/ot-bootloader-uboot.h \
src/ostree/ot-bootloader-uboot.c \ src/ostree/ot-bootloader-uboot.c \
src/ostree/ot-config-parser.h \
src/ostree/ot-config-parser.c \
src/ostree/ot-deployment.h \
src/ostree/ot-deployment.c \
src/ostree/ot-ordered-hash.h \ src/ostree/ot-ordered-hash.h \
src/ostree/ot-ordered-hash.c \ src/ostree/ot-ordered-hash.c \
$(NULL) $(NULL)

View File

@ -20,10 +20,10 @@
#include "config.h" #include "config.h"
#include "ot-config-parser.h" #include "ostree-bootconfig-parser.h"
#include "libgsystem.h" #include "libgsystem.h"
struct _OtConfigParser struct _OstreeBootconfigParser
{ {
GObject parent_instance; GObject parent_instance;
@ -34,15 +34,15 @@ struct _OtConfigParser
GPtrArray *lines; GPtrArray *lines;
}; };
typedef GObjectClass OtConfigParserClass; typedef GObjectClass OstreeBootconfigParserClass;
G_DEFINE_TYPE (OtConfigParser, ot_config_parser, G_TYPE_OBJECT) G_DEFINE_TYPE (OstreeBootconfigParser, ostree_bootconfig_parser, G_TYPE_OBJECT)
gboolean gboolean
ot_config_parser_parse (OtConfigParser *self, ostree_bootconfig_parser_parse (OstreeBootconfigParser *self,
GFile *path, GFile *path,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
gs_free char *contents = NULL; gs_free char *contents = NULL;
@ -88,22 +88,22 @@ ot_config_parser_parse (OtConfigParser *self,
} }
void void
ot_config_parser_set (OtConfigParser *self, ostree_bootconfig_parser_set (OstreeBootconfigParser *self,
const char *key, const char *key,
const char *value) const char *value)
{ {
g_hash_table_replace (self->options, g_strdup (key), g_strdup (value)); g_hash_table_replace (self->options, g_strdup (key), g_strdup (value));
} }
const char * const char *
ot_config_parser_get (OtConfigParser *self, ostree_bootconfig_parser_get (OstreeBootconfigParser *self,
const char *key) const char *key)
{ {
return g_hash_table_lookup (self->options, key); return g_hash_table_lookup (self->options, key);
} }
static gboolean static gboolean
write_key (OtConfigParser *self, write_key (OstreeBootconfigParser *self,
GDataOutputStream *out, GDataOutputStream *out,
const char *key, const char *key,
const char *value, const char *value,
@ -127,10 +127,10 @@ write_key (OtConfigParser *self,
} }
gboolean gboolean
ot_config_parser_write (OtConfigParser *self, ostree_bootconfig_parser_write (OstreeBootconfigParser *self,
GFile *output, GFile *output,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
GHashTableIter hashiter; GHashTableIter hashiter;
@ -191,40 +191,38 @@ ot_config_parser_write (OtConfigParser *self,
} }
static void static void
ot_config_parser_finalize (GObject *object) ostree_bootconfig_parser_finalize (GObject *object)
{ {
OtConfigParser *self = OT_CONFIG_PARSER (object); OstreeBootconfigParser *self = OSTREE_BOOTCONFIG_PARSER (object);
g_hash_table_unref (self->options); g_hash_table_unref (self->options);
g_ptr_array_unref (self->lines); g_ptr_array_unref (self->lines);
g_free (self->separators); g_free (self->separators);
G_OBJECT_CLASS (ot_config_parser_parent_class)->finalize (object); G_OBJECT_CLASS (ostree_bootconfig_parser_parent_class)->finalize (object);
} }
static void static void
ot_config_parser_init (OtConfigParser *self) ostree_bootconfig_parser_init (OstreeBootconfigParser *self)
{ {
self->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); self->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
self->lines = g_ptr_array_new (); self->lines = g_ptr_array_new ();
} }
void void
ot_config_parser_class_init (OtConfigParserClass *class) ostree_bootconfig_parser_class_init (OstreeBootconfigParserClass *class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (class); GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = ot_config_parser_finalize; object_class->finalize = ostree_bootconfig_parser_finalize;
} }
OtConfigParser * OstreeBootconfigParser *
ot_config_parser_new (const char *separators) ostree_bootconfig_parser_new (void)
{ {
OtConfigParser *self = NULL; OstreeBootconfigParser *self = NULL;
g_return_val_if_fail (separators != NULL && separators[0], NULL); self = g_object_new (OSTREE_TYPE_BOOTCONFIG_PARSER, NULL);
self->separators = g_strdup (" \t");
self = g_object_new (OT_TYPE_CONFIG_PARSER, NULL);
self->separators = g_strdup (separators);
return self; return self;
} }

View File

@ -0,0 +1,56 @@
/* -*- 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_BOOTCONFIG_PARSER (ostree_bootconfig_parser_get_type ())
#define OSTREE_BOOTCONFIG_PARSER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), OSTREE_TYPE_BOOTCONFIG_PARSER, OstreeBootconfigParser))
#define OSTREE_IS_BOOTCONFIG_PARSER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), OSTREE_TYPE_BOOTCONFIG_PARSER))
typedef struct _OstreeBootconfigParser OstreeBootconfigParser;
GType ostree_bootconfig_parser_get_type (void) G_GNUC_CONST;
OstreeBootconfigParser * ostree_bootconfig_parser_new (void);
gboolean ostree_bootconfig_parser_parse (OstreeBootconfigParser *self,
GFile *path,
GCancellable *cancellable,
GError **error);
gboolean ostree_bootconfig_parser_write (OstreeBootconfigParser *self,
GFile *output,
GCancellable *cancellable,
GError **error);
void ostree_bootconfig_parser_set (OstreeBootconfigParser *self,
const char *key,
const char *value);
const char *ostree_bootconfig_parser_get (OstreeBootconfigParser *self,
const char *key);
G_END_DECLS

View File

@ -20,10 +20,10 @@
#include "config.h" #include "config.h"
#include "ot-deployment.h" #include "ostree-deployment.h"
#include "libgsystem.h" #include "libgsystem.h"
struct _OtDeployment struct _OstreeDeployment
{ {
GObject parent_instance; GObject parent_instance;
@ -33,76 +33,76 @@ struct _OtDeployment
int deployserial; /* How many times this particular csum appears in deployment list */ int deployserial; /* How many times this particular csum appears in deployment list */
char *bootcsum; /* Checksum of kernel+initramfs */ char *bootcsum; /* Checksum of kernel+initramfs */
int bootserial; /* An integer assigned to this tree per its ${bootcsum} */ int bootserial; /* An integer assigned to this tree per its ${bootcsum} */
OtConfigParser *bootconfig; /* Bootloader configuration */ OstreeBootconfigParser *bootconfig; /* Bootloader configuration */
GKeyFile *origin; /* How to construct an upgraded version of this tree */ GKeyFile *origin; /* How to construct an upgraded version of this tree */
}; };
typedef GObjectClass OtDeploymentClass; typedef GObjectClass OstreeDeploymentClass;
G_DEFINE_TYPE (OtDeployment, ot_deployment, G_TYPE_OBJECT) G_DEFINE_TYPE (OstreeDeployment, ostree_deployment, G_TYPE_OBJECT)
const char * const char *
ot_deployment_get_csum (OtDeployment *self) ostree_deployment_get_csum (OstreeDeployment *self)
{ {
return self->csum; return self->csum;
} }
const char * const char *
ot_deployment_get_bootcsum (OtDeployment *self) ostree_deployment_get_bootcsum (OstreeDeployment *self)
{ {
return self->bootcsum; return self->bootcsum;
} }
const char * const char *
ot_deployment_get_osname (OtDeployment *self) ostree_deployment_get_osname (OstreeDeployment *self)
{ {
return self->osname; return self->osname;
} }
int int
ot_deployment_get_deployserial (OtDeployment *self) ostree_deployment_get_deployserial (OstreeDeployment *self)
{ {
return self->deployserial; return self->deployserial;
} }
int int
ot_deployment_get_bootserial (OtDeployment *self) ostree_deployment_get_bootserial (OstreeDeployment *self)
{ {
return self->bootserial; return self->bootserial;
} }
OtConfigParser * OstreeBootconfigParser *
ot_deployment_get_bootconfig (OtDeployment *self) ostree_deployment_get_bootconfig (OstreeDeployment *self)
{ {
return self->bootconfig; return self->bootconfig;
} }
GKeyFile * GKeyFile *
ot_deployment_get_origin (OtDeployment *self) ostree_deployment_get_origin (OstreeDeployment *self)
{ {
return self->origin; return self->origin;
} }
int int
ot_deployment_get_index (OtDeployment *self) ostree_deployment_get_index (OstreeDeployment *self)
{ {
return self->index; return self->index;
} }
void void
ot_deployment_set_index (OtDeployment *self, int index) ostree_deployment_set_index (OstreeDeployment *self, int index)
{ {
self->index = index; self->index = index;
} }
void void
ot_deployment_set_bootserial (OtDeployment *self, int index) ostree_deployment_set_bootserial (OstreeDeployment *self, int index)
{ {
self->bootserial = index; self->bootserial = index;
} }
void void
ot_deployment_set_bootconfig (OtDeployment *self, OtConfigParser *bootconfig) ostree_deployment_set_bootconfig (OstreeDeployment *self, OstreeBootconfigParser *bootconfig)
{ {
g_clear_object (&self->bootconfig); g_clear_object (&self->bootconfig);
if (bootconfig) if (bootconfig)
@ -110,55 +110,55 @@ ot_deployment_set_bootconfig (OtDeployment *self, OtConfigParser *bootconfig)
} }
void void
ot_deployment_set_origin (OtDeployment *self, GKeyFile *origin) ostree_deployment_set_origin (OstreeDeployment *self, GKeyFile *origin)
{ {
g_clear_pointer (&self->origin, g_key_file_unref); g_clear_pointer (&self->origin, g_key_file_unref);
if (origin) if (origin)
self->origin = g_key_file_ref (origin); self->origin = g_key_file_ref (origin);
} }
OtDeployment * OstreeDeployment *
ot_deployment_clone (OtDeployment *self) ostree_deployment_clone (OstreeDeployment *self)
{ {
OtDeployment *ret = ot_deployment_new (self->index, self->osname, self->csum, OstreeDeployment *ret = ostree_deployment_new (self->index, self->osname, self->csum,
self->deployserial, self->deployserial,
self->bootcsum, self->bootserial); self->bootcsum, self->bootserial);
ot_deployment_set_bootconfig (ret, self->bootconfig); ostree_deployment_set_bootconfig (ret, self->bootconfig);
ot_deployment_set_origin (ret, self->origin); ostree_deployment_set_origin (ret, self->origin);
return ret; return ret;
} }
guint guint
ot_deployment_hash (gconstpointer v) ostree_deployment_hash (gconstpointer v)
{ {
OtDeployment *d = (OtDeployment*)v; OstreeDeployment *d = (OstreeDeployment*)v;
return g_str_hash (ot_deployment_get_osname (d)) + return g_str_hash (ostree_deployment_get_osname (d)) +
g_str_hash (ot_deployment_get_csum (d)) + g_str_hash (ostree_deployment_get_csum (d)) +
ot_deployment_get_deployserial (d); ostree_deployment_get_deployserial (d);
} }
gboolean gboolean
ot_deployment_equal (gconstpointer ap, gconstpointer bp) ostree_deployment_equal (gconstpointer ap, gconstpointer bp)
{ {
OtDeployment *a = (OtDeployment*)ap; OstreeDeployment *a = (OstreeDeployment*)ap;
OtDeployment *b = (OtDeployment*)bp; OstreeDeployment *b = (OstreeDeployment*)bp;
if (a == NULL && b == NULL) if (a == NULL && b == NULL)
return TRUE; return TRUE;
else if (a != NULL && b != NULL) else if (a != NULL && b != NULL)
return g_str_equal (ot_deployment_get_osname (a), return g_str_equal (ostree_deployment_get_osname (a),
ot_deployment_get_osname (b)) && ostree_deployment_get_osname (b)) &&
g_str_equal (ot_deployment_get_csum (a), g_str_equal (ostree_deployment_get_csum (a),
ot_deployment_get_csum (b)) && ostree_deployment_get_csum (b)) &&
ot_deployment_get_deployserial (a) == ot_deployment_get_deployserial (b); ostree_deployment_get_deployserial (a) == ostree_deployment_get_deployserial (b);
else else
return FALSE; return FALSE;
} }
static void static void
ot_deployment_finalize (GObject *object) ostree_deployment_finalize (GObject *object)
{ {
OtDeployment *self = OT_DEPLOYMENT (object); OstreeDeployment *self = OSTREE_DEPLOYMENT (object);
g_free (self->osname); g_free (self->osname);
g_free (self->csum); g_free (self->csum);
@ -166,31 +166,31 @@ ot_deployment_finalize (GObject *object)
g_clear_object (&self->bootconfig); g_clear_object (&self->bootconfig);
g_clear_pointer (&self->origin, g_key_file_unref); g_clear_pointer (&self->origin, g_key_file_unref);
G_OBJECT_CLASS (ot_deployment_parent_class)->finalize (object); G_OBJECT_CLASS (ostree_deployment_parent_class)->finalize (object);
} }
void void
ot_deployment_init (OtDeployment *self) ostree_deployment_init (OstreeDeployment *self)
{ {
} }
void void
ot_deployment_class_init (OtDeploymentClass *class) ostree_deployment_class_init (OstreeDeploymentClass *class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (class); GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = ot_deployment_finalize; object_class->finalize = ostree_deployment_finalize;
} }
OtDeployment * OstreeDeployment *
ot_deployment_new (int index, ostree_deployment_new (int index,
const char *osname, const char *osname,
const char *csum, const char *csum,
int deployserial, int deployserial,
const char *bootcsum, const char *bootcsum,
int bootserial) int bootserial)
{ {
OtDeployment *self; OstreeDeployment *self;
/* index may be -1 */ /* index may be -1 */
g_return_val_if_fail (osname != NULL, NULL); g_return_val_if_fail (osname != NULL, NULL);
@ -199,7 +199,7 @@ ot_deployment_new (int index,
/* We can have "disconnected" deployments that don't have a /* We can have "disconnected" deployments that don't have a
bootcsum/serial */ bootcsum/serial */
self = g_object_new (OT_TYPE_DEPLOYMENT, NULL); self = g_object_new (OSTREE_TYPE_DEPLOYMENT, NULL);
self->index = index; self->index = index;
self->osname = g_strdup (osname); self->osname = g_strdup (osname);
self->csum = g_strdup (csum); self->csum = g_strdup (csum);

View File

@ -0,0 +1,63 @@
/* -*- 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 "ostree-bootconfig-parser.h"
G_BEGIN_DECLS
#define OSTREE_TYPE_DEPLOYMENT (ostree_deployment_get_type ())
#define OSTREE_DEPLOYMENT(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), OSTREE_TYPE_DEPLOYMENT, OstreeDeployment))
#define OSTREE_IS_DEPLOYMENT(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), OSTREE_TYPE_DEPLOYMENT))
typedef struct _OstreeDeployment OstreeDeployment;
GType ostree_deployment_get_type (void) G_GNUC_CONST;
guint ostree_deployment_hash (gconstpointer v);
gboolean ostree_deployment_equal (gconstpointer a, gconstpointer b);
OstreeDeployment * ostree_deployment_new (int index,
const char *osname,
const char *csum,
int deployserial,
const char *bootcsum,
int bootserial);
int ostree_deployment_get_index (OstreeDeployment *self);
const char *ostree_deployment_get_osname (OstreeDeployment *self);
int ostree_deployment_get_deployserial (OstreeDeployment *self);
const char *ostree_deployment_get_csum (OstreeDeployment *self);
const char *ostree_deployment_get_bootcsum (OstreeDeployment *self);
int ostree_deployment_get_bootserial (OstreeDeployment *self);
OstreeBootconfigParser *ostree_deployment_get_bootconfig (OstreeDeployment *self);
GKeyFile *ostree_deployment_get_origin (OstreeDeployment *self);
void ostree_deployment_set_index (OstreeDeployment *self, int index);
void ostree_deployment_set_bootserial (OstreeDeployment *self, int index);
void ostree_deployment_set_bootconfig (OstreeDeployment *self, OstreeBootconfigParser *bootconfig);
void ostree_deployment_set_origin (OstreeDeployment *self, GKeyFile *origin);
OstreeDeployment *ostree_deployment_clone (OstreeDeployment *self);
G_END_DECLS

View File

@ -27,4 +27,6 @@
#include <ostree-mutable-tree.h> #include <ostree-mutable-tree.h>
#include <ostree-repo-file.h> #include <ostree-repo-file.h>
#include <ostree-sysroot.h> #include <ostree-sysroot.h>
#include <ostree-deployment.h>
#include <ostree-bootconfig-parser.h>
#include <ostree-diff.h> #include <ostree-diff.h>

View File

@ -58,8 +58,8 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeSysroot *sysroot, GCancell
gs_unref_object OstreeRepo *repo = NULL; gs_unref_object OstreeRepo *repo = NULL;
gs_unref_ptrarray GPtrArray *current_deployments = NULL; gs_unref_ptrarray GPtrArray *current_deployments = NULL;
gs_unref_ptrarray GPtrArray *new_deployments = NULL; gs_unref_ptrarray GPtrArray *new_deployments = NULL;
gs_unref_object OtDeployment *new_deployment = NULL; gs_unref_object OstreeDeployment *new_deployment = NULL;
gs_unref_object OtDeployment *booted_deployment = NULL; gs_unref_object OstreeDeployment *booted_deployment = NULL;
gs_free char *revision = NULL; gs_free char *revision = NULL;
context = g_option_context_new ("REFSPEC - Checkout revision REFSPEC as the new default deployment"); context = g_option_context_new ("REFSPEC - Checkout revision REFSPEC as the new default deployment");

View File

@ -42,7 +42,7 @@ ot_admin_builtin_diff (int argc, char **argv, OstreeSysroot *sysroot, GCancellab
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
gs_unref_object GFile *repo_path = NULL; gs_unref_object GFile *repo_path = NULL;
gs_unref_object OtDeployment *deployment = NULL; gs_unref_object OstreeDeployment *deployment = NULL;
gs_unref_object GFile *deployment_dir = NULL; gs_unref_object GFile *deployment_dir = NULL;
gs_unref_ptrarray GPtrArray *modified = NULL; gs_unref_ptrarray GPtrArray *modified = NULL;
gs_unref_ptrarray GPtrArray *removed = NULL; gs_unref_ptrarray GPtrArray *removed = NULL;
@ -73,7 +73,7 @@ ot_admin_builtin_diff (int argc, char **argv, OstreeSysroot *sysroot, GCancellab
cancellable, error)) cancellable, error))
goto out; goto out;
if (deployment != NULL) if (deployment != NULL)
opt_osname = (char*)ot_deployment_get_osname (deployment); opt_osname = (char*)ostree_deployment_get_osname (deployment);
if (deployment == NULL) if (deployment == NULL)
deployment = ot_admin_get_merge_deployment (deployments, opt_osname, deployment); deployment = ot_admin_get_merge_deployment (deployments, opt_osname, deployment);
if (deployment == NULL) if (deployment == NULL)

View File

@ -39,7 +39,7 @@ ot_admin_builtin_status (int argc, char **argv, OstreeSysroot *sysroot, GCancell
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
int bootversion; int bootversion;
gs_unref_object OtDeployment *booted_deployment = NULL; gs_unref_object OstreeDeployment *booted_deployment = NULL;
gs_unref_ptrarray GPtrArray *deployments = NULL; gs_unref_ptrarray GPtrArray *deployments = NULL;
guint i; guint i;
@ -77,15 +77,15 @@ ot_admin_builtin_status (int argc, char **argv, OstreeSysroot *sysroot, GCancell
for (i = 0; i < deployments->len; i++) for (i = 0; i < deployments->len; i++)
{ {
OtDeployment *deployment = deployments->pdata[i]; OstreeDeployment *deployment = deployments->pdata[i];
GKeyFile *origin; GKeyFile *origin;
g_print ("%c %s %s.%d\n", g_print ("%c %s %s.%d\n",
deployment == booted_deployment ? '*' : ' ', deployment == booted_deployment ? '*' : ' ',
ot_deployment_get_osname (deployment), ostree_deployment_get_osname (deployment),
ot_deployment_get_csum (deployment), ostree_deployment_get_csum (deployment),
ot_deployment_get_deployserial (deployment)); ostree_deployment_get_deployserial (deployment));
origin = ot_deployment_get_origin (deployment); origin = ostree_deployment_get_origin (deployment);
if (!origin) if (!origin)
g_print (" origin: none\n"); g_print (" origin: none\n");
else else

View File

@ -42,8 +42,8 @@ ot_admin_builtin_undeploy (int argc, char **argv, OstreeSysroot *sysroot, GCance
int deploy_index; int deploy_index;
int current_bootversion; int current_bootversion;
gs_unref_ptrarray GPtrArray *current_deployments = NULL; gs_unref_ptrarray GPtrArray *current_deployments = NULL;
gs_unref_object OtDeployment *booted_deployment = NULL; gs_unref_object OstreeDeployment *booted_deployment = NULL;
gs_unref_object OtDeployment *target_deployment = NULL; gs_unref_object OstreeDeployment *target_deployment = NULL;
context = g_option_context_new ("INDEX - Delete deployment INDEX"); context = g_option_context_new ("INDEX - Delete deployment INDEX");
@ -100,8 +100,8 @@ ot_admin_builtin_undeploy (int argc, char **argv, OstreeSysroot *sysroot, GCance
cancellable, error)) cancellable, error))
goto out; goto out;
g_print ("Deleted deployment %s.%d\n", ot_deployment_get_csum (target_deployment), g_print ("Deleted deployment %s.%d\n", ostree_deployment_get_csum (target_deployment),
ot_deployment_get_deployserial (target_deployment)); ostree_deployment_get_deployserial (target_deployment));
if (!ot_admin_cleanup (ostree_sysroot_get_path (sysroot), cancellable, error)) if (!ot_admin_cleanup (ostree_sysroot_get_path (sysroot), cancellable, error))
{ {

View File

@ -55,11 +55,11 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancel
gs_free char *new_revision = NULL; gs_free char *new_revision = NULL;
gs_unref_object GFile *deployment_path = NULL; gs_unref_object GFile *deployment_path = NULL;
gs_unref_object GFile *deployment_origin_path = NULL; gs_unref_object GFile *deployment_origin_path = NULL;
gs_unref_object OtDeployment *booted_deployment = NULL; gs_unref_object OstreeDeployment *booted_deployment = NULL;
gs_unref_object OtDeployment *merge_deployment = NULL; gs_unref_object OstreeDeployment *merge_deployment = NULL;
gs_unref_ptrarray GPtrArray *current_deployments = NULL; gs_unref_ptrarray GPtrArray *current_deployments = NULL;
gs_unref_ptrarray GPtrArray *new_deployments = NULL; gs_unref_ptrarray GPtrArray *new_deployments = NULL;
gs_unref_object OtDeployment *new_deployment = NULL; gs_unref_object OstreeDeployment *new_deployment = NULL;
int current_bootversion; int current_bootversion;
int new_bootversion; int new_bootversion;
GKeyFile *origin; GKeyFile *origin;
@ -84,7 +84,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancel
cancellable, error)) cancellable, error))
goto out; goto out;
if (!opt_osname) if (!opt_osname)
opt_osname = (char*)ot_deployment_get_osname (booted_deployment); opt_osname = (char*)ostree_deployment_get_osname (booted_deployment);
merge_deployment = ot_admin_get_merge_deployment (current_deployments, opt_osname, merge_deployment = ot_admin_get_merge_deployment (current_deployments, opt_osname,
booted_deployment); booted_deployment);
@ -96,7 +96,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancel
if (!ostree_repo_open (repo, cancellable, error)) if (!ostree_repo_open (repo, cancellable, error))
goto out; goto out;
origin = ot_deployment_get_origin (merge_deployment); origin = ostree_deployment_get_origin (merge_deployment);
if (!origin) if (!origin)
{ {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
@ -128,7 +128,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancel
error)) error))
goto out; goto out;
if (strcmp (ot_deployment_get_csum (merge_deployment), new_revision) == 0) if (strcmp (ostree_deployment_get_csum (merge_deployment), new_revision) == 0)
{ {
g_print ("Refspec %s is unchanged\n", origin_refspec); g_print ("Refspec %s is unchanged\n", origin_refspec);
} }

View File

@ -23,8 +23,6 @@
#include "config.h" #include "config.h"
#include "ot-admin-functions.h" #include "ot-admin-functions.h"
#include "ot-deployment.h"
#include "ot-config-parser.h"
#include "otutil.h" #include "otutil.h"
#include "ostree.h" #include "ostree.h"
#include "libgsystem.h" #include "libgsystem.h"
@ -65,7 +63,7 @@ list_deployment_dirs_for_os (GFile *osdir,
const char *name; const char *name;
GFileInfo *file_info = NULL; GFileInfo *file_info = NULL;
GFile *child = NULL; GFile *child = NULL;
gs_unref_object OtDeployment *deployment = NULL; gs_unref_object OstreeDeployment *deployment = NULL;
gs_free char *csum = NULL; gs_free char *csum = NULL;
gint deployserial; gint deployserial;
@ -83,7 +81,7 @@ list_deployment_dirs_for_os (GFile *osdir,
if (!ot_admin_parse_deploy_path_name (name, &csum, &deployserial, error)) if (!ot_admin_parse_deploy_path_name (name, &csum, &deployserial, error))
goto out; goto out;
deployment = ot_deployment_new (-1, osname, csum, deployserial, NULL, -1); deployment = ostree_deployment_new (-1, osname, csum, deployserial, NULL, -1);
g_ptr_array_add (inout_deployments, g_object_ref (deployment)); g_ptr_array_add (inout_deployments, g_object_ref (deployment));
} }
@ -315,9 +313,9 @@ cleanup_old_deployments (GFile *sysroot,
for (i = 0; i < deployments->len; i++) for (i = 0; i < deployments->len; i++)
{ {
OtDeployment *deployment = deployments->pdata[i]; OstreeDeployment *deployment = deployments->pdata[i];
GFile *deployment_path = ot_admin_get_deployment_directory (sysroot, deployment); GFile *deployment_path = ot_admin_get_deployment_directory (sysroot, deployment);
char *bootcsum = g_strdup (ot_deployment_get_bootcsum (deployment)); char *bootcsum = g_strdup (ostree_deployment_get_bootcsum (deployment));
/* Transfer ownership */ /* Transfer ownership */
g_hash_table_insert (active_deployment_dirs, deployment_path, deployment_path); g_hash_table_insert (active_deployment_dirs, deployment_path, deployment_path);
g_hash_table_insert (active_boot_checksums, bootcsum, bootcsum); g_hash_table_insert (active_boot_checksums, bootcsum, bootcsum);
@ -329,7 +327,7 @@ cleanup_old_deployments (GFile *sysroot,
for (i = 0; i < all_deployment_dirs->len; i++) for (i = 0; i < all_deployment_dirs->len; i++)
{ {
OtDeployment *deployment = all_deployment_dirs->pdata[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 *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 *origin_path = ot_admin_get_deployment_origin_path (deployment_path);
if (!g_hash_table_lookup (active_deployment_dirs, deployment_path)) if (!g_hash_table_lookup (active_deployment_dirs, deployment_path))
@ -453,7 +451,7 @@ generate_deployment_refs_and_prune (GFile *sysroot,
for (i = 0; i < deployments->len; i++) for (i = 0; i < deployments->len; i++)
{ {
OtDeployment *deployment = deployments->pdata[i]; OstreeDeployment *deployment = deployments->pdata[i];
gs_free char *refname = g_strdup_printf ("ostree/%d/%d/%u", gs_free char *refname = g_strdup_printf ("ostree/%d/%d/%u",
bootversion, subbootversion, bootversion, subbootversion,
i); i);
@ -461,7 +459,7 @@ generate_deployment_refs_and_prune (GFile *sysroot,
if (!ostree_repo_prepare_transaction (repo, NULL, cancellable, error)) if (!ostree_repo_prepare_transaction (repo, NULL, cancellable, error))
goto out; goto out;
ostree_repo_transaction_set_refspec (repo, refname, ot_deployment_get_csum (deployment)); ostree_repo_transaction_set_refspec (repo, refname, ostree_deployment_get_csum (deployment));
if (!ostree_repo_commit_transaction (repo, NULL, cancellable, error)) if (!ostree_repo_commit_transaction (repo, NULL, cancellable, error))
goto out; goto out;

View File

@ -24,8 +24,6 @@
#include "ot-admin-functions.h" #include "ot-admin-functions.h"
#include "ot-admin-deploy.h" #include "ot-admin-deploy.h"
#include "ot-deployment.h"
#include "ot-config-parser.h"
#include "ot-bootloader-syslinux.h" #include "ot-bootloader-syslinux.h"
#include "otutil.h" #include "otutil.h"
#include "ostree-core.h" #include "ostree-core.h"
@ -202,13 +200,13 @@ merge_etc_changes (GFile *orig_etc,
static gboolean static gboolean
checkout_deployment_tree (GFile *sysroot, checkout_deployment_tree (GFile *sysroot,
OstreeRepo *repo, OstreeRepo *repo,
OtDeployment *deployment, OstreeDeployment *deployment,
GFile **out_deployment_path, GFile **out_deployment_path,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
const char *csum = ot_deployment_get_csum (deployment); const char *csum = ostree_deployment_get_csum (deployment);
gs_unref_object GFile *root = NULL; gs_unref_object GFile *root = NULL;
gs_unref_object GFileInfo *file_info = NULL; gs_unref_object GFileInfo *file_info = NULL;
gs_free char *checkout_target_name = NULL; gs_free char *checkout_target_name = NULL;
@ -226,9 +224,9 @@ checkout_deployment_tree (GFile *sysroot,
goto out; goto out;
osdeploy_path = ot_gfile_get_child_build_path (sysroot, "ostree", "deploy", osdeploy_path = ot_gfile_get_child_build_path (sysroot, "ostree", "deploy",
ot_deployment_get_osname (deployment), ostree_deployment_get_osname (deployment),
"deploy", NULL); "deploy", NULL);
checkout_target_name = g_strdup_printf ("%s.%d", csum, ot_deployment_get_deployserial (deployment)); checkout_target_name = g_strdup_printf ("%s.%d", csum, ostree_deployment_get_deployserial (deployment));
deploy_target_path = g_file_get_child (osdeploy_path, checkout_target_name); deploy_target_path = g_file_get_child (osdeploy_path, checkout_target_name);
deploy_parent = g_file_get_parent (deploy_target_path); deploy_parent = g_file_get_parent (deploy_target_path);
@ -250,8 +248,8 @@ checkout_deployment_tree (GFile *sysroot,
static gboolean static gboolean
merge_configuration (GFile *sysroot, merge_configuration (GFile *sysroot,
OtDeployment *previous_deployment, OstreeDeployment *previous_deployment,
OtDeployment *deployment, OstreeDeployment *deployment,
GFile *deployment_path, GFile *deployment_path,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
@ -267,20 +265,20 @@ merge_configuration (GFile *sysroot,
if (previous_deployment) if (previous_deployment)
{ {
gs_unref_object GFile *previous_path = NULL; gs_unref_object GFile *previous_path = NULL;
OtConfigParser *previous_bootconfig; OstreeBootconfigParser *previous_bootconfig;
previous_path = ot_admin_get_deployment_directory (sysroot, previous_deployment); previous_path = ot_admin_get_deployment_directory (sysroot, previous_deployment);
source_etc_path = g_file_resolve_relative_path (previous_path, "etc"); source_etc_path = g_file_resolve_relative_path (previous_path, "etc");
source_etc_pristine_path = g_file_resolve_relative_path (previous_path, "usr/etc"); source_etc_pristine_path = g_file_resolve_relative_path (previous_path, "usr/etc");
previous_bootconfig = ot_deployment_get_bootconfig (previous_deployment); previous_bootconfig = ostree_deployment_get_bootconfig (previous_deployment);
if (previous_bootconfig) if (previous_bootconfig)
{ {
const char *previous_options = ot_config_parser_get (previous_bootconfig, "options"); const char *previous_options = ostree_bootconfig_parser_get (previous_bootconfig, "options");
/* Completely overwrite the previous options here; we will extend /* Completely overwrite the previous options here; we will extend
* them later. * them later.
*/ */
ot_config_parser_set (ot_deployment_get_bootconfig (deployment), "options", ostree_bootconfig_parser_set (ostree_deployment_get_bootconfig (deployment), "options",
previous_options); previous_options);
} }
} }
@ -334,12 +332,12 @@ merge_configuration (GFile *sysroot,
static gboolean static gboolean
write_origin_file (GFile *sysroot, write_origin_file (GFile *sysroot,
OtDeployment *deployment, OstreeDeployment *deployment,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
GKeyFile *origin = ot_deployment_get_origin (deployment); GKeyFile *origin = ostree_deployment_get_origin (deployment);
if (origin) if (origin)
{ {
@ -468,14 +466,14 @@ checksum_from_kernel_src (GFile *src,
static int static int
sort_by_bootserial (gconstpointer ap, gconstpointer bp) sort_by_bootserial (gconstpointer ap, gconstpointer bp)
{ {
OtDeployment **a_loc = (OtDeployment**)ap; OstreeDeployment **a_loc = (OstreeDeployment**)ap;
OtDeployment *a = *a_loc; OstreeDeployment *a = *a_loc;
OtDeployment **b_loc = (OtDeployment**)bp; OstreeDeployment **b_loc = (OstreeDeployment**)bp;
OtDeployment *b = *b_loc; OstreeDeployment *b = *b_loc;
if (ot_deployment_get_bootserial (a) == ot_deployment_get_bootserial (b)) if (ostree_deployment_get_bootserial (a) == ostree_deployment_get_bootserial (b))
return 0; return 0;
else if (ot_deployment_get_bootserial (a) < ot_deployment_get_bootserial (b)) else if (ostree_deployment_get_bootserial (a) < ostree_deployment_get_bootserial (b))
return -1; return -1;
return 1; return 1;
} }
@ -490,11 +488,11 @@ filter_deployments_by_bootcsum (GPtrArray *deployments,
for (i = 0; i < deployments->len; i++) for (i = 0; i < deployments->len; i++)
{ {
OtDeployment *deployment = deployments->pdata[i]; OstreeDeployment *deployment = deployments->pdata[i];
if (strcmp (ot_deployment_get_osname (deployment), osname) != 0) if (strcmp (ostree_deployment_get_osname (deployment), osname) != 0)
continue; continue;
if (strcmp (ot_deployment_get_bootcsum (deployment), bootcsum) != 0) if (strcmp (ostree_deployment_get_bootcsum (deployment), bootcsum) != 0)
continue; continue;
g_ptr_array_add (ret, deployment); g_ptr_array_add (ret, deployment);
@ -508,8 +506,8 @@ static void
compute_new_deployment_list (int current_bootversion, compute_new_deployment_list (int current_bootversion,
GPtrArray *current_deployments, GPtrArray *current_deployments,
const char *osname, const char *osname,
OtDeployment *booted_deployment, OstreeDeployment *booted_deployment,
OtDeployment *merge_deployment, OstreeDeployment *merge_deployment,
gboolean retain, gboolean retain,
const char *revision, const char *revision,
const char *bootcsum, const char *bootcsum,
@ -520,28 +518,28 @@ compute_new_deployment_list (int current_bootversion,
int new_index; int new_index;
guint new_deployserial = 0; guint new_deployserial = 0;
int new_bootserial = 0; int new_bootserial = 0;
gs_unref_object OtDeployment *new_deployment = NULL; gs_unref_object OstreeDeployment *new_deployment = NULL;
gs_unref_ptrarray GPtrArray *matching_deployments_by_bootserial = NULL; gs_unref_ptrarray GPtrArray *matching_deployments_by_bootserial = NULL;
OtDeployment *deployment_to_delete = NULL; OstreeDeployment *deployment_to_delete = NULL;
gs_unref_ptrarray GPtrArray *ret_new_deployments = NULL; gs_unref_ptrarray GPtrArray *ret_new_deployments = NULL;
gboolean requires_new_bootversion; gboolean requires_new_bootversion;
if (osname == NULL) if (osname == NULL)
osname = ot_deployment_get_osname (booted_deployment); osname = ostree_deployment_get_osname (booted_deployment);
/* First, compute the serial for this deployment; we look /* First, compute the serial for this deployment; we look
* for other ones in this os with the same checksum. * for other ones in this os with the same checksum.
*/ */
for (i = 0; i < current_deployments->len; i++) for (i = 0; i < current_deployments->len; i++)
{ {
OtDeployment *deployment = current_deployments->pdata[i]; OstreeDeployment *deployment = current_deployments->pdata[i];
if (strcmp (ot_deployment_get_osname (deployment), osname) != 0) if (strcmp (ostree_deployment_get_osname (deployment), osname) != 0)
continue; continue;
if (strcmp (ot_deployment_get_csum (deployment), revision) != 0) if (strcmp (ostree_deployment_get_csum (deployment), revision) != 0)
continue; continue;
new_deployserial = MAX(new_deployserial, ot_deployment_get_deployserial (deployment)+1); new_deployserial = MAX(new_deployserial, ostree_deployment_get_deployserial (deployment)+1);
} }
/* We retain by default (well, hardcoded now) one previous /* We retain by default (well, hardcoded now) one previous
@ -558,14 +556,14 @@ compute_new_deployment_list (int current_bootversion,
{ {
for (i = 0; i < current_deployments->len; i++) for (i = 0; i < current_deployments->len; i++)
{ {
OtDeployment *deployment = current_deployments->pdata[i]; OstreeDeployment *deployment = current_deployments->pdata[i];
if (strcmp (ot_deployment_get_osname (deployment), osname) != 0) if (strcmp (ostree_deployment_get_osname (deployment), osname) != 0)
continue; continue;
// Keep both the booted and merge deployments // Keep both the booted and merge deployments
if (ot_deployment_equal (deployment, booted_deployment) || if (ostree_deployment_equal (deployment, booted_deployment) ||
ot_deployment_equal (deployment, merge_deployment)) ostree_deployment_equal (deployment, merge_deployment))
continue; continue;
deployment_to_delete = deployment; deployment_to_delete = deployment;
@ -577,24 +575,24 @@ compute_new_deployment_list (int current_bootversion,
*/ */
requires_new_bootversion = requires_new_bootversion =
(deployment_to_delete == NULL) || (deployment_to_delete == NULL) ||
(strcmp (ot_deployment_get_bootcsum (deployment_to_delete), bootcsum) != 0); (strcmp (ostree_deployment_get_bootcsum (deployment_to_delete), bootcsum) != 0);
ret_new_deployments = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref); ret_new_deployments = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
new_deployment = ot_deployment_new (0, osname, revision, new_deployserial, new_deployment = ostree_deployment_new (0, osname, revision, new_deployserial,
bootcsum, new_bootserial); bootcsum, new_bootserial);
g_ptr_array_add (ret_new_deployments, g_object_ref (new_deployment)); g_ptr_array_add (ret_new_deployments, g_object_ref (new_deployment));
new_index = 1; new_index = 1;
for (i = 0; i < current_deployments->len; i++) for (i = 0; i < current_deployments->len; i++)
{ {
OtDeployment *orig_deployment = current_deployments->pdata[i]; OstreeDeployment *orig_deployment = current_deployments->pdata[i];
gs_unref_object OtDeployment *deployment_clone = NULL; gs_unref_object OstreeDeployment *deployment_clone = NULL;
if (orig_deployment == deployment_to_delete) if (orig_deployment == deployment_to_delete)
continue; continue;
deployment_clone = ot_deployment_clone (orig_deployment); deployment_clone = ostree_deployment_clone (orig_deployment);
ot_deployment_set_index (deployment_clone, new_index); ostree_deployment_set_index (deployment_clone, new_index);
new_index++; new_index++;
g_ptr_array_add (ret_new_deployments, g_object_ref (deployment_clone)); g_ptr_array_add (ret_new_deployments, g_object_ref (deployment_clone));
} }
@ -606,8 +604,8 @@ compute_new_deployment_list (int current_bootversion,
osname, bootcsum); osname, bootcsum);
for (i = 0; i < matching_deployments_by_bootserial->len; i++) for (i = 0; i < matching_deployments_by_bootserial->len; i++)
{ {
OtDeployment *deployment = matching_deployments_by_bootserial->pdata[i]; OstreeDeployment *deployment = matching_deployments_by_bootserial->pdata[i];
ot_deployment_set_bootserial (deployment, i); ostree_deployment_set_bootserial (deployment, i);
} }
*out_new_deployments = ret_new_deployments; *out_new_deployments = ret_new_deployments;
@ -671,15 +669,15 @@ print_deployment_set (gboolean for_removal,
g_hash_table_iter_init (&hashiter, set); g_hash_table_iter_init (&hashiter, set);
while (g_hash_table_iter_next (&hashiter, &hashkey, &hashvalue)) while (g_hash_table_iter_next (&hashiter, &hashkey, &hashvalue))
{ {
OtDeployment *deployment = hashkey; OstreeDeployment *deployment = hashkey;
g_print (" %c %s %s.%d", g_print (" %c %s %s.%d",
for_removal ? '-' : '+', ot_deployment_get_osname (deployment), for_removal ? '-' : '+', ostree_deployment_get_osname (deployment),
ot_deployment_get_csum (deployment), ostree_deployment_get_csum (deployment),
ot_deployment_get_deployserial (deployment)); ostree_deployment_get_deployserial (deployment));
if (!for_removal) if (!for_removal)
g_print (" index=%d", ot_deployment_get_index (deployment)); g_print (" index=%d", ostree_deployment_get_index (deployment));
g_print ("\n"); g_print ("\n");
} }
} }
@ -688,8 +686,8 @@ static void
print_deployment_diff (GPtrArray *current_deployments, print_deployment_diff (GPtrArray *current_deployments,
GPtrArray *new_deployments) GPtrArray *new_deployments)
{ {
gs_unref_hashtable GHashTable *curset = object_array_to_set (current_deployments, ot_deployment_hash, ot_deployment_equal); gs_unref_hashtable GHashTable *curset = object_array_to_set (current_deployments, ostree_deployment_hash, ostree_deployment_equal);
gs_unref_hashtable GHashTable *newset = object_array_to_set (new_deployments, ot_deployment_hash, ot_deployment_equal); gs_unref_hashtable GHashTable *newset = object_array_to_set (new_deployments, ostree_deployment_hash, ostree_deployment_equal);
gs_unref_hashtable GHashTable *removed = NULL; gs_unref_hashtable GHashTable *removed = NULL;
gs_unref_hashtable GHashTable *added = NULL; gs_unref_hashtable GHashTable *added = NULL;
@ -743,15 +741,15 @@ swap_bootlinks (GFile *sysroot,
for (i = 0; i < new_deployments->len; i++) for (i = 0; i < new_deployments->len; i++)
{ {
OtDeployment *deployment = new_deployments->pdata[i]; OstreeDeployment *deployment = new_deployments->pdata[i];
gs_free char *bootlink_pathname = g_strdup_printf ("%s/%s/%d", gs_free char *bootlink_pathname = g_strdup_printf ("%s/%s/%d",
ot_deployment_get_osname (deployment), ostree_deployment_get_osname (deployment),
ot_deployment_get_bootcsum (deployment), ostree_deployment_get_bootcsum (deployment),
ot_deployment_get_bootserial (deployment)); ostree_deployment_get_bootserial (deployment));
gs_free char *bootlink_target = g_strdup_printf ("../../../deploy/%s/deploy/%s.%d", gs_free char *bootlink_target = g_strdup_printf ("../../../deploy/%s/deploy/%s.%d",
ot_deployment_get_osname (deployment), ostree_deployment_get_osname (deployment),
ot_deployment_get_csum (deployment), ostree_deployment_get_csum (deployment),
ot_deployment_get_deployserial (deployment)); ostree_deployment_get_deployserial (deployment));
gs_unref_object GFile *linkname = g_file_get_child (ostree_subbootdir, bootlink_pathname); gs_unref_object GFile *linkname = g_file_get_child (ostree_subbootdir, bootlink_pathname);
gs_unref_object GFile *linkname_parent = g_file_get_parent (linkname); gs_unref_object GFile *linkname_parent = g_file_get_parent (linkname);
@ -822,15 +820,15 @@ parse_os_release (const char *contents,
static gboolean static gboolean
install_deployment_kernel (GFile *sysroot, install_deployment_kernel (GFile *sysroot,
int new_bootversion, int new_bootversion,
OtDeployment *deployment, OstreeDeployment *deployment,
guint n_deployments, guint n_deployments,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
const char *osname = ot_deployment_get_osname (deployment); const char *osname = ostree_deployment_get_osname (deployment);
const char *bootcsum = ot_deployment_get_bootcsum (deployment); const char *bootcsum = ostree_deployment_get_bootcsum (deployment);
gs_unref_object GFile *bootdir = NULL; gs_unref_object GFile *bootdir = NULL;
gs_unref_object GFile *bootcsumdir = NULL; gs_unref_object GFile *bootcsumdir = NULL;
gs_unref_object GFile *bootconfpath = NULL; gs_unref_object GFile *bootconfpath = NULL;
@ -854,10 +852,10 @@ install_deployment_kernel (GFile *sysroot,
gs_free char *options_key = NULL; gs_free char *options_key = NULL;
__attribute__((cleanup(ot_ordered_hash_cleanup))) OtOrderedHash *ohash = NULL; __attribute__((cleanup(ot_ordered_hash_cleanup))) OtOrderedHash *ohash = NULL;
const char *val; const char *val;
OtConfigParser *bootconfig; OstreeBootconfigParser *bootconfig;
gsize len; gsize len;
bootconfig = ot_deployment_get_bootconfig (deployment); bootconfig = ostree_deployment_get_bootconfig (deployment);
deployment_dir = ot_admin_get_deployment_directory (sysroot, deployment); deployment_dir = ot_admin_get_deployment_directory (sysroot, deployment);
if (!get_kernel_from_tree (deployment_dir, &tree_kernel_path, &tree_initramfs_path, if (!get_kernel_from_tree (deployment_dir, &tree_kernel_path, &tree_initramfs_path,
@ -870,8 +868,8 @@ install_deployment_kernel (GFile *sysroot,
bootcsum); bootcsum);
bootconfpath = ot_gfile_resolve_path_printf (bootdir, "loader.%d/entries/ostree-%s-%s-%d.conf", bootconfpath = ot_gfile_resolve_path_printf (bootdir, "loader.%d/entries/ostree-%s-%s-%d.conf",
new_bootversion, osname, new_bootversion, osname,
ot_deployment_get_csum (deployment), ostree_deployment_get_csum (deployment),
ot_deployment_get_bootserial (deployment)); ostree_deployment_get_bootserial (deployment));
if (!gs_file_ensure_directory (bootcsumdir, TRUE, cancellable, error)) if (!gs_file_ensure_directory (bootcsumdir, TRUE, cancellable, error))
goto out; goto out;
@ -925,35 +923,35 @@ install_deployment_kernel (GFile *sysroot,
goto out; goto out;
} }
title_key = g_strdup_printf ("ostree:%s:%d %s", ot_deployment_get_osname (deployment), title_key = g_strdup_printf ("ostree:%s:%d %s", ostree_deployment_get_osname (deployment),
ot_deployment_get_index (deployment), ostree_deployment_get_index (deployment),
val); val);
ot_config_parser_set (bootconfig, "title", title_key); ostree_bootconfig_parser_set (bootconfig, "title", title_key);
version_key = g_strdup_printf ("%d", n_deployments - ot_deployment_get_index (deployment)); version_key = g_strdup_printf ("%d", n_deployments - ostree_deployment_get_index (deployment));
ot_config_parser_set (bootconfig, "version", version_key); ostree_bootconfig_parser_set (bootconfig, "version", version_key);
linux_relpath = g_file_get_relative_path (bootdir, dest_kernel_path); linux_relpath = g_file_get_relative_path (bootdir, dest_kernel_path);
linux_key = g_strconcat ("/", linux_relpath, NULL); linux_key = g_strconcat ("/", linux_relpath, NULL);
ot_config_parser_set (bootconfig, "linux", linux_key); ostree_bootconfig_parser_set (bootconfig, "linux", linux_key);
if (dest_initramfs_path) if (dest_initramfs_path)
{ {
initramfs_relpath = g_file_get_relative_path (bootdir, dest_initramfs_path); initramfs_relpath = g_file_get_relative_path (bootdir, dest_initramfs_path);
initrd_key = g_strconcat ("/", initramfs_relpath, NULL); initrd_key = g_strconcat ("/", initramfs_relpath, NULL);
ot_config_parser_set (bootconfig, "initrd", initrd_key); ostree_bootconfig_parser_set (bootconfig, "initrd", initrd_key);
} }
val = ot_config_parser_get (bootconfig, "options"); val = ostree_bootconfig_parser_get (bootconfig, "options");
ostree_kernel_arg = g_strdup_printf ("/ostree/boot.%d/%s/%s/%d", ostree_kernel_arg = g_strdup_printf ("/ostree/boot.%d/%s/%s/%d",
new_bootversion, osname, bootcsum, new_bootversion, osname, bootcsum,
ot_deployment_get_bootserial (deployment)); ostree_deployment_get_bootserial (deployment));
ohash = ot_admin_parse_kernel_args (val); ohash = ot_admin_parse_kernel_args (val);
ot_ordered_hash_replace_key (ohash, "ostree", ostree_kernel_arg); ot_ordered_hash_replace_key (ohash, "ostree", ostree_kernel_arg);
options_key = ot_admin_kernel_arg_string_serialize (ohash); options_key = ot_admin_kernel_arg_string_serialize (ohash);
ot_config_parser_set (bootconfig, "options", options_key); ostree_bootconfig_parser_set (bootconfig, "options", options_key);
if (!ot_config_parser_write (ot_deployment_get_bootconfig (deployment), bootconfpath, if (!ostree_bootconfig_parser_write (ostree_deployment_get_bootconfig (deployment), bootconfpath,
cancellable, error)) cancellable, error))
goto out; goto out;
@ -1025,7 +1023,7 @@ ot_admin_write_deployments (GFile *sysroot,
{ {
for (i = 0; i < new_deployments->len; i++) for (i = 0; i < new_deployments->len; i++)
{ {
OtDeployment *deployment = new_deployments->pdata[i]; OstreeDeployment *deployment = new_deployments->pdata[i];
if (!install_deployment_kernel (sysroot, new_bootversion, if (!install_deployment_kernel (sysroot, new_bootversion,
deployment, new_deployments->len, deployment, new_deployments->len,
cancellable, error)) cancellable, error))
@ -1078,24 +1076,24 @@ ot_admin_deploy (GFile *sysroot,
GKeyFile *origin, GKeyFile *origin,
char **add_kernel_argv, char **add_kernel_argv,
gboolean retain, gboolean retain,
OtDeployment *booted_deployment, OstreeDeployment *booted_deployment,
OtDeployment *provided_merge_deployment, OstreeDeployment *provided_merge_deployment,
OtDeployment **out_new_deployment, OstreeDeployment **out_new_deployment,
int *out_new_bootversion, int *out_new_bootversion,
GPtrArray **out_new_deployments, GPtrArray **out_new_deployments,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
OtDeployment *new_deployment; OstreeDeployment *new_deployment;
gs_unref_object OtDeployment *merge_deployment = NULL; gs_unref_object OstreeDeployment *merge_deployment = NULL;
gs_unref_object OstreeRepo *repo = NULL; gs_unref_object OstreeRepo *repo = NULL;
gs_unref_object GFile *commit_root = NULL; gs_unref_object GFile *commit_root = NULL;
gs_unref_object GFile *tree_kernel_path = NULL; gs_unref_object GFile *tree_kernel_path = NULL;
gs_unref_object GFile *tree_initramfs_path = NULL; gs_unref_object GFile *tree_initramfs_path = NULL;
gs_unref_object GFile *new_deployment_path = NULL; gs_unref_object GFile *new_deployment_path = NULL;
gs_free char *new_bootcsum = NULL; gs_free char *new_bootcsum = NULL;
gs_unref_object OtConfigParser *bootconfig = NULL; gs_unref_object OstreeBootconfigParser *bootconfig = NULL;
gs_unref_ptrarray GPtrArray *new_deployments = NULL; gs_unref_ptrarray GPtrArray *new_deployments = NULL;
int new_bootversion; int new_bootversion;
@ -1151,7 +1149,7 @@ ot_admin_deploy (GFile *sysroot,
&new_deployments, &new_deployments,
&new_bootversion); &new_bootversion);
new_deployment = g_object_ref (new_deployments->pdata[0]); new_deployment = g_object_ref (new_deployments->pdata[0]);
ot_deployment_set_origin (new_deployment, origin); ostree_deployment_set_origin (new_deployment, origin);
print_deployment_diff (current_deployments, new_deployments); print_deployment_diff (current_deployments, new_deployments);
@ -1172,8 +1170,8 @@ ot_admin_deploy (GFile *sysroot,
/* Create an empty boot configuration; we will merge things into /* Create an empty boot configuration; we will merge things into
* it as we go. * it as we go.
*/ */
bootconfig = ot_config_parser_new (" "); bootconfig = ostree_bootconfig_parser_new ();
ot_deployment_set_bootconfig (new_deployment, bootconfig); ostree_deployment_set_bootconfig (new_deployment, bootconfig);
if (!merge_configuration (sysroot, merge_deployment, new_deployment, if (!merge_configuration (sysroot, merge_deployment, new_deployment,
new_deployment_path, new_deployment_path,
@ -1196,7 +1194,7 @@ ot_admin_deploy (GFile *sysroot,
__attribute__((cleanup(ot_ordered_hash_cleanup))) OtOrderedHash *ohash = NULL; __attribute__((cleanup(ot_ordered_hash_cleanup))) OtOrderedHash *ohash = NULL;
gs_free char *new_options = NULL; gs_free char *new_options = NULL;
ohash = ot_admin_parse_kernel_args (ot_config_parser_get (bootconfig, "options")); ohash = ot_admin_parse_kernel_args (ostree_bootconfig_parser_get (bootconfig, "options"));
for (strviter = add_kernel_argv; *strviter; strviter++) for (strviter = add_kernel_argv; *strviter; strviter++)
{ {
@ -1207,7 +1205,7 @@ ot_admin_deploy (GFile *sysroot,
} }
new_options = ot_admin_kernel_arg_string_serialize (ohash); new_options = ot_admin_kernel_arg_string_serialize (ohash);
ot_config_parser_set (bootconfig, "options", new_options); ostree_bootconfig_parser_set (bootconfig, "options", new_options);
} }
if (!ot_admin_write_deployments (sysroot, current_bootversion, new_bootversion, if (!ot_admin_write_deployments (sysroot, current_bootversion, new_bootversion,
@ -1222,7 +1220,7 @@ ot_admin_deploy (GFile *sysroot,
* done from the host. * done from the host.
*/ */
{ {
gs_unref_object GFile *osdir = ot_gfile_resolve_path_printf (sysroot, "ostree/deploy/%s", ot_deployment_get_osname (new_deployment)); gs_unref_object GFile *osdir = ot_gfile_resolve_path_printf (sysroot, "ostree/deploy/%s", ostree_deployment_get_osname (new_deployment));
gs_unref_object GFile *os_current_path = g_file_get_child (osdir, "current"); gs_unref_object GFile *os_current_path = g_file_get_child (osdir, "current");
gs_free char *target = g_file_get_relative_path (osdir, new_deployment_path); gs_free char *target = g_file_get_relative_path (osdir, new_deployment_path);
g_assert (target != NULL); g_assert (target != NULL);

View File

@ -23,7 +23,7 @@
#pragma once #pragma once
#include <gio/gio.h> #include <gio/gio.h>
#include "ot-deployment.h" #include <ostree.h>
#include "ot-bootloader.h" #include "ot-bootloader.h"
#include "ot-ordered-hash.h" #include "ot-ordered-hash.h"
@ -44,9 +44,9 @@ gboolean ot_admin_deploy (GFile *sysroot,
GKeyFile *origin, GKeyFile *origin,
char **add_kernel_argv, char **add_kernel_argv,
gboolean retain, gboolean retain,
OtDeployment *booted_deployment, OstreeDeployment *booted_deployment,
OtDeployment *merge_deployment, OstreeDeployment *merge_deployment,
OtDeployment **out_new_deployment, OstreeDeployment **out_new_deployment,
int *out_new_bootversion, int *out_new_bootversion,
GPtrArray **out_new_deployments, GPtrArray **out_new_deployments,
GCancellable *cancellable, GCancellable *cancellable,

View File

@ -23,8 +23,6 @@
#include "config.h" #include "config.h"
#include "ot-admin-functions.h" #include "ot-admin-functions.h"
#include "ot-deployment.h"
#include "ot-config-parser.h"
#include "ot-bootloader-syslinux.h" #include "ot-bootloader-syslinux.h"
#include "ot-bootloader-uboot.h" #include "ot-bootloader-uboot.h"
#include "otutil.h" #include "otutil.h"
@ -281,13 +279,13 @@ parse_origin (GFile *sysroot,
static gboolean static gboolean
parse_deployment (GFile *sysroot, parse_deployment (GFile *sysroot,
const char *boot_link, const char *boot_link,
OtDeployment **out_deployment, OstreeDeployment **out_deployment,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
const char *relative_boot_link; const char *relative_boot_link;
gs_unref_object OtDeployment *ret_deployment = NULL; gs_unref_object OstreeDeployment *ret_deployment = NULL;
int entry_boot_version; int entry_boot_version;
int treebootserial = -1; int treebootserial = -1;
int deployserial = -1; int deployserial = -1;
@ -326,10 +324,10 @@ parse_deployment (GFile *sysroot,
cancellable, error)) cancellable, error))
goto out; goto out;
ret_deployment = ot_deployment_new (-1, osname, treecsum, deployserial, ret_deployment = ostree_deployment_new (-1, osname, treecsum, deployserial,
bootcsum, treebootserial); bootcsum, treebootserial);
if (origin) if (origin)
ot_deployment_set_origin (ret_deployment, origin); ostree_deployment_set_origin (ret_deployment, origin);
ret = TRUE; ret = TRUE;
ot_transfer_out_value (out_deployment, &ret_deployment); ot_transfer_out_value (out_deployment, &ret_deployment);
@ -362,7 +360,7 @@ parse_kernel_commandline (OtOrderedHash **out_args,
/** /**
* ot_admin_find_booted_deployment: * ot_admin_find_booted_deployment:
* @target_sysroot: Root directory * @target_sysroot: Root directory
* @deployments: (element-type OtDeployment): Loaded deployments * @deployments: (element-type OstreeDeployment): Loaded deployments
* @out_deployment: (out): The currently booted deployment * @out_deployment: (out): The currently booted deployment
* @cancellable: * @cancellable:
* @error: * @error:
@ -374,13 +372,13 @@ parse_kernel_commandline (OtOrderedHash **out_args,
gboolean gboolean
ot_admin_find_booted_deployment (GFile *target_sysroot, ot_admin_find_booted_deployment (GFile *target_sysroot,
GPtrArray *deployments, GPtrArray *deployments,
OtDeployment **out_deployment, OstreeDeployment **out_deployment,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
gs_unref_object GFile *active_root = g_file_new_for_path ("/"); gs_unref_object GFile *active_root = g_file_new_for_path ("/");
gs_unref_object OtDeployment *ret_deployment = NULL; gs_unref_object OstreeDeployment *ret_deployment = NULL;
if (g_file_equal (active_root, target_sysroot)) if (g_file_equal (active_root, target_sysroot))
{ {
@ -402,7 +400,7 @@ ot_admin_find_booted_deployment (GFile *target_sysroot,
{ {
for (i = 0; i < deployments->len; i++) for (i = 0; i < deployments->len; i++)
{ {
OtDeployment *deployment = deployments->pdata[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 = ot_admin_get_deployment_directory (active_root, deployment);
guint32 device; guint32 device;
guint64 inode; guint64 inode;
@ -440,12 +438,12 @@ gboolean
ot_admin_require_deployment_or_osname (GFile *sysroot, ot_admin_require_deployment_or_osname (GFile *sysroot,
GPtrArray *deployments, GPtrArray *deployments,
const char *osname, const char *osname,
OtDeployment **out_deployment, OstreeDeployment **out_deployment,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
gs_unref_object OtDeployment *ret_deployment = NULL; gs_unref_object OstreeDeployment *ret_deployment = NULL;
if (!ot_admin_find_booted_deployment (sysroot, deployments, &ret_deployment, if (!ot_admin_find_booted_deployment (sysroot, deployments, &ret_deployment,
cancellable, error)) cancellable, error))
@ -464,18 +462,18 @@ ot_admin_require_deployment_or_osname (GFile *sysroot,
return ret; return ret;
} }
OtDeployment * OstreeDeployment *
ot_admin_get_merge_deployment (GPtrArray *deployments, ot_admin_get_merge_deployment (GPtrArray *deployments,
const char *osname, const char *osname,
OtDeployment *booted_deployment) OstreeDeployment *booted_deployment)
{ {
g_return_val_if_fail (osname != NULL || booted_deployment != NULL, NULL); g_return_val_if_fail (osname != NULL || booted_deployment != NULL, NULL);
if (osname == NULL) if (osname == NULL)
osname = ot_deployment_get_osname (booted_deployment); osname = ostree_deployment_get_osname (booted_deployment);
if (booted_deployment && if (booted_deployment &&
g_strcmp0 (ot_deployment_get_osname (booted_deployment), osname) == 0) g_strcmp0 (ostree_deployment_get_osname (booted_deployment), osname) == 0)
{ {
return g_object_ref (booted_deployment); return g_object_ref (booted_deployment);
} }
@ -484,9 +482,9 @@ ot_admin_get_merge_deployment (GPtrArray *deployments,
guint i; guint i;
for (i = 0; i < deployments->len; i++) for (i = 0; i < deployments->len; i++)
{ {
OtDeployment *deployment = deployments->pdata[i]; OstreeDeployment *deployment = deployments->pdata[i];
if (strcmp (ot_deployment_get_osname (deployment), osname) != 0) if (strcmp (ostree_deployment_get_osname (deployment), osname) != 0)
continue; continue;
return g_object_ref (deployment); return g_object_ref (deployment);
@ -637,9 +635,9 @@ ot_admin_read_boot_loader_configs (GFile *sysroot,
g_str_has_suffix (name, ".conf") && g_str_has_suffix (name, ".conf") &&
g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR) g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR)
{ {
gs_unref_object OtConfigParser *config = ot_config_parser_new (" \t"); gs_unref_object OstreeBootconfigParser *config = ostree_bootconfig_parser_new ();
if (!ot_config_parser_parse (config, child, cancellable, error)) if (!ostree_bootconfig_parser_parse (config, child, cancellable, error))
{ {
g_prefix_error (error, "Parsing %s: ", gs_file_get_path_cached (child)); g_prefix_error (error, "Parsing %s: ", gs_file_get_path_cached (child));
goto out; goto out;
@ -657,13 +655,13 @@ ot_admin_read_boot_loader_configs (GFile *sysroot,
} }
static char * static char *
get_ostree_kernel_arg_from_config (OtConfigParser *config) get_ostree_kernel_arg_from_config (OstreeBootconfigParser *config)
{ {
const char *options; const char *options;
char *ret = NULL; char *ret = NULL;
char **opts, **iter; char **opts, **iter;
options = ot_config_parser_get (config, "options"); options = ostree_bootconfig_parser_get (config, "options");
if (!options) if (!options)
return NULL; return NULL;
@ -684,14 +682,14 @@ get_ostree_kernel_arg_from_config (OtConfigParser *config)
static gboolean static gboolean
list_deployments_process_one_boot_entry (GFile *sysroot, list_deployments_process_one_boot_entry (GFile *sysroot,
OtConfigParser *config, OstreeBootconfigParser *config,
GPtrArray *inout_deployments, GPtrArray *inout_deployments,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
gs_free char *ostree_arg = NULL; gs_free char *ostree_arg = NULL;
gs_unref_object OtDeployment *deployment = NULL; gs_unref_object OstreeDeployment *deployment = NULL;
ostree_arg = get_ostree_kernel_arg_from_config (config); ostree_arg = get_ostree_kernel_arg_from_config (config);
if (ostree_arg == NULL) if (ostree_arg == NULL)
@ -705,7 +703,7 @@ list_deployments_process_one_boot_entry (GFile *sysroot,
cancellable, error)) cancellable, error))
goto out; goto out;
ot_deployment_set_bootconfig (deployment, config); ostree_deployment_set_bootconfig (deployment, config);
g_ptr_array_add (inout_deployments, g_object_ref (deployment)); g_ptr_array_add (inout_deployments, g_object_ref (deployment));
@ -718,12 +716,12 @@ static gint
compare_deployments_by_boot_loader_version_reversed (gconstpointer a_pp, compare_deployments_by_boot_loader_version_reversed (gconstpointer a_pp,
gconstpointer b_pp) gconstpointer b_pp)
{ {
OtDeployment *a = *((OtDeployment**)a_pp); OstreeDeployment *a = *((OstreeDeployment**)a_pp);
OtDeployment *b = *((OtDeployment**)b_pp); OstreeDeployment *b = *((OstreeDeployment**)b_pp);
OtConfigParser *a_bootconfig = ot_deployment_get_bootconfig (a); OstreeBootconfigParser *a_bootconfig = ostree_deployment_get_bootconfig (a);
OtConfigParser *b_bootconfig = ot_deployment_get_bootconfig (b); OstreeBootconfigParser *b_bootconfig = ostree_deployment_get_bootconfig (b);
const char *a_version = ot_config_parser_get (a_bootconfig, "version"); const char *a_version = ostree_bootconfig_parser_get (a_bootconfig, "version");
const char *b_version = ot_config_parser_get (b_bootconfig, "version"); const char *b_version = ostree_bootconfig_parser_get (b_bootconfig, "version");
if (a_version && b_version) if (a_version && b_version)
{ {
@ -761,7 +759,7 @@ ot_admin_list_deployments (GFile *sysroot,
for (i = 0; i < boot_loader_configs->len; i++) for (i = 0; i < boot_loader_configs->len; i++)
{ {
OtConfigParser *config = boot_loader_configs->pdata[i]; OstreeBootconfigParser *config = boot_loader_configs->pdata[i];
if (!list_deployments_process_one_boot_entry (sysroot, config, ret_deployments, if (!list_deployments_process_one_boot_entry (sysroot, config, ret_deployments,
cancellable, error)) cancellable, error))
@ -771,8 +769,8 @@ ot_admin_list_deployments (GFile *sysroot,
g_ptr_array_sort (ret_deployments, compare_deployments_by_boot_loader_version_reversed); g_ptr_array_sort (ret_deployments, compare_deployments_by_boot_loader_version_reversed);
for (i = 0; i < ret_deployments->len; i++) for (i = 0; i < ret_deployments->len; i++)
{ {
OtDeployment *deployment = ret_deployments->pdata[i]; OstreeDeployment *deployment = ret_deployments->pdata[i];
ot_deployment_set_index (deployment, i); ostree_deployment_set_index (deployment, i);
} }
ret = TRUE; ret = TRUE;
@ -784,12 +782,12 @@ ot_admin_list_deployments (GFile *sysroot,
GFile * GFile *
ot_admin_get_deployment_directory (GFile *sysroot, ot_admin_get_deployment_directory (GFile *sysroot,
OtDeployment *deployment) OstreeDeployment *deployment)
{ {
gs_free char *path = g_strdup_printf ("ostree/deploy/%s/deploy/%s.%d", gs_free char *path = g_strdup_printf ("ostree/deploy/%s/deploy/%s.%d",
ot_deployment_get_osname (deployment), ostree_deployment_get_osname (deployment),
ot_deployment_get_csum (deployment), ostree_deployment_get_csum (deployment),
ot_deployment_get_deployserial (deployment)); ostree_deployment_get_deployserial (deployment));
return g_file_resolve_relative_path (sysroot, path); return g_file_resolve_relative_path (sysroot, path);
} }

View File

@ -23,8 +23,7 @@
#pragma once #pragma once
#include <gio/gio.h> #include <gio/gio.h>
#include "ostree.h" #include <ostree.h>
#include "ot-deployment.h"
#include "ot-bootloader.h" #include "ot-bootloader.h"
#include "ot-ordered-hash.h" #include "ot-ordered-hash.h"
@ -79,30 +78,30 @@ gboolean ot_admin_list_deployments (GFile *sysroot,
gboolean ot_admin_find_booted_deployment (GFile *sysroot, gboolean ot_admin_find_booted_deployment (GFile *sysroot,
GPtrArray *deployments, GPtrArray *deployments,
OtDeployment **out_deployment, OstreeDeployment **out_deployment,
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);
gboolean ot_admin_require_booted_deployment (GFile *sysroot, gboolean ot_admin_require_booted_deployment (GFile *sysroot,
OtDeployment **out_deployment, OstreeDeployment **out_deployment,
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);
gboolean ot_admin_require_deployment_or_osname (GFile *sysroot, gboolean ot_admin_require_deployment_or_osname (GFile *sysroot,
GPtrArray *deployment_list, GPtrArray *deployment_list,
const char *osname, const char *osname,
OtDeployment **out_deployment, OstreeDeployment **out_deployment,
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);
OtDeployment *ot_admin_get_merge_deployment (GPtrArray *deployment_list, OstreeDeployment *ot_admin_get_merge_deployment (GPtrArray *deployment_list,
const char *osname, const char *osname,
OtDeployment *booted_deployment); OstreeDeployment *booted_deployment);
GFile *ot_admin_get_deployment_origin_path (GFile *deployment_path); GFile *ot_admin_get_deployment_origin_path (GFile *deployment_path);
GFile *ot_admin_get_deployment_directory (GFile *sysroot, GFile *ot_admin_get_deployment_directory (GFile *sysroot,
OtDeployment *deployment); OstreeDeployment *deployment);
gboolean ot_admin_get_repo (GFile *sysroot, gboolean ot_admin_get_repo (GFile *sysroot,
OstreeRepo **out_repo, OstreeRepo **out_repo,

View File

@ -73,10 +73,10 @@ append_config_from_boot_loader_entries (OtBootloaderSyslinux *self,
for (i = 0; i < boot_loader_configs->len; i++) for (i = 0; i < boot_loader_configs->len; i++)
{ {
OtConfigParser *config = boot_loader_configs->pdata[i]; OstreeBootconfigParser *config = boot_loader_configs->pdata[i];
const char *val; const char *val;
val = ot_config_parser_get (config, "title"); val = ostree_bootconfig_parser_get (config, "title");
if (!val) if (!val)
val = "(Untitled)"; val = "(Untitled)";
@ -87,7 +87,7 @@ append_config_from_boot_loader_entries (OtBootloaderSyslinux *self,
g_ptr_array_add (new_lines, g_strdup_printf ("LABEL %s", val)); g_ptr_array_add (new_lines, g_strdup_printf ("LABEL %s", val));
val = ot_config_parser_get (config, "linux"); val = ostree_bootconfig_parser_get (config, "linux");
if (!val) if (!val)
{ {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
@ -96,11 +96,11 @@ append_config_from_boot_loader_entries (OtBootloaderSyslinux *self,
} }
g_ptr_array_add (new_lines, g_strdup_printf ("\tKERNEL %s", val)); g_ptr_array_add (new_lines, g_strdup_printf ("\tKERNEL %s", val));
val = ot_config_parser_get (config, "initrd"); val = ostree_bootconfig_parser_get (config, "initrd");
if (val) if (val)
g_ptr_array_add (new_lines, g_strdup_printf ("\tINITRD %s", val)); g_ptr_array_add (new_lines, g_strdup_printf ("\tINITRD %s", val));
val = ot_config_parser_get (config, "options"); val = ostree_bootconfig_parser_get (config, "options");
if (val) if (val)
g_ptr_array_add (new_lines, g_strdup_printf ("\tAPPEND %s", val)); g_ptr_array_add (new_lines, g_strdup_printf ("\tAPPEND %s", val));
} }

View File

@ -67,7 +67,7 @@ create_config_from_boot_loader_entries (OtBootloaderUboot *self,
GError **error) GError **error)
{ {
gs_unref_ptrarray GPtrArray *boot_loader_configs = NULL; gs_unref_ptrarray GPtrArray *boot_loader_configs = NULL;
OtConfigParser *config; OstreeBootconfigParser *config;
const char *val; const char *val;
if (!ot_admin_read_boot_loader_configs (self->sysroot, bootversion, &boot_loader_configs, if (!ot_admin_read_boot_loader_configs (self->sysroot, bootversion, &boot_loader_configs,
@ -77,7 +77,7 @@ create_config_from_boot_loader_entries (OtBootloaderUboot *self,
/* U-Boot doesn't support a menu so just pick the first one since the list is ordered */ /* U-Boot doesn't support a menu so just pick the first one since the list is ordered */
config = boot_loader_configs->pdata[0]; config = boot_loader_configs->pdata[0];
val = ot_config_parser_get (config, "linux"); val = ostree_bootconfig_parser_get (config, "linux");
if (!val) if (!val)
{ {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
@ -86,11 +86,11 @@ create_config_from_boot_loader_entries (OtBootloaderUboot *self,
} }
g_ptr_array_add (new_lines, g_strdup_printf ("kernel_image=%s", val)); g_ptr_array_add (new_lines, g_strdup_printf ("kernel_image=%s", val));
val = ot_config_parser_get (config, "initrd"); val = ostree_bootconfig_parser_get (config, "initrd");
if (val) if (val)
g_ptr_array_add (new_lines, g_strdup_printf ("ramdisk_image=%s", val)); g_ptr_array_add (new_lines, g_strdup_printf ("ramdisk_image=%s", val));
val = ot_config_parser_get (config, "options"); val = ostree_bootconfig_parser_get (config, "options");
if (val) if (val)
g_ptr_array_add (new_lines, g_strdup_printf ("bootargs=%s", val)); g_ptr_array_add (new_lines, g_strdup_printf ("bootargs=%s", val));

View File

@ -1,56 +0,0 @@
/* -*- 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 OT_TYPE_CONFIG_PARSER (ot_config_parser_get_type ())
#define OT_CONFIG_PARSER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), OT_TYPE_CONFIG_PARSER, OtConfigParser))
#define OT_IS_CONFIG_PARSER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), OT_TYPE_CONFIG_PARSER))
typedef struct _OtConfigParser OtConfigParser;
GType ot_config_parser_get_type (void) G_GNUC_CONST;
OtConfigParser * ot_config_parser_new (const char *separator);
gboolean ot_config_parser_parse (OtConfigParser *self,
GFile *path,
GCancellable *cancellable,
GError **error);
gboolean ot_config_parser_write (OtConfigParser *self,
GFile *output,
GCancellable *cancellable,
GError **error);
void ot_config_parser_set (OtConfigParser *self,
const char *key,
const char *value);
const char *ot_config_parser_get (OtConfigParser *self,
const char *key);
G_END_DECLS

View File

@ -1,64 +0,0 @@
/* -*- 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>
#include "ot-config-parser.h"
G_BEGIN_DECLS
#define OT_TYPE_DEPLOYMENT (ot_deployment_get_type ())
#define OT_DEPLOYMENT(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), OT_TYPE_DEPLOYMENT, OtDeployment))
#define OT_IS_DEPLOYMENT(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), OT_TYPE_DEPLOYMENT))
typedef struct _OtDeployment OtDeployment;
GType ot_deployment_get_type (void) G_GNUC_CONST;
guint ot_deployment_hash (gconstpointer v);
gboolean ot_deployment_equal (gconstpointer a, gconstpointer b);
OtDeployment * ot_deployment_new (int index,
const char *osname,
const char *csum,
int deployserial,
const char *bootcsum,
int bootserial);
int ot_deployment_get_index (OtDeployment *self);
const char *ot_deployment_get_osname (OtDeployment *self);
int ot_deployment_get_deployserial (OtDeployment *self);
const char *ot_deployment_get_csum (OtDeployment *self);
const char *ot_deployment_get_bootcsum (OtDeployment *self);
int ot_deployment_get_bootserial (OtDeployment *self);
OtConfigParser *ot_deployment_get_bootconfig (OtDeployment *self);
GKeyFile *ot_deployment_get_origin (OtDeployment *self);
void ot_deployment_set_index (OtDeployment *self, int index);
void ot_deployment_set_bootserial (OtDeployment *self, int index);
void ot_deployment_set_bootconfig (OtDeployment *self, OtConfigParser *bootconfig);
void ot_deployment_set_origin (OtDeployment *self, GKeyFile *origin);
OtDeployment *ot_deployment_clone (OtDeployment *self);
G_END_DECLS