[gnome-software] Properly support multi-line .deb descriptions
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Properly support multi-line .deb descriptions
- Date: Sun, 24 Apr 2016 20:14:45 +0000 (UTC)
commit f8a5d2c6a8c9d0d99b05431b041dc0b5fff5b26c
Author: Richard Hughes <richard hughsie com>
Date: Sun Apr 24 21:08:20 2016 +0100
Properly support multi-line .deb descriptions
data/tests/build-deb.sh | 1 +
data/tests/chiron-1.1-1.deb | Bin 0 -> 806 bytes
data/tests/debian/DEBIAN/control | 13 +++++++++++++
src/gs-self-test.c | 36 ++++++++++++++++++++++++++++++++++++
src/plugins/gs-plugin-dpkg.c | 19 ++++++++++++++++---
src/plugins/gs-plugin-dummy.c | 3 ++-
6 files changed, 68 insertions(+), 4 deletions(-)
---
diff --git a/data/tests/build-deb.sh b/data/tests/build-deb.sh
new file mode 100755
index 0000000..cbf50f6
--- /dev/null
+++ b/data/tests/build-deb.sh
@@ -0,0 +1 @@
+dpkg-deb --build debian chiron-1.1-1.deb
diff --git a/data/tests/chiron-1.1-1.deb b/data/tests/chiron-1.1-1.deb
new file mode 100644
index 0000000..f4f921a
Binary files /dev/null and b/data/tests/chiron-1.1-1.deb differ
diff --git a/data/tests/debian/DEBIAN/control b/data/tests/debian/DEBIAN/control
new file mode 100644
index 0000000..ad5d9c6
--- /dev/null
+++ b/data/tests/debian/DEBIAN/control
@@ -0,0 +1,13 @@
+Package: chiron
+Version: 1.1-1
+Section: base
+Priority: optional
+Architecture: all
+Homepage: http://127.0.0.1/
+Maintainer: Richard Hughes <richard hughsie com>
+Description: Single line synopsis
+ This is the first
+ paragraph in the example package
+ control file.
+ .
+ This is the second paragraph.
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index a1a8799..0a926c5 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -431,6 +431,38 @@ gs_plugin_loader_webapps_func (GsPluginLoader *plugin_loader)
g_assert (gs_app_get_pixbuf (app) != NULL);
}
+static void
+gs_plugin_loader_dpkg_func (GsPluginLoader *plugin_loader)
+{
+ g_autoptr(GsApp) app = NULL;
+ g_autoptr(GError) error = NULL;
+ g_autofree gchar *fn = NULL;
+
+ /* no dpkg, abort */
+ if (!gs_plugin_loader_get_enabled (plugin_loader, "dpkg"))
+ return;
+
+ /* load local file */
+ fn = gs_test_get_filename ("tests/chiron-1.1-1.deb");
+ g_assert (fn != NULL);
+ app = gs_plugin_loader_filename_to_app (plugin_loader,
+ fn,
+ GS_PLUGIN_REFINE_FLAGS_DEFAULT,
+ NULL,
+ &error);
+ g_assert_no_error (error);
+ g_assert (app != NULL);
+ g_assert_cmpstr (gs_app_get_id (app), ==, NULL);
+ g_assert_cmpstr (gs_app_get_source_default (app), ==, "chiron");
+ g_assert_cmpstr (gs_app_get_url (app, AS_URL_KIND_HOMEPAGE), ==, "http://127.0.0.1/");
+ g_assert_cmpstr (gs_app_get_name (app), ==, "chiron");
+ g_assert_cmpstr (gs_app_get_version (app), ==, "1.1-1");
+ g_assert_cmpstr (gs_app_get_summary (app), ==, "Single line synopsis");
+ g_assert_cmpstr (gs_app_get_description (app), ==,
+ "This is the first paragraph in the example "
+ "package control file.\nThis is the second paragraph.");
+}
+
int
main (int argc, char **argv)
{
@@ -441,6 +473,7 @@ main (int argc, char **argv)
g_autoptr(GsPluginLoader) plugin_loader = NULL;
const gchar *whitelist[] = {
"appstream",
+ "dpkg",
"dummy",
"epiphany",
"hardcoded-blacklist",
@@ -531,6 +564,9 @@ main (int argc, char **argv)
g_assert (gs_plugin_loader_get_enabled (plugin_loader, "dummy"));
/* plugin tests go here */
+ g_test_add_data_func ("/gnome-software/plugin-loader{dpkg}",
+ plugin_loader,
+ (GTestDataFunc) gs_plugin_loader_dpkg_func);
g_test_add_data_func ("/gnome-software/plugin-loader{webapps}",
plugin_loader,
(GTestDataFunc) gs_plugin_loader_webapps_func);
diff --git a/src/plugins/gs-plugin-dpkg.c b/src/plugins/gs-plugin-dpkg.c
index 0ea214d..76bb266 100644
--- a/src/plugins/gs-plugin-dpkg.c
+++ b/src/plugins/gs-plugin-dpkg.c
@@ -52,11 +52,12 @@ gs_plugin_filename_to_app (GsPlugin *plugin,
GError **error)
{
GsApp *app;
+ guint i;
g_autofree gchar *content_type = NULL;
- g_autofree gchar *description = NULL;
g_autofree gchar *output = NULL;
g_auto(GStrv) argv = NULL;
g_auto(GStrv) tokens = NULL;
+ g_autoptr(GString) str = NULL;
const gchar *mimetypes[] = {
"application/vnd.debian.binary-package",
NULL };
@@ -105,8 +106,20 @@ gs_plugin_filename_to_app (GsPlugin *plugin,
gs_app_set_kind (app, AS_APP_KIND_GENERIC);
/* multiline text */
- description = g_strjoinv (NULL, tokens + 5);
- gs_app_set_description (app, GS_APP_QUALITY_LOWEST, description + 1);
+ str = g_string_new ("");
+ for (i = 5; tokens[i] != NULL; i++) {
+ if (g_strcmp0 (tokens[i], " .") == 0) {
+ if (str->len > 0)
+ g_string_truncate (str, str->len - 1);
+ g_string_append (str, "\n");
+ continue;
+ }
+ g_strstrip (tokens[i]);
+ g_string_append_printf (str, "%s ", tokens[i]);
+ }
+ if (str->len > 0)
+ g_string_truncate (str, str->len - 1);
+ gs_app_set_description (app, GS_APP_QUALITY_LOWEST, str->str);
/* success */
gs_app_list_add (list, app);
diff --git a/src/plugins/gs-plugin-dummy.c b/src/plugins/gs-plugin-dummy.c
index 914dd9f..e5c0115 100644
--- a/src/plugins/gs-plugin-dummy.c
+++ b/src/plugins/gs-plugin-dummy.c
@@ -77,7 +77,8 @@ gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
if (g_strcmp0 (gs_app_get_id (app), "mate-spell.desktop") == 0 ||
g_strcmp0 (gs_app_get_id (app), "chiron.desktop") == 0 ||
g_strcmp0 (gs_app_get_id (app), "zeus.desktop") == 0 ||
- g_strcmp0 (gs_app_get_id (app), "zeus-spell.addon") == 0)
+ g_strcmp0 (gs_app_get_id (app), "zeus-spell.addon") == 0 ||
+ g_strcmp0 (gs_app_get_source_default (app), "chiron") == 0)
gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]