summaryrefslogtreecommitdiff
path: root/src/ostree/ot-admin-builtin-diff.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2013-06-29 11:45:53 -0400
committerColin Walters <walters@verbum.org>2013-07-07 11:31:26 -0400
commitbb6eedfb258d3001f61c42c7e920c03dae2bdc1a (patch)
treebfce00f47de8191e5ef7709f3112f1757f9d8306 /src/ostree/ot-admin-builtin-diff.c
parentecb3f0de035c09d8b280ac116eeede483638fd5d (diff)
downloadostree-bb6eedfb258d3001f61c42c7e920c03dae2bdc1a.tar.gz
[INCOMPATIBLE CHANGE] Implement new deployment model
See https://wiki.gnome.org/OSTree/DeploymentModel2 This is a major rework of the on-disk filesystem layout, and the boot process. OSTree now explicitly supports upgrading kernels, and these upgrades are also atomic. The core concept of the new model is the "deployment list", which is an ordered list of bootable operating system trees. The deployment list is reflected in the bootloader configuration; which has a kernel argument that tells the initramfs (dracut) which operating system root to use. Invidiual notable changes that come along with this: 1) Operating systems should now come with their etc in usr/etc; OSTree will perform a 3-way merge at deployment time, and place etc in the actual root. This avoids the need for a bind mount, and is just a lot cleaner. 2) OSTree no longer bind mounts /root, /home, and /tmp. It is expected that the the OS/ has these as symbolic links into /var. At the moment, OSTree only supports managing syslinux; other bootloader backends will follow.
Diffstat (limited to 'src/ostree/ot-admin-builtin-diff.c')
-rw-r--r--src/ostree/ot-admin-builtin-diff.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/src/ostree/ot-admin-builtin-diff.c b/src/ostree/ot-admin-builtin-diff.c
index 7792db38..97fb16aa 100644
--- a/src/ostree/ot-admin-builtin-diff.c
+++ b/src/ostree/ot-admin-builtin-diff.c
@@ -28,7 +28,10 @@
#include <glib/gi18n.h>
+static char *opt_osname;
+
static GOptionEntry options[] = {
+ { "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Specify operating system root to use", NULL },
{ NULL }
};
@@ -37,57 +40,55 @@ ot_admin_builtin_diff (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GE
{
GOptionContext *context;
gboolean ret = FALSE;
- const char *osname;
- GFile *ostree_dir = admin_opts->ostree_dir;
+ gs_free char *booted_osname = NULL;
ot_lobj GFile *repo_path = NULL;
- ot_lobj GFile *deployment = NULL;
+ gs_unref_object OtDeployment *deployment = NULL;
+ gs_unref_object GFile *deployment_dir = NULL;
ot_lobj GFile *deploy_parent = NULL;
ot_lptrarray GPtrArray *modified = NULL;
ot_lptrarray GPtrArray *removed = NULL;
ot_lptrarray GPtrArray *added = NULL;
+ gs_unref_ptrarray GPtrArray *deployments = NULL;
ot_lobj GFile *orig_etc_path = NULL;
ot_lobj GFile *new_etc_path = NULL;
__attribute__((unused)) GCancellable *cancellable = NULL;
+ int bootversion;
- context = g_option_context_new ("OSNAME [REVISION] - Diff configuration for OSNAME");
+ context = g_option_context_new ("Diff current /etc configuration versus default");
g_option_context_add_main_entries (context, options, NULL);
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
- repo_path = g_file_get_child (ostree_dir, "repo");
+ repo_path = g_file_resolve_relative_path (admin_opts->sysroot, "ostree/repo");
- if (argc < 2)
+ if (!ot_admin_list_deployments (admin_opts->sysroot, &bootversion, &deployments,
+ cancellable, error))
{
- ot_util_usage_error (context, "OSNAME must be specified", error);
+ g_prefix_error (error, "While listing deployments: ");
goto out;
}
- osname = argv[1];
-
- if (argc > 2)
- {
- deployment = ot_gfile_get_child_build_path (ostree_dir, "deploy", osname, argv[2], NULL);
- if (!g_file_query_exists (deployment, NULL))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Deployment %s doesn't exist", gs_file_get_path_cached (deployment));
- goto out;
- }
- }
- else
+ if (!ot_admin_require_deployment_or_osname (admin_opts->sysroot, deployments,
+ opt_osname, &deployment,
+ cancellable, error))
+ goto out;
+ if (deployment != NULL)
+ opt_osname = (char*)ot_deployment_get_osname (deployment);
+ if (deployment == NULL)
+ deployment = ot_admin_get_merge_deployment (deployments, opt_osname, deployment, NULL);
+ if (deployment == NULL)
{
- if (!ot_admin_get_current_deployment (ostree_dir, osname, &deployment,
- cancellable, error))
- goto out;
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+ "No deployment for OS '%s'", opt_osname);
+ goto out;
}
- orig_etc_path = g_file_resolve_relative_path (deployment, "etc");
- deploy_parent = g_file_get_parent (deployment);
- new_etc_path = ot_gfile_get_child_strconcat (deploy_parent,
- gs_file_get_basename_cached (deployment),
- "-etc", NULL);
+ deployment_dir = ot_admin_get_deployment_directory (admin_opts->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");
modified = g_ptr_array_new_with_free_func ((GDestroyNotify) ostree_diff_item_unref);
removed = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);