summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2015-04-07 09:45:05 +0100
committerRichard Hughes <richard@hughsie.com>2015-04-07 10:00:14 +0100
commit067ea762046fd1045cd41794c553c468eb73a7d0 (patch)
tree75a2f80db9f8e1821ecbde61133c8cf5119511e6
parentc5a8e1cda057e78b26505a43fba88273bfa2ef09 (diff)
downloadappstream-glib-067ea762046fd1045cd41794c553c468eb73a7d0.tar.gz
Remove the extra screenshots and appdata options from the builder
This never worked very well, and had the effect of files and screenshots not being pushed either downstream into the packages, or upstream into the tarballs.
-rw-r--r--client/as-builder.c14
-rw-r--r--libappstream-builder/asb-context.c40
-rw-r--r--libappstream-builder/asb-context.h4
-rw-r--r--libappstream-builder/plugins/asb-plugin-appdata.c168
-rw-r--r--libappstream-builder/plugins/asb-plugin-hardcoded.c61
5 files changed, 15 insertions, 272 deletions
diff --git a/client/as-builder.c b/client/as-builder.c
index af6c414..2ff0c12 100644
--- a/client/as-builder.c
+++ b/client/as-builder.c
@@ -145,8 +145,6 @@ main (int argc, char **argv)
_cleanup_error_free_ GError *error = NULL;
_cleanup_free_ gchar *basename = NULL;
_cleanup_free_ gchar *cache_dir = NULL;
- _cleanup_free_ gchar *extra_appdata = NULL;
- _cleanup_free_ gchar *extra_screenshots = NULL;
_cleanup_free_ gchar *log_dir = NULL;
_cleanup_free_ gchar *icons_dir = NULL;
_cleanup_free_ gchar *old_metadata = NULL;
@@ -189,12 +187,6 @@ main (int argc, char **argv)
{ "temp-dir", '\0', 0, G_OPTION_ARG_FILENAME, &temp_dir,
/* TRANSLATORS: command line option */
_("Set the temporary directory"), "DIR" },
- { "extra-appdata-dir", '\0', 0, G_OPTION_ARG_FILENAME, &extra_appdata,
- /* TRANSLATORS: command line option */
- _("Use extra appdata data"), "DIR" },
- { "extra-screenshots-dir", '\0', 0, G_OPTION_ARG_FILENAME, &extra_screenshots,
- /* TRANSLATORS: command line option */
- _("Use extra screenshots data"), "DIR" },
{ "output-dir", '\0', 0, G_OPTION_ARG_FILENAME, &output_dir,
/* TRANSLATORS: command line option */
_("Set the output directory"), "DIR" },
@@ -273,17 +265,11 @@ main (int argc, char **argv)
basename = g_strdup ("appstream");
if (origin == NULL)
origin = g_strdup ("example");
- if (extra_appdata == NULL)
- extra_appdata = g_strdup ("./appdata-extra");
- if (extra_screenshots == NULL)
- extra_screenshots = g_strdup ("./screenshots-extra");
setlocale (LC_ALL, "");
ctx = asb_context_new ();
asb_context_set_api_version (ctx, api_version);
asb_context_set_old_metadata (ctx, old_metadata);
- asb_context_set_extra_appdata (ctx, extra_appdata);
- asb_context_set_extra_screenshots (ctx, extra_screenshots);
asb_context_set_log_dir (ctx, log_dir);
asb_context_set_temp_dir (ctx, temp_dir);
asb_context_set_output_dir (ctx, output_dir);
diff --git a/libappstream-builder/asb-context.c b/libappstream-builder/asb-context.c
index d9ccd03..4980c61 100644
--- a/libappstream-builder/asb-context.c
+++ b/libappstream-builder/asb-context.c
@@ -68,8 +68,6 @@ struct _AsbContextPrivate
guint min_icon_size;
gdouble api_version;
gchar *old_metadata;
- gchar *extra_appdata;
- gchar *extra_screenshots;
gchar *log_dir;
gchar *cache_dir;
gchar *temp_dir;
@@ -213,40 +211,6 @@ asb_context_set_old_metadata (AsbContext *ctx, const gchar *old_metadata)
}
/**
- * asb_context_set_extra_appdata:
- * @ctx: A #AsbContext
- * @extra_appdata: directory name, or %NULL
- *
- * Sets the location of a directory which is used for supplimental AppData
- * files.
- *
- * Since: 0.1.0
- **/
-void
-asb_context_set_extra_appdata (AsbContext *ctx, const gchar *extra_appdata)
-{
- AsbContextPrivate *priv = GET_PRIVATE (ctx);
- priv->extra_appdata = asb_context_realpath (extra_appdata);
-}
-
-/**
- * asb_context_set_extra_screenshots:
- * @ctx: A #AsbContext
- * @extra_screenshots: directory name, or %NULL
- *
- * Sets the location of a directory which is used for supplimental screenshot
- * files.
- *
- * Since: 0.1.0
- **/
-void
-asb_context_set_extra_screenshots (AsbContext *ctx, const gchar *extra_screenshots)
-{
- AsbContextPrivate *priv = GET_PRIVATE (ctx);
- priv->extra_screenshots = asb_context_realpath (extra_screenshots);
-}
-
-/**
* asb_context_set_log_dir:
* @ctx: A #AsbContext
* @log_dir: directory
@@ -1282,8 +1246,6 @@ asb_context_process (AsbContext *ctx, GError **error)
}
/* set locations of external resources */
- asb_package_set_config (pkg, "AppDataExtra", priv->extra_appdata);
- asb_package_set_config (pkg, "ScreenshotsExtra", priv->extra_screenshots);
asb_package_set_config (pkg, "LogDir", priv->log_dir);
asb_package_set_config (pkg, "TempDir", priv->temp_dir);
asb_package_set_config (pkg, "IconsDir", priv->icons_dir);
@@ -1526,8 +1488,6 @@ asb_context_finalize (GObject *object)
g_ptr_array_unref (priv->file_globs);
g_mutex_clear (&priv->apps_mutex);
g_free (priv->old_metadata);
- g_free (priv->extra_appdata);
- g_free (priv->extra_screenshots);
g_free (priv->log_dir);
g_free (priv->cache_dir);
g_free (priv->temp_dir);
diff --git a/libappstream-builder/asb-context.h b/libappstream-builder/asb-context.h
index 2f41517..7d06f48 100644
--- a/libappstream-builder/asb-context.h
+++ b/libappstream-builder/asb-context.h
@@ -107,10 +107,6 @@ void asb_context_set_min_icon_size (AsbContext *ctx,
guint min_icon_size);
void asb_context_set_old_metadata (AsbContext *ctx,
const gchar *old_metadata);
-void asb_context_set_extra_appdata (AsbContext *ctx,
- const gchar *extra_appdata);
-void asb_context_set_extra_screenshots (AsbContext *ctx,
- const gchar *extra_screenshots);
void asb_context_set_log_dir (AsbContext *ctx,
const gchar *log_dir);
void asb_context_set_screenshot_dir (AsbContext *ctx,
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 */
diff --git a/libappstream-builder/plugins/asb-plugin-hardcoded.c b/libappstream-builder/plugins/asb-plugin-hardcoded.c
index 5f79a67..e0e5b8b 100644
--- a/libappstream-builder/plugins/asb-plugin-hardcoded.c
+++ b/libappstream-builder/plugins/asb-plugin-hardcoded.c
@@ -88,56 +88,6 @@ asb_plugin_destroy (AsbPlugin *plugin)
}
/**
- * asb_plugin_hardcoded_sort_screenshots_cb:
- */
-static gint
-asb_plugin_hardcoded_sort_screenshots_cb (gconstpointer a, gconstpointer b)
-{
- return g_strcmp0 ((gchar *) a, (gchar *) b);
-}
-
-/**
- * asb_plugin_hardcoded_add_screenshots:
- */
-static gboolean
-asb_plugin_hardcoded_add_screenshots (AsbApp *app,
- const gchar *location,
- GError **error)
-{
- const gchar *tmp;
- gboolean ret = TRUE;
- GList *l;
- GList *list = NULL;
- _cleanup_dir_close_ GDir *dir = NULL;
-
- /* scan for files */
- dir = g_dir_open (location, 0, error);
- if (dir == NULL) {
- ret = FALSE;
- goto out;
- }
- while ((tmp = g_dir_read_name (dir)) != NULL) {
- if (!g_str_has_suffix (tmp, ".png"))
- continue;
- list = g_list_prepend (list, g_build_filename (location, tmp, NULL));
- }
- list = g_list_sort (list, asb_plugin_hardcoded_sort_screenshots_cb);
- for (l = list; l != NULL; l = l->next) {
- tmp = l->data;
- asb_package_log (asb_app_get_package (app),
- ASB_PACKAGE_LOG_LEVEL_DEBUG,
- "Adding extra screenshot: %s", tmp);
- ret = asb_app_add_screenshot_source (app, tmp, error);
- if (!ret)
- goto out;
- }
- as_app_add_metadata (AS_APP (app), "DistroScreenshots", NULL, -1);
-out:
- g_list_free_full (list, g_free);
- return ret;
-}
-
-/**
* asb_plugin_process_app:
*/
gboolean
@@ -309,17 +259,6 @@ asb_plugin_process_app (AsbPlugin *plugin,
}
}
- /* do any extra screenshots exist */
- tmp = asb_package_get_config (pkg, "ScreenshotsExtra");
- if (tmp != NULL) {
- _cleanup_free_ gchar *dirname = NULL;
- dirname = g_build_filename (tmp, as_app_get_id_filename (AS_APP (app)), NULL);
- if (g_file_test (dirname, G_FILE_TEST_EXISTS)) {
- if (!asb_plugin_hardcoded_add_screenshots (app, dirname, error))
- return FALSE;
- }
- }
-
/* a ConsoleOnly category means we require AppData */
if (as_app_has_category (AS_APP(app), "ConsoleOnly"))
asb_app_add_requires_appdata (app, "ConsoleOnly");