Add: --sysroot and --os arguments
These match OSTree. There are a variety of use cases here. One is for test suites; we can stand up a temporary sysroot directory, and operate on content inside there. Another is doing virtual machine upgrades offline from a host system, or upgrading a different OS. The duplication here is a bit unfortunate; if we add a lot more commands we should revisit this and perhaps have a common option group.
This commit is contained in:
parent
f642512ae6
commit
711745bbc6
@ -29,7 +29,12 @@
|
||||
|
||||
#include "libgsystem.h"
|
||||
|
||||
static char *opt_sysroot = "/";
|
||||
static char *opt_osname;
|
||||
|
||||
static GOptionEntry option_entries[] = {
|
||||
{ "sysroot", 0, 0, G_OPTION_ARG_STRING, &opt_sysroot, "Use system root SYSROOT (default: /)", "SYSROOT" },
|
||||
{ "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Operate on provided OSNAME", "OSNAME" },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -51,6 +56,7 @@ rpmostree_builtin_rebase (int argc,
|
||||
gs_free char *new_ref = NULL;
|
||||
gs_free char *new_refspec = NULL;
|
||||
gs_free char *new_revision = NULL;
|
||||
gs_unref_object GFile *sysroot_path = NULL;
|
||||
gs_unref_object GFile *deployment_path = NULL;
|
||||
gs_unref_object GFile *deployment_origin_path = NULL;
|
||||
gs_unref_object OstreeDeployment *merge_deployment = NULL;
|
||||
@ -77,11 +83,12 @@ rpmostree_builtin_rebase (int argc,
|
||||
|
||||
new_provided_refspec = argv[1];
|
||||
|
||||
sysroot = ostree_sysroot_new_default ();
|
||||
sysroot_path = g_file_new_for_path (opt_sysroot);
|
||||
sysroot = ostree_sysroot_new (sysroot_path);
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
upgrader = ostree_sysroot_upgrader_new_for_os (sysroot, NULL,
|
||||
upgrader = ostree_sysroot_upgrader_new_for_os (sysroot, opt_osname,
|
||||
cancellable, error);
|
||||
if (!upgrader)
|
||||
goto out;
|
||||
|
@ -28,9 +28,11 @@
|
||||
|
||||
#include "libgsystem.h"
|
||||
|
||||
static char *opt_sysroot = "/";
|
||||
static gboolean opt_reboot;
|
||||
|
||||
static GOptionEntry option_entries[] = {
|
||||
{ "sysroot", 0, 0, G_OPTION_ARG_STRING, &opt_sysroot, "Use system root SYSROOT (default: /)", "SYSROOT" },
|
||||
{ "reboot", 'r', 0, G_OPTION_ARG_NONE, &opt_reboot, "Initiate a reboot after rollback is prepared", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
@ -43,6 +45,7 @@ rpmostree_builtin_rollback (int argc,
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context = g_option_context_new ("- Revert to the previously booted tree");
|
||||
gs_unref_object GFile *sysroot_path = NULL;
|
||||
gs_unref_object OstreeSysroot *sysroot = NULL;
|
||||
gs_free char *origin_description = NULL;
|
||||
gs_unref_ptrarray GPtrArray *deployments = NULL;
|
||||
@ -58,7 +61,8 @@ rpmostree_builtin_rollback (int argc,
|
||||
if (!g_option_context_parse (context, &argc, &argv, error))
|
||||
goto out;
|
||||
|
||||
sysroot = ostree_sysroot_new_default ();
|
||||
sysroot_path = g_file_new_for_path (opt_sysroot);
|
||||
sysroot = ostree_sysroot_new (sysroot_path);
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
|
@ -28,9 +28,11 @@
|
||||
|
||||
#include "libgsystem.h"
|
||||
|
||||
static char *opt_sysroot = "/";
|
||||
static gboolean opt_pretty;
|
||||
|
||||
static GOptionEntry option_entries[] = {
|
||||
{ "sysroot", 0, 0, G_OPTION_ARG_STRING, &opt_sysroot, "Use system root SYSROOT (default: /)", "SYSROOT" },
|
||||
{ "pretty", 'p', 0, G_OPTION_ARG_NONE, &opt_pretty, "Display status in formatted rows", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
@ -51,6 +53,7 @@ rpmostree_builtin_status (int argc,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
gs_unref_object GFile *sysroot_path = NULL;
|
||||
gs_unref_object OstreeSysroot *sysroot = NULL;
|
||||
gs_unref_ptrarray GPtrArray *deployments = NULL; // list of all depoyments
|
||||
OstreeDeployment *booted_deployment = NULL; // current booted deployment
|
||||
@ -68,7 +71,8 @@ rpmostree_builtin_status (int argc,
|
||||
if (!g_option_context_parse (context, &argc, &argv, error))
|
||||
goto out;
|
||||
|
||||
sysroot = ostree_sysroot_new_default ();
|
||||
sysroot_path = g_file_new_for_path (opt_sysroot);
|
||||
sysroot = ostree_sysroot_new (sysroot_path);
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
|
@ -29,10 +29,14 @@
|
||||
|
||||
#include "libgsystem.h"
|
||||
|
||||
static char *opt_sysroot = "/";
|
||||
static char *opt_osname;
|
||||
static gboolean opt_reboot;
|
||||
static gboolean opt_allow_downgrade;
|
||||
|
||||
static GOptionEntry option_entries[] = {
|
||||
{ "sysroot", 0, 0, G_OPTION_ARG_STRING, &opt_sysroot, "Use system root SYSROOT (default: /)", "SYSROOT" },
|
||||
{ "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Operate on provided OSNAME", "OSNAME" },
|
||||
{ "reboot", 'r', 0, G_OPTION_ARG_NONE, &opt_reboot, "Initiate a reboot after an upgrade is prepared", NULL },
|
||||
{ "allow-downgrade", 0, 0, G_OPTION_ARG_NONE, &opt_allow_downgrade, "Permit deployment of chronologically older trees", NULL },
|
||||
{ NULL }
|
||||
@ -46,6 +50,7 @@ rpmostree_builtin_upgrade (int argc,
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context = g_option_context_new ("- Perform a system upgrade");
|
||||
gs_unref_object GFile *sysroot_path = NULL;
|
||||
gs_unref_object OstreeSysroot *sysroot = NULL;
|
||||
gs_unref_object OstreeSysrootUpgrader *upgrader = NULL;
|
||||
gs_unref_object OstreeAsyncProgress *progress = NULL;
|
||||
@ -59,11 +64,13 @@ rpmostree_builtin_upgrade (int argc,
|
||||
if (!g_option_context_parse (context, &argc, &argv, error))
|
||||
goto out;
|
||||
|
||||
sysroot = ostree_sysroot_new_default ();
|
||||
sysroot_path = g_file_new_for_path (opt_sysroot);
|
||||
sysroot = ostree_sysroot_new (sysroot_path);
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
upgrader = ostree_sysroot_upgrader_new (sysroot, cancellable, error);
|
||||
upgrader = ostree_sysroot_upgrader_new_for_os (sysroot, opt_osname,
|
||||
cancellable, error);
|
||||
if (!upgrader)
|
||||
goto out;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user