mirror of
https://github.com/flatpak/flatpak.git
synced 2026-05-11 09:30:09 -04:00
app: Port to libappstream
libappstream-glib is mostly unmaintained, and libappstream is more actively developed (and up to date with the AppStream specification). Port from libappstream-glib to libappstream. Handily, a lot of the APIs are exactly the same. The main changes are: * `AsApp` → `AsComponent` * `AsStore` → `AsMetadata` Signed-off-by: Philip Withnall <pwithnall@endlessos.org> (Mostly done by Philip, then Phaedrus finished this)
This commit is contained in:
committed by
Phaedrus Leeds
parent
fca2e5285f
commit
9c059def69
6
.github/workflows/check.yml
vendored
6
.github/workflows/check.yml
vendored
@@ -45,7 +45,7 @@ jobs:
|
||||
libfuse-dev ostree libostree-dev libarchive-dev libzstd-dev libcap-dev libattr1-dev libdw-dev libelf-dev python3-pyparsing \
|
||||
libjson-glib-dev shared-mime-info desktop-file-utils libpolkit-agent-1-dev libpolkit-gobject-1-dev \
|
||||
libseccomp-dev libsoup2.4-dev libsystemd-dev libxml2-utils libgpgme11-dev gobject-introspection \
|
||||
libgirepository1.0-dev libappstream-glib-dev libdconf-dev clang socat meson libdbus-1-dev e2fslibs-dev
|
||||
libgirepository1.0-dev libappstream-dev libdconf-dev clang socat meson libdbus-1-dev e2fslibs-dev
|
||||
# One of the tests wants this
|
||||
sudo mkdir /tmp/flatpak-com.example.App-OwnedByRoot
|
||||
- name: Check out flatpak
|
||||
@@ -123,7 +123,7 @@ jobs:
|
||||
libfuse-dev ostree libostree-dev libarchive-dev libzstd-dev libcap-dev libattr1-dev libdw-dev libelf-dev python3-pyparsing \
|
||||
libjson-glib-dev shared-mime-info desktop-file-utils libpolkit-agent-1-dev libpolkit-gobject-1-dev \
|
||||
libseccomp-dev libsoup2.4-dev libsystemd-dev libxml2-utils libgpgme11-dev gobject-introspection \
|
||||
libgirepository1.0-dev libappstream-glib-dev libdconf-dev clang e2fslibs-dev
|
||||
libgirepository1.0-dev libappstream-dev libdconf-dev clang e2fslibs-dev
|
||||
- name: Check out flatpak
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
@@ -151,7 +151,7 @@ jobs:
|
||||
libfuse-dev ostree libostree-dev libarchive-dev libzstd-dev libcap-dev libattr1-dev libdw-dev libelf-dev python3-pyparsing \
|
||||
libjson-glib-dev shared-mime-info desktop-file-utils libpolkit-agent-1-dev libpolkit-gobject-1-dev \
|
||||
libseccomp-dev libsoup2.4-dev libsystemd-dev libxml2-utils libgpgme11-dev gobject-introspection \
|
||||
libgirepository1.0-dev libappstream-glib-dev libdconf-dev clang socat meson libdbus-1-dev \
|
||||
libgirepository1.0-dev libappstream-dev libdconf-dev clang socat meson libdbus-1-dev \
|
||||
valgrind e2fslibs-dev
|
||||
- name: Check out flatpak
|
||||
uses: actions/checkout@v1
|
||||
|
||||
@@ -46,7 +46,7 @@ libflatpak_app_la_LIBADD = \
|
||||
$(OSTREE_LIBS) \
|
||||
$(SOUP_LIBS) \
|
||||
$(JSON_LIBS) \
|
||||
$(APPSTREAM_GLIB_LIBS) \
|
||||
$(APPSTREAM_LIBS) \
|
||||
$(SYSTEMD_LIBS) \
|
||||
$(POLKIT_LIBS) \
|
||||
$(NULL)
|
||||
@@ -57,7 +57,7 @@ libflatpak_app_la_CFLAGS = \
|
||||
$(OSTREE_CFLAGS) \
|
||||
$(SOUP_CFLAGS) \
|
||||
$(JSON_CFLAGS) \
|
||||
$(APPSTREAM_GLIB_CFLAGS) \
|
||||
$(APPSTREAM_CFLAGS) \
|
||||
$(SYSTEMD_CFLAGS) \
|
||||
$(POLKIT_CFLAGS) \
|
||||
-DFLATPAK_COMPILATION \
|
||||
@@ -138,7 +138,7 @@ flatpak_LDADD = \
|
||||
$(OSTREE_LIBS) \
|
||||
$(SOUP_LIBS) \
|
||||
$(JSON_LIBS) \
|
||||
$(APPSTREAM_GLIB_LIBS) \
|
||||
$(APPSTREAM_LIBS) \
|
||||
$(SYSTEMD_LIBS) \
|
||||
$(POLKIT_LIBS) \
|
||||
libglnx.la \
|
||||
@@ -153,7 +153,7 @@ flatpak_CFLAGS = \
|
||||
$(OSTREE_CFLAGS) \
|
||||
$(SOUP_CFLAGS) \
|
||||
$(JSON_CFLAGS) \
|
||||
$(APPSTREAM_GLIB_CFLAGS) \
|
||||
$(APPSTREAM_CFLAGS) \
|
||||
$(SYSTEMD_CFLAGS) \
|
||||
$(POLKIT_CFLAGS) \
|
||||
-DFLATPAK_COMPILATION \
|
||||
|
||||
@@ -185,20 +185,16 @@ flatpak_builtin_remote_info (int argc, char **argv, GCancellable *cancellable, G
|
||||
int len;
|
||||
int rows, cols;
|
||||
int width;
|
||||
g_autoptr(AsStore) store = as_store_new ();
|
||||
AsApp *app = NULL;
|
||||
g_autoptr(AsMetadata) mdata = as_metadata_new ();
|
||||
AsComponent *app = NULL;
|
||||
const char *version = NULL;
|
||||
const char *license = NULL;
|
||||
g_autofree char *id = flatpak_decomposed_dup_id (ref);
|
||||
|
||||
flatpak_get_window_size (&rows, &cols);
|
||||
|
||||
#if AS_CHECK_VERSION (0, 6, 1)
|
||||
as_store_set_add_flags (store, as_store_get_add_flags (store) | AS_STORE_ADD_FLAG_USE_UNIQUE_ID);
|
||||
#endif
|
||||
|
||||
flatpak_dir_load_appstream_store (preferred_dir, remote, id, store, NULL, NULL);
|
||||
app = as_store_find_app (store, flatpak_decomposed_get_ref (ref));
|
||||
flatpak_dir_load_appstream_store (preferred_dir, remote, id, mdata, NULL, NULL);
|
||||
app = as_store_find_app (mdata, flatpak_decomposed_get_ref (ref));
|
||||
if (app)
|
||||
{
|
||||
const char *name = as_app_get_localized_name (app);
|
||||
@@ -207,7 +203,7 @@ flatpak_builtin_remote_info (int argc, char **argv, GCancellable *cancellable, G
|
||||
print_wrapped (MIN (cols, 80), "\n%s - %s\n", name, comment);
|
||||
|
||||
version = as_app_get_version (app);
|
||||
license = as_app_get_project_license (app);
|
||||
license = as_component_get_project_license (app);
|
||||
}
|
||||
|
||||
if (commit_v)
|
||||
|
||||
@@ -162,7 +162,7 @@ ls_remote (GHashTable *refs_hash, const char **arches, const char *app_runtime,
|
||||
FlatpakDir *dir = remote_state_dir_pair->dir;
|
||||
FlatpakRemoteState *state = remote_state_dir_pair->state;
|
||||
const char *remote = state->remote_name;
|
||||
g_autoptr(AsStore) store = NULL;
|
||||
g_autoptr(AsMetadata) mdata = NULL;
|
||||
g_autoptr(GHashTable) pref_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); /* value owned by refs */
|
||||
g_autoptr(GHashTable) names = g_hash_table_new_full ((GHashFunc)flatpak_decomposed_hash, (GEqualFunc)flatpak_decomposed_equal, (GDestroyNotify)flatpak_decomposed_unref, g_free);
|
||||
|
||||
@@ -230,13 +230,8 @@ ls_remote (GHashTable *refs_hash, const char **arches, const char *app_runtime,
|
||||
|
||||
if (need_appstream_data)
|
||||
{
|
||||
store = as_store_new ();
|
||||
|
||||
#if AS_CHECK_VERSION (0, 6, 1)
|
||||
as_store_set_add_flags (store, as_store_get_add_flags (store) | AS_STORE_ADD_FLAG_USE_UNIQUE_ID);
|
||||
#endif
|
||||
|
||||
flatpak_dir_load_appstream_store (dir, remote, NULL, store, NULL, NULL);
|
||||
mdata = as_metadata_new ();
|
||||
flatpak_dir_load_appstream_store (dir, remote, NULL, mdata, NULL, NULL);
|
||||
}
|
||||
|
||||
keys = (FlatpakDecomposed **) g_hash_table_get_keys_as_array (names, &n_keys);
|
||||
@@ -249,7 +244,7 @@ ls_remote (GHashTable *refs_hash, const char **arches, const char *app_runtime,
|
||||
guint64 installed_size;
|
||||
guint64 download_size;
|
||||
g_autofree char *runtime = NULL;
|
||||
AsApp *app = NULL;
|
||||
AsComponent *app = NULL;
|
||||
gboolean has_sparse_cache;
|
||||
VarMetadataRef sparse_cache;
|
||||
g_autofree char *id = flatpak_decomposed_dup_id (ref);
|
||||
@@ -283,7 +278,7 @@ ls_remote (GHashTable *refs_hash, const char **arches, const char *app_runtime,
|
||||
}
|
||||
|
||||
if (need_appstream_data)
|
||||
app = as_store_find_app (store, ref_str);
|
||||
app = as_store_find_app (mdata, ref_str);
|
||||
|
||||
if (app_runtime && runtime)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <appstream-glib.h>
|
||||
#include <appstream.h>
|
||||
|
||||
#include "flatpak-builtins.h"
|
||||
#include "flatpak-builtins-utils.h"
|
||||
@@ -43,7 +43,7 @@ static Column all_columns[] = {
|
||||
{ "description", N_("Description"), N_("Show the description"), 1, FLATPAK_ELLIPSIZE_MODE_END, 1, 1 },
|
||||
{ "application", N_("Application ID"), N_("Show the application ID"), 1, FLATPAK_ELLIPSIZE_MODE_START, 1, 1 },
|
||||
{ "version", N_("Version"), N_("Show the version"), 1, FLATPAK_ELLIPSIZE_MODE_NONE, 1, 1 },
|
||||
#if AS_CHECK_VERSION (0, 6, 1)
|
||||
#if AS_CHECK_VERSION(0,14,0)
|
||||
{ "branch", N_("Branch"), N_("Show the application branch"), 1, FLATPAK_ELLIPSIZE_MODE_NONE, 1, 1 },
|
||||
#endif
|
||||
{ "remotes", N_("Remotes"), N_("Show the remotes"), 1, FLATPAK_ELLIPSIZE_MODE_NONE, 1, 1 },
|
||||
@@ -76,14 +76,9 @@ get_remote_stores (GPtrArray *dirs, const char *arch, GCancellable *cancellable)
|
||||
|
||||
for (j = 0; remotes[j]; ++j)
|
||||
{
|
||||
g_autoptr(AsStore) store = as_store_new ();
|
||||
g_autoptr(AsMetadata) mdata = as_metadata_new ();
|
||||
|
||||
#if AS_CHECK_VERSION (0, 6, 1)
|
||||
// We want to see multiple versions/branches of same app-id's, e.g. org.gnome.Platform
|
||||
as_store_set_add_flags (store, as_store_get_add_flags (store) | AS_STORE_ADD_FLAG_USE_UNIQUE_ID);
|
||||
#endif
|
||||
|
||||
flatpak_dir_load_appstream_store (dir, remotes[j], arch, store, cancellable, &error);
|
||||
flatpak_dir_load_appstream_store (dir, remotes[j], arch, mdata, cancellable, &error);
|
||||
|
||||
if (error)
|
||||
{
|
||||
@@ -91,26 +86,18 @@ get_remote_stores (GPtrArray *dirs, const char *arch, GCancellable *cancellable)
|
||||
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 (mdata), "remote-name", g_strdup (remotes[j]), g_free);
|
||||
g_ptr_array_add (ret, g_steal_pointer (&mdata));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
clear_app_arches (AsApp *app)
|
||||
{
|
||||
GPtrArray *arches = as_app_get_architectures (app);
|
||||
|
||||
g_ptr_array_set_size (arches, 0);
|
||||
}
|
||||
|
||||
typedef struct MatchResult
|
||||
{
|
||||
AsApp *app;
|
||||
GPtrArray *remotes;
|
||||
guint score;
|
||||
AsComponent *app;
|
||||
GPtrArray *remotes;
|
||||
guint score;
|
||||
} MatchResult;
|
||||
|
||||
static void
|
||||
@@ -122,7 +109,7 @@ match_result_free (MatchResult *result)
|
||||
}
|
||||
|
||||
static MatchResult *
|
||||
match_result_new (AsApp *app, guint score)
|
||||
match_result_new (AsComponent *app, guint score)
|
||||
{
|
||||
MatchResult *result = g_new (MatchResult, 1);
|
||||
|
||||
@@ -130,8 +117,6 @@ match_result_new (AsApp *app, guint score)
|
||||
result->remotes = g_ptr_array_new_with_free_func (g_free);
|
||||
result->score = score;
|
||||
|
||||
clear_app_arches (result->app);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -156,53 +141,28 @@ compare_by_score (MatchResult *a, MatchResult *b, gpointer user_data)
|
||||
return (int) b->score - (int) a->score;
|
||||
}
|
||||
|
||||
#if !AS_CHECK_VERSION (0, 6, 1)
|
||||
/* Roughly copied directly from appstream-glib */
|
||||
|
||||
static const gchar *
|
||||
as_app_fix_unique_nullable (const gchar *tmp)
|
||||
{
|
||||
if (tmp == NULL || tmp[0] == '\0')
|
||||
return "*";
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static char *
|
||||
as_app_get_unique_id (AsApp *app)
|
||||
{
|
||||
const gchar *id_str = NULL;
|
||||
const gchar *kind_str = NULL;
|
||||
AsAppKind kind = as_app_get_kind (app);
|
||||
|
||||
if (kind != AS_APP_KIND_UNKNOWN)
|
||||
kind_str = as_app_kind_to_string (kind);
|
||||
id_str = as_app_get_id_no_prefix (app);
|
||||
return g_strdup_printf ("%s/%s",
|
||||
as_app_fix_unique_nullable (kind_str),
|
||||
as_app_fix_unique_nullable (id_str));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
as_app_equal (AsApp *app1, AsApp *app2)
|
||||
as_app_equal (AsComponent *app1, AsComponent *app2)
|
||||
{
|
||||
if (app1 == app2)
|
||||
return TRUE;
|
||||
|
||||
g_autofree char *app1_id = as_app_get_unique_id (app1);
|
||||
g_autofree char *app2_id = as_app_get_unique_id (app2);
|
||||
return strcmp (app1_id, app2_id) == 0;
|
||||
AsBundle *app1_bundle = as_component_get_bundle (app1, AS_BUNDLE_KIND_FLATPAK);
|
||||
AsBundle *app2_bundle = as_component_get_bundle (app2, AS_BUNDLE_KIND_FLATPAK);
|
||||
const char *app1_ref = as_bundle_get_id (app1_bundle);
|
||||
const char *app2_ref = as_bundle_get_id (app2_bundle);
|
||||
g_autoptr(FlatpakDecomposed) app1_decomposed = flatpak_decomposed_new_from_ref (app1_ref, NULL);
|
||||
g_autoptr(FlatpakDecomposed) app2_decomposed = flatpak_decomposed_new_from_ref (app2_ref, NULL);
|
||||
|
||||
/* Ignore arch when comparing since it's not shown in the search output and
|
||||
* we don't want duplicate results for the same app with different arches.
|
||||
*/
|
||||
return flatpak_decomposed_equal_except_arch (app1_decomposed, app2_decomposed);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
compare_apps (MatchResult *a, AsApp *b)
|
||||
compare_apps (MatchResult *a, AsComponent *b)
|
||||
{
|
||||
/* For now we want to ignore arch when comparing applications
|
||||
* It may be valuable to show runtime arches in the future though.
|
||||
* This is a naughty hack but for our purposes totally fine.
|
||||
*/
|
||||
clear_app_arches (b);
|
||||
|
||||
return !as_app_equal (a->app, b);
|
||||
}
|
||||
|
||||
@@ -210,7 +170,7 @@ static void
|
||||
print_app (Column *columns, MatchResult *res, FlatpakTablePrinter *printer)
|
||||
{
|
||||
const char *version = as_app_get_version (res->app);
|
||||
const char *id = as_app_get_id_filename (res->app);
|
||||
const char *id = as_component_get_id (res->app);
|
||||
const char *name = as_app_get_localized_name (res->app);
|
||||
const char *comment = as_app_get_localized_comment (res->app);
|
||||
guint i;
|
||||
@@ -225,9 +185,9 @@ print_app (Column *columns, MatchResult *res, FlatpakTablePrinter *printer)
|
||||
flatpak_table_printer_add_column (printer, id);
|
||||
else if (strcmp (columns[i].name, "version") == 0)
|
||||
flatpak_table_printer_add_column (printer, version);
|
||||
#if AS_CHECK_VERSION (0, 6, 1)
|
||||
#if AS_CHECK_VERSION(0,14,0)
|
||||
else if (strcmp (columns[i].name, "branch") == 0)
|
||||
flatpak_table_printer_add_column (printer, as_app_get_branch (res->app));
|
||||
flatpak_table_printer_add_column (printer, as_component_get_branch (res->app));
|
||||
#endif
|
||||
else if (strcmp (columns[i].name, "remotes") == 0)
|
||||
{
|
||||
@@ -293,21 +253,33 @@ flatpak_builtin_search (int argc, char **argv, GCancellable *cancellable, GError
|
||||
guint j;
|
||||
|
||||
// We want a store for each remote so we keep the remote information
|
||||
// as AsApp doesn't currently contain that information
|
||||
// as AsComponent doesn't currently contain that information
|
||||
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);
|
||||
GPtrArray *apps = as_store_get_apps (store);
|
||||
AsMetadata *mdata = g_ptr_array_index (remote_stores, j);
|
||||
GPtrArray *apps = as_metadata_get_components (mdata);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < apps->len; ++i)
|
||||
{
|
||||
AsApp *app = g_ptr_array_index (apps, i);
|
||||
guint score = as_app_search_matches (app, search_text);
|
||||
AsComponent *app = g_ptr_array_index (apps, i);
|
||||
const char *app_id = as_component_get_id (app);
|
||||
const char *remote_name = g_object_get_data (G_OBJECT (mdata), "remote-name");
|
||||
g_autoptr(FlatpakDecomposed) decomposed = NULL;
|
||||
|
||||
AsBundle *bundle = as_component_get_bundle (app, AS_BUNDLE_KIND_FLATPAK);
|
||||
if (bundle == NULL || as_bundle_get_id (bundle) == NULL ||
|
||||
(decomposed = flatpak_decomposed_new_from_ref (as_bundle_get_id (bundle), NULL)) == NULL)
|
||||
{
|
||||
g_debug ("Ignoring app %s from remote %s as it lacks a flatpak bundle",
|
||||
app_id, remote_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
guint score = as_component_search_matches (app, search_text);
|
||||
if (score == 0)
|
||||
{
|
||||
const char *app_id = as_app_get_id_filename (app);
|
||||
if (strcasestr (app_id, search_text) != NULL)
|
||||
score = 50;
|
||||
else
|
||||
@@ -326,8 +298,7 @@ flatpak_builtin_search (int argc, char **argv, GCancellable *cancellable, GError
|
||||
matches = g_slist_insert_sorted_with_data (matches, result,
|
||||
(GCompareDataFunc) compare_by_score, NULL);
|
||||
}
|
||||
match_result_add_remote (result,
|
||||
g_object_get_data (G_OBJECT (store), "remote-name"));
|
||||
match_result_add_remote (result, remote_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1042,49 +1042,32 @@ ellipsize_string_full (const char *text, int len, FlatpakEllipsizeMode mode)
|
||||
}
|
||||
|
||||
const char *
|
||||
as_app_get_localized_name (AsApp *app)
|
||||
as_app_get_localized_name (AsComponent *app)
|
||||
{
|
||||
const char * const * languages = g_get_language_names ();
|
||||
gsize i;
|
||||
|
||||
for (i = 0; languages[i]; ++i)
|
||||
{
|
||||
const char *name = as_app_get_name (app, languages[i]);
|
||||
if (name != NULL)
|
||||
return name;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
/* Automatically returns for the current locale */
|
||||
return as_component_get_name (app);
|
||||
}
|
||||
|
||||
const char *
|
||||
as_app_get_localized_comment (AsApp *app)
|
||||
as_app_get_localized_comment (AsComponent *app)
|
||||
{
|
||||
const char * const * languages = g_get_language_names ();
|
||||
gsize i;
|
||||
|
||||
for (i = 0; languages[i]; ++i)
|
||||
{
|
||||
const char *comment = as_app_get_comment (app, languages[i]);
|
||||
if (comment != NULL)
|
||||
return comment;
|
||||
}
|
||||
return NULL;
|
||||
/* Automatically returns for the current locale */
|
||||
return as_component_get_summary (app);
|
||||
}
|
||||
|
||||
const char *
|
||||
as_app_get_version (AsApp *app)
|
||||
as_app_get_version (AsComponent *app)
|
||||
{
|
||||
AsRelease *release = as_app_get_release_default (app);
|
||||
GPtrArray *releases = as_component_get_releases (app);
|
||||
|
||||
if (release)
|
||||
return as_release_get_version (release);
|
||||
if (releases != NULL && releases->len > 0)
|
||||
return as_release_get_version (AS_RELEASE (g_ptr_array_index (releases, 0)));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AsApp *
|
||||
as_store_find_app (AsStore *store,
|
||||
AsComponent *
|
||||
as_store_find_app (AsMetadata *mdata,
|
||||
const char *ref)
|
||||
{
|
||||
g_autoptr(FlatpakRef) rref = flatpak_ref_parse (ref, NULL);
|
||||
@@ -1095,17 +1078,18 @@ as_store_find_app (AsStore *store,
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
const char *id = j == 0 ? appid : desktopid;
|
||||
g_autoptr(GPtrArray) apps = as_store_get_apps_by_id (store, id);
|
||||
int i;
|
||||
GPtrArray *components = as_metadata_get_components (mdata);
|
||||
|
||||
for (i = 0; i < apps->len; i++)
|
||||
for (gsize i = 0; i < components->len; i++)
|
||||
{
|
||||
AsApp *app = g_ptr_array_index (apps, i);
|
||||
AsBundle *bundle = as_app_get_bundle_default (app);
|
||||
AsComponent *app = g_ptr_array_index (components, i);
|
||||
AsBundle *bundle;
|
||||
|
||||
if (g_strcmp0 (as_component_get_id (app), id) != 0)
|
||||
continue;
|
||||
|
||||
bundle = as_component_get_bundle (app, AS_BUNDLE_KIND_FLATPAK);
|
||||
if (bundle &&
|
||||
#if AS_CHECK_VERSION (0, 5, 15)
|
||||
as_bundle_get_kind (bundle) == AS_BUNDLE_KIND_FLATPAK &&
|
||||
#endif
|
||||
g_str_equal (as_bundle_get_id (bundle), ref))
|
||||
return app;
|
||||
}
|
||||
@@ -1125,7 +1109,7 @@ as_store_find_app (AsStore *store,
|
||||
* @error: return location for a #GError
|
||||
*
|
||||
* Load the cached AppStream data for the given @remote_name into @store, which
|
||||
* must have already been constructed using as_store_new(). If no cache
|
||||
* must have already been constructed using as_metadata_new(). If no cache
|
||||
* exists, %FALSE is returned with no error set. If there is an error loading or
|
||||
* parsing the cache, an error is returned.
|
||||
*
|
||||
@@ -1136,7 +1120,7 @@ gboolean
|
||||
flatpak_dir_load_appstream_store (FlatpakDir *self,
|
||||
const gchar *remote_name,
|
||||
const gchar *arch,
|
||||
AsStore *store,
|
||||
AsMetadata *mdata,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
@@ -1159,8 +1143,8 @@ flatpak_dir_load_appstream_store (FlatpakDir *self,
|
||||
NULL);
|
||||
|
||||
appstream_file = g_file_new_for_path (appstream_path);
|
||||
as_store_from_file (store, appstream_file, NULL, cancellable, &local_error);
|
||||
success = (local_error == NULL);
|
||||
as_metadata_set_format_style (mdata, AS_FORMAT_STYLE_COLLECTION);
|
||||
success = as_metadata_parse_file (mdata, appstream_file, AS_FORMAT_KIND_XML, &local_error);
|
||||
|
||||
/* We want to ignore ENOENT error as it is harmless and valid
|
||||
* FIXME: appstream-glib doesn't have granular file-not-found error
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#define __FLATPAK_BUILTINS_UTILS_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <appstream-glib.h>
|
||||
#include <appstream.h>
|
||||
#include "libglnx/libglnx.h"
|
||||
#include "flatpak-utils-private.h"
|
||||
#include "flatpak-dir-private.h"
|
||||
@@ -154,16 +154,16 @@ void print_aligned_take (int len,
|
||||
const char *title,
|
||||
char *value);
|
||||
|
||||
AsApp *as_store_find_app (AsStore *store,
|
||||
const char *ref);
|
||||
const char *as_app_get_localized_name (AsApp *app);
|
||||
const char *as_app_get_localized_comment (AsApp *app);
|
||||
const char *as_app_get_version (AsApp *app);
|
||||
AsComponent *as_store_find_app (AsMetadata *mdata,
|
||||
const char *ref);
|
||||
const char *as_app_get_localized_name (AsComponent *component);
|
||||
const char *as_app_get_localized_comment (AsComponent *component);
|
||||
const char *as_app_get_version (AsComponent *component);
|
||||
|
||||
gboolean flatpak_dir_load_appstream_store (FlatpakDir *self,
|
||||
const gchar *remote_name,
|
||||
const gchar *arch,
|
||||
AsStore *store,
|
||||
AsMetadata *mdata,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
|
||||
@@ -88,6 +88,8 @@ gboolean flatpak_decomposed_equal (FlatpakDecomposed
|
||||
FlatpakDecomposed *ref_b);
|
||||
gboolean flatpak_decomposed_equal_except_branch (FlatpakDecomposed *ref_a,
|
||||
FlatpakDecomposed *ref_b);
|
||||
gboolean flatpak_decomposed_equal_except_arch (FlatpakDecomposed *ref_a,
|
||||
FlatpakDecomposed *ref_b);
|
||||
gint flatpak_decomposed_strcmp (FlatpakDecomposed *ref_a,
|
||||
FlatpakDecomposed *ref_b);
|
||||
gint flatpak_decomposed_strcmp_p (FlatpakDecomposed **ref_a,
|
||||
|
||||
@@ -1100,6 +1100,16 @@ flatpak_decomposed_equal_except_branch (FlatpakDecomposed *ref_a,
|
||||
g_strcmp0 (ref_a->collection_id, ref_b->collection_id) == 0;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_decomposed_equal_except_arch (FlatpakDecomposed *ref_a,
|
||||
FlatpakDecomposed *ref_b)
|
||||
{
|
||||
return
|
||||
ref_a->arch_offset == ref_b->arch_offset &&
|
||||
strncmp (ref_a->data, ref_b->data, ref_a->arch_offset) == 0 &&
|
||||
strcmp (&ref_a->data[ref_a->branch_offset], &ref_b->data[ref_b->branch_offset]) == 0 &&
|
||||
g_strcmp0 (ref_a->collection_id, ref_b->collection_id) == 0;
|
||||
}
|
||||
|
||||
guint
|
||||
flatpak_decomposed_hash (FlatpakDecomposed *ref)
|
||||
|
||||
@@ -331,7 +331,7 @@ PKG_CHECK_MODULES(OSTREE, [ostree-1 >= $OSTREE_REQS])
|
||||
|
||||
PKG_CHECK_MODULES(JSON, [json-glib-1.0])
|
||||
|
||||
PKG_CHECK_MODULES(APPSTREAM_GLIB, [appstream-glib >= 0.5.10])
|
||||
PKG_CHECK_MODULES(APPSTREAM, [appstream >= 0.12.0])
|
||||
|
||||
PKG_CHECK_MODULES(GDK_PIXBUF, [gdk-pixbuf-2.0])
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ flatpak_system_helper_SOURCES = \
|
||||
$(NULL)
|
||||
|
||||
flatpak_system_helper_LDADD = $(BASE_LIBS) $(OSTREE_LIBS) $(JSON_LIBS) $(POLKIT_LIBS) libflatpak-common.la libflatpak-common-base.la libglnx.la
|
||||
flatpak_system_helper_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) $(OSTREE_CFLAGS) $(APPSTREAM_GLIB_CFLAGS) $(SOUP_CFLAGS) $(JSON_CFLAGS) $(POLKIT_CFLAGS) -DFLATPAK_COMPILATION -DLIBEXECDIR=\"$(libexecdir)\"
|
||||
flatpak_system_helper_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) $(OSTREE_CFLAGS) $(APPSTREAM_CFLAGS) $(SOUP_CFLAGS) $(JSON_CFLAGS) $(POLKIT_CFLAGS) -DFLATPAK_COMPILATION -DLIBEXECDIR=\"$(libexecdir)\"
|
||||
|
||||
system-helper/org.freedesktop.Flatpak.rules: system-helper/org.freedesktop.Flatpak.rules.in
|
||||
$(AM_V_GEN) $(SED) -e "s|\@privileged_group\@|$(PRIVILEGED_GROUP)|" $< > $@
|
||||
|
||||
@@ -64,7 +64,7 @@ testcommon_CFLAGS = \
|
||||
$(OSTREE_CFLAGS) \
|
||||
$(SOUP_CFLAGS) \
|
||||
$(JSON_CFLAGS) \
|
||||
$(APPSTREAM_GLIB_CFLAGS) \
|
||||
$(APPSTREAM_CFLAGS) \
|
||||
-DFLATPAK_COMPILATION \
|
||||
-DLIBEXECDIR=\"$(libexecdir)\" \
|
||||
-I$(srcdir)/app \
|
||||
@@ -76,7 +76,7 @@ testcommon_LDADD = \
|
||||
$(OSTREE_LIBS) \
|
||||
$(SOUP_LIBS) \
|
||||
$(JSON_LIBS) \
|
||||
$(APPSTREAM_GLIB_LIBS) \
|
||||
$(APPSTREAM_LIBS) \
|
||||
libflatpak-app.la \
|
||||
libflatpak-common.la \
|
||||
libflatpak-common-base.la \
|
||||
|
||||
Reference in New Issue
Block a user