summaryrefslogtreecommitdiff
path: root/libappstream-builder/plugins/asb-plugin-appdata.c
diff options
context:
space:
mode:
Diffstat (limited to 'libappstream-builder/plugins/asb-plugin-appdata.c')
-rw-r--r--libappstream-builder/plugins/asb-plugin-appdata.c168
1 files changed, 15 insertions, 153 deletions
diff --git a/libappstream-builder/plugins/asb-plugin-appdata.c b/libappstream-builder/plugins/asb-plugin-appdata.c
index cb2f253..b42d617 100644
--- a/libappstream-builder/plugins/asb-plugin-appdata.c
+++ b/libappstream-builder/plugins/asb-plugin-appdata.c
@@ -22,16 +22,9 @@
#include <config.h>
#include <appstream-glib.h>
-#include <libsoup/soup.h>
#include <asb-plugin.h>
-struct AsbPluginPrivate {
- SoupSession *session;
- GPtrArray *filenames;
- GMutex filenames_mutex;
-};
-
/**
* asb_plugin_get_name:
*/
@@ -42,43 +35,6 @@ asb_plugin_get_name (void)
}
/**
- * asb_plugin_initialize:
- */
-void
-asb_plugin_initialize (AsbPlugin *plugin)
-{
- plugin->priv = ASB_PLUGIN_GET_PRIVATE (AsbPluginPrivate);
- plugin->priv->filenames = g_ptr_array_new_with_free_func (g_free);
- g_mutex_init (&plugin->priv->filenames_mutex);
- plugin->priv->session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT, "createrepo_as",
- SOUP_SESSION_TIMEOUT, 10,
- NULL);
- soup_session_add_feature_by_type (plugin->priv->session,
- SOUP_TYPE_PROXY_RESOLVER_DEFAULT);
-}
-
-/**
- * asb_plugin_destroy:
- */
-void
-asb_plugin_destroy (AsbPlugin *plugin)
-{
- const gchar *tmp;
- guint i;
-
- /* print out AppData files not used */
- if (g_getenv ("ASB_PERFORM_EXTRA_CHECKS") != NULL) {
- for (i = 0; i < plugin->priv->filenames->len; i++) {
- tmp = g_ptr_array_index (plugin->priv->filenames, i);
- g_debug ("%s was not used", tmp);
- }
- }
- g_ptr_array_unref (plugin->priv->filenames);
- g_mutex_clear (&plugin->priv->filenames_mutex);
- g_object_unref (plugin->priv->session);
-}
-
-/**
* asb_plugin_add_globs:
*/
void
@@ -89,71 +45,6 @@ asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs)
}
/**
- * asb_plugin_appdata_add_path:
- */
-static gboolean
-asb_plugin_appdata_add_path (AsbPlugin *plugin, const gchar *path, GError **error)
-{
- const gchar *tmp;
- _cleanup_dir_close_ GDir *dir = NULL;
-
- /* scan all the files */
- dir = g_dir_open (path, 0, error);
- if (dir == NULL)
- return FALSE;
- while ((tmp = g_dir_read_name (dir)) != NULL) {
- _cleanup_free_ gchar *filename = NULL;
- filename = g_build_filename (path, tmp, NULL);
- if (g_file_test (filename, G_FILE_TEST_IS_DIR)) {
- if (!asb_plugin_appdata_add_path (plugin, filename, error))
- return FALSE;
- } else {
- g_ptr_array_add (plugin->priv->filenames, g_strdup (filename));
- }
- }
- return TRUE;
-}
-
-/**
- * asb_plugin_appdata_add_files:
- */
-static gboolean
-asb_plugin_appdata_add_files (AsbPlugin *plugin, const gchar *path, GError **error)
-{
- gboolean ret;
-
- /* already done */
- if (plugin->priv->filenames->len > 0)
- return TRUE;
-
- g_mutex_lock (&plugin->priv->filenames_mutex);
- ret = asb_plugin_appdata_add_path (plugin, path, error);
- g_mutex_unlock (&plugin->priv->filenames_mutex);
- return ret;
-}
-
-/**
- * asb_plugin_appdata_remove_file:
- */
-static void
-asb_plugin_appdata_remove_file (AsbPlugin *plugin, const gchar *filename)
-{
- const gchar *tmp;
- guint i;
-
- g_mutex_lock (&plugin->priv->filenames_mutex);
- for (i = 0; i < plugin->priv->filenames->len; i++) {
- tmp = g_ptr_array_index (plugin->priv->filenames, i);
- if (g_strcmp0 (tmp, filename) == 0) {
- g_ptr_array_remove_fast (plugin->priv->filenames,
- (gpointer) tmp);
- break;
- }
- }
- g_mutex_unlock (&plugin->priv->filenames_mutex);
-}
-
-/**
* asb_plugin_appdata_log_overwrite:
*/
static void
@@ -415,57 +306,28 @@ asb_plugin_process_app (AsbPlugin *plugin,
GError **error)
{
GError *error_local = NULL;
- const gchar *kind_str;
- const gchar *tmp;
- _cleanup_free_ gchar *appdata_basename = NULL;
_cleanup_free_ gchar *appdata_filename = NULL;
- _cleanup_free_ gchar *appdata_filename_extra = NULL;
/* get possible sources */
- appdata_basename = asb_plugin_appdata_get_fn_for_app (AS_APP (app));
- appdata_filename = g_strdup_printf ("%s/files/share/appdata/%s.appdata.xml",
- tmpdir, appdata_basename);
- if (!g_file_test (appdata_filename, G_FILE_TEST_EXISTS)) {
- g_free (appdata_filename);
- appdata_filename = g_strdup_printf ("%s/usr/share/appdata/%s.appdata.xml",
- tmpdir, appdata_basename);
- }
- tmp = asb_package_get_config (pkg, "AppDataExtra");
- if (tmp != NULL && g_file_test (tmp, G_FILE_TEST_EXISTS)) {
- if (!asb_plugin_appdata_add_files (plugin, tmp, error))
- return FALSE;
- kind_str = as_id_kind_to_string (as_app_get_id_kind (AS_APP (app)));
- appdata_filename_extra = g_strdup_printf ("%s/%s/%s.appdata.xml",
- tmp,
- kind_str,
- appdata_basename);
- if (g_file_test (appdata_filename, G_FILE_TEST_EXISTS) &&
- g_file_test (appdata_filename_extra, G_FILE_TEST_EXISTS)) {
- asb_package_log (pkg,
- ASB_PACKAGE_LOG_LEVEL_WARNING,
- "extra AppData file %s overwrites upstream",
- appdata_filename_extra);
- }
-
- /* we used this */
- asb_plugin_appdata_remove_file (plugin, appdata_filename_extra);
- }
-
- /* firmware */
if (asb_package_get_kind (pkg) == ASB_PACKAGE_KIND_FIRMWARE) {
appdata_filename = g_strdup_printf ("%s/%s.metainfo.xml",
tmpdir,
asb_package_get_source_pkgname (pkg));
- }
-
- /* any appdata-extra file */
- if (appdata_filename_extra != NULL &&
- g_file_test (appdata_filename_extra, G_FILE_TEST_EXISTS)) {
- as_app_add_metadata (AS_APP (app), "DistroMetadata", NULL, -1);
- return asb_plugin_process_filename (plugin,
- app,
- appdata_filename_extra,
- error);
+ } else {
+ _cleanup_free_ gchar *appdata_basename = NULL;
+ appdata_basename = asb_plugin_appdata_get_fn_for_app (AS_APP (app));
+ appdata_filename = g_strdup_printf ("%s/files/share/appdata/%s.appdata.xml",
+ tmpdir, appdata_basename);
+ if (!g_file_test (appdata_filename, G_FILE_TEST_EXISTS)) {
+ g_free (appdata_filename);
+ appdata_filename = g_strdup_printf ("%s/usr/share/appdata/%s.appdata.xml",
+ tmpdir, appdata_basename);
+ }
+ if (!g_file_test (appdata_filename, G_FILE_TEST_EXISTS)) {
+ g_free (appdata_filename);
+ appdata_filename = g_strdup_printf ("%s/usr/share/appdata-extra/%s.appdata.xml",
+ tmpdir, appdata_basename);
+ }
}
/* any installed appdata file */