Fold ostree-pull into main binary

The rationale for the separation was always kind of weak; I want to
refactor the command line argument parsing, and it was complicating
things.
This commit is contained in:
Colin Walters 2013-05-30 18:32:46 -04:00
parent 86e504ba1d
commit ba5fc5cbcc
5 changed files with 10 additions and 62 deletions

View File

@ -70,15 +70,13 @@ ostree_CFLAGS = $(ostree_bin_shared_cflags) $(OT_INTERNAL_GIO_UNIX_CFLAGS)
ostree_LDADD = $(ostree_bin_shared_ldadd) $(OT_INTERNAL_GIO_UNIX_LIBS) ostree_LDADD = $(ostree_bin_shared_ldadd) $(OT_INTERNAL_GIO_UNIX_LIBS)
if USE_LIBSOUP if USE_LIBSOUP
bin_PROGRAMS += ostree-pull ostree_SOURCES += src/ostree/ostree-fetcher.h \
ostree_pull_SOURCES = src/ostree/ot-main.h \
src/ostree/ot-main.c \
src/ostree/ostree-fetcher.h \
src/ostree/ostree-fetcher.c \ src/ostree/ostree-fetcher.c \
src/ostree/ostree-pull.c src/ostree/ostree-pull.c \
$(NULL)
ostree_pull_CFLAGS = $(ostree_bin_shared_cflags) $(OT_INTERNAL_SOUP_CFLAGS) ostree_CFLAGS += $(OT_INTERNAL_SOUP_CFLAGS)
ostree_pull_LDADD = $(ostree_bin_shared_ldadd) $(OT_INTERNAL_SOUP_LIBS) ostree_LDADD += $(OT_INTERNAL_SOUP_LIBS)
endif endif
MANPAGES += doc/ostree.1 MANPAGES += doc/ostree.1

View File

@ -43,7 +43,7 @@ static OstreeCommand commands[] = {
{ "log", ostree_builtin_log, 0 }, { "log", ostree_builtin_log, 0 },
{ "ls", ostree_builtin_ls, 0 }, { "ls", ostree_builtin_ls, 0 },
{ "prune", ostree_builtin_prune, 0 }, { "prune", ostree_builtin_prune, 0 },
{ "pull", NULL, 0 }, { "pull", ostree_builtin_pull, 0 },
{ "pull-local", ostree_builtin_pull_local, 0 }, { "pull-local", ostree_builtin_pull_local, 0 },
{ "remote", ostree_builtin_remote, 0 }, { "remote", ostree_builtin_remote, 0 },
{ "rev-parse", ostree_builtin_rev_parse, 0 }, { "rev-parse", ostree_builtin_rev_parse, 0 },
@ -52,40 +52,6 @@ static OstreeCommand commands[] = {
{ NULL } { NULL }
}; };
static int
exec_external (int argc,
char **argv,
GError **error)
{
gchar *command;
gchar *tmp;
int errn;
command = g_strdup_printf ("ostree-%s", argv[1]);
tmp = argv[1];
argv[1] = command;
execvp (command, argv + 1);
errn = errno;
argv[1] = tmp;
g_free (command);
if (errn == ENOENT)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"Unknown command: '%s'", argv[1]);
}
else
{
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errn),
"Failed to execute command: %s", g_strerror (errn));
}
return 1;
}
int int
main (int argc, main (int argc,
char **argv) char **argv)
@ -94,12 +60,6 @@ main (int argc,
int ret; int ret;
ret = ostree_run (argc, argv, commands, &error); ret = ostree_run (argc, argv, commands, &error);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
{
g_clear_error (&error);
ret = exec_external (argc, argv, &error);
}
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
ostree_usage (argv, commands, TRUE); ostree_usage (argv, commands, TRUE);

View File

@ -70,6 +70,7 @@
#include "ostree.h" #include "ostree.h"
#include "ot-main.h" #include "ot-main.h"
#include "ot-builtins.h"
#include "ostree-fetcher.h" #include "ostree-fetcher.h"
@ -1170,7 +1171,7 @@ load_remote_repo_config (OtPullData *pull_data,
return ret; return ret;
} }
static gboolean gboolean
ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error) ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
@ -1469,15 +1470,3 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
soup_uri_free (summary_uri); soup_uri_free (summary_uri);
return ret; return ret;
} }
static OstreeCommand commands[] = {
{ "pull", ostree_builtin_pull, 0 },
{ NULL }
};
int
main (int argc,
char **argv)
{
return ostree_main (argc, argv, commands);
}

View File

@ -482,7 +482,7 @@ ot_admin_pull (GFile *ostree_dir,
return gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir), return gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT, GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
cancellable, error, cancellable, error,
"ostree", "pull", repo_arg, osname, NULL); "ostree", repo_arg, "pull", osname, NULL);
} }
void void

View File

@ -35,6 +35,7 @@ gboolean ostree_builtin_checksum (int argc, char **argv, GFile *repo_path, GErro
gboolean ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GError **error); gboolean ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GError **error);
gboolean ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GError **error); gboolean ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GError **error);
gboolean ostree_builtin_init (int argc, char **argv, GFile *repo_path, GError **error); gboolean ostree_builtin_init (int argc, char **argv, GFile *repo_path, GError **error);
gboolean ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error);
gboolean ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GError **error); gboolean ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GError **error);
gboolean ostree_builtin_log (int argc, char **argv, GFile *repo_path, GError **error); gboolean ostree_builtin_log (int argc, char **argv, GFile *repo_path, GError **error);
gboolean ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GError **error); gboolean ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GError **error);