#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 }
};
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;
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))
};
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;
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)
};
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;
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,
};
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)
#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:");
}
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;
argc = out;
- OstreeAdminInstUtilCommand *subcommand = admin_instutil_subcommands;
+ OstreeCommand *subcommand = admin_instutil_subcommands;
while (subcommand->name)
{
if (g_strcmp0 (subcommand_name, subcommand->name) == 0)
/* 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)
{
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;
};
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;
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))
};
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;
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)
}
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;
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))
};
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)
};
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;
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)
};
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;
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)
};
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)
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
};
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;
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)
};
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;
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);
};
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;
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);
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
#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:");
}
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;
/* 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)
{
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;
}
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)
}
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;
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)
}
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)
}
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;
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))
}
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;
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)
gboolean
ostree_builtin_create_usb (int argc,
char **argv,
+ OstreeCommandInvocation *invocation,
GCancellable *cancellable,
GError **error)
{
/* 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)
}
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;
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)
#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;
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
gboolean
ostree_builtin_find_remotes (int argc,
char **argv,
+ OstreeCommandInvocation *invocation,
GCancellable *cancellable,
GError **error)
{
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))
}
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)
}
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;
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)
};
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;
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))
gboolean
ostree_builtin_log (int argc,
char **argv,
+ OstreeCommandInvocation *invocation,
GCancellable *cancellable,
GError **error)
{
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)
}
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;
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)
}
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))
}
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;
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))
}
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;
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))
}
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;
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)
#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:");
}
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;
/* 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)
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;
gboolean
ostree_builtin_reset (int argc,
char **argv,
+ OstreeCommandInvocation *invocation,
GCancellable *cancellable,
GError **error)
{
/* 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))
};
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;
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)
}
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)
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);
#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:
}
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;
}
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;
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)
}
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;
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)
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))
}
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;
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))
}
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;
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);
}
}
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;
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)
#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 ();
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);
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)
{
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;
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. */
int *argc,
char ***argv,
OstreeAdminBuiltinFlags flags,
+ OstreeCommandInvocation *invocation,
OstreeSysroot **out_sysroot,
GCancellable *cancellable,
GError **error)
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))
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);
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);
const GOptionEntry *main_entries,
int *argc, char ***argv,
OstreeAdminBuiltinFlags flags,
+ OstreeCommandInvocation *invocation,
OstreeSysroot **out_sysroot,
GCancellable *cancellable, GError **error);
};
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)
};
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;
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,
};
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)
};
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;
}
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;
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)
};
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)
};
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;
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);
};
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;
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)
};
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;
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)
};
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;
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)
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