mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-22 17:35:55 +03:00
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:
parent
86e504ba1d
commit
ba5fc5cbcc
@ -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)
|
||||
|
||||
if USE_LIBSOUP
|
||||
bin_PROGRAMS += ostree-pull
|
||||
ostree_pull_SOURCES = src/ostree/ot-main.h \
|
||||
src/ostree/ot-main.c \
|
||||
src/ostree/ostree-fetcher.h \
|
||||
ostree_SOURCES += src/ostree/ostree-fetcher.h \
|
||||
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_pull_LDADD = $(ostree_bin_shared_ldadd) $(OT_INTERNAL_SOUP_LIBS)
|
||||
ostree_CFLAGS += $(OT_INTERNAL_SOUP_CFLAGS)
|
||||
ostree_LDADD += $(OT_INTERNAL_SOUP_LIBS)
|
||||
endif
|
||||
|
||||
MANPAGES += doc/ostree.1
|
||||
|
@ -43,7 +43,7 @@ static OstreeCommand commands[] = {
|
||||
{ "log", ostree_builtin_log, 0 },
|
||||
{ "ls", ostree_builtin_ls, 0 },
|
||||
{ "prune", ostree_builtin_prune, 0 },
|
||||
{ "pull", NULL, 0 },
|
||||
{ "pull", ostree_builtin_pull, 0 },
|
||||
{ "pull-local", ostree_builtin_pull_local, 0 },
|
||||
{ "remote", ostree_builtin_remote, 0 },
|
||||
{ "rev-parse", ostree_builtin_rev_parse, 0 },
|
||||
@ -52,40 +52,6 @@ static OstreeCommand commands[] = {
|
||||
{ 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
|
||||
main (int argc,
|
||||
char **argv)
|
||||
@ -94,12 +60,6 @@ main (int argc,
|
||||
int ret;
|
||||
|
||||
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))
|
||||
ostree_usage (argv, commands, TRUE);
|
||||
|
||||
|
@ -70,6 +70,7 @@
|
||||
|
||||
#include "ostree.h"
|
||||
#include "ot-main.h"
|
||||
#include "ot-builtins.h"
|
||||
|
||||
#include "ostree-fetcher.h"
|
||||
|
||||
@ -1170,7 +1171,7 @@ load_remote_repo_config (OtPullData *pull_data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gboolean
|
||||
ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
@ -1469,15 +1470,3 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
soup_uri_free (summary_uri);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static OstreeCommand commands[] = {
|
||||
{ "pull", ostree_builtin_pull, 0 },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
return ostree_main (argc, argv, commands);
|
||||
}
|
||||
|
@ -482,7 +482,7 @@ ot_admin_pull (GFile *ostree_dir,
|
||||
return gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
||||
GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
|
||||
cancellable, error,
|
||||
"ostree", "pull", repo_arg, osname, NULL);
|
||||
"ostree", repo_arg, "pull", osname, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -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_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_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_log (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
|
Loading…
Reference in New Issue
Block a user