forked from Mirrors/flatpak-builder
Use xdg_app_compose_ref helper
parent
b820249178
commit
604f71937a
|
@ -103,7 +103,7 @@ xdg_app_builtin_install_runtime (int argc, char **argv, GCancellable *cancellabl
|
||||||
g_autoptr(GFile) deploy_base = NULL;
|
g_autoptr(GFile) deploy_base = NULL;
|
||||||
const char *repository;
|
const char *repository;
|
||||||
const char *runtime;
|
const char *runtime;
|
||||||
const char *branch = "master";
|
const char *branch = NULL;
|
||||||
g_autofree char *ref = NULL;
|
g_autofree char *ref = NULL;
|
||||||
gboolean created_deploy_base = FALSE;
|
gboolean created_deploy_base = FALSE;
|
||||||
|
|
||||||
|
@ -123,19 +123,9 @@ xdg_app_builtin_install_runtime (int argc, char **argv, GCancellable *cancellabl
|
||||||
if (argc >= 4)
|
if (argc >= 4)
|
||||||
branch = argv[3];
|
branch = argv[3];
|
||||||
|
|
||||||
if (!xdg_app_is_valid_name (runtime))
|
ref = xdg_app_compose_ref (FALSE, runtime, branch, opt_arch, error);
|
||||||
{
|
if (ref == NULL)
|
||||||
xdg_app_fail (error, "'%s' is not a valid runtime name", runtime);
|
goto out;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!xdg_app_is_valid_branch (branch))
|
|
||||||
{
|
|
||||||
xdg_app_fail (error, "'%s' is not a valid branch name", branch);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ref = xdg_app_build_runtime_ref (runtime, branch, opt_arch);
|
|
||||||
|
|
||||||
deploy_base = xdg_app_dir_get_deploy_dir (dir, ref);
|
deploy_base = xdg_app_dir_get_deploy_dir (dir, ref);
|
||||||
if (g_file_query_exists (deploy_base, cancellable))
|
if (g_file_query_exists (deploy_base, cancellable))
|
||||||
|
@ -178,7 +168,7 @@ xdg_app_builtin_install_app (int argc, char **argv, GCancellable *cancellable, G
|
||||||
g_autoptr(GFile) deploy_base = NULL;
|
g_autoptr(GFile) deploy_base = NULL;
|
||||||
const char *repository;
|
const char *repository;
|
||||||
const char *app;
|
const char *app;
|
||||||
const char *branch = "master";
|
const char *branch = NULL;
|
||||||
g_autofree char *ref = NULL;
|
g_autofree char *ref = NULL;
|
||||||
gboolean created_deploy_base = FALSE;
|
gboolean created_deploy_base = FALSE;
|
||||||
|
|
||||||
|
@ -198,19 +188,9 @@ xdg_app_builtin_install_app (int argc, char **argv, GCancellable *cancellable, G
|
||||||
if (argc >= 4)
|
if (argc >= 4)
|
||||||
branch = argv[3];
|
branch = argv[3];
|
||||||
|
|
||||||
if (!xdg_app_is_valid_name (app))
|
ref = xdg_app_compose_ref (TRUE, app, branch, opt_arch, error);
|
||||||
{
|
if (ref == NULL)
|
||||||
xdg_app_fail (error, "'%s' is not a valid application name", app);
|
goto out;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!xdg_app_is_valid_branch (branch))
|
|
||||||
{
|
|
||||||
xdg_app_fail (error, "'%s' is not a valid branch name", branch);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ref = xdg_app_build_app_ref (app, branch, opt_arch);
|
|
||||||
|
|
||||||
deploy_base = xdg_app_dir_get_deploy_dir (dir, ref);
|
deploy_base = xdg_app_dir_get_deploy_dir (dir, ref);
|
||||||
if (g_file_query_exists (deploy_base, cancellable))
|
if (g_file_query_exists (deploy_base, cancellable))
|
||||||
|
|
|
@ -59,13 +59,9 @@ xdg_app_builtin_make_current_app (int argc, char **argv, GCancellable *cancellab
|
||||||
app = argv[1];
|
app = argv[1];
|
||||||
branch = argv[2];
|
branch = argv[2];
|
||||||
|
|
||||||
if (!xdg_app_is_valid_name (app))
|
ref = xdg_app_compose_ref (TRUE, app, branch, opt_arch, error);
|
||||||
return xdg_app_fail (error, "'%s' is not a valid application name", app);
|
if (ref == NULL)
|
||||||
|
return FALSE;
|
||||||
if (!xdg_app_is_valid_branch (branch))
|
|
||||||
return xdg_app_fail (error, "'%s' is not a valid branch name", branch);
|
|
||||||
|
|
||||||
ref = xdg_app_build_app_ref (app, branch, opt_arch);
|
|
||||||
|
|
||||||
deploy_base = xdg_app_dir_get_deploy_dir (dir, ref);
|
deploy_base = xdg_app_dir_get_deploy_dir (dir, ref);
|
||||||
if (!g_file_query_exists (deploy_base, cancellable))
|
if (!g_file_query_exists (deploy_base, cancellable))
|
||||||
|
|
|
@ -91,13 +91,9 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
|
||||||
if (opt_branch)
|
if (opt_branch)
|
||||||
branch = opt_branch;
|
branch = opt_branch;
|
||||||
|
|
||||||
if (!xdg_app_is_valid_name (app))
|
app_ref = xdg_app_compose_ref (TRUE, app, branch, opt_arch, error);
|
||||||
return xdg_app_fail (error, "'%s' is not a valid application name", app);
|
if (app_ref == NULL)
|
||||||
|
return FALSE;
|
||||||
if (!xdg_app_is_valid_branch (branch))
|
|
||||||
return xdg_app_fail (error, "'%s' is not a valid branch name", branch);
|
|
||||||
|
|
||||||
app_ref = xdg_app_build_app_ref (app, branch, opt_arch);
|
|
||||||
|
|
||||||
app_deploy = xdg_app_find_deploy_for_ref (app_ref, cancellable, error);
|
app_deploy = xdg_app_find_deploy_for_ref (app_ref, cancellable, error);
|
||||||
if (app_deploy == NULL)
|
if (app_deploy == NULL)
|
||||||
|
|
|
@ -47,9 +47,8 @@ xdg_app_builtin_uninstall_runtime (int argc, char **argv, GCancellable *cancella
|
||||||
{
|
{
|
||||||
g_autoptr(GOptionContext) context = NULL;
|
g_autoptr(GOptionContext) context = NULL;
|
||||||
g_autoptr(XdgAppDir) dir = NULL;
|
g_autoptr(XdgAppDir) dir = NULL;
|
||||||
const char *name;
|
const char *name = NULL;
|
||||||
const char *arch;
|
const char *branch = NULL;
|
||||||
const char *branch;
|
|
||||||
g_autofree char *ref = NULL;
|
g_autofree char *ref = NULL;
|
||||||
g_autofree char *repository = NULL;
|
g_autofree char *repository = NULL;
|
||||||
gboolean was_deployed;
|
gboolean was_deployed;
|
||||||
|
@ -65,23 +64,13 @@ xdg_app_builtin_uninstall_runtime (int argc, char **argv, GCancellable *cancella
|
||||||
name = argv[1];
|
name = argv[1];
|
||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
branch = argv[2];
|
branch = argv[2];
|
||||||
else
|
|
||||||
branch = "master";
|
|
||||||
if (opt_arch)
|
|
||||||
arch = opt_arch;
|
|
||||||
else
|
|
||||||
arch = xdg_app_get_arch ();
|
|
||||||
|
|
||||||
if (!xdg_app_is_valid_name (name))
|
ref = xdg_app_compose_ref (FALSE, name, branch, opt_arch, error);
|
||||||
return xdg_app_fail (error, "'%s' is not a valid runtime name", name);
|
if (ref == NULL)
|
||||||
|
return FALSE;
|
||||||
if (!xdg_app_is_valid_branch (branch))
|
|
||||||
return xdg_app_fail (error, "'%s' is not a valid branch name", branch);
|
|
||||||
|
|
||||||
/* TODO: look for apps, require --force */
|
/* TODO: look for apps, require --force */
|
||||||
|
|
||||||
ref = g_build_filename ("runtime", name, arch, branch, NULL);
|
|
||||||
|
|
||||||
repository = xdg_app_dir_get_origin (dir, ref, cancellable, NULL);
|
repository = xdg_app_dir_get_origin (dir, ref, cancellable, NULL);
|
||||||
|
|
||||||
g_debug ("dropping active ref");
|
g_debug ("dropping active ref");
|
||||||
|
@ -113,9 +102,8 @@ xdg_app_builtin_uninstall_app (int argc, char **argv, GCancellable *cancellable,
|
||||||
{
|
{
|
||||||
g_autoptr(GOptionContext) context = NULL;
|
g_autoptr(GOptionContext) context = NULL;
|
||||||
g_autoptr(XdgAppDir) dir = NULL;
|
g_autoptr(XdgAppDir) dir = NULL;
|
||||||
const char *name;
|
const char *name = NULL;
|
||||||
const char *arch;
|
const char *branch = NULL;
|
||||||
const char *branch;
|
|
||||||
g_autofree char *ref = NULL;
|
g_autofree char *ref = NULL;
|
||||||
g_autofree char *repository = NULL;
|
g_autofree char *repository = NULL;
|
||||||
g_autofree char *current_ref = NULL;
|
g_autofree char *current_ref = NULL;
|
||||||
|
@ -132,20 +120,10 @@ xdg_app_builtin_uninstall_app (int argc, char **argv, GCancellable *cancellable,
|
||||||
name = argv[1];
|
name = argv[1];
|
||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
branch = argv[2];
|
branch = argv[2];
|
||||||
else
|
|
||||||
branch = "master";
|
|
||||||
if (opt_arch)
|
|
||||||
arch = opt_arch;
|
|
||||||
else
|
|
||||||
arch = xdg_app_get_arch ();
|
|
||||||
|
|
||||||
if (!xdg_app_is_valid_name (name))
|
ref = xdg_app_compose_ref (TRUE, name, branch, opt_arch, error);
|
||||||
return xdg_app_fail (error, "'%s' is not a valid application name", name);
|
if (ref == NULL)
|
||||||
|
return FALSE;
|
||||||
if (!xdg_app_is_valid_branch (branch))
|
|
||||||
return xdg_app_fail (error, "'%s' is not a valid branch name", branch);
|
|
||||||
|
|
||||||
ref = g_build_filename ("app", name, arch, branch, NULL);
|
|
||||||
|
|
||||||
repository = xdg_app_dir_get_origin (dir, ref, cancellable, NULL);
|
repository = xdg_app_dir_get_origin (dir, ref, cancellable, NULL);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ xdg_app_builtin_update_runtime (int argc, char **argv, GCancellable *cancellable
|
||||||
g_autoptr(GOptionContext) context = NULL;
|
g_autoptr(GOptionContext) context = NULL;
|
||||||
g_autoptr(XdgAppDir) dir = NULL;
|
g_autoptr(XdgAppDir) dir = NULL;
|
||||||
const char *runtime;
|
const char *runtime;
|
||||||
const char *branch = "master";
|
const char *branch = NULL;
|
||||||
g_autofree char *previous_deployment = NULL;
|
g_autofree char *previous_deployment = NULL;
|
||||||
g_autofree char *ref = NULL;
|
g_autofree char *ref = NULL;
|
||||||
g_autofree char *repository = NULL;
|
g_autofree char *repository = NULL;
|
||||||
|
@ -66,13 +66,9 @@ xdg_app_builtin_update_runtime (int argc, char **argv, GCancellable *cancellable
|
||||||
if (argc >= 3)
|
if (argc >= 3)
|
||||||
branch = argv[2];
|
branch = argv[2];
|
||||||
|
|
||||||
if (!xdg_app_is_valid_name (runtime))
|
ref = xdg_app_compose_ref (FALSE, runtime, branch, opt_arch, error);
|
||||||
return xdg_app_fail (error, "'%s' is not a valid runtime name", runtime);
|
if (ref == NULL)
|
||||||
|
return FALSE;
|
||||||
if (!xdg_app_is_valid_branch (branch))
|
|
||||||
return xdg_app_fail (error, "'%s' is not a valid branch name", branch);
|
|
||||||
|
|
||||||
ref = xdg_app_build_runtime_ref (runtime, branch, opt_arch);
|
|
||||||
|
|
||||||
repository = xdg_app_dir_get_origin (dir, ref, cancellable, error);
|
repository = xdg_app_dir_get_origin (dir, ref, cancellable, error);
|
||||||
if (repository == NULL)
|
if (repository == NULL)
|
||||||
|
@ -120,7 +116,7 @@ xdg_app_builtin_update_app (int argc, char **argv, GCancellable *cancellable, GE
|
||||||
g_autoptr(GOptionContext) context = NULL;
|
g_autoptr(GOptionContext) context = NULL;
|
||||||
g_autoptr(XdgAppDir) dir = NULL;
|
g_autoptr(XdgAppDir) dir = NULL;
|
||||||
const char *app;
|
const char *app;
|
||||||
const char *branch = "master";
|
const char *branch = NULL;
|
||||||
g_autofree char *ref = NULL;
|
g_autofree char *ref = NULL;
|
||||||
g_autofree char *repository = NULL;
|
g_autofree char *repository = NULL;
|
||||||
g_autofree char *previous_deployment = NULL;
|
g_autofree char *previous_deployment = NULL;
|
||||||
|
@ -138,13 +134,9 @@ xdg_app_builtin_update_app (int argc, char **argv, GCancellable *cancellable, GE
|
||||||
if (argc >= 3)
|
if (argc >= 3)
|
||||||
branch = argv[2];
|
branch = argv[2];
|
||||||
|
|
||||||
if (!xdg_app_is_valid_name (app))
|
ref = xdg_app_compose_ref (TRUE, app, branch, opt_arch, error);
|
||||||
return xdg_app_fail (error, "'%s' is not a valid application name", app);
|
if (ref == NULL)
|
||||||
|
return FALSE;
|
||||||
if (!xdg_app_is_valid_branch (branch))
|
|
||||||
return xdg_app_fail (error, "'%s' is not a valid branch name", branch);
|
|
||||||
|
|
||||||
ref = xdg_app_build_app_ref (app, branch, opt_arch);
|
|
||||||
|
|
||||||
repository = xdg_app_dir_get_origin (dir, ref, cancellable, error);
|
repository = xdg_app_dir_get_origin (dir, ref, cancellable, error);
|
||||||
if (repository == NULL)
|
if (repository == NULL)
|
||||||
|
|
|
@ -483,28 +483,9 @@ xdg_app_installation_install (XdgAppInstallation *self,
|
||||||
g_autoptr(OstreeAsyncProgress) ostree_progress = NULL;
|
g_autoptr(OstreeAsyncProgress) ostree_progress = NULL;
|
||||||
XdgAppInstalledRef *result = NULL;
|
XdgAppInstalledRef *result = NULL;
|
||||||
|
|
||||||
if (version == NULL)
|
ref = xdg_app_compose_ref (kind == XDG_APP_REF_KIND_APP, name, version, arch, error);
|
||||||
version = "master";
|
if (ref == NULL)
|
||||||
|
return NULL;
|
||||||
if (arch == NULL)
|
|
||||||
arch = xdg_app_get_arch ();
|
|
||||||
|
|
||||||
if (!xdg_app_is_valid_name (name))
|
|
||||||
{
|
|
||||||
xdg_app_fail (error, "'%s' is not a valid name", name);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!xdg_app_is_valid_branch (version))
|
|
||||||
{
|
|
||||||
xdg_app_fail (error, "'%s' is not a valid branch name", version);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kind == XDG_APP_REF_KIND_APP)
|
|
||||||
ref = xdg_app_build_app_ref (name, version, arch);
|
|
||||||
else
|
|
||||||
ref = xdg_app_build_runtime_ref (name, version, arch);
|
|
||||||
|
|
||||||
deploy_base = xdg_app_dir_get_deploy_dir (priv->dir, ref);
|
deploy_base = xdg_app_dir_get_deploy_dir (priv->dir, ref);
|
||||||
if (g_file_query_exists (deploy_base, cancellable))
|
if (g_file_query_exists (deploy_base, cancellable))
|
||||||
|
@ -596,28 +577,9 @@ xdg_app_installation_update (XdgAppInstallation *self,
|
||||||
XdgAppInstalledRef *result = NULL;
|
XdgAppInstalledRef *result = NULL;
|
||||||
g_autoptr(GError) my_error = NULL;
|
g_autoptr(GError) my_error = NULL;
|
||||||
|
|
||||||
if (version == NULL)
|
ref = xdg_app_compose_ref (kind == XDG_APP_REF_KIND_APP, name, version, arch, error);
|
||||||
version = "master";
|
if (ref == NULL)
|
||||||
|
return NULL;
|
||||||
if (arch == NULL)
|
|
||||||
arch = xdg_app_get_arch ();
|
|
||||||
|
|
||||||
if (!xdg_app_is_valid_name (name))
|
|
||||||
{
|
|
||||||
xdg_app_fail (error, "'%s' is not a valid name", name);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!xdg_app_is_valid_branch (version))
|
|
||||||
{
|
|
||||||
xdg_app_fail (error, "'%s' is not a valid branch name", version);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kind == XDG_APP_REF_KIND_APP)
|
|
||||||
ref = xdg_app_build_app_ref (name, version, arch);
|
|
||||||
else
|
|
||||||
ref = xdg_app_build_runtime_ref (name, version, arch);
|
|
||||||
|
|
||||||
remote_name = xdg_app_dir_get_origin (priv->dir, ref, cancellable, error);
|
remote_name = xdg_app_dir_get_origin (priv->dir, ref, cancellable, error);
|
||||||
if (remote_name == NULL)
|
if (remote_name == NULL)
|
||||||
|
|
Loading…
Reference in New Issue