diff options
author | Richard Hughes <richard@hughsie.com> | 2016-06-13 10:47:29 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2016-06-13 10:47:47 +0100 |
commit | a6690f229ffb6146c26f2b2ce31be9cb38da1d3d (patch) | |
tree | 67aa72f338ca92798895268fd379d5672ccdd68d | |
parent | 30f849c30b55b9748997f3755875ba4da6e4caea (diff) | |
download | appstream-glib-a6690f229ffb6146c26f2b2ce31be9cb38da1d3d.tar.gz |
Load metainfo files if present
/usr/share/appdata is the old location, but will be supported for a long time.
Replaces https://github.com/hughsie/appstream-glib/pull/112
-rw-r--r-- | client/as-compose.c | 13 | ||||
-rw-r--r-- | data/appstream-compose.xml | 6 | ||||
-rw-r--r-- | libappstream-glib/as-store.c | 9 |
3 files changed, 23 insertions, 5 deletions
diff --git a/client/as-compose.c b/client/as-compose.c index eed5325..35356e4 100644 --- a/client/as-compose.c +++ b/client/as-compose.c @@ -1,6 +1,6 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * - * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com> + * Copyright (C) 2014-2016 Richard Hughes <richard@hughsie.com> * Copyright (C) 2016 Alexander Larsson <alexl@redhat.com> * * Licensed under the GNU General Public License Version 2 @@ -261,9 +261,18 @@ load_appdata (const gchar *prefix, const gchar *app_name, GError **error) NULL); appdata_path = g_build_filename (prefix, "share", - "appdata", + "metainfo", appdata_basename, NULL); + /* fall back to the legacy path */ + if (!g_file_test (appdata_path, G_FILE_TEST_EXISTS)) { + g_free (appdata_path); + appdata_path = g_build_filename (prefix, + "share", + "appdata", + appdata_basename, + NULL); + } g_debug ("Looking for %s", appdata_path); app = as_app_new (); diff --git a/data/appstream-compose.xml b/data/appstream-compose.xml index ec8a39f..91ce906 100644 --- a/data/appstream-compose.xml +++ b/data/appstream-compose.xml @@ -13,7 +13,7 @@ <email>richard@hughsie.com</email> </author> <copyright> - <year>2013-2014</year> + <year>2013-2016</year> <holder>Richard Hughes</holder> </copyright> </refentryinfo> @@ -44,8 +44,8 @@ <para> <command>appstream-compose</command> is a simple app that takes a prefix (default /usr) and a set of application names. - It looks for appdata, desktop and icon files with that - basename in $prefix/share/[appdata|applications|icons] and generates + It looks for appdata, metainfo, desktop and icon files with that + basename in $prefix/share/[appdata|metainfo|applications|icons] and generates appstream xml files and icons in (by default) $prefix/share/app-info. </para> </refsect1> diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c index d524db2..e22683e 100644 --- a/libappstream-glib/as-store.c +++ b/libappstream-glib/as-store.c @@ -2836,6 +2836,15 @@ as_store_search_per_user (AsStore *store, return FALSE; } + /* MetaInfo */ + if ((flags & AS_STORE_LOAD_FLAG_APPDATA) > 0) { + g_autofree gchar *dest = NULL; + dest = g_build_filename (g_get_user_data_dir (), "metainfo", NULL); + if (!as_store_search_installed (store, flags, "user", + dest, cancellable, error)) + return FALSE; + } + /* desktop files */ if ((flags & AS_STORE_LOAD_FLAG_DESKTOP) > 0) { g_autofree gchar *dest = NULL; |