mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-03 05:18:24 +03:00
admin: Clean up builtin prototype
Pass through GCancellable, and just use GFile *sysroot, since that's all OtAdminBuiltinOpts was.
This commit is contained in:
parent
760b866104
commit
8d5b8dd740
@ -34,11 +34,10 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_cleanup (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error)
|
||||
ot_admin_builtin_cleanup (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
__attribute__((unused)) GCancellable *cancellable = NULL;
|
||||
|
||||
context = g_option_context_new ("Delete untagged deployments and repository objects");
|
||||
|
||||
@ -47,7 +46,7 @@ ot_admin_builtin_cleanup (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
|
||||
if (!g_option_context_parse (context, &argc, &argv, error))
|
||||
goto out;
|
||||
|
||||
if (!ot_admin_cleanup (admin_opts->sysroot, cancellable, error))
|
||||
if (!ot_admin_cleanup (sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
ret = TRUE;
|
||||
|
@ -47,13 +47,11 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_deploy (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error)
|
||||
ot_admin_builtin_deploy (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
__attribute__((unused)) GCancellable *cancellable = NULL;
|
||||
const char *refspec;
|
||||
GOptionContext *context;
|
||||
GFile *sysroot = admin_opts->sysroot;
|
||||
GKeyFile *origin = NULL;
|
||||
int current_bootversion;
|
||||
int new_bootversion;
|
||||
|
@ -37,7 +37,7 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_diff (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error)
|
||||
ot_admin_builtin_diff (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
@ -52,7 +52,6 @@ ot_admin_builtin_diff (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GE
|
||||
gs_unref_ptrarray GPtrArray *deployments = NULL;
|
||||
gs_unref_object GFile *orig_etc_path = NULL;
|
||||
gs_unref_object GFile *new_etc_path = NULL;
|
||||
__attribute__((unused)) GCancellable *cancellable = NULL;
|
||||
int bootversion;
|
||||
|
||||
context = g_option_context_new ("Diff current /etc configuration versus default");
|
||||
@ -62,16 +61,16 @@ ot_admin_builtin_diff (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GE
|
||||
if (!g_option_context_parse (context, &argc, &argv, error))
|
||||
goto out;
|
||||
|
||||
repo_path = g_file_resolve_relative_path (admin_opts->sysroot, "ostree/repo");
|
||||
repo_path = g_file_resolve_relative_path (sysroot, "ostree/repo");
|
||||
|
||||
if (!ot_admin_list_deployments (admin_opts->sysroot, &bootversion, &deployments,
|
||||
if (!ot_admin_list_deployments (sysroot, &bootversion, &deployments,
|
||||
cancellable, error))
|
||||
{
|
||||
g_prefix_error (error, "While listing deployments: ");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!ot_admin_require_deployment_or_osname (admin_opts->sysroot, deployments,
|
||||
if (!ot_admin_require_deployment_or_osname (sysroot, deployments,
|
||||
opt_osname, &deployment,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
@ -86,7 +85,7 @@ ot_admin_builtin_diff (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GE
|
||||
goto out;
|
||||
}
|
||||
|
||||
deployment_dir = ot_admin_get_deployment_directory (admin_opts->sysroot, deployment);
|
||||
deployment_dir = ot_admin_get_deployment_directory (sysroot, deployment);
|
||||
|
||||
orig_etc_path = g_file_resolve_relative_path (deployment_dir, "usr/etc");
|
||||
new_etc_path = g_file_resolve_relative_path (deployment_dir, "etc");
|
||||
|
@ -34,7 +34,7 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_init_fs (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error)
|
||||
ot_admin_builtin_init_fs (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
@ -42,7 +42,6 @@ ot_admin_builtin_init_fs (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
|
||||
gs_unref_object GFile *child = NULL;
|
||||
guint i;
|
||||
const char *normal_toplevels[] = {"boot", "dev", "home", "proc", "run", "sys"};
|
||||
GCancellable *cancellable = NULL;
|
||||
|
||||
context = g_option_context_new ("PATH - Initialize a root filesystem");
|
||||
g_option_context_add_main_entries (context, options, NULL);
|
||||
|
@ -34,14 +34,13 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_os_init (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error)
|
||||
ot_admin_builtin_os_init (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
const char *osname = NULL;
|
||||
gs_unref_object GFile *deploy_dir = NULL;
|
||||
gs_unref_object GFile *dir = NULL;
|
||||
__attribute__((unused)) GCancellable *cancellable = NULL;
|
||||
|
||||
context = g_option_context_new ("OSNAME - Initialize empty state for given operating system");
|
||||
g_option_context_add_main_entries (context, options, NULL);
|
||||
@ -49,7 +48,7 @@ ot_admin_builtin_os_init (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
|
||||
if (!g_option_context_parse (context, &argc, &argv, error))
|
||||
goto out;
|
||||
|
||||
if (!ot_admin_ensure_initialized (admin_opts->sysroot, cancellable, error))
|
||||
if (!ot_admin_ensure_initialized (sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc < 2)
|
||||
@ -60,7 +59,7 @@ ot_admin_builtin_os_init (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
|
||||
|
||||
osname = argv[1];
|
||||
|
||||
deploy_dir = ot_gfile_get_child_build_path (admin_opts->sysroot, "ostree", "deploy", osname, NULL);
|
||||
deploy_dir = ot_gfile_get_child_build_path (sysroot, "ostree", "deploy", osname, NULL);
|
||||
|
||||
/* Ensure core subdirectories of /var exist, since we need them for
|
||||
* dracut generation, and the host will want them too. Note that at
|
||||
|
@ -34,14 +34,13 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_status (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error)
|
||||
ot_admin_builtin_status (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
int bootversion;
|
||||
gs_unref_object OtDeployment *booted_deployment = NULL;
|
||||
gs_unref_ptrarray GPtrArray *deployments = NULL;
|
||||
__attribute__((unused)) GCancellable *cancellable = NULL;
|
||||
guint i;
|
||||
|
||||
context = g_option_context_new ("List deployments");
|
||||
@ -51,14 +50,14 @@ ot_admin_builtin_status (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
|
||||
if (!g_option_context_parse (context, &argc, &argv, error))
|
||||
goto out;
|
||||
|
||||
if (!ot_admin_list_deployments (admin_opts->sysroot, &bootversion, &deployments,
|
||||
if (!ot_admin_list_deployments (sysroot, &bootversion, &deployments,
|
||||
cancellable, error))
|
||||
{
|
||||
g_prefix_error (error, "While listing deployments: ");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!ot_admin_find_booted_deployment (admin_opts->sysroot, deployments,
|
||||
if (!ot_admin_find_booted_deployment (sysroot, deployments,
|
||||
&booted_deployment,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
@ -71,7 +70,7 @@ ot_admin_builtin_status (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
|
||||
{
|
||||
int subbootversion;
|
||||
|
||||
if (!ot_admin_read_current_subbootversion (admin_opts->sysroot, bootversion,
|
||||
if (!ot_admin_read_current_subbootversion (sysroot, bootversion,
|
||||
&subbootversion,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
@ -34,11 +34,9 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_undeploy (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error)
|
||||
ot_admin_builtin_undeploy (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
__attribute__((unused)) GCancellable *cancellable = NULL;
|
||||
GFile *sysroot = admin_opts->sysroot;
|
||||
GOptionContext *context;
|
||||
const char *deploy_index_str;
|
||||
int deploy_index;
|
||||
|
@ -43,12 +43,10 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_upgrade (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error)
|
||||
ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
__attribute__((unused)) GCancellable *cancellable = NULL;
|
||||
GOptionContext *context;
|
||||
GFile *sysroot = admin_opts->sysroot;
|
||||
gs_free char *booted_osname = NULL;
|
||||
gs_unref_object OstreeRepo *repo = NULL;
|
||||
gs_unref_object GFile *repo_path = NULL;
|
||||
@ -74,7 +72,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
|
||||
if (!g_option_context_parse (context, &argc, &argv, error))
|
||||
goto out;
|
||||
|
||||
if (!ot_admin_list_deployments (admin_opts->sysroot, ¤t_bootversion,
|
||||
if (!ot_admin_list_deployments (sysroot, ¤t_bootversion,
|
||||
¤t_deployments,
|
||||
cancellable, error))
|
||||
{
|
||||
@ -82,7 +80,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!ot_admin_require_deployment_or_osname (admin_opts->sysroot, current_deployments,
|
||||
if (!ot_admin_require_deployment_or_osname (sysroot, current_deployments,
|
||||
opt_osname,
|
||||
&booted_deployment,
|
||||
cancellable, error))
|
||||
@ -92,10 +90,10 @@ ot_admin_builtin_upgrade (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
|
||||
merge_deployment = ot_admin_get_merge_deployment (current_deployments, opt_osname,
|
||||
booted_deployment);
|
||||
|
||||
deployment_path = ot_admin_get_deployment_directory (admin_opts->sysroot, merge_deployment);
|
||||
deployment_path = ot_admin_get_deployment_directory (sysroot, merge_deployment);
|
||||
deployment_origin_path = ot_admin_get_deployment_origin_path (deployment_path);
|
||||
|
||||
repo_path = g_file_resolve_relative_path (admin_opts->sysroot, "ostree/repo");
|
||||
repo_path = g_file_resolve_relative_path (sysroot, "ostree/repo");
|
||||
repo = ostree_repo_new (repo_path);
|
||||
if (!ostree_repo_check (repo, error))
|
||||
goto out;
|
||||
@ -139,7 +137,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
|
||||
else
|
||||
{
|
||||
gs_unref_object GFile *real_sysroot = g_file_new_for_path ("/");
|
||||
if (!ot_admin_deploy (admin_opts->sysroot,
|
||||
if (!ot_admin_deploy (sysroot,
|
||||
current_bootversion, current_deployments,
|
||||
opt_osname, new_revision, origin,
|
||||
NULL, FALSE,
|
||||
|
@ -26,19 +26,15 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct {
|
||||
GFile *sysroot;
|
||||
} OtAdminBuiltinOpts;
|
||||
|
||||
gboolean ot_admin_builtin_os_init (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error);
|
||||
gboolean ot_admin_builtin_install (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error);
|
||||
gboolean ot_admin_builtin_init_fs (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error);
|
||||
gboolean ot_admin_builtin_undeploy (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error);
|
||||
gboolean ot_admin_builtin_deploy (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error);
|
||||
gboolean ot_admin_builtin_cleanup (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error);
|
||||
gboolean ot_admin_builtin_status (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error);
|
||||
gboolean ot_admin_builtin_diff (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error);
|
||||
gboolean ot_admin_builtin_upgrade (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error);
|
||||
gboolean ot_admin_builtin_os_init (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_install (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_init_fs (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_undeploy (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_deploy (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_cleanup (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_status (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_diff (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
gboolean (*fn) (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error);
|
||||
gboolean (*fn) (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
|
||||
} OstreeAdminCommand;
|
||||
|
||||
static OstreeAdminCommand admin_subcommands[] = {
|
||||
@ -57,7 +57,7 @@ ostree_builtin_admin (int argc, char **argv, GFile *repo_path, GCancellable *can
|
||||
const char *subcommand_name;
|
||||
OstreeAdminCommand *subcommand;
|
||||
int subcmd_argc;
|
||||
OtAdminBuiltinOpts admin_opts;
|
||||
gs_unref_object GFile *sysroot = NULL;
|
||||
char **subcmd_argv = NULL;
|
||||
|
||||
if (argc > 1 && g_str_has_prefix (argv[1], "--sysroot="))
|
||||
@ -98,8 +98,8 @@ ostree_builtin_admin (int argc, char **argv, GFile *repo_path, GCancellable *can
|
||||
|
||||
ostree_prep_builtin_argv (subcommand_name, argc-2, argv+2, &subcmd_argc, &subcmd_argv);
|
||||
|
||||
admin_opts.sysroot = g_file_new_for_path (opt_sysroot);
|
||||
if (!subcommand->fn (subcmd_argc, subcmd_argv, &admin_opts, error))
|
||||
sysroot = g_file_new_for_path (opt_sysroot);
|
||||
if (!subcommand->fn (subcmd_argc, subcmd_argv, sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
ret = TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user