mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-14 04:59:00 +03:00
ostree: move flags into command struct, pass down through builtins
This is a similar approach as12c34bb249
. One thing to note is when we parse the admin related functions, we still keep the old admin related flags, and added a new parameter to represent the command struct. This allows us to identify the caller of the function, making it easier for us to possibly deduplicate the subcommand handling in the future. A similar approach is done in rpm-ostree:83aeb018c1
This also makes it easier for us to change the prototype of the function. If we want to add something new in the future, we won't need to touch every prototype. Closes: #1267 Approved by: cgwalters
This commit is contained in:
parent
3c360a720f
commit
298c151fd8
@ -32,62 +32,93 @@
|
||||
#include "ot-builtins.h"
|
||||
|
||||
static OstreeCommand commands[] = {
|
||||
{ "admin", ostree_builtin_admin ,
|
||||
/* Note: all admin related commands have
|
||||
* no_repo as their command flag, but each
|
||||
* admin command may have their own
|
||||
* admin flag
|
||||
*/
|
||||
{ "admin", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ostree_builtin_admin,
|
||||
"Commands that needs admin privilege" },
|
||||
{ "cat", ostree_builtin_cat,
|
||||
{ "cat", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_cat,
|
||||
"Concatenate contents of files"},
|
||||
{ "checkout", ostree_builtin_checkout,
|
||||
{ "checkout", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_checkout,
|
||||
"Check out a commit into a filesystem tree" },
|
||||
{ "checksum", ostree_builtin_checksum,
|
||||
{ "checksum", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ostree_builtin_checksum,
|
||||
"Checksum a file or directory" },
|
||||
{ "commit", ostree_builtin_commit,
|
||||
{ "commit", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_commit,
|
||||
"Commit a new revision" },
|
||||
{ "config", ostree_builtin_config,
|
||||
{ "config", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_config,
|
||||
"Change repo configuration settings" },
|
||||
{ "diff", ostree_builtin_diff,
|
||||
{ "diff", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_diff,
|
||||
"Compare directory TARGETDIR against revision REV"},
|
||||
{ "export", ostree_builtin_export,
|
||||
{ "export", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_export,
|
||||
"Stream COMMIT to stdout in tar format" },
|
||||
#ifdef OSTREE_ENABLE_EXPERIMENTAL_API
|
||||
{ "find-remotes", ostree_builtin_find_remotes,
|
||||
{ "find-remotes", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_find_remotes,
|
||||
"Find remotes to serve the given refs" },
|
||||
{ "create-usb", ostree_builtin_create_usb,
|
||||
{ "create-usb", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_create_usb,
|
||||
"Copy the refs to a USB stick" },
|
||||
#endif
|
||||
{ "fsck", ostree_builtin_fsck,
|
||||
{ "fsck", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_fsck,
|
||||
"Check the repository for consistency" },
|
||||
{ "gpg-sign", ostree_builtin_gpg_sign,
|
||||
{ "gpg-sign", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_gpg_sign,
|
||||
"Sign a commit" },
|
||||
{ "init", ostree_builtin_init,
|
||||
{ "init", OSTREE_BUILTIN_FLAG_NO_CHECK,
|
||||
ostree_builtin_init,
|
||||
"Initialize a new empty repository" },
|
||||
{ "log", ostree_builtin_log,
|
||||
{ "log", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_log,
|
||||
"Show log starting at commit or ref" },
|
||||
{ "ls", ostree_builtin_ls,
|
||||
{ "ls", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_ls,
|
||||
"List file paths" },
|
||||
{ "prune", ostree_builtin_prune,
|
||||
{ "prune", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_prune,
|
||||
"Search for unreachable objects" },
|
||||
{ "pull-local", ostree_builtin_pull_local,
|
||||
{ "pull-local", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_pull_local,
|
||||
"Copy data from SRC_REPO" },
|
||||
#ifdef HAVE_LIBCURL_OR_LIBSOUP
|
||||
{ "pull", ostree_builtin_pull,
|
||||
{ "pull", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_pull,
|
||||
"Download data from remote repository" },
|
||||
#endif
|
||||
{ "refs", ostree_builtin_refs,
|
||||
{ "refs", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_refs,
|
||||
"List refs" },
|
||||
{ "remote", ostree_builtin_remote,
|
||||
{ "remote", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ostree_builtin_remote,
|
||||
"Remote commands that may involve internet access" },
|
||||
{ "reset", ostree_builtin_reset,
|
||||
{ "reset", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_reset,
|
||||
"Reset a REF to a previous COMMIT" },
|
||||
{ "rev-parse", ostree_builtin_rev_parse,
|
||||
{ "rev-parse", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_rev_parse,
|
||||
"Output the target of a rev" },
|
||||
{ "show", ostree_builtin_show,
|
||||
{ "show", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_show,
|
||||
"Output a metadata object" },
|
||||
{ "static-delta", ostree_builtin_static_delta,
|
||||
{ "static-delta", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_static_delta,
|
||||
"Static delta related commands" },
|
||||
{ "summary", ostree_builtin_summary,
|
||||
{ "summary", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_summary,
|
||||
"Manage summary metadata" },
|
||||
#if defined(HAVE_LIBSOUP) && defined(BUILDOPT_ENABLE_TRIVIAL_HTTPD_CMDLINE)
|
||||
{ "trivial-httpd", ostree_builtin_trivial_httpd,
|
||||
{ "trivial-httpd", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ostree_builtin_trivial_httpd,
|
||||
NULL },
|
||||
#endif
|
||||
{ NULL }
|
||||
|
@ -38,7 +38,7 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_cleanup (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_admin_builtin_cleanup (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeSysroot) sysroot = NULL;
|
||||
@ -48,7 +48,7 @@ ot_admin_builtin_cleanup (int argc, char **argv, GCancellable *cancellable, GErr
|
||||
|
||||
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
|
||||
&sysroot, cancellable, error))
|
||||
invocation, &sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_sysroot_cleanup (sysroot, cancellable, error))
|
||||
|
@ -60,7 +60,7 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
__attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = NULL;
|
||||
|
||||
@ -70,7 +70,7 @@ ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GErro
|
||||
g_autoptr(OstreeSysroot) sysroot = NULL;
|
||||
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
|
||||
&sysroot, cancellable, error))
|
||||
invocation, &sysroot, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -41,7 +41,7 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_admin_builtin_diff (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeSysroot) sysroot = NULL;
|
||||
@ -60,7 +60,7 @@ ot_admin_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError
|
||||
|
||||
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
|
||||
&sysroot, cancellable, error))
|
||||
invocation, &sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ot_admin_require_booted_deployment_or_osname (sysroot, opt_osname,
|
||||
|
@ -38,15 +38,15 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_init_fs (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_admin_builtin_init_fs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("PATH - Initialize a root filesystem");
|
||||
|
||||
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER |
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED |
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT,
|
||||
NULL, cancellable, error))
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED |
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT,
|
||||
invocation, NULL, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -28,28 +28,25 @@
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
gboolean (*fn) (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
const char *description;
|
||||
} OstreeAdminInstUtilCommand;
|
||||
|
||||
static OstreeAdminInstUtilCommand admin_instutil_subcommands[] = {
|
||||
static OstreeCommand admin_instutil_subcommands[] = {
|
||||
#ifdef HAVE_SELINUX
|
||||
{ "selinux-ensure-labeled", ot_admin_instutil_builtin_selinux_ensure_labeled,
|
||||
{ "selinux-ensure-labeled", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_admin_instutil_builtin_selinux_ensure_labeled,
|
||||
"Relabel all or part of a deployment" },
|
||||
#endif
|
||||
{ "set-kargs", ot_admin_instutil_builtin_set_kargs,
|
||||
{ "set-kargs", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_admin_instutil_builtin_set_kargs,
|
||||
"Set new kernel command line arguments(Not stable)" },
|
||||
{ "grub2-generate", ot_admin_instutil_builtin_grub2_generate,
|
||||
{ "grub2-generate", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_admin_instutil_builtin_grub2_generate,
|
||||
"Generate GRUB2 configuration from given BLS entries" },
|
||||
{ NULL, NULL, NULL }
|
||||
{ NULL, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static GOptionContext *
|
||||
ostree_admin_instutil_option_context_new_with_commands (void)
|
||||
{
|
||||
OstreeAdminInstUtilCommand *command = admin_instutil_subcommands;
|
||||
OstreeCommand *command = admin_instutil_subcommands;
|
||||
GOptionContext *context = g_option_context_new ("COMMAND");
|
||||
|
||||
g_autoptr(GString) summary = g_string_new ("Builtin \"admin instutil\" Commands:");
|
||||
@ -69,7 +66,7 @@ ostree_admin_instutil_option_context_new_with_commands (void)
|
||||
}
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_instutil (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_admin_builtin_instutil (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
const char *subcommand_name = NULL;
|
||||
int in, out;
|
||||
@ -97,7 +94,7 @@ ot_admin_builtin_instutil (int argc, char **argv, GCancellable *cancellable, GEr
|
||||
|
||||
argc = out;
|
||||
|
||||
OstreeAdminInstUtilCommand *subcommand = admin_instutil_subcommands;
|
||||
OstreeCommand *subcommand = admin_instutil_subcommands;
|
||||
while (subcommand->name)
|
||||
{
|
||||
if (g_strcmp0 (subcommand_name, subcommand->name) == 0)
|
||||
@ -113,7 +110,7 @@ ot_admin_builtin_instutil (int argc, char **argv, GCancellable *cancellable, GEr
|
||||
/* This will not return for some options (e.g. --version). */
|
||||
if (ostree_admin_option_context_parse (context, NULL, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT,
|
||||
NULL, cancellable, error))
|
||||
invocation, NULL, cancellable, error))
|
||||
{
|
||||
if (subcommand_name == NULL)
|
||||
{
|
||||
@ -135,7 +132,8 @@ ot_admin_builtin_instutil (int argc, char **argv, GCancellable *cancellable, GEr
|
||||
g_autofree char *prgname = g_strdup_printf ("%s %s", g_get_prgname (), subcommand_name);
|
||||
g_set_prgname (prgname);
|
||||
|
||||
if (!subcommand->fn (argc, argv, cancellable, error))
|
||||
OstreeCommandInvocation sub_invocation = { .command = subcommand };
|
||||
if (!subcommand->fn (argc, argv, &sub_invocation, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
@ -38,7 +38,7 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_os_init (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_admin_builtin_os_init (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeSysroot) sysroot = NULL;
|
||||
@ -49,7 +49,7 @@ ot_admin_builtin_os_init (int argc, char **argv, GCancellable *cancellable, GErr
|
||||
|
||||
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
|
||||
&sysroot, cancellable, error))
|
||||
invocation, &sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_sysroot_ensure_initialized (sysroot, cancellable, error))
|
||||
|
@ -45,7 +45,7 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_set_origin (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_admin_builtin_set_origin (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
@ -60,7 +60,7 @@ ot_admin_builtin_set_origin (int argc, char **argv, GCancellable *cancellable, G
|
||||
|
||||
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
|
||||
&sysroot, cancellable, error))
|
||||
invocation, &sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc < 3)
|
||||
|
@ -85,7 +85,7 @@ out:
|
||||
}
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_status (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_admin_builtin_status (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeSysroot) sysroot = NULL;
|
||||
@ -104,7 +104,7 @@ ot_admin_builtin_status (int argc, char **argv, GCancellable *cancellable, GErro
|
||||
|
||||
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
|
||||
&sysroot, cancellable, error))
|
||||
invocation, &sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_sysroot_get_repo (sysroot, &repo, cancellable, error))
|
||||
|
@ -44,14 +44,14 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_switch (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_admin_builtin_switch (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context =
|
||||
g_option_context_new ("REF - Construct new tree from REF and deploy it");
|
||||
g_autoptr(OstreeSysroot) sysroot = NULL;
|
||||
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
|
||||
&sysroot, cancellable, error))
|
||||
invocation, &sysroot, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -37,7 +37,7 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_undeploy (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_admin_builtin_undeploy (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeSysroot) sysroot = NULL;
|
||||
@ -50,7 +50,7 @@ ot_admin_builtin_undeploy (int argc, char **argv, GCancellable *cancellable, GEr
|
||||
|
||||
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
|
||||
&sysroot, cancellable, error))
|
||||
invocation, &sysroot, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -43,7 +43,7 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_unlock (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_admin_builtin_unlock (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
@ -55,7 +55,7 @@ ot_admin_builtin_unlock (int argc, char **argv, GCancellable *cancellable, GErro
|
||||
|
||||
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
|
||||
&sysroot, cancellable, error))
|
||||
invocation, &sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc > 1)
|
||||
|
@ -54,14 +54,14 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_upgrade (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_admin_builtin_upgrade (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("Construct new tree from current origin and deploy it, if it changed");
|
||||
|
||||
g_autoptr(OstreeSysroot) sysroot = NULL;
|
||||
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
|
||||
&sysroot, cancellable, error))
|
||||
invocation, &sysroot, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (opt_pull_only && opt_deploy_only)
|
||||
|
@ -25,19 +25,25 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean ot_admin_builtin_selinux_ensure_labeled (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_os_init (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_install (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_instutil (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_init_fs (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_undeploy (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_cleanup (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_unlock (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_status (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_set_origin (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_switch (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_builtin_upgrade (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
#define BUILTINPROTO(name) gboolean ot_admin_builtin_ ## name (int argc, char **argv, \
|
||||
OstreeCommandInvocation *invocation, \
|
||||
GCancellable *cancellable, GError **error)
|
||||
|
||||
BUILTINPROTO(selinux_ensure_labeled);
|
||||
BUILTINPROTO(os_init);
|
||||
BUILTINPROTO(install);
|
||||
BUILTINPROTO(instutil);
|
||||
BUILTINPROTO(init_fs);
|
||||
BUILTINPROTO(undeploy);
|
||||
BUILTINPROTO(deploy);
|
||||
BUILTINPROTO(cleanup);
|
||||
BUILTINPROTO(unlock);
|
||||
BUILTINPROTO(status);
|
||||
BUILTINPROTO(set_origin);
|
||||
BUILTINPROTO(diff);
|
||||
BUILTINPROTO(switch);
|
||||
BUILTINPROTO(upgrade);
|
||||
|
||||
#undef BUILTINPROTO
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -38,7 +38,7 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
guint bootversion;
|
||||
@ -49,7 +49,7 @@ ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, GCancellable *c
|
||||
|
||||
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
|
||||
&sysroot, cancellable, error))
|
||||
invocation, &sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc >= 2)
|
||||
|
@ -183,7 +183,7 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
const char *policy_name;
|
||||
@ -200,7 +200,7 @@ ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, GCancel
|
||||
|
||||
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
|
||||
&sysroot, cancellable, error))
|
||||
invocation, &sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
deployments = ostree_sysroot_get_deployments (sysroot);
|
||||
|
@ -48,7 +48,7 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_admin_instutil_builtin_set_kargs (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
guint i;
|
||||
@ -62,7 +62,7 @@ ot_admin_instutil_builtin_set_kargs (int argc, char **argv, GCancellable *cancel
|
||||
|
||||
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
|
||||
&sysroot, cancellable, error))
|
||||
invocation, &sysroot, cancellable, error))
|
||||
goto out;
|
||||
|
||||
deployments = ostree_sysroot_get_deployments (sysroot);
|
||||
|
@ -23,8 +23,8 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_instutil_builtin_set_kargs (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -30,44 +30,50 @@
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
gboolean (*fn) (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
const char *description;
|
||||
} OstreeAdminCommand;
|
||||
|
||||
static OstreeAdminCommand admin_subcommands[] = {
|
||||
{ "cleanup", ot_admin_builtin_cleanup,
|
||||
static OstreeCommand admin_subcommands[] = {
|
||||
{ "cleanup", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_admin_builtin_cleanup,
|
||||
"Delete untagged deployments and repository objects" },
|
||||
{ "config-diff", ot_admin_builtin_diff,
|
||||
{ "config-diff", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_admin_builtin_diff,
|
||||
"Diff current /etc configuration versus default" },
|
||||
{ "deploy", ot_admin_builtin_deploy,
|
||||
{ "deploy", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_admin_builtin_deploy,
|
||||
"Checkout revision REFSPEC as the new default deployment" },
|
||||
{ "init-fs", ot_admin_builtin_init_fs,
|
||||
{ "init-fs", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_admin_builtin_init_fs,
|
||||
"Initialize a root filesystem" },
|
||||
{ "instutil", ot_admin_builtin_instutil,
|
||||
{ "instutil", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_admin_builtin_instutil,
|
||||
"Provide instutil commands, allow admin to change boot configuration and relabel selinux " },
|
||||
{ "os-init", ot_admin_builtin_os_init,
|
||||
{ "os-init", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_admin_builtin_os_init,
|
||||
"Initialize empty state for given operating system" },
|
||||
{ "set-origin", ot_admin_builtin_set_origin,
|
||||
{ "set-origin", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_admin_builtin_set_origin,
|
||||
"Set Origin and create a new origin file" },
|
||||
{ "status", ot_admin_builtin_status,
|
||||
{ "status", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_admin_builtin_status,
|
||||
"List deployments" },
|
||||
{ "switch", ot_admin_builtin_switch,
|
||||
{ "switch", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_admin_builtin_switch,
|
||||
"Construct new tree from REF and deploy it" },
|
||||
{ "undeploy", ot_admin_builtin_undeploy,
|
||||
{ "undeploy", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_admin_builtin_undeploy,
|
||||
"Delete deployment INDEX" },
|
||||
{ "unlock", ot_admin_builtin_unlock,
|
||||
{ "unlock", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_admin_builtin_unlock,
|
||||
"Make the current deployment mutable (as a hotfix or development)" },
|
||||
{ "upgrade", ot_admin_builtin_upgrade,
|
||||
{ "upgrade", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_admin_builtin_upgrade,
|
||||
"Construct new tree from current origin and deploy it, if it changed" },
|
||||
{ NULL, NULL, NULL }
|
||||
{ NULL, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static GOptionContext *
|
||||
ostree_admin_option_context_new_with_commands (void)
|
||||
{
|
||||
OstreeAdminCommand *command = admin_subcommands;
|
||||
OstreeCommand *command = admin_subcommands;
|
||||
GOptionContext *context = g_option_context_new ("--print-current-dir|COMMAND");
|
||||
|
||||
g_autoptr(GString) summary = g_string_new ("Builtin \"admin\" Commands:");
|
||||
@ -86,11 +92,11 @@ ostree_admin_option_context_new_with_commands (void)
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_admin (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_admin (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
const char *subcommand_name = NULL;
|
||||
OstreeAdminCommand *subcommand;
|
||||
OstreeCommand *subcommand;
|
||||
g_autofree char *prgname = NULL;
|
||||
int in, out;
|
||||
|
||||
@ -141,7 +147,7 @@ ostree_builtin_admin (int argc, char **argv, GCancellable *cancellable, GError *
|
||||
/* This will not return for some options (e.g. --version). */
|
||||
if (ostree_admin_option_context_parse (context, NULL, &argc, &argv,
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT,
|
||||
NULL, cancellable, error))
|
||||
invocation, NULL, cancellable, error))
|
||||
{
|
||||
if (subcommand_name == NULL)
|
||||
{
|
||||
@ -164,7 +170,8 @@ ostree_builtin_admin (int argc, char **argv, GCancellable *cancellable, GError *
|
||||
prgname = g_strdup_printf ("%s %s", g_get_prgname (), subcommand_name);
|
||||
g_set_prgname (prgname);
|
||||
|
||||
if (!subcommand->fn (argc, argv, cancellable, error))
|
||||
OstreeCommandInvocation sub_invocation = { .command = subcommand };
|
||||
if (!subcommand->fn (argc, argv, &sub_invocation, cancellable, error))
|
||||
goto out;
|
||||
|
||||
ret = TRUE;
|
||||
|
@ -55,11 +55,11 @@ cat_one_file (GFile *f,
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_cat (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_cat (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("COMMIT PATH... - Concatenate contents of files");
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (argc <= 2)
|
||||
|
@ -279,7 +279,7 @@ process_many_checkouts (OstreeRepo *repo,
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_checkout (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_checkout (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
@ -290,7 +290,7 @@ ostree_builtin_checkout (int argc, char **argv, GCancellable *cancellable, GErro
|
||||
|
||||
context = g_option_context_new ("COMMIT [DESTINATION] - Check out a commit into a filesystem tree");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (opt_disable_fsync)
|
||||
|
@ -66,12 +66,12 @@ on_checksum_received (GObject *obj,
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_checksum (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_checksum (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context =
|
||||
g_option_context_new ("PATH - Checksum a file or directory");
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv,
|
||||
OSTREE_BUILTIN_FLAG_NO_REPO, NULL, cancellable, error))
|
||||
invocation, NULL, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -407,7 +407,7 @@ fill_bindings (OstreeRepo *repo,
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_commit (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
@ -433,7 +433,7 @@ ostree_builtin_commit (int argc, char **argv, GCancellable *cancellable, GError
|
||||
|
||||
context = g_option_context_new ("[PATH] - Commit a new revision");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_ensure_repo_writable (repo, error))
|
||||
|
@ -56,7 +56,7 @@ split_key_string (const char *k,
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_config (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
@ -70,7 +70,7 @@ ostree_builtin_config (int argc, char **argv, GCancellable *cancellable, GError
|
||||
|
||||
context = g_option_context_new ("(get KEY|set KEY VALUE) - Change repo configuration settings");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -43,6 +43,7 @@ static GOptionEntry options[] =
|
||||
gboolean
|
||||
ostree_builtin_create_usb (int argc,
|
||||
char **argv,
|
||||
OstreeCommandInvocation *invocation,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
@ -55,7 +56,7 @@ ostree_builtin_create_usb (int argc,
|
||||
/* Parse options. */
|
||||
g_autoptr(OstreeRepo) src_repo = NULL;
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &src_repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &src_repo, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -126,7 +126,7 @@ object_set_total_size (OstreeRepo *repo,
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_diff (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
@ -142,7 +142,7 @@ ostree_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **
|
||||
|
||||
context = g_option_context_new ("REV TARGETDIR - Compare directory TARGETDIR against revision REV");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -62,7 +62,7 @@ propagate_libarchive_error (GError **error,
|
||||
#endif
|
||||
|
||||
gboolean
|
||||
ostree_builtin_export (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_export (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
@ -79,7 +79,7 @@ ostree_builtin_export (int argc, char **argv, GCancellable *cancellable, GError
|
||||
|
||||
context = g_option_context_new ("COMMIT - Stream COMMIT to stdout in tar format");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
#ifdef HAVE_LIBARCHIVE
|
||||
|
@ -120,6 +120,7 @@ collection_ref_free0 (OstreeCollectionRef *ref)
|
||||
gboolean
|
||||
ostree_builtin_find_remotes (int argc,
|
||||
char **argv,
|
||||
OstreeCommandInvocation *invocation,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
@ -136,7 +137,7 @@ ostree_builtin_find_remotes (int argc,
|
||||
context = g_option_context_new ("COLLECTION-ID REF [COLLECTION-ID REF...] - Find remotes to serve the given refs");
|
||||
|
||||
/* Parse options. */
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!ostree_ensure_repo_writable (repo, error))
|
||||
|
@ -214,13 +214,13 @@ fsck_reachable_objects_from_commits (OstreeRepo *repo,
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_fsck (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_fsck (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
gboolean found_corruption = FALSE;
|
||||
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("- Check the repository for consistency");
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!opt_quiet)
|
||||
|
@ -200,7 +200,7 @@ out:
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_gpg_sign (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_gpg_sign (int argc, char **argv,OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
@ -212,7 +212,7 @@ ostree_builtin_gpg_sign (int argc, char **argv, GCancellable *cancellable, GErro
|
||||
|
||||
context = g_option_context_new ("COMMIT KEY-ID... - Sign a commit");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -45,7 +45,7 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ostree_builtin_init (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_init (int argc, char **argv,OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
@ -54,7 +54,7 @@ ostree_builtin_init (int argc, char **argv, GCancellable *cancellable, GError **
|
||||
|
||||
context = g_option_context_new ("- Initialize a new empty repository");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NO_CHECK, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_repo_mode_from_string (opt_mode, &mode, error))
|
||||
|
@ -82,6 +82,7 @@ out:
|
||||
gboolean
|
||||
ostree_builtin_log (int argc,
|
||||
char **argv,
|
||||
OstreeCommandInvocation *invocation,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
@ -94,7 +95,7 @@ ostree_builtin_log (int argc,
|
||||
|
||||
context = g_option_context_new ("REF - Show log starting at commit or ref");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (opt_raw)
|
||||
|
@ -240,7 +240,7 @@ print_one_argument (OstreeRepo *repo,
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_ls (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_ls (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
@ -251,7 +251,7 @@ ostree_builtin_ls (int argc, char **argv, GCancellable *cancellable, GError **er
|
||||
|
||||
context = g_option_context_new ("COMMIT [PATH...] - List file paths");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc <= 1)
|
||||
|
@ -144,11 +144,11 @@ traverse_keep_younger_than (OstreeRepo *repo, const char *checksum,
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_prune (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_prune (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("- Search for unreachable objects");
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!opt_no_prune && !ostree_ensure_repo_writable (repo, error))
|
||||
|
@ -64,7 +64,7 @@ noninteractive_console_progress_changed (OstreeAsyncProgress *progress,
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_pull_local (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
@ -78,7 +78,7 @@ ostree_builtin_pull_local (int argc, char **argv, GCancellable *cancellable, GEr
|
||||
|
||||
context = g_option_context_new ("SRC_REPO [REFS...] - Copy data from SRC_REPO");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_ensure_repo_writable (repo, error))
|
||||
|
@ -143,7 +143,7 @@ noninteractive_console_progress_changed (OstreeAsyncProgress *progress,
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_pull (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
@ -157,7 +157,7 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **
|
||||
|
||||
context = g_option_context_new ("REMOTE [BRANCH...] - Download data from remote repository");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_ensure_repo_writable (repo, error))
|
||||
|
@ -261,7 +261,7 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_refs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
@ -270,7 +270,7 @@ ostree_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError **
|
||||
|
||||
context = g_option_context_new ("[PREFIX] - List refs");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc >= 2)
|
||||
|
@ -25,42 +25,46 @@
|
||||
#include "ot-builtins.h"
|
||||
#include "ot-remote-builtins.h"
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
gboolean (*fn) (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
const char *description;
|
||||
} OstreeRemoteCommand;
|
||||
|
||||
static OstreeRemoteCommand remote_subcommands[] = {
|
||||
{ "add", ot_remote_builtin_add,
|
||||
static OstreeCommand remote_subcommands[] = {
|
||||
{ "add", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_remote_builtin_add,
|
||||
"Add a remote repository" },
|
||||
{ "delete", ot_remote_builtin_delete,
|
||||
{ "delete", OSTREE_BUILTIN_FLAG_NO_REPO,
|
||||
ot_remote_builtin_delete,
|
||||
"Delete a remote repository" },
|
||||
{ "show-url", ot_remote_builtin_show_url,
|
||||
{ "show-url", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_remote_builtin_show_url,
|
||||
"Show remote repository URL" },
|
||||
{ "list", ot_remote_builtin_list,
|
||||
{ "list", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_remote_builtin_list,
|
||||
"List remote repository names" },
|
||||
{ "gpg-import", ot_remote_builtin_gpg_import,
|
||||
{ "gpg-import", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_remote_builtin_gpg_import,
|
||||
"Import GPG keys" },
|
||||
#ifdef HAVE_LIBSOUP
|
||||
{ "add-cookie", ot_remote_builtin_add_cookie,
|
||||
{ "add-cookie", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_remote_builtin_add_cookie,
|
||||
"Add a cookie to remote" },
|
||||
{ "delete-cookie", ot_remote_builtin_delete_cookie,
|
||||
{ "delete-cookie", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_remote_builtin_delete_cookie,
|
||||
"Remove one cookie from remote" },
|
||||
{ "list-cookies", ot_remote_builtin_list_cookies,
|
||||
{ "list-cookies", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_remote_builtin_list_cookies,
|
||||
"Show remote repository cookies" },
|
||||
#endif
|
||||
{ "refs", ot_remote_builtin_refs,
|
||||
{ "refs", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_remote_builtin_refs,
|
||||
"List remote refs" },
|
||||
{ "summary", ot_remote_builtin_summary,
|
||||
{ "summary", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_remote_builtin_summary,
|
||||
"Show remote summary" },
|
||||
{ NULL, NULL, NULL }
|
||||
{ NULL, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static GOptionContext *
|
||||
remote_option_context_new_with_commands (void)
|
||||
{
|
||||
OstreeRemoteCommand *subcommand = remote_subcommands;
|
||||
OstreeCommand *subcommand = remote_subcommands;
|
||||
GOptionContext *context = g_option_context_new ("COMMAND");
|
||||
|
||||
g_autoptr(GString) summary = g_string_new ("Builtin \"remote\" Commands:");
|
||||
@ -80,9 +84,9 @@ remote_option_context_new_with_commands (void)
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_remote (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_remote (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
OstreeRemoteCommand *subcommand;
|
||||
OstreeCommand *subcommand;
|
||||
const char *subcommand_name = NULL;
|
||||
g_autofree char *prgname = NULL;
|
||||
gboolean ret = FALSE;
|
||||
@ -128,7 +132,7 @@ ostree_builtin_remote (int argc, char **argv, GCancellable *cancellable, GError
|
||||
|
||||
/* This will not return for some options (e.g. --version). */
|
||||
if (ostree_option_context_parse (context, NULL, &argc, &argv,
|
||||
OSTREE_BUILTIN_FLAG_NO_REPO, NULL, cancellable,
|
||||
invocation, NULL, cancellable,
|
||||
error))
|
||||
{
|
||||
if (subcommand_name == NULL)
|
||||
@ -152,7 +156,8 @@ ostree_builtin_remote (int argc, char **argv, GCancellable *cancellable, GError
|
||||
prgname = g_strdup_printf ("%s %s", g_get_prgname (), subcommand_name);
|
||||
g_set_prgname (prgname);
|
||||
|
||||
if (!subcommand->fn (argc, argv, cancellable, error))
|
||||
OstreeCommandInvocation sub_invocation = { .command = subcommand };
|
||||
if (!subcommand->fn (argc, argv, &sub_invocation, cancellable, error))
|
||||
goto out;
|
||||
|
||||
ret = TRUE;
|
||||
|
@ -38,6 +38,7 @@ static GOptionEntry options[] = {
|
||||
gboolean
|
||||
ostree_builtin_reset (int argc,
|
||||
char **argv,
|
||||
OstreeCommandInvocation *invocation,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
@ -52,7 +53,7 @@ ostree_builtin_reset (int argc,
|
||||
/* FIXME: Add support for collection–refs. */
|
||||
context = g_option_context_new ("REF COMMIT - Reset a REF to a previous COMMIT");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_ensure_repo_writable (repo, error))
|
||||
|
@ -36,7 +36,7 @@ static GOptionEntry options[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ostree_builtin_rev_parse (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_rev_parse (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
@ -47,7 +47,7 @@ ostree_builtin_rev_parse (int argc, char **argv, GCancellable *cancellable, GErr
|
||||
|
||||
context = g_option_context_new ("REV - Output the target of a rev");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -226,12 +226,12 @@ print_if_found (OstreeRepo *repo,
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_show (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_show (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("OBJECT - Output a metadata object");
|
||||
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (argc <= 1)
|
||||
|
@ -39,7 +39,7 @@ static gboolean opt_inline;
|
||||
static gboolean opt_disable_bsdiff;
|
||||
static gboolean opt_if_not_exists;
|
||||
|
||||
#define BUILTINPROTO(name) static gboolean ot_static_delta_builtin_ ## name (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
#define BUILTINPROTO(name) static gboolean ot_static_delta_builtin_ ## name (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
|
||||
BUILTINPROTO(list);
|
||||
BUILTINPROTO(show);
|
||||
@ -50,17 +50,22 @@ BUILTINPROTO(apply_offline);
|
||||
#undef BUILTINPROTO
|
||||
|
||||
static OstreeCommand static_delta_subcommands[] = {
|
||||
{ "list", ot_static_delta_builtin_list,
|
||||
{ "list", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_static_delta_builtin_list,
|
||||
"List static delta files" },
|
||||
{ "show", ot_static_delta_builtin_show,
|
||||
{ "show", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_static_delta_builtin_show,
|
||||
"Dump information on a delta" },
|
||||
{ "delete", ot_static_delta_builtin_delete,
|
||||
{ "delete", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_static_delta_builtin_delete,
|
||||
"Remove a delta" },
|
||||
{ "generate", ot_static_delta_builtin_generate,
|
||||
{ "generate", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_static_delta_builtin_generate,
|
||||
"Generate static delta files" },
|
||||
{ "apply-offline", ot_static_delta_builtin_apply_offline,
|
||||
{ "apply-offline", OSTREE_BUILTIN_FLAG_NONE,
|
||||
ot_static_delta_builtin_apply_offline,
|
||||
"Apply static delta file" },
|
||||
{ NULL, NULL, NULL }
|
||||
{ NULL, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
/* ATTENTION:
|
||||
@ -118,12 +123,12 @@ static_delta_usage (char **argv,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ot_static_delta_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_static_delta_builtin_list (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("- list static delta files");
|
||||
if (!ostree_option_context_parse (context, list_options, &argc, &argv,
|
||||
OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
invocation, &repo, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
g_autoptr(GPtrArray) delta_names = NULL;
|
||||
@ -142,7 +147,7 @@ ot_static_delta_builtin_list (int argc, char **argv, GCancellable *cancellable,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ot_static_delta_builtin_show (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_static_delta_builtin_show (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
@ -151,7 +156,7 @@ ot_static_delta_builtin_show (int argc, char **argv, GCancellable *cancellable,
|
||||
|
||||
context = g_option_context_new ("- Dump information on a delta");
|
||||
|
||||
if (!ostree_option_context_parse (context, list_options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, list_options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc < 3)
|
||||
@ -172,7 +177,7 @@ ot_static_delta_builtin_show (int argc, char **argv, GCancellable *cancellable,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ot_static_delta_builtin_delete (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_static_delta_builtin_delete (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
@ -181,7 +186,7 @@ ot_static_delta_builtin_delete (int argc, char **argv, GCancellable *cancellable
|
||||
|
||||
context = g_option_context_new ("- Remove a delta");
|
||||
|
||||
if (!ostree_option_context_parse (context, list_options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, list_options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc < 3)
|
||||
@ -203,14 +208,14 @@ ot_static_delta_builtin_delete (int argc, char **argv, GCancellable *cancellable
|
||||
|
||||
|
||||
static gboolean
|
||||
ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_static_delta_builtin_generate (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
|
||||
context = g_option_context_new ("[TO] - Generate static delta files");
|
||||
if (!ostree_option_context_parse (context, generate_options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, generate_options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_ensure_repo_writable (repo, error))
|
||||
@ -352,7 +357,7 @@ ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellab
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ot_static_delta_builtin_apply_offline (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_static_delta_builtin_apply_offline (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
const char *patharg;
|
||||
@ -361,7 +366,7 @@ ot_static_delta_builtin_apply_offline (int argc, char **argv, GCancellable *canc
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
|
||||
context = g_option_context_new ("- Apply static delta file");
|
||||
if (!ostree_option_context_parse (context, apply_offline_options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, apply_offline_options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_ensure_repo_writable (repo, error))
|
||||
@ -392,7 +397,7 @@ ot_static_delta_builtin_apply_offline (int argc, char **argv, GCancellable *canc
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_static_delta (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_static_delta (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean want_help = FALSE;
|
||||
const char *cmdname = NULL;
|
||||
@ -443,5 +448,6 @@ ostree_builtin_static_delta (int argc, char **argv, GCancellable *cancellable, G
|
||||
g_autofree char *prgname = g_strdup_printf ("%s %s", g_get_prgname (), cmdname);
|
||||
g_set_prgname (prgname);
|
||||
|
||||
return command->fn (argc, argv, cancellable, error);
|
||||
OstreeCommandInvocation sub_invocation = { .command = command };
|
||||
return command->fn (argc, argv, &sub_invocation, cancellable, error);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ build_additional_metadata (const char * const *args,
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
@ -89,7 +89,7 @@ ostree_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError
|
||||
|
||||
context = g_option_context_new ("Manage summary metadata");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (opt_update)
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "otutil.h"
|
||||
|
||||
gboolean
|
||||
ostree_builtin_trivial_httpd (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_trivial_httpd (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GPtrArray) new_argv = g_ptr_array_new ();
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define BUILTINPROTO(name) gboolean ostree_builtin_ ## name (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
#define BUILTINPROTO(name) gboolean ostree_builtin_ ## name (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
|
||||
BUILTINPROTO(admin);
|
||||
BUILTINPROTO(cat);
|
||||
|
@ -171,7 +171,7 @@ ostree_run (int argc,
|
||||
ostree_option_context_new_with_commands (commands);
|
||||
|
||||
/* This will not return for some options (e.g. --version). */
|
||||
if (ostree_option_context_parse (context, NULL, &argc, &argv, OSTREE_BUILTIN_FLAG_NO_REPO, NULL, cancellable, &error))
|
||||
if (ostree_option_context_parse (context, NULL, &argc, &argv, NULL, NULL, cancellable, &error))
|
||||
{
|
||||
if (command_name == NULL)
|
||||
{
|
||||
@ -193,8 +193,8 @@ ostree_run (int argc,
|
||||
prgname = g_strdup_printf ("%s %s", g_get_prgname (), command_name);
|
||||
g_set_prgname (prgname);
|
||||
#endif
|
||||
|
||||
if (!command->fn (argc, argv, cancellable, &error))
|
||||
OstreeCommandInvocation invocation = { .command = command };
|
||||
if (!command->fn (argc, argv, &invocation, cancellable, &error))
|
||||
goto out;
|
||||
|
||||
success = TRUE;
|
||||
@ -296,13 +296,14 @@ ostree_option_context_parse (GOptionContext *context,
|
||||
const GOptionEntry *main_entries,
|
||||
int *argc,
|
||||
char ***argv,
|
||||
OstreeBuiltinFlags flags,
|
||||
OstreeCommandInvocation *invocation,
|
||||
OstreeRepo **out_repo,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
|
||||
/* When invocation is NULL, it usually means an error occurs, do not fetch repo this case */
|
||||
const OstreeBuiltinFlags flags = invocation ? invocation->command->flags : OSTREE_BUILTIN_FLAG_NO_REPO;
|
||||
/* Entries are listed in --help output in the order added. We add the
|
||||
* main entries ourselves so that we can add the --repo entry first. */
|
||||
|
||||
@ -366,6 +367,7 @@ ostree_admin_option_context_parse (GOptionContext *context,
|
||||
int *argc,
|
||||
char ***argv,
|
||||
OstreeAdminBuiltinFlags flags,
|
||||
OstreeCommandInvocation *invocation,
|
||||
OstreeSysroot **out_sysroot,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
@ -376,7 +378,7 @@ ostree_admin_option_context_parse (GOptionContext *context,
|
||||
g_option_context_add_main_entries (context, global_admin_entries, NULL);
|
||||
|
||||
if (!ostree_option_context_parse (context, main_entries, argc, argv,
|
||||
OSTREE_BUILTIN_FLAG_NO_REPO, NULL, cancellable, error))
|
||||
invocation, NULL, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!opt_print_current_dir && (flags & OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT))
|
||||
|
@ -37,12 +37,26 @@ typedef enum {
|
||||
OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT = (1 << 2),
|
||||
} OstreeAdminBuiltinFlags;
|
||||
|
||||
|
||||
typedef struct OstreeCommandInvocation OstreeCommandInvocation;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
gboolean (*fn) (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
OstreeBuiltinFlags flags;
|
||||
gboolean (*fn) (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error);
|
||||
const char *description;
|
||||
} OstreeCommand;
|
||||
|
||||
/* This is a similar implementation as
|
||||
* https://github.com/projectatomic/rpm-ostree/commit/12c34bb2491a07079c911ef26401fee939e5573c.
|
||||
*
|
||||
* In the future if we want to add something new we won't need to
|
||||
* touch every prototype
|
||||
*/
|
||||
struct OstreeCommandInvocation {
|
||||
OstreeCommand *command;
|
||||
};
|
||||
|
||||
int ostree_run (int argc, char **argv, OstreeCommand *commands, GError **error);
|
||||
|
||||
int ostree_usage (OstreeCommand *commands, gboolean is_error);
|
||||
@ -58,7 +72,7 @@ gboolean ostree_parse_sysroot_or_repo_option (GOptionContext *context,
|
||||
gboolean ostree_option_context_parse (GOptionContext *context,
|
||||
const GOptionEntry *main_entries,
|
||||
int *argc, char ***argv,
|
||||
OstreeBuiltinFlags flags,
|
||||
OstreeCommandInvocation *invocation,
|
||||
OstreeRepo **out_repo,
|
||||
GCancellable *cancellable, GError **error);
|
||||
|
||||
@ -66,6 +80,7 @@ gboolean ostree_admin_option_context_parse (GOptionContext *context,
|
||||
const GOptionEntry *main_entries,
|
||||
int *argc, char ***argv,
|
||||
OstreeAdminBuiltinFlags flags,
|
||||
OstreeCommandInvocation *invocation,
|
||||
OstreeSysroot **out_sysroot,
|
||||
GCancellable *cancellable, GError **error);
|
||||
|
||||
|
@ -37,12 +37,12 @@ static GOptionEntry option_entries[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_remote_builtin_add_cookie (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_remote_builtin_add_cookie (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("NAME DOMAIN PATH COOKIE_NAME VALUE - Add a cookie to remote");
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
|
||||
OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
invocation, &repo, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (argc < 6)
|
||||
|
@ -57,7 +57,7 @@ static GOptionEntry option_entries[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_remote_builtin_add (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_remote_builtin_add (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeSysroot) sysroot = NULL;
|
||||
@ -72,7 +72,7 @@ ot_remote_builtin_add (int argc, char **argv, GCancellable *cancellable, GError
|
||||
context = g_option_context_new ("NAME [metalink=|mirrorlist=]URL [BRANCH...] - Add a remote repository");
|
||||
|
||||
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
|
||||
OSTREE_BUILTIN_FLAG_NO_REPO, NULL, cancellable, error))
|
||||
invocation, NULL, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!ostree_parse_sysroot_or_repo_option (context, opt_sysroot, opt_repo,
|
||||
|
@ -38,13 +38,13 @@ static GOptionEntry option_entries[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_remote_builtin_delete_cookie (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_remote_builtin_delete_cookie (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("NAME DOMAIN PATH COOKIE_NAME- Remove one cookie from remote");
|
||||
|
||||
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
|
||||
OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
invocation, &repo, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (argc < 5)
|
||||
|
@ -41,13 +41,13 @@ static GOptionEntry option_entries[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_remote_builtin_delete (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_remote_builtin_delete (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("NAME - Delete a remote repository");
|
||||
|
||||
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
|
||||
OSTREE_BUILTIN_FLAG_NO_REPO, NULL, cancellable, error))
|
||||
invocation, NULL, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
g_autoptr(OstreeSysroot) sysroot = NULL;
|
||||
|
@ -95,7 +95,7 @@ out:
|
||||
}
|
||||
|
||||
gboolean
|
||||
ot_remote_builtin_gpg_import (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_remote_builtin_gpg_import (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
@ -108,7 +108,7 @@ ot_remote_builtin_gpg_import (int argc, char **argv, GCancellable *cancellable,
|
||||
context = g_option_context_new ("NAME [KEY-ID...] - Import GPG keys");
|
||||
|
||||
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
|
||||
OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -37,13 +37,13 @@ static GOptionEntry option_entries[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_remote_builtin_list_cookies (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_remote_builtin_list_cookies (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("NAME - Show remote repository cookies");
|
||||
|
||||
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
|
||||
OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
invocation, &repo, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -35,7 +35,7 @@ static GOptionEntry option_entries[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_remote_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_remote_builtin_list (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
@ -46,7 +46,7 @@ ot_remote_builtin_list (int argc, char **argv, GCancellable *cancellable, GError
|
||||
context = g_option_context_new ("- List remote repository names");
|
||||
|
||||
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
|
||||
OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
remotes = ostree_repo_remote_list (repo, &n_remotes);
|
||||
|
@ -37,7 +37,7 @@ static GOptionEntry option_entries[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_remote_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_remote_builtin_refs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
@ -48,7 +48,7 @@ ot_remote_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError
|
||||
context = g_option_context_new ("NAME - List remote refs");
|
||||
|
||||
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
|
||||
OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -34,7 +34,7 @@ static GOptionEntry option_entries[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_remote_builtin_show_url (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_remote_builtin_show_url (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
@ -45,7 +45,7 @@ ot_remote_builtin_show_url (int argc, char **argv, GCancellable *cancellable, GE
|
||||
context = g_option_context_new ("NAME - Show remote repository URL");
|
||||
|
||||
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
|
||||
OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -41,7 +41,7 @@ static GOptionEntry option_entries[] = {
|
||||
};
|
||||
|
||||
gboolean
|
||||
ot_remote_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
ot_remote_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
@ -55,7 +55,7 @@ ot_remote_builtin_summary (int argc, char **argv, GCancellable *cancellable, GEr
|
||||
context = g_option_context_new ("NAME - Show remote summary");
|
||||
|
||||
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
|
||||
OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||
invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -23,17 +23,23 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean ot_remote_builtin_add (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_remote_builtin_delete (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_remote_builtin_gpg_import (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_remote_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
#define BUILTINPROTO(name) gboolean ot_remote_builtin_ ## name (int argc, char **argv, \
|
||||
OstreeCommandInvocation *invocation, \
|
||||
GCancellable *cancellable, GError **error)
|
||||
|
||||
BUILTINPROTO(add);
|
||||
BUILTINPROTO(delete);
|
||||
BUILTINPROTO(gpg_import);
|
||||
BUILTINPROTO(list);
|
||||
#ifdef HAVE_LIBSOUP
|
||||
gboolean ot_remote_builtin_add_cookie (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_remote_builtin_list_cookies (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_remote_builtin_delete_cookie (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
BUILTINPROTO(add_cookie);
|
||||
BUILTINPROTO(list_cookies);
|
||||
BUILTINPROTO(delete_cookie);
|
||||
#endif
|
||||
gboolean ot_remote_builtin_show_url (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_remote_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean ot_remote_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
BUILTINPROTO(show_url);
|
||||
BUILTINPROTO(refs);
|
||||
BUILTINPROTO(summary);
|
||||
|
||||
#undef BUILTINPROTO
|
||||
|
||||
G_END_DECLS
|
||||
|
Loading…
x
Reference in New Issue
Block a user