[gnome-builder] meson-templates: Set project_license if appdata
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] meson-templates: Set project_license if appdata
- Date: Sat, 24 Feb 2018 22:50:24 +0000 (UTC)
commit 7bf52d7a2674e87d4670961d7baecb357c547b99
Author: Patrick Griffis <tingping tingping se>
Date: Sat Feb 24 17:49:38 2018 -0500
meson-templates: Set project_license if appdata
src/plugins/meson-templates/meson_templates.py | 14 ++++++++++++++
.../meson-templates/resources/data/hello.appdata.xml.in | 1 +
2 files changed, 15 insertions(+)
---
diff --git a/src/plugins/meson-templates/meson_templates.py b/src/plugins/meson-templates/meson_templates.py
index ab80416e4..78c995e39 100644
--- a/src/plugins/meson-templates/meson_templates.py
+++ b/src/plugins/meson-templates/meson_templates.py
@@ -187,6 +187,16 @@ class MesonTemplate(Ide.TemplateBase, Ide.ProjectTemplate):
}
self.prepare_files(files)
+ spdx_license = ''
+ # https://spdx.org/licenses/
+ LICENSE_TO_SPDX = {
+ 'agpl_3': 'AGPL-3.0-or-later',
+ 'gpl_3': 'GPL-3.0-or-later',
+ 'lgpl_2_1': 'LGPL-2.1-or-later',
+ 'lgpl_3': 'LGPL-3.0-or-later',
+ 'mit_x11': 'MIT',
+ }
+
if 'license_full' in params:
license_full_path = params['license_full'].get_string()
files[license_full_path] = 'COPYING'
@@ -195,6 +205,10 @@ class MesonTemplate(Ide.TemplateBase, Ide.ProjectTemplate):
license_short_path = params['license_short'].get_string()
license_base = Gio.resources_lookup_data(license_short_path[11:], 0).get_data().decode()
self.locator.license = license_base
+ license_name = license_short_path.rsplit('/', 1)[1]
+ spdx_license = LICENSE_TO_SPDX.get(license_name, '')
+
+ scope.get('project_license').assign_string(spdx_license)
if 'path' in params:
dir_path = params['path'].get_string()
diff --git a/src/plugins/meson-templates/resources/data/hello.appdata.xml.in
b/src/plugins/meson-templates/resources/data/hello.appdata.xml.in
index eee87ef7f..b1c11abff 100644
--- a/src/plugins/meson-templates/resources/data/hello.appdata.xml.in
+++ b/src/plugins/meson-templates/resources/data/hello.appdata.xml.in
@@ -2,6 +2,7 @@
<component type="desktop">
<id>{{appid}}.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
+ <project_license>{{project_license}}</project_license>
<description>
</description>
</component>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]