forked from Mirrors/flatpak-builder
cleanup: Remove trivial use of goto out
parent
b25830d8f9
commit
e4920a8e7e
|
@ -68,7 +68,6 @@ open_source_stream (GInputStream **out_source_stream,
|
|||
{
|
||||
g_autoptr(GInputStream) source_stream = NULL;
|
||||
guint n_keyrings = 0;
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GPtrArray) streams = NULL;
|
||||
|
||||
if (opt_gpg_import != NULL)
|
||||
|
@ -92,7 +91,7 @@ open_source_stream (GInputStream **out_source_stream,
|
|||
input_stream = G_INPUT_STREAM(g_file_read (file, cancellable, error));
|
||||
|
||||
if (input_stream == NULL)
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Takes ownership. */
|
||||
|
@ -104,10 +103,7 @@ open_source_stream (GInputStream **out_source_stream,
|
|||
|
||||
*out_source_stream = g_steal_pointer (&source_stream);
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -159,10 +155,7 @@ xdg_app_builtin_add_remote (int argc, char **argv,
|
|||
return FALSE;
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
usage_error (context, "NAME and LOCATION must be specified", error);
|
||||
return FALSE;
|
||||
}
|
||||
return usage_error (context, "NAME and LOCATION must be specified", error);
|
||||
|
||||
remote_name = argv[1];
|
||||
url_or_path = argv[2];
|
||||
|
@ -227,10 +220,7 @@ xdg_app_builtin_modify_remote (int argc, char **argv, GCancellable *cancellable,
|
|||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
usage_error (context, "remote NAME must be specified", error);
|
||||
return FALSE;
|
||||
}
|
||||
return usage_error (context, "remote NAME must be specified", error);
|
||||
|
||||
remote_name = argv[1];
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ static GOptionEntry options[] = {
|
|||
static gboolean
|
||||
metadata_get_arch (GFile *file, char **out_arch, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autofree char *path = NULL;
|
||||
g_autoptr(GKeyFile) keyfile = NULL;
|
||||
g_autofree char *runtime = NULL;
|
||||
|
@ -53,24 +52,22 @@ metadata_get_arch (GFile *file, char **out_arch, GError **error)
|
|||
keyfile = g_key_file_new ();
|
||||
path = g_file_get_path (file);
|
||||
if (!g_key_file_load_from_file (keyfile, path, G_KEY_FILE_NONE, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
runtime = g_key_file_get_string (keyfile, "Application", "runtime", error);
|
||||
if (*error)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
parts = g_strsplit (runtime, "/", 0);
|
||||
if (g_strv_length (parts) != 3)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Failed to determine arch from metadata runtime key: %s", runtime);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*out_arch = g_strdup (parts[1]);
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -117,7 +114,7 @@ gboolean
|
|||
xdg_app_builtin_build_export (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(GFile) base = NULL;
|
||||
g_autoptr(GFile) files = NULL;
|
||||
g_autoptr(GFile) metadata = NULL;
|
||||
|
@ -264,8 +261,6 @@ xdg_app_builtin_build_export (int argc, char **argv, GCancellable *cancellable,
|
|||
out:
|
||||
if (repo)
|
||||
ostree_repo_abort_transaction (repo, cancellable, NULL);
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
if (modifier)
|
||||
ostree_repo_commit_modifier_unref (modifier);
|
||||
|
||||
|
|
|
@ -50,14 +50,13 @@ export_dir (int source_parent_fd,
|
|||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int res;
|
||||
g_auto(GLnxDirFdIterator) source_iter = {0};
|
||||
glnx_fd_close int destination_dfd = -1;
|
||||
struct dirent *dent;
|
||||
|
||||
if (!glnx_dirfd_iterator_init_at (source_parent_fd, source_name, FALSE, &source_iter, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
do
|
||||
res = mkdirat (destination_parent_fd, destination_name, 0755);
|
||||
|
@ -67,14 +66,14 @@ export_dir (int source_parent_fd,
|
|||
if (errno != EEXIST)
|
||||
{
|
||||
glnx_set_error_from_errno (error);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!gs_file_open_dir_fd_at (destination_parent_fd, destination_name,
|
||||
&destination_dfd,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
|
@ -82,7 +81,7 @@ export_dir (int source_parent_fd,
|
|||
g_autofree char *source_printable = NULL;
|
||||
|
||||
if (!glnx_dirfd_iterator_next_dent (&source_iter, &dent, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (dent == NULL)
|
||||
break;
|
||||
|
@ -94,7 +93,7 @@ export_dir (int source_parent_fd,
|
|||
else
|
||||
{
|
||||
glnx_set_error_from_errno (error);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +108,7 @@ export_dir (int source_parent_fd,
|
|||
|
||||
if (!export_dir (source_iter.fd, dent->d_name, child_relpath, destination_dfd, dent->d_name,
|
||||
required_prefix, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
else if (S_ISREG (stbuf.st_mode))
|
||||
{
|
||||
|
@ -129,7 +128,7 @@ export_dir (int source_parent_fd,
|
|||
GLNX_FILE_COPY_NOXATTRS,
|
||||
cancellable,
|
||||
error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -138,10 +137,7 @@ export_dir (int source_parent_fd,
|
|||
}
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -152,27 +148,21 @@ copy_exports (GFile *source,
|
|||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
|
||||
if (!gs_file_ensure_directory (destination, TRUE, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
/* The fds are closed by this call */
|
||||
if (!export_dir (AT_FDCWD, gs_file_get_path_cached (source), source_prefix,
|
||||
AT_FDCWD, gs_file_get_path_cached (destination),
|
||||
required_prefix, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
collect_exports (GFile *base, const char *app_id, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GFile) files = NULL;
|
||||
g_autoptr(GFile) export = NULL;
|
||||
const char *paths[] = {
|
||||
|
@ -188,7 +178,7 @@ collect_exports (GFile *base, const char *app_id, GCancellable *cancellable, GEr
|
|||
export = g_file_get_child (base, "export");
|
||||
|
||||
if (!gs_file_ensure_directory (export, TRUE, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; paths[i]; i++)
|
||||
{
|
||||
|
@ -203,18 +193,15 @@ collect_exports (GFile *base, const char *app_id, GCancellable *cancellable, GEr
|
|||
dest_parent = g_file_get_parent (dest);
|
||||
g_debug ("Ensuring export/%s parent exists", paths[i]);
|
||||
if (!gs_file_ensure_directory (dest_parent, TRUE, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
g_debug ("Copying from files/%s", paths[i]);
|
||||
if (!copy_exports (src, dest, paths[i], app_id, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
g_assert_no_error (*error);
|
||||
out:
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -312,8 +299,7 @@ out:
|
|||
gboolean
|
||||
xdg_app_builtin_build_finish (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(GFile) base = NULL;
|
||||
g_autoptr(GFile) files_dir = NULL;
|
||||
g_autoptr(GFile) export_dir = NULL;
|
||||
|
@ -331,13 +317,10 @@ xdg_app_builtin_build_finish (int argc, char **argv, GCancellable *cancellable,
|
|||
g_option_context_add_group (context, xdg_app_context_get_options (arg_context));
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
usage_error (context, "DIRECTORY must be specified", error);
|
||||
goto out;
|
||||
}
|
||||
return usage_error (context, "DIRECTORY must be specified", error);
|
||||
|
||||
directory = argv[1];
|
||||
|
||||
|
@ -351,39 +334,35 @@ xdg_app_builtin_build_finish (int argc, char **argv, GCancellable *cancellable,
|
|||
!g_file_query_exists (metadata_file, cancellable))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Build directory %s not initialized", directory);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!g_file_load_contents (metadata_file, cancellable, &metadata_contents, &metadata_size, NULL, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
metakey = g_key_file_new ();
|
||||
if (!g_key_file_load_from_data (metakey, metadata_contents, metadata_size, 0, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
app_id = g_key_file_get_string (metakey, "Application", "name", error);
|
||||
if (app_id == NULL)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (g_file_query_exists (export_dir, cancellable))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Build directory %s already finalized", directory);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_debug ("Collecting exports");
|
||||
if (!collect_exports (base, app_id, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
g_debug ("Updating metadata");
|
||||
if (!update_metadata (base, arg_context, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
g_print ("Please review the exported files and the metadata\n");
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -43,8 +43,7 @@ static GOptionEntry options[] = {
|
|||
gboolean
|
||||
xdg_app_builtin_build_init (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(GFile) var_deploy_base = NULL;
|
||||
g_autoptr(GFile) var_deploy_files = NULL;
|
||||
g_autoptr(GFile) base = NULL;
|
||||
|
@ -66,13 +65,10 @@ xdg_app_builtin_build_init (int argc, char **argv, GCancellable *cancellable, GE
|
|||
context = g_option_context_new ("DIRECTORY APPNAME SDK RUNTIME [BRANCH] - Initialize a directory for building");
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (argc < 5)
|
||||
{
|
||||
usage_error (context, "RUNTIME must be specified", error);
|
||||
goto out;
|
||||
}
|
||||
return usage_error (context, "RUNTIME must be specified", error);
|
||||
|
||||
directory = argv[1];
|
||||
app_id = argv[2];
|
||||
|
@ -84,25 +80,25 @@ xdg_app_builtin_build_init (int argc, char **argv, GCancellable *cancellable, GE
|
|||
if (!xdg_app_is_valid_name (app_id))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid application name", app_id);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!xdg_app_is_valid_name (runtime))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid runtime name", runtime);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!xdg_app_is_valid_name (sdk))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid sdk name", sdk);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!xdg_app_is_valid_branch (branch))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid branch name", branch);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
runtime_ref = xdg_app_build_untyped_ref (runtime, branch, opt_arch);
|
||||
|
@ -111,7 +107,7 @@ xdg_app_builtin_build_init (int argc, char **argv, GCancellable *cancellable, GE
|
|||
base = g_file_new_for_commandline_arg (directory);
|
||||
|
||||
if (!gs_file_ensure_directory (base, TRUE, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
files_dir = g_file_get_child (base, "files");
|
||||
var_dir = g_file_get_child (base, "var");
|
||||
|
@ -122,7 +118,7 @@ xdg_app_builtin_build_init (int argc, char **argv, GCancellable *cancellable, GE
|
|||
if (g_file_query_exists (files_dir, cancellable))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Build directory %s already initialized", directory);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (opt_var)
|
||||
|
@ -131,31 +127,31 @@ xdg_app_builtin_build_init (int argc, char **argv, GCancellable *cancellable, GE
|
|||
|
||||
var_deploy_base = xdg_app_find_deploy_dir_for_ref (var_ref, cancellable, error);
|
||||
if (var_deploy_base == NULL)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
var_deploy_files = g_file_get_child (var_deploy_base, "files");
|
||||
}
|
||||
|
||||
if (!g_file_make_directory (files_dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (var_deploy_files)
|
||||
{
|
||||
if (!gs_shutil_cp_a (var_deploy_files, var_dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!g_file_make_directory (var_dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!gs_file_ensure_directory (var_tmp_dir, FALSE, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!g_file_query_exists (var_run_dir, cancellable) &&
|
||||
!g_file_make_symbolic_link (var_run_dir, "/run", cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
metadata_contents = g_strdup_printf("[Application]\n"
|
||||
"name=%s\n"
|
||||
|
@ -166,11 +162,7 @@ xdg_app_builtin_build_init (int argc, char **argv, GCancellable *cancellable, GE
|
|||
metadata_contents, strlen (metadata_contents), NULL, FALSE,
|
||||
G_FILE_CREATE_REPLACE_DESTINATION,
|
||||
NULL, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -88,10 +88,7 @@ xdg_app_builtin_build (int argc, char **argv, GCancellable *cancellable, GError
|
|||
return FALSE;
|
||||
|
||||
if (rest_argc == 0)
|
||||
{
|
||||
usage_error (context, "DIRECTORY must be specified", error);
|
||||
return FALSE;
|
||||
}
|
||||
return usage_error (context, "DIRECTORY must be specified", error);
|
||||
|
||||
directory = argv[rest_argv_start];
|
||||
if (rest_argc >= 2)
|
||||
|
|
|
@ -33,21 +33,17 @@
|
|||
gboolean
|
||||
xdg_app_builtin_delete_remote (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(XdgAppDir) dir = NULL;
|
||||
const char *remote_name;
|
||||
|
||||
context = g_option_context_new ("NAME - Delete a remote repository");
|
||||
|
||||
if (!xdg_app_option_context_parse (context, NULL, &argc, &argv, 0, &dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
usage_error (context, "NAME must be specified", error);
|
||||
goto out;
|
||||
}
|
||||
return usage_error (context, "NAME must be specified", error);
|
||||
|
||||
remote_name = argv[1];
|
||||
|
||||
|
@ -56,12 +52,7 @@ xdg_app_builtin_delete_remote (int argc, char **argv, GCancellable *cancellable,
|
|||
remote_name, NULL,
|
||||
NULL,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -58,8 +58,7 @@ xdg_app_builtin_export_file (int argc, char **argv,
|
|||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(GVariant) reply = NULL;
|
||||
g_autoptr(GDBusConnection) session_bus = NULL;
|
||||
g_autoptr(GPtrArray) permissions = NULL;
|
||||
|
@ -78,36 +77,33 @@ xdg_app_builtin_export_file (int argc, char **argv,
|
|||
if (!xdg_app_option_context_parse (context, options, &argc, &argv,
|
||||
XDG_APP_BUILTIN_FLAG_NO_DIR,
|
||||
NULL, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
usage_error (context, "FILE must be specified", error);
|
||||
goto out;
|
||||
}
|
||||
return usage_error (context, "FILE must be specified", error);
|
||||
|
||||
file = argv[1];
|
||||
|
||||
session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
|
||||
if (session_bus == NULL)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
documents = xdp_dbus_documents_proxy_new_sync (session_bus, 0,
|
||||
"org.freedesktop.portal.Documents",
|
||||
"/org/freedesktop/portal/documents",
|
||||
NULL, error);
|
||||
if (documents == NULL)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!xdp_dbus_documents_call_get_mount_point_sync (documents, &mountpoint,
|
||||
NULL, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
fd = open (file, O_PATH | O_CLOEXEC);
|
||||
if (fd == -1)
|
||||
{
|
||||
glnx_set_error_from_errno (error);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fd_list = g_unix_fd_list_new ();
|
||||
|
@ -129,7 +125,7 @@ xdg_app_builtin_export_file (int argc, char **argv,
|
|||
g_object_unref (fd_list);
|
||||
|
||||
if (reply == NULL)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
g_variant_get (reply, "(&s)", &doc_id);
|
||||
|
||||
|
@ -152,7 +148,7 @@ xdg_app_builtin_export_file (int argc, char **argv,
|
|||
(const char **)permissions->pdata,
|
||||
NULL,
|
||||
error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
|
@ -160,12 +156,5 @@ xdg_app_builtin_export_file (int argc, char **argv,
|
|||
doc_path = g_build_filename (mountpoint, doc_id, basename, NULL);
|
||||
g_print ("%s\n", doc_path);
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ gboolean
|
|||
xdg_app_builtin_install_runtime (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(XdgAppDir) dir = NULL;
|
||||
g_autoptr(GFile) deploy_base = NULL;
|
||||
g_autoptr(GFile) origin = NULL;
|
||||
|
@ -113,8 +113,6 @@ xdg_app_builtin_install_runtime (int argc, char **argv, GCancellable *cancellabl
|
|||
if (created_deploy_base && !ret)
|
||||
gs_shutil_rm_rf (deploy_base, cancellable, NULL);
|
||||
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -122,7 +120,7 @@ gboolean
|
|||
xdg_app_builtin_install_app (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(XdgAppDir) dir = NULL;
|
||||
g_autoptr(GFile) deploy_base = NULL;
|
||||
g_autoptr(GFile) origin = NULL;
|
||||
|
@ -199,7 +197,5 @@ xdg_app_builtin_install_app (int argc, char **argv, GCancellable *cancellable, G
|
|||
if (created_deploy_base && !ret)
|
||||
gs_shutil_rm_rf (deploy_base, cancellable, NULL);
|
||||
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@ static GOptionEntry options[] = {
|
|||
static gboolean
|
||||
print_installed_refs (const char *kind, gboolean print_system, gboolean print_user, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autofree char *last = NULL;
|
||||
g_auto(GStrv) system = NULL;
|
||||
g_auto(GStrv) user = NULL;
|
||||
|
@ -57,7 +56,7 @@ print_installed_refs (const char *kind, gboolean print_system, gboolean print_us
|
|||
|
||||
dir = xdg_app_dir_get (TRUE);
|
||||
if (!xdg_app_dir_list_refs (dir, kind, &user, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
user = g_new0 (char *, 1);
|
||||
|
@ -68,7 +67,7 @@ print_installed_refs (const char *kind, gboolean print_system, gboolean print_us
|
|||
|
||||
dir = xdg_app_dir_get (FALSE);
|
||||
if (!xdg_app_dir_list_refs (dir, kind, &system, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
system = g_new0 (char *, 1);
|
||||
|
@ -137,62 +136,43 @@ print_installed_refs (const char *kind, gboolean print_system, gboolean print_us
|
|||
xdg_app_table_printer_print (printer);
|
||||
xdg_app_table_printer_free (printer);
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xdg_app_builtin_list_runtimes (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
|
||||
context = g_option_context_new (" - List installed runtimes");
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!print_installed_refs ("runtime",
|
||||
opt_system || (!opt_user && !opt_system),
|
||||
opt_user || (!opt_user && !opt_system),
|
||||
cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xdg_app_builtin_list_apps (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
|
||||
context = g_option_context_new (" - List installed applications");
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!print_installed_refs ("app",
|
||||
opt_system || (!opt_user && !opt_system),
|
||||
opt_user || (!opt_user && !opt_system),
|
||||
cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -47,8 +47,7 @@ static GOptionEntry options[] = {
|
|||
gboolean
|
||||
xdg_app_builtin_ls_remote (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(XdgAppDir) dir = NULL;
|
||||
OstreeRepo *repo = NULL;
|
||||
g_autoptr(GHashTable) refs = NULL;
|
||||
|
@ -64,22 +63,19 @@ xdg_app_builtin_ls_remote (int argc, char **argv, GCancellable *cancellable, GEr
|
|||
context = g_option_context_new (" REMOTE - Show available runtimes and applications");
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, 0, &dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
usage_error (context, "REMOTE must be specified", error);
|
||||
goto out;
|
||||
}
|
||||
return usage_error (context, "REMOTE must be specified", error);
|
||||
|
||||
repository = argv[1];
|
||||
|
||||
repo = xdg_app_dir_get_repo (dir);
|
||||
if (!ostree_repo_remote_get_url (repo, repository, &url, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!ostree_repo_load_summary (url, &refs, &title, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
names = g_ptr_array_new_with_free_func (g_free);
|
||||
|
||||
|
@ -94,7 +90,7 @@ xdg_app_builtin_ls_remote (int argc, char **argv, GCancellable *cancellable, GEr
|
|||
char *p;
|
||||
|
||||
if (!ostree_parse_refspec (refspec, &remote, &ref, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (remote != NULL && !g_str_equal (remote, repository))
|
||||
continue;
|
||||
|
@ -164,11 +160,5 @@ xdg_app_builtin_ls_remote (int argc, char **argv, GCancellable *cancellable, GEr
|
|||
for (i = 0; i < names->len; i++)
|
||||
g_print ("%s\n", (char *)g_ptr_array_index (names, i));
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -41,8 +41,7 @@ static GOptionEntry options[] = {
|
|||
gboolean
|
||||
xdg_app_builtin_make_current_app (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(XdgAppDir) dir = NULL;
|
||||
g_autoptr(GFile) deploy_base = NULL;
|
||||
const char *app;
|
||||
|
@ -52,13 +51,10 @@ xdg_app_builtin_make_current_app (int argc, char **argv, GCancellable *cancellab
|
|||
context = g_option_context_new ("APP BRANCH - Make branch of application current");
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, 0, &dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
usage_error (context, "APP and BRANCH must be specified", error);
|
||||
goto out;
|
||||
}
|
||||
return usage_error (context, "APP and BRANCH must be specified", error);
|
||||
|
||||
app = argv[1];
|
||||
branch = argv[2];
|
||||
|
@ -66,13 +62,13 @@ xdg_app_builtin_make_current_app (int argc, char **argv, GCancellable *cancellab
|
|||
if (!xdg_app_is_valid_name (app))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid application name", app);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!xdg_app_is_valid_branch (branch))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid branch name", branch);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ref = xdg_app_build_app_ref (app, branch, opt_arch);
|
||||
|
@ -81,19 +77,14 @@ xdg_app_builtin_make_current_app (int argc, char **argv, GCancellable *cancellab
|
|||
if (!g_file_query_exists (deploy_base, cancellable))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "App %s branch %s is not installed", app, branch);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!xdg_app_dir_make_current_ref (dir, ref, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!xdg_app_dir_update_exports (dir, app, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -42,8 +42,7 @@ static GOptionEntry options[] = {
|
|||
gboolean
|
||||
xdg_app_builtin_repo_update (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(GFile) repofile = NULL;
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
const char *location;
|
||||
|
@ -52,13 +51,10 @@ xdg_app_builtin_repo_update (int argc, char **argv, GCancellable *cancellable, G
|
|||
context = g_option_context_new ("LOCATION - Update repository metadata");
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
usage_error (context, "LOCATION must be specified", error);
|
||||
goto out;
|
||||
}
|
||||
return usage_error (context, "LOCATION must be specified", error);
|
||||
|
||||
location = argv[1];
|
||||
|
||||
|
@ -66,7 +62,7 @@ xdg_app_builtin_repo_update (int argc, char **argv, GCancellable *cancellable, G
|
|||
repo = ostree_repo_new (repofile);
|
||||
|
||||
if (!ostree_repo_open (repo, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (opt_title)
|
||||
{
|
||||
|
@ -78,15 +74,9 @@ xdg_app_builtin_repo_update (int argc, char **argv, GCancellable *cancellable, G
|
|||
}
|
||||
|
||||
if (!ostree_repo_regenerate_summary (repo, extra, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
/* TODO: appstream data */
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -60,8 +60,7 @@ dbus_spawn_child_setup (gpointer user_data)
|
|||
gboolean
|
||||
xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(XdgAppDeploy) app_deploy = NULL;
|
||||
g_autoptr(XdgAppDeploy) runtime_deploy = NULL;
|
||||
g_autoptr(GFile) app_files = NULL;
|
||||
|
@ -115,13 +114,10 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
|
|||
g_option_context_add_group (context, xdg_app_context_get_options (arg_context));
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (rest_argc == 0)
|
||||
{
|
||||
usage_error (context, "APP must be specified", error);
|
||||
goto out;
|
||||
}
|
||||
return usage_error (context, "APP must be specified", error);
|
||||
|
||||
app = argv[rest_argv_start];
|
||||
|
||||
|
@ -131,20 +127,20 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
|
|||
if (!xdg_app_is_valid_name (app))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid application name", app);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!xdg_app_is_valid_branch (branch))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid branch name", branch);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
app_ref = xdg_app_build_app_ref (app, branch, opt_arch);
|
||||
|
||||
app_deploy = xdg_app_find_deploy_for_ref (app_ref, cancellable, error);
|
||||
if (app_deploy == NULL)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
metakey = xdg_app_deploy_get_metadata (app_deploy);
|
||||
|
||||
|
@ -154,7 +150,7 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
|
|||
g_ptr_array_add (argv_array, g_strdup ("-l"));
|
||||
|
||||
if (!xdg_app_run_add_extension_args (argv_array, metakey, app_ref, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (opt_runtime)
|
||||
runtime = opt_runtime;
|
||||
|
@ -162,22 +158,22 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
|
|||
{
|
||||
runtime = g_key_file_get_string (metakey, "Application", opt_devel ? "sdk" : "runtime", error);
|
||||
if (*error)
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
runtime_ref = g_build_filename ("runtime", runtime, NULL);
|
||||
|
||||
runtime_deploy = xdg_app_find_deploy_for_ref (runtime_ref, cancellable, error);
|
||||
if (runtime_deploy == NULL)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
runtime_metakey = xdg_app_deploy_get_metadata (runtime_deploy);
|
||||
|
||||
app_context = xdg_app_context_new ();
|
||||
if (!xdg_app_context_load_metadata (app_context, runtime_metakey, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
if (!xdg_app_context_load_metadata (app_context, metakey, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
overrides = xdg_app_deploy_get_overrides (app_deploy);
|
||||
xdg_app_context_merge (app_context, overrides);
|
||||
|
@ -185,10 +181,10 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
|
|||
xdg_app_context_merge (app_context, arg_context);
|
||||
|
||||
if (!xdg_app_run_add_extension_args (argv_array, runtime_metakey, runtime_ref, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if ((app_id_dir = xdg_app_ensure_data_dir (app, cancellable, error)) == NULL)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
app_cache_dir = g_file_get_child (app_id_dir, "cache");
|
||||
g_ptr_array_add (argv_array, g_strdup ("-B"));
|
||||
|
@ -207,7 +203,7 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
|
|||
|
||||
default_command = g_key_file_get_string (metakey, "Application", "command", error);
|
||||
if (*error)
|
||||
goto out;
|
||||
return FALSE;
|
||||
if (opt_command)
|
||||
command = opt_command;
|
||||
else
|
||||
|
@ -294,7 +290,7 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
|
|||
if (pipe (sync_proxy_pipes) < 0)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno), "Unable to create sync pipe");
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_ptr_array_insert (dbus_proxy_argv, 0, g_strdup (DBUSPROXY));
|
||||
|
@ -309,7 +305,7 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
|
|||
dbus_spawn_child_setup,
|
||||
GINT_TO_POINTER (sync_proxy_pipes[1]),
|
||||
NULL, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
close (sync_proxy_pipes[1]);
|
||||
|
||||
|
@ -317,7 +313,7 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
|
|||
if (read (sync_proxy_pipes[0], &x, 1) != 1)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno), "Failed to sync with dbus proxy");
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_ptr_array_add (argv_array, g_strdup ("-S"));
|
||||
|
@ -346,14 +342,9 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
|
|||
if (execvpe (HELPER, (char **)argv_array->pdata, envp) == -1)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno), "Unable to start app");
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Not actually reached... */
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -45,8 +45,7 @@ static GOptionEntry options[] = {
|
|||
gboolean
|
||||
xdg_app_builtin_uninstall_runtime (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(XdgAppDir) dir = NULL;
|
||||
g_autoptr(GFile) deploy_base = NULL;
|
||||
g_autoptr(GFile) arch_dir = NULL;
|
||||
|
@ -64,13 +63,10 @@ xdg_app_builtin_uninstall_runtime (int argc, char **argv, GCancellable *cancella
|
|||
context = g_option_context_new ("RUNTIME [BRANCH] - Uninstall a runtime");
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, 0, &dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
usage_error (context, "RUNTIME must be specified", error);
|
||||
goto out;
|
||||
}
|
||||
return usage_error (context, "RUNTIME must be specified", error);
|
||||
|
||||
name = argv[1];
|
||||
if (argc > 2)
|
||||
|
@ -85,13 +81,13 @@ xdg_app_builtin_uninstall_runtime (int argc, char **argv, GCancellable *cancella
|
|||
if (!xdg_app_is_valid_name (name))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid runtime name", name);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!xdg_app_is_valid_branch (branch))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid branch name", branch);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* TODO: look for apps, require --force */
|
||||
|
@ -102,30 +98,30 @@ xdg_app_builtin_uninstall_runtime (int argc, char **argv, GCancellable *cancella
|
|||
if (!g_file_query_exists (deploy_base, cancellable))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Nothing to uninstall");
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
repository = xdg_app_dir_get_origin (dir, ref, cancellable, error);
|
||||
if (repository == NULL)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
g_debug ("dropping active ref");
|
||||
if (!xdg_app_dir_set_active (dir, ref, NULL, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!xdg_app_dir_list_deployed (dir, ref, &deployed, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; deployed[i] != NULL; i++)
|
||||
{
|
||||
g_debug ("undeploying %s", deployed[i]);
|
||||
if (!xdg_app_dir_undeploy (dir, ref, deployed[i], opt_force_remove, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_debug ("removing deploy base");
|
||||
if (!gs_shutil_rm_rf (deploy_base, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
g_debug ("cleaning up empty directories");
|
||||
arch_dir = g_file_get_parent (deploy_base);
|
||||
|
@ -134,7 +130,7 @@ xdg_app_builtin_uninstall_runtime (int argc, char **argv, GCancellable *cancella
|
|||
if (!g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_EMPTY))
|
||||
{
|
||||
g_propagate_error (error, temp_error);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
g_clear_error (&temp_error);
|
||||
}
|
||||
|
@ -145,7 +141,7 @@ xdg_app_builtin_uninstall_runtime (int argc, char **argv, GCancellable *cancella
|
|||
if (!g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_EMPTY))
|
||||
{
|
||||
g_propagate_error (error, temp_error);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
g_clear_error (&temp_error);
|
||||
}
|
||||
|
@ -155,27 +151,21 @@ xdg_app_builtin_uninstall_runtime (int argc, char **argv, GCancellable *cancella
|
|||
repo = xdg_app_dir_get_repo (dir);
|
||||
|
||||
if (!ostree_repo_set_ref_immediate (repo, repository, ref, NULL, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!xdg_app_dir_prune (dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
xdg_app_dir_cleanup_removed (dir, cancellable, NULL);
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xdg_app_builtin_uninstall_app (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(XdgAppDir) dir = NULL;
|
||||
g_autoptr(GFile) deploy_base = NULL;
|
||||
g_autoptr(GFile) arch_dir = NULL;
|
||||
|
@ -194,13 +184,10 @@ xdg_app_builtin_uninstall_app (int argc, char **argv, GCancellable *cancellable,
|
|||
context = g_option_context_new ("APP [BRANCH] - Uninstall an application");
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, 0, &dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
usage_error (context, "APP must be specified", error);
|
||||
goto out;
|
||||
}
|
||||
return usage_error (context, "APP must be specified", error);
|
||||
|
||||
name = argv[1];
|
||||
if (argc > 2)
|
||||
|
@ -215,13 +202,13 @@ xdg_app_builtin_uninstall_app (int argc, char **argv, GCancellable *cancellable,
|
|||
if (!xdg_app_is_valid_name (name))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid application name", name);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!xdg_app_is_valid_branch (branch))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid branch name", branch);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ref = g_build_filename ("app", name, arch, branch, NULL);
|
||||
|
@ -230,41 +217,41 @@ xdg_app_builtin_uninstall_app (int argc, char **argv, GCancellable *cancellable,
|
|||
if (!g_file_query_exists (deploy_base, cancellable))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Nothing to uninstall");
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
repository = xdg_app_dir_get_origin (dir, ref, cancellable, error);
|
||||
if (repository == NULL)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
g_debug ("dropping active ref");
|
||||
if (!xdg_app_dir_set_active (dir, ref, NULL, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
current_ref = xdg_app_dir_current_ref (dir, name, cancellable);
|
||||
if (current_ref != NULL && strcmp (ref, current_ref) == 0)
|
||||
{
|
||||
g_debug ("dropping current ref");
|
||||
if (!xdg_app_dir_drop_current_ref (dir, name, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!xdg_app_dir_list_deployed (dir, ref, &deployed, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; deployed[i] != NULL; i++)
|
||||
{
|
||||
g_debug ("undeploying %s", deployed[i]);
|
||||
if (!xdg_app_dir_undeploy (dir, ref, deployed[i], opt_force_remove, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_debug ("removing deploy base");
|
||||
if (!gs_shutil_rm_rf (deploy_base, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!xdg_app_dir_update_exports (dir, name, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
g_debug ("cleaning up empty directories");
|
||||
arch_dir = g_file_get_parent (deploy_base);
|
||||
|
@ -273,7 +260,7 @@ xdg_app_builtin_uninstall_app (int argc, char **argv, GCancellable *cancellable,
|
|||
if (!g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_EMPTY))
|
||||
{
|
||||
g_propagate_error (error, temp_error);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
g_clear_error (&temp_error);
|
||||
}
|
||||
|
@ -284,7 +271,7 @@ xdg_app_builtin_uninstall_app (int argc, char **argv, GCancellable *cancellable,
|
|||
if (!g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_EMPTY))
|
||||
{
|
||||
g_propagate_error (error, temp_error);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
g_clear_error (&temp_error);
|
||||
}
|
||||
|
@ -294,18 +281,13 @@ xdg_app_builtin_uninstall_app (int argc, char **argv, GCancellable *cancellable,
|
|||
repo = xdg_app_dir_get_repo (dir);
|
||||
|
||||
if (!ostree_repo_set_ref_immediate (repo, repository, ref, NULL, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!xdg_app_dir_prune (dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
xdg_app_dir_cleanup_removed (dir, cancellable, NULL);
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -45,8 +45,7 @@ static GOptionEntry options[] = {
|
|||
gboolean
|
||||
xdg_app_builtin_update_runtime (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(XdgAppDir) dir = NULL;
|
||||
const char *runtime;
|
||||
const char *branch = "master";
|
||||
|
@ -58,13 +57,10 @@ xdg_app_builtin_update_runtime (int argc, char **argv, GCancellable *cancellable
|
|||
context = g_option_context_new ("RUNTIME [BRANCH] - Update a runtime");
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, 0, &dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
usage_error (context, "RUNTIME must be specified", error);
|
||||
goto out;
|
||||
}
|
||||
return usage_error (context, "RUNTIME must be specified", error);
|
||||
|
||||
runtime = argv[1];
|
||||
if (argc >= 3)
|
||||
|
@ -73,24 +69,24 @@ xdg_app_builtin_update_runtime (int argc, char **argv, GCancellable *cancellable
|
|||
if (!xdg_app_is_valid_name (runtime))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid runtime name", runtime);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!xdg_app_is_valid_branch (branch))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid branch name", branch);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ref = xdg_app_build_runtime_ref (runtime, branch, opt_arch);
|
||||
|
||||
repository = xdg_app_dir_get_origin (dir, ref, cancellable, error);
|
||||
if (repository == NULL)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!xdg_app_dir_pull (dir, repository, ref,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
previous_deployment = xdg_app_dir_read_active (dir, ref, cancellable);
|
||||
|
||||
|
@ -102,7 +98,7 @@ xdg_app_builtin_update_runtime (int argc, char **argv, GCancellable *cancellable
|
|||
else
|
||||
{
|
||||
g_propagate_error (error, my_error);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -112,25 +108,20 @@ xdg_app_builtin_update_runtime (int argc, char **argv, GCancellable *cancellable
|
|||
if (!xdg_app_dir_undeploy (dir, ref, previous_deployment,
|
||||
opt_force_remove,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!xdg_app_dir_prune (dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xdg_app_builtin_update_app (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(XdgAppDir) dir = NULL;
|
||||
const char *app;
|
||||
const char *branch = "master";
|
||||
|
@ -142,13 +133,10 @@ xdg_app_builtin_update_app (int argc, char **argv, GCancellable *cancellable, GE
|
|||
context = g_option_context_new ("APP [BRANCH] - Update an application");
|
||||
|
||||
if (!xdg_app_option_context_parse (context, options, &argc, &argv, 0, &dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
usage_error (context, "APP must be specified", error);
|
||||
goto out;
|
||||
}
|
||||
return usage_error (context, "APP must be specified", error);
|
||||
|
||||
app = argv[1];
|
||||
if (argc >= 3)
|
||||
|
@ -157,24 +145,24 @@ xdg_app_builtin_update_app (int argc, char **argv, GCancellable *cancellable, GE
|
|||
if (!xdg_app_is_valid_name (app))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid application name", app);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!xdg_app_is_valid_branch (branch))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "'%s' is not a valid branch name", branch);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ref = xdg_app_build_app_ref (app, branch, opt_arch);
|
||||
|
||||
repository = xdg_app_dir_get_origin (dir, ref, cancellable, error);
|
||||
if (repository == NULL)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!xdg_app_dir_pull (dir, repository, ref,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
previous_deployment = xdg_app_dir_read_active (dir, ref, cancellable);
|
||||
|
||||
|
@ -186,7 +174,7 @@ xdg_app_builtin_update_app (int argc, char **argv, GCancellable *cancellable, GE
|
|||
else
|
||||
{
|
||||
g_propagate_error (error, my_error);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -196,19 +184,15 @@ xdg_app_builtin_update_app (int argc, char **argv, GCancellable *cancellable, GE
|
|||
if (!xdg_app_dir_undeploy (dir, ref, previous_deployment,
|
||||
opt_force_remove,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!xdg_app_dir_prune (dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!xdg_app_dir_update_exports (dir, app, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -149,7 +149,6 @@ xdg_app_option_context_parse (GOptionContext *context,
|
|||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = FALSE;
|
||||
g_autoptr(XdgAppDir) dir = NULL;
|
||||
|
||||
if (!(flags & XDG_APP_BUILTIN_FLAG_NO_DIR))
|
||||
|
@ -174,11 +173,11 @@ xdg_app_option_context_parse (GOptionContext *context,
|
|||
dir = xdg_app_dir_get (opt_user);
|
||||
|
||||
if (!xdg_app_dir_ensure_path (dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (!(flags & XDG_APP_BUILTIN_FLAG_NO_REPO) &&
|
||||
!xdg_app_dir_ensure_repo (dir, cancellable,error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (opt_verbose)
|
||||
|
@ -187,9 +186,7 @@ xdg_app_option_context_parse (GOptionContext *context,
|
|||
if (out_dir)
|
||||
*out_dir = g_steal_pointer (&dir);
|
||||
|
||||
success = TRUE;
|
||||
out:
|
||||
return success;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
Loading…
Reference in New Issue