bin/admin: Do sysroot loading during argument parsing
Followup from previous patch - we can now centralize the sysroot loading. Besides the obvious cleanup value, this is also prep for dropping an `ostree_sysroot_get_path()` user. Closes: #1123 Approved by: jlebon
This commit is contained in:
parent
517dd9c964
commit
4bd63dd919
|
|
@ -52,9 +52,6 @@ ot_admin_builtin_cleanup (int argc, char **argv, GCancellable *cancellable, GErr
|
|||
&sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_sysroot_cleanup (sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
|
|
|
|||
|
|
@ -82,8 +82,6 @@ ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GErro
|
|||
|
||||
const char *refspec = argv[1];
|
||||
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
return FALSE;
|
||||
OstreeRepo *repo = ostree_sysroot_repo (sysroot);
|
||||
|
||||
/* Find the currently booted deployment, if any; we will ensure it
|
||||
|
|
|
|||
|
|
@ -63,9 +63,6 @@ ot_admin_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError
|
|||
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
|
||||
&sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ot_admin_require_booted_deployment_or_osname (sysroot, opt_osname,
|
||||
cancellable, error))
|
||||
|
|
|
|||
|
|
@ -75,9 +75,6 @@ ot_admin_builtin_set_origin (int argc, char **argv, GCancellable *cancellable, G
|
|||
if (argc > 3)
|
||||
branch = argv[3];
|
||||
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_sysroot_get_repo (sysroot, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
|
|
|
|||
|
|
@ -108,9 +108,6 @@ ot_admin_builtin_status (int argc, char **argv, GCancellable *cancellable, GErro
|
|||
&sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_sysroot_get_repo (sysroot, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
|
|
|
|||
|
|
@ -63,9 +63,6 @@ ot_admin_builtin_switch (int argc, char **argv, GCancellable *cancellable, GErro
|
|||
|
||||
const char *new_provided_refspec = argv[1];
|
||||
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
g_autoptr(OstreeSysrootUpgrader) upgrader =
|
||||
ostree_sysroot_upgrader_new_for_os_with_flags (sysroot, opt_osname,
|
||||
OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED,
|
||||
|
|
|
|||
|
|
@ -60,8 +60,6 @@ ot_admin_builtin_undeploy (int argc, char **argv, GCancellable *cancellable, GEr
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
return FALSE;
|
||||
current_deployments = ostree_sysroot_get_deployments (sysroot);
|
||||
|
||||
deploy_index_str = argv[1];
|
||||
|
|
|
|||
|
|
@ -65,9 +65,6 @@ ot_admin_builtin_unlock (int argc, char **argv, GCancellable *cancellable, GErro
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
booted_deployment = ostree_sysroot_get_booted_deployment (sysroot);
|
||||
if (!booted_deployment)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -78,9 +78,6 @@ ot_admin_builtin_upgrade (int argc, char **argv, GCancellable *cancellable, GErr
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
g_autoptr(OstreeSysrootUpgrader) upgrader =
|
||||
ostree_sysroot_upgrader_new_for_os (sysroot, opt_osname,
|
||||
cancellable, error);
|
||||
|
|
|
|||
|
|
@ -53,9 +53,6 @@ ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, GCancellable *c
|
|||
&sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc >= 2)
|
||||
{
|
||||
bootversion = (guint) g_ascii_strtoull (argv[1], NULL, 10);
|
||||
|
|
|
|||
|
|
@ -204,9 +204,6 @@ ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, GCancel
|
|||
&sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
deployments = ostree_sysroot_get_deployments (sysroot);
|
||||
if (deployments->len == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -66,9 +66,6 @@ ot_admin_instutil_builtin_set_kargs (int argc, char **argv, GCancellable *cancel
|
|||
&sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
deployments = ostree_sysroot_get_deployments (sysroot);
|
||||
if (deployments->len == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -391,6 +391,16 @@ ostree_admin_option_context_parse (GOptionContext *context,
|
|||
g_autoptr(OstreeSysroot) sysroot = ostree_sysroot_new (sysroot_path);
|
||||
g_signal_connect (sysroot, "journal-msg", G_CALLBACK (on_sysroot_journal_msg), NULL);
|
||||
|
||||
if ((flags & OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED) == 0)
|
||||
{
|
||||
/* Released when sysroot is finalized, or on process exit */
|
||||
if (!ot_admin_sysroot_lock (sysroot, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (flags & OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER)
|
||||
{
|
||||
GFile *path = ostree_sysroot_get_path (sysroot);
|
||||
|
|
@ -411,9 +421,6 @@ ostree_admin_option_context_parse (GOptionContext *context,
|
|||
g_autoptr(GFile) deployment_file = NULL;
|
||||
g_autofree char *deployment_path = NULL;
|
||||
|
||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
deployments = ostree_sysroot_get_deployments (sysroot);
|
||||
if (deployments->len == 0)
|
||||
return glnx_throw (error, "Unable to find a deployment in sysroot");
|
||||
|
|
@ -433,13 +440,6 @@ ostree_admin_option_context_parse (GOptionContext *context,
|
|||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if ((flags & OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED) == 0)
|
||||
{
|
||||
/* Released when sysroot is finalized, or on process exit */
|
||||
if (!ot_admin_sysroot_lock (sysroot, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (out_sysroot)
|
||||
*out_sysroot = g_steal_pointer (&sysroot);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue