From bba9ac25ecf9ac97c9143cc89cb3105474ef7f11 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Fri, 31 Dec 2021 06:38:00 +0100 Subject: [PATCH 1/4] issue-tag: Add release-version-missing tag This tag can be used if a release tag is missing the version which should be present according to section 2.1: https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-releases --- src/as-validator-issue-tag.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/as-validator-issue-tag.h b/src/as-validator-issue-tag.h index 70ba6625..4252b914 100644 --- a/src/as-validator-issue-tag.h +++ b/src/as-validator-issue-tag.h @@ -685,6 +685,12 @@ AsValidatorIssueTag as_validator_issue_tag_list[] = { N_("The value set as release type is invalid."), }, + { "release-version-missing", + AS_ISSUE_SEVERITY_ERROR, + /* TRANSLATORS: Please do not translate AppStream tag and property names (in backticks). */ + N_("The release is missing the `version` property."), + }, + { "artifact-type-invalid", AS_ISSUE_SEVERITY_ERROR, /* TRANSLATORS: Please do not translate AppStream tag and property names (in backticks). */ From f528ffa95d823a3f57f887fa5e8cde834a9a161c Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Fri, 31 Dec 2021 06:42:24 +0100 Subject: [PATCH 2/4] validator: Check existence of version release property --- src/as-validator.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/as-validator.c b/src/as-validator.c index 5e1bdce0..cb8f1d75 100644 --- a/src/as-validator.c +++ b/src/as-validator.c @@ -1519,6 +1519,12 @@ as_validator_check_release (AsValidator *validator, xmlNode *node, AsFormatStyle { gchar *prop; + /* validate presence of version property */ + prop = as_xml_get_prop_value (node, "version"); + if (prop == NULL) + as_validator_add_issue (validator, node, "release-version-missing", "version"); + g_free (prop); + /* validate date strings */ prop = as_xml_get_prop_value (node, "date"); if (prop != NULL) { From 943197eed07674b2f6da795e1d92dd5672c46050 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Thu, 6 Jan 2022 06:22:51 +0100 Subject: [PATCH 3/4] issue-tag: Add release-time-missing tag This tag can be used if a release tag is missing both date and timestamp which should be present according to section 2.1: https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-releases --- src/as-validator-issue-tag.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/as-validator-issue-tag.h b/src/as-validator-issue-tag.h index 4252b914..00daab1a 100644 --- a/src/as-validator-issue-tag.h +++ b/src/as-validator-issue-tag.h @@ -691,6 +691,11 @@ AsValidatorIssueTag as_validator_issue_tag_list[] = { N_("The release is missing the `version` property."), }, + { "release-time-missing", + AS_ISSUE_SEVERITY_ERROR, + /* TRANSLATORS: Please do not translate AppStream tag and property names (in backticks). */ + N_("The release is missing either the `date` (preferred) or the `timestamp` property."), + }, { "artifact-type-invalid", AS_ISSUE_SEVERITY_ERROR, /* TRANSLATORS: Please do not translate AppStream tag and property names (in backticks). */ From e96b1fd3efcd721dc41cac203ba81f07c17ee593 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Fri, 31 Dec 2021 06:41:34 +0100 Subject: [PATCH 4/4] validator: Check existence of date or timestamp release property --- src/as-validator.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/as-validator.c b/src/as-validator.c index cb8f1d75..5d6d9223 100644 --- a/src/as-validator.c +++ b/src/as-validator.c @@ -1530,6 +1530,11 @@ as_validator_check_release (AsValidator *validator, xmlNode *node, AsFormatStyle if (prop != NULL) { as_validator_validate_iso8601_complete_date (validator, node, prop); g_free (prop); + } else { + g_autofree gchar *timestamp = as_xml_get_prop_value (node, "timestamp"); + /* Neither timestamp, nor date property exists */ + if (timestamp == NULL) + as_validator_add_issue (validator, node, "release-time-missing", "date"); } prop = as_xml_get_prop_value (node, "date_eol"); if (prop != NULL) {