Commit 8e1d386f authored by Matthias Klumpp's avatar Matthias Klumpp
Browse files

Implement support for "runtime" component type

parent 3e27bcad
/*
* Copyright (C) 2016-2019 Matthias Klumpp <matthias@tenstral.net>
* Copyright (C) 2016-2020 Matthias Klumpp <matthias@tenstral.net>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
......@@ -54,6 +54,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(KindMap, kindMap, ( {
{ Component::KindRepository, QLatin1String("repository") },
{ Component::KindOperatingSystem, QLatin1String("operating-system") },
{ Component::KindIconTheme, QLatin1String("icon-theme") },
{ Component::KindRuntime, QLatin1String("runtime") },
{ Component::KindUnknown, QLatin1String("unknown") }
}
));
......@@ -111,6 +112,9 @@ Component::Kind Component::stringToKind(const QString& kindString) {
if (kindString == QLatin1String("icon-theme"))
return KindIconTheme;
if (kindString == QLatin1String("runtime"))
return KindRuntime;
return KindUnknown;
}
......
/*
* Copyright (C) 2016-2019 Matthias Klumpp <matthias@tenstral.net>
* Copyright (C) 2016-2020 Matthias Klumpp <matthias@tenstral.net>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
......@@ -66,7 +66,8 @@ Q_GADGET
KindService,
KindRepository,
KindOperatingSystem,
KindIconTheme
KindIconTheme,
KindRuntime
};
Q_ENUM(Kind)
......
......@@ -182,6 +182,7 @@ as_component_kind_get_type (void)
{AS_COMPONENT_KIND_REPOSITORY, "AS_COMPONENT_KIND_REPOSITORY", "repository"},
{AS_COMPONENT_KIND_OPERATING_SYSTEM, "AS_COMPONENT_KIND_OPERATING_SYSTEM", "operating-system"},
{AS_COMPONENT_KIND_ICON_THEME, "AS_COMPONENT_KIND_ICON_THEME", "icon-theme"},
{AS_COMPONENT_KIND_RUNTIME, "AS_COMPONENT_KIND_RUNTIME", "runtime"},
{0, NULL, NULL}
};
GType as_component_type_type_id;
......@@ -232,6 +233,8 @@ as_component_kind_to_string (AsComponentKind kind)
return "operating-system";
if (kind == AS_COMPONENT_KIND_ICON_THEME)
return "icon-theme";
if (kind == AS_COMPONENT_KIND_RUNTIME)
return "runtime";
return "unknown";
}
......@@ -278,6 +281,8 @@ as_component_kind_from_string (const gchar *kind_str)
return AS_COMPONENT_KIND_OPERATING_SYSTEM;
if (g_strcmp0 (kind_str, "icon-theme") == 0)
return AS_COMPONENT_KIND_ICON_THEME;
if (g_strcmp0 (kind_str, "runtime") == 0)
return AS_COMPONENT_KIND_RUNTIME;
/* legacy */
if (g_strcmp0 (kind_str, "desktop") == 0)
......
......@@ -75,6 +75,7 @@ struct _AsComponentClass
* @AS_COMPONENT_KIND_REPOSITORY: A remote software or data source
* @AS_COMPONENT_KIND_OPERATING_SYSTEM: A computer operating system
* @AS_COMPONENT_KIND_ICON_THEME: An icon theme following the XDG specification
* @AS_COMPONENT_KIND_RUNTIME: An application runtime platform
*
* The type of an #AsComponent.
**/
......@@ -95,6 +96,7 @@ typedef enum {
AS_COMPONENT_KIND_REPOSITORY,
AS_COMPONENT_KIND_OPERATING_SYSTEM,
AS_COMPONENT_KIND_ICON_THEME,
AS_COMPONENT_KIND_RUNTIME,
/*< private >*/
AS_COMPONENT_KIND_LAST
} AsComponentKind;
......
......@@ -623,6 +623,18 @@ AsValidatorIssueTag as_validator_issue_tag_list[] = {
"with this metadata."),
},
{ "runtime-project-license-no-ref",
AS_ISSUE_SEVERITY_INFO,
/* TRANSLATORS: Please do not translate AppStream tag and property names. */
N_("Licenses for 'runtime' components are usually too complex to reflect them in a simple SPDX expression. Consider using a `LicenseRef` and a web URL "
"as value for this component's 'project_license'. E.g. `LicenseRef-free=https://example.com/licenses.html`")
},
{ "runtime-no-provides",
AS_ISSUE_SEVERITY_PEDANTIC,
N_("Since a 'runtime' component is comprised of multiple other software components, their component-IDs may be listed in a `<provides/>` section for this runtime.")
},
{ "unknown-provides-item-type",
AS_ISSUE_SEVERITY_INFO,
N_("The type of the item that the component provides is not known to AppStream."),
......
......@@ -1584,6 +1584,16 @@ as_validator_validate_component_node (AsValidator *validator, AsContext *ctx, xm
as_validator_add_issue (validator, NULL, "service-no-service-launchable", NULL);
}
/* validate runtime specific stuff */
if (as_component_get_kind (cpt) == AS_COMPONENT_KIND_RUNTIME) {
const gchar *project_license = as_component_get_project_license (cpt);
if ((project_license == NULL) || (!g_str_has_prefix (project_license, "LicenseRef")))
as_validator_add_issue (validator, NULL, "runtime-project-license-no-ref", NULL);
if (as_component_get_provided (cpt)->len == 0)
as_validator_add_issue (validator, NULL, "runtime-no-provides", NULL);
}
/* validate suggestions */
if (as_component_get_suggested (cpt)->len > 0) {
guint j;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment