forked from Mirrors/flatpak-builder
Add and use xdg_app_find_deploy_dir_for_ref helper
parent
5f36dda947
commit
734ca13f82
|
@ -99,14 +99,9 @@ xdg_app_builtin_build_init (int argc, char **argv, GCancellable *cancellable, GE
|
|||
|
||||
var_ref = xdg_app_build_runtime_ref (opt_var, branch, opt_arch);
|
||||
|
||||
var_deploy_base = xdg_app_dir_get_if_deployed (user_dir, var_ref, NULL, cancellable);
|
||||
var_deploy_base = xdg_app_find_deploy_dir_for_ref (var_ref, cancellable, error);
|
||||
if (var_deploy_base == NULL)
|
||||
var_deploy_base = xdg_app_dir_get_if_deployed (system_dir, var_ref, NULL, cancellable);
|
||||
if (var_deploy_base == NULL)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Var runtime %s branch %s not installed", opt_var, branch);
|
||||
goto out;
|
||||
}
|
||||
goto out;
|
||||
|
||||
var_deploy_files = g_file_get_child (var_deploy_base, "files");
|
||||
}
|
||||
|
|
|
@ -62,7 +62,6 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
|
|||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
gs_unref_object XdgAppDir *user_dir = NULL;
|
||||
gs_unref_object XdgAppDir *system_dir = NULL;
|
||||
gs_unref_variant_builder GVariantBuilder *optbuilder = NULL;
|
||||
gs_unref_object GFile *deploy_base = NULL;
|
||||
gs_unref_object GFile *var = NULL;
|
||||
|
@ -125,16 +124,10 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
|
|||
app_ref = xdg_app_build_app_ref (app, branch, opt_arch);
|
||||
|
||||
user_dir = xdg_app_dir_get_user ();
|
||||
system_dir = xdg_app_dir_get_system ();
|
||||
|
||||
app_deploy = xdg_app_dir_get_if_deployed (user_dir, app_ref, NULL, cancellable);
|
||||
app_deploy = xdg_app_find_deploy_dir_for_ref (app_ref, cancellable, error);
|
||||
if (app_deploy == NULL)
|
||||
app_deploy = xdg_app_dir_get_if_deployed (system_dir, app_ref, NULL, cancellable);
|
||||
if (app_deploy == NULL)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "App %s branch %s not installed", app, branch);
|
||||
goto out;
|
||||
}
|
||||
goto out;
|
||||
|
||||
metadata = g_file_get_child (app_deploy, "metadata");
|
||||
if (!g_file_load_contents (metadata, cancellable, &metadata_contents, &metadata_size, NULL, error))
|
||||
|
@ -150,14 +143,9 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
|
|||
|
||||
runtime_ref = g_build_filename ("runtime", runtime, NULL);
|
||||
|
||||
runtime_deploy = xdg_app_dir_get_if_deployed (user_dir, runtime_ref, NULL, cancellable);
|
||||
runtime_deploy = xdg_app_find_deploy_dir_for_ref (runtime_ref, cancellable, error);
|
||||
if (runtime_deploy == NULL)
|
||||
runtime_deploy = xdg_app_dir_get_if_deployed (system_dir, runtime_ref, NULL, cancellable);
|
||||
if (runtime_deploy == NULL)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Required runtime %s not installed", runtime);
|
||||
goto out;
|
||||
}
|
||||
goto out;
|
||||
|
||||
if (!xdg_app_dir_ensure_path (user_dir, cancellable, error))
|
||||
goto out;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#include "config.h"
|
||||
|
||||
#include "xdg-app-utils.h"
|
||||
#include "xdg-app-dir.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include "libgsystem.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/utsname.h>
|
||||
|
@ -56,3 +58,28 @@ xdg_app_build_app_ref (const char *app,
|
|||
|
||||
return g_build_filename ("app", app, arch, branch, NULL);
|
||||
}
|
||||
|
||||
GFile *
|
||||
xdg_app_find_deploy_dir_for_ref (const char *ref,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gs_unref_object XdgAppDir *user_dir = NULL;
|
||||
gs_unref_object XdgAppDir *system_dir = NULL;
|
||||
GFile *deploy = NULL;
|
||||
|
||||
user_dir = xdg_app_dir_get_user ();
|
||||
system_dir = xdg_app_dir_get_system ();
|
||||
|
||||
deploy = xdg_app_dir_get_if_deployed (user_dir, ref, NULL, cancellable);
|
||||
if (deploy == NULL)
|
||||
deploy = xdg_app_dir_get_if_deployed (system_dir, ref, NULL, cancellable);
|
||||
if (deploy == NULL)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "%s not installed", ref);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return deploy;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef __XDG_APP_UTILS_H__
|
||||
#define __XDG_APP_UTILS_H__
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
const char * xdg_app_get_arch (void);
|
||||
|
||||
char * xdg_app_build_untyped_ref (const char *runtime,
|
||||
|
@ -12,5 +14,9 @@ char * xdg_app_build_runtime_ref (const char *runtime,
|
|||
char * xdg_app_build_app_ref (const char *app,
|
||||
const char *branch,
|
||||
const char *arch);
|
||||
GFile * xdg_app_find_deploy_dir_for_ref (const char *ref,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
|
||||
#endif /* __XDG_APP_UTILS_H__ */
|
||||
|
|
Loading…
Reference in New Issue