diff options
author | Richard Hughes <richard@hughsie.com> | 2015-12-09 15:01:42 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2015-12-09 16:14:48 +0000 |
commit | ac8575f1568378afc7a4e12d77a2461b970b9e02 (patch) | |
tree | 35c050c6215912f75e083bacbf82419b5d3f9626 | |
parent | 1681d0514ad07848b1ca3ddc10287b213075c812 (diff) | |
download | appstream-glib-ac8575f1568378afc7a4e12d77a2461b970b9e02.tar.gz |
Only use the package license when not provided by the AppData file
In doing so, we found a number of invalid AppData files, so fix up the values
the best we can.
-rw-r--r-- | libappstream-builder/asb-self-test.c | 2 | ||||
-rw-r--r-- | libappstream-builder/asb-task.c | 3 | ||||
-rw-r--r-- | libappstream-builder/plugins/asb-plugin-appdata.c | 19 |
3 files changed, 22 insertions, 2 deletions
diff --git a/libappstream-builder/asb-self-test.c b/libappstream-builder/asb-self-test.c index 4ea67a5..12010c7 100644 --- a/libappstream-builder/asb-self-test.c +++ b/libappstream-builder/asb-self-test.c @@ -496,7 +496,7 @@ asb_test_context_test_func (AsbTestContextMode mode) "<kudo>SearchProvider</kudo>\n" "<kudo>UserDocs</kudo>\n" "</kudos>\n" - "<project_license>GPL-2.0+</project_license>\n" + "<project_license>LGPL-2.0+</project_license>\n" "<url type=\"homepage\">http://people.freedesktop.org/~hughsient/appdata/</url>\n" "<screenshots>\n" "<screenshot type=\"default\">\n" diff --git a/libappstream-builder/asb-task.c b/libappstream-builder/asb-task.c index 5e747c8..8a8b2cc 100644 --- a/libappstream-builder/asb-task.c +++ b/libappstream-builder/asb-task.c @@ -403,7 +403,8 @@ asb_task_process (AsbTask *task, GError **error_not_used) AS_URL_KIND_HOMEPAGE, asb_package_get_url (priv->pkg)); } - if (asb_package_get_license (priv->pkg) != NULL) { + if (asb_package_get_license (priv->pkg) != NULL && + as_app_get_project_license (AS_APP (app)) == NULL) { as_app_set_project_license (AS_APP (app), asb_package_get_license (priv->pkg)); } diff --git a/libappstream-builder/plugins/asb-plugin-appdata.c b/libappstream-builder/plugins/asb-plugin-appdata.c index 110cd14..28a0d1c 100644 --- a/libappstream-builder/plugins/asb-plugin-appdata.c +++ b/libappstream-builder/plugins/asb-plugin-appdata.c @@ -120,6 +120,25 @@ asb_plugin_process_filename (AsbPlugin *plugin, if (icons->len > 0) g_ptr_array_set_size (icons, 0); + /* fix up the project license */ + tmp = as_app_get_project_license (AS_APP (app)); + if (tmp != NULL && !as_utils_is_spdx_license (tmp)) { + g_autofree gchar *license_spdx = NULL; + license_spdx = as_utils_license_to_spdx (tmp); + if (as_utils_is_spdx_license (license_spdx)) { + asb_package_log (asb_app_get_package (app), + ASB_PACKAGE_LOG_LEVEL_WARNING, + "project license fixup: %s -> %s", + tmp, license_spdx); + as_app_set_project_license (AS_APP (app), license_spdx); + } else { + asb_package_log (asb_app_get_package (app), + ASB_PACKAGE_LOG_LEVEL_WARNING, + "project license is invalid: %s", tmp); + as_app_set_project_license (AS_APP (app), NULL); + } + } + /* add provide if missing */ tmp = as_app_get_id (AS_APP (app)); if (as_app_get_id_kind (AS_APP (app)) == AS_ID_KIND_FIRMWARE && |