Install/update/uninstall related refs

Any "related" references from the same remote are automatically
handled when installing, unless you specify --no-related.

The set of related refs is based on the declared extensions for
the main ref. By default, all such extensions are automatically
installed/updated unless they have "no-autodownload" set to false
in the extension info, and its not already installed locally.

Only extensions marked as "autodelete" will be automatically deleted
when you remove the main ref.

There is some special handling:

Any *.Debug or *.Locale extension is automatically treated as "autodelete".

A *.Locale extension that is autodownloaded will be subsetted using subpaths
such that existing subpaths are kept, and the current locale is added.
This commit is contained in:
Alexander Larsson committed 2016-06-30 16:55:32 +02:00
1 parent 4a40fece78
commit 5ab628d0ee
6 files changed
+164

No files matched your search

+48
View File
@@ -40,6 +40,7 @@ static char **opt_gpg_file;
static char **opt_subpaths;
static gboolean opt_no_pull;
static gboolean opt_no_deploy;
static gboolean opt_no_related;
static gboolean opt_runtime;
static gboolean opt_app;
static gboolean opt_bundle;
@@ -48,6 +49,7 @@ static GOptionEntry options[] = {
{ "arch", 0, 0, G_OPTION_ARG_STRING, &opt_arch, "Arch to install for", "ARCH" },
{ "no-pull", 0, 0, G_OPTION_ARG_NONE, &opt_no_pull, "Don't pull, only install from local cache", },
{ "no-deploy", 0, 0, G_OPTION_ARG_NONE, &opt_no_deploy, "Don't deploy, only download to local cache", },
{ "no-related", 0, 0, G_OPTION_ARG_NONE, &opt_no_related, "Don't install related refs", },
{ "runtime", 0, 0, G_OPTION_ARG_NONE, &opt_runtime, "Look for runtime with the specified name", },
{ "app", 0, 0, G_OPTION_ARG_NONE, &opt_app, "Look for app with the specified name", },
{ "bundle", 0, 0, G_OPTION_ARG_NONE, &opt_bundle, "Install from local bundle file", },
@@ -144,6 +146,9 @@ flatpak_builtin_install (int argc, char **argv, GCancellable *cancellable, GErro
gboolean is_app;
g_autoptr(GFile) deploy_dir = NULL;
g_autoptr(GVariant) deploy_data = NULL;
g_autoptr(GPtrArray) related = NULL;
g_autoptr(GError) local_error = NULL;
int i;
context = g_option_context_new ("REPOSITORY NAME [BRANCH] - Install an application or runtime");
@@ -186,6 +191,49 @@ flatpak_builtin_install (int argc, char **argv, GCancellable *cancellable, GErro
cancellable, error))
return FALSE;
if (!opt_no_related)
{
g_autoptr(GError) local_error = NULL;
if (opt_no_pull)
related = flatpak_dir_find_local_related (dir, ref, repository, NULL, &local_error);
else
related = flatpak_dir_find_remote_related (dir, ref, repository, NULL, &local_error);
if (related == NULL)
{
g_printerr ("Warning: Problem looking for related refs: %s\n", local_error->message);
g_clear_error (&local_error);
}
else
{
for (i = 0; i < related->len; i++)
{
FlatpakRelated *rel = g_ptr_array_index (related, i);
g_auto(GStrv) parts = NULL;
if (!rel->download)
continue;
parts = g_strsplit (rel->ref, "/", 0);
g_print ("Installing related: %s\n", parts[1]);
if (!flatpak_dir_install_or_update (dir,
opt_no_pull,
opt_no_deploy,
rel->ref, repository,
(const char **)rel->subpaths,
NULL,
cancellable, &local_error))
{
g_printerr ("Warning: Failed to install related ref: %s\n",
rel->ref);
g_clear_error (&local_error);
}
}
}
}
return TRUE;
}
+41
View File
@@ -34,12 +34,14 @@
static char *opt_arch;
static gboolean opt_keep_ref;
static gboolean opt_force_remove;
static gboolean opt_no_related;
static gboolean opt_runtime;
static gboolean opt_app;
static GOptionEntry options[] = {
{ "arch", 0, 0, G_OPTION_ARG_STRING, &opt_arch, "Arch to uninstall", "ARCH" },
{ "keep-ref", 0, 0, G_OPTION_ARG_NONE, &opt_keep_ref, "Keep ref in local repository", NULL },
{ "no-related", 0, 0, G_OPTION_ARG_NONE, &opt_no_related, "Don't uninstall related refs", },
{ "force-remove", 0, 0, G_OPTION_ARG_NONE, &opt_force_remove, "Remove files even if running", NULL },
{ "runtime", 0, 0, G_OPTION_ARG_NONE, &opt_runtime, "Look for runtime with the specified name", },
{ "app", 0, 0, G_OPTION_ARG_NONE, &opt_app, "Look for app with the specified name", },
@@ -56,6 +58,8 @@ flatpak_builtin_uninstall (int argc, char **argv, GCancellable *cancellable, GEr
g_autofree char *ref = NULL;
gboolean is_app;
FlatpakHelperUninstallFlags flags = 0;
g_autoptr(GPtrArray) related = NULL;
int i;
context = g_option_context_new ("NAME [BRANCH] - Uninstall an application");
@@ -88,10 +92,47 @@ flatpak_builtin_uninstall (int argc, char **argv, GCancellable *cancellable, GEr
if (opt_force_remove)
flags |= FLATPAK_HELPER_UNINSTALL_FLAGS_FORCE_REMOVE;
if (!opt_no_related)
{
g_autoptr(GError) local_error = NULL;
g_autofree char *origin = NULL;
origin =flatpak_dir_get_origin (dir, ref, NULL, NULL);
if (origin)
{
related = flatpak_dir_find_local_related (dir, ref, origin,
NULL, &local_error);
if (related == NULL)
g_printerr ("Warning: Problem looking for related refs: %s\n",
local_error->message);
}
}
if (!flatpak_dir_uninstall (dir, ref, flags,
cancellable, error))
return FALSE;
if (related != NULL)
{
for (i = 0; i < related->len; i++)
{
FlatpakRelated *rel = g_ptr_array_index (related, i);
g_autoptr(GError) local_error = NULL;
g_auto(GStrv) parts = NULL;
if (!rel->delete)
continue;
parts = g_strsplit (rel->ref, "/", 0);
g_print ("Uninstalling related: %s\n", parts[1]);
if (!flatpak_dir_uninstall (dir, rel->ref, flags,
cancellable, &local_error))
g_printerr ("Warning: Failed to uninstall related ref: %s\n",
rel->ref);
}
}
return TRUE;
}
+51
View File
@@ -37,6 +37,7 @@ static char **opt_subpaths;
static gboolean opt_force_remove;
static gboolean opt_no_pull;
static gboolean opt_no_deploy;
static gboolean opt_no_related;
static gboolean opt_runtime;
static gboolean opt_app;
static gboolean opt_appstream;
@@ -47,6 +48,7 @@ static GOptionEntry options[] = {
{ "force-remove", 0, 0, G_OPTION_ARG_NONE, &opt_force_remove, "Remove old files even if running", NULL },
{ "no-pull", 0, 0, G_OPTION_ARG_NONE, &opt_no_pull, "Don't pull, only update from local cache", },
{ "no-deploy", 0, 0, G_OPTION_ARG_NONE, &opt_no_deploy, "Don't deploy, only download to local cache", },
{ "no-related", 0, 0, G_OPTION_ARG_NONE, &opt_no_related, "Don't update related refs", },
{ "runtime", 0, 0, G_OPTION_ARG_NONE, &opt_runtime, "Look for runtime with the specified name", },
{ "app", 0, 0, G_OPTION_ARG_NONE, &opt_app, "Look for app with the specified name", },
{ "appstream", 0, 0, G_OPTION_ARG_NONE, &opt_appstream, "Update appstream for remote", },
@@ -73,6 +75,8 @@ do_update (FlatpakDir * dir,
GError **error)
{
g_autofree char *repository = NULL;
g_autoptr(GPtrArray) related = NULL;
int i;
repository = flatpak_dir_get_origin (dir, ref, cancellable, error);
if (repository == NULL)
@@ -89,6 +93,53 @@ do_update (FlatpakDir * dir,
cancellable, error))
return FALSE;
if (!opt_no_related)
{
g_autoptr(GError) local_error = NULL;
if (opt_no_pull)
related = flatpak_dir_find_local_related (dir, ref, repository, NULL,
&local_error);
else
related = flatpak_dir_find_remote_related (dir, ref, repository, NULL,
&local_error);
if (related == NULL)
{
g_printerr ("Warning: Problem looking for related refs: %s\n",
local_error->message);
g_clear_error (&local_error);
}
else
{
for (i = 0; i < related->len; i++)
{
FlatpakRelated *rel = g_ptr_array_index (related, i);
g_autoptr(GError) local_error = NULL;
g_auto(GStrv) parts = NULL;
if (!rel->download)
continue;
parts = g_strsplit (rel->ref, "/", 0);
g_print ("Updating related: %s\n", parts[1]);
if (!flatpak_dir_install_or_update (dir,
opt_no_pull,
opt_no_deploy,
rel->ref, repository,
(const char **)rel->subpaths,
NULL,
cancellable, &local_error))
{
g_printerr ("Warning: Failed to update related ref: %s\n", rel->ref);
g_clear_error (&local_error);
}
}
}
}
return TRUE;
}
+8
View File
@@ -157,6 +157,14 @@
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--no-related</option></term>
<listitem><para>
Don't download related extensions, such as the locale data.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--app</option></term>
+8
View File
@@ -136,6 +136,14 @@
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--no-related</option></term>
<listitem><para>
Don't uninstall related extensions, such as the locale data.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option></term>
<term><option>--verbose</option></term>
+8
View File
@@ -145,6 +145,14 @@
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--no-related</option></term>
<listitem><para>
Don't download related extensions, such as the locale data.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--app</option></term>