mirror of
https://github.com/flatpak/flatpak.git
synced 2026-03-18 23:16:31 -04:00
appdata: Only pull appstream branch for main arch
Now that it also includes compat refs as needed we don't need to pull other branches. Closes: #1585 Approved by: alexlarsson
This commit is contained in:
committed by
Atomic Bot
parent
484c743e4a
commit
33c8e29d3f
@@ -29,13 +29,23 @@
|
||||
#include "flatpak-table-printer.h"
|
||||
#include "flatpak-utils.h"
|
||||
|
||||
static char *opt_arch;
|
||||
|
||||
static GOptionEntry options[] = {
|
||||
{ "arch", 0, 0, G_OPTION_ARG_STRING, &opt_arch, N_("Arch to search for"), N_("ARCH") },
|
||||
{ NULL}
|
||||
};
|
||||
|
||||
static GPtrArray *
|
||||
get_remote_stores (GPtrArray *dirs, GCancellable *cancellable)
|
||||
get_remote_stores (GPtrArray *dirs, const char *arch, GCancellable *cancellable)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GPtrArray *ret = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
const char **arches = flatpak_get_arches ();
|
||||
guint i,j,k;
|
||||
guint i,j;
|
||||
|
||||
if (arch == NULL)
|
||||
arch = flatpak_get_arch ();
|
||||
|
||||
for (i = 0; i < dirs->len; ++i)
|
||||
{
|
||||
FlatpakDir *dir = g_ptr_array_index (dirs, i);
|
||||
@@ -64,27 +74,23 @@ get_remote_stores (GPtrArray *dirs, GCancellable *cancellable)
|
||||
as_store_set_add_flags (store, as_store_get_add_flags (store) | AS_STORE_ADD_FLAG_USE_UNIQUE_ID);
|
||||
#endif
|
||||
|
||||
for (k = 0; arches[k]; ++k)
|
||||
{
|
||||
g_autofree char *appstream_path = g_build_filename (install_path, "appstream", remotes[j],
|
||||
arches[k], "active", "appstream.xml.gz",
|
||||
NULL);
|
||||
g_autoptr(GFile) appstream_file = g_file_new_for_path (appstream_path);
|
||||
g_autofree char *appstream_path = g_build_filename (install_path, "appstream", remotes[j],
|
||||
arch, "active", "appstream.xml.gz",
|
||||
NULL);
|
||||
g_autoptr(GFile) appstream_file = g_file_new_for_path (appstream_path);
|
||||
|
||||
as_store_from_file (store, appstream_file, NULL, cancellable, &error);
|
||||
if (error)
|
||||
{
|
||||
// We want to ignore this error as it is harmless and valid
|
||||
// NOTE: appstream-glib doesn't have granular file-not-found error
|
||||
if (!g_str_has_suffix (error->message, "No such file or directory"))
|
||||
g_warning ("%s", error->message);
|
||||
g_clear_error (&error);
|
||||
continue;
|
||||
}
|
||||
as_store_from_file (store, appstream_file, NULL, cancellable, &error);
|
||||
if (error)
|
||||
{
|
||||
// We want to ignore this error as it is harmless and valid
|
||||
// NOTE: appstream-glib doesn't have granular file-not-found error
|
||||
if (!g_str_has_suffix (error->message, "No such file or directory"))
|
||||
g_warning ("%s", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
g_object_set_data_full (G_OBJECT(store), "remote-name", g_strdup (remotes[j]), g_free);
|
||||
g_ptr_array_add (ret, g_steal_pointer (&store));
|
||||
g_object_set_data_full (G_OBJECT(store), "remote-name", g_strdup (remotes[j]), g_free);
|
||||
g_ptr_array_add (ret, g_steal_pointer (&store));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -235,21 +241,16 @@ flatpak_builtin_search (int argc, char **argv, GCancellable *cancellable, GError
|
||||
g_autoptr(GPtrArray) dirs = NULL;
|
||||
g_autoptr(GOptionContext) context = g_option_context_new (_("TEXT - Search remote apps/runtimes for text"));
|
||||
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
|
||||
const char **arches = flatpak_get_arches ();
|
||||
int i;
|
||||
|
||||
if (!flatpak_option_context_parse (context, NULL, &argc, &argv,
|
||||
if (!flatpak_option_context_parse (context, options, &argc, &argv,
|
||||
FLATPAK_BUILTIN_FLAG_STANDARD_DIRS, &dirs, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
return usage_error (context, _("TEXT must be specified"), error);
|
||||
|
||||
for (i = 0; arches[i] != NULL; i++)
|
||||
{
|
||||
if (!update_appstream (dirs, NULL, arches[i], FLATPAK_APPSTREAM_TTL, TRUE, cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
if (!update_appstream (dirs, NULL, opt_arch, FLATPAK_APPSTREAM_TTL, TRUE, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
const char *search_text = argv[1];
|
||||
GSList *matches = NULL;
|
||||
@@ -257,7 +258,7 @@ flatpak_builtin_search (int argc, char **argv, GCancellable *cancellable, GError
|
||||
|
||||
// We want a store for each remote so we keep the remote information
|
||||
// as AsApp doesn't currently contain that information
|
||||
g_autoptr(GPtrArray) remote_stores = get_remote_stores (dirs, cancellable);
|
||||
g_autoptr(GPtrArray) remote_stores = get_remote_stores (dirs, opt_arch, cancellable);
|
||||
for (j = 0; j < remote_stores->len; ++j)
|
||||
{
|
||||
AsStore *store = g_ptr_array_index (remote_stores, j);
|
||||
@@ -325,7 +326,7 @@ flatpak_complete_search (FlatpakCompletion *completion)
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
if (!flatpak_option_context_parse (context, NULL, &completion->argc, &completion->argv,
|
||||
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv,
|
||||
FLATPAK_BUILTIN_FLAG_STANDARD_DIRS, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
|
||||
@@ -79,8 +79,6 @@ flatpak_builtin_update (int argc,
|
||||
const char *default_branch = NULL;
|
||||
FlatpakKinds kinds;
|
||||
g_autoptr(GPtrArray) transactions = NULL;
|
||||
const char *opt_arches[2] = {NULL, NULL};
|
||||
const char **arches = flatpak_get_arches ();
|
||||
|
||||
context = g_option_context_new (_("[REF...] - Update applications or runtimes"));
|
||||
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
|
||||
@@ -90,19 +88,10 @@ flatpak_builtin_update (int argc,
|
||||
&dirs, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (opt_arch)
|
||||
{
|
||||
opt_arches[0] = opt_arch;
|
||||
arches = opt_arches;
|
||||
}
|
||||
|
||||
if (opt_appstream)
|
||||
{
|
||||
for (i = 0; arches[i] != NULL; i++)
|
||||
{
|
||||
if (!update_appstream (dirs, argc >= 2 ? argv[1] : NULL, arches[i], 0, FALSE, cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
if (!update_appstream (dirs, argc >= 2 ? argv[1] : NULL, opt_arch, 0, FALSE, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -243,11 +232,8 @@ flatpak_builtin_update (int argc,
|
||||
|
||||
if (n_prefs == 0)
|
||||
{
|
||||
for (i = 0; arches[i] != NULL; i++)
|
||||
{
|
||||
if (!update_appstream (dirs, NULL, arches[i], FLATPAK_APPSTREAM_TTL, TRUE, cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
if (!update_appstream (dirs, NULL, opt_arch, FLATPAK_APPSTREAM_TTL, TRUE, cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -448,7 +448,9 @@ update_appstream (GPtrArray *dirs,
|
||||
int i, j;
|
||||
|
||||
g_return_val_if_fail (dirs != NULL, FALSE);
|
||||
g_return_val_if_fail (arch != NULL, FALSE);
|
||||
|
||||
if (arch == NULL)
|
||||
arch = flatpak_get_arch ();
|
||||
|
||||
if (remote == NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user