type= property of the component root-node in the MetaInfo XML file does not contain a spelling mistake."
},
+ { "metainfo-releases-download-failed",
+ AS_ISSUE_SEVERITY_WARNING,
+ "Unable to download release information from {{url}}. The error message was: {{msg}}."
+ },
+
+ { "metainfo-releases-read-failed",
+ AS_ISSUE_SEVERITY_ERROR,
+ "Unable to read release information from {{path}}. The error message was: {{msg}}."
+ },
+
{ "file-read-error",
AS_ISSUE_SEVERITY_ERROR,
"Unable to read data from file {{fname}}: {{msg}}",
diff --git a/compose/asc-utils-metainfo.c b/compose/asc-utils-metainfo.c
index e10784c4..179f8616 100644
--- a/compose/asc-utils-metainfo.c
+++ b/compose/asc-utils-metainfo.c
@@ -95,15 +95,6 @@ asc_parse_metainfo_data (AscResult *cres, AsMetadata *mdata, GBytes *bytes, cons
return NULL;
}
- /* limit the amount of releases that we add to the output metadata.
- * since releases are sorted with the newest one at the top, we will only
- * remove the older ones. */
- if (as_component_get_kind (cpt) != AS_COMPONENT_KIND_OPERATING_SYSTEM) {
- GPtrArray *releases = as_component_get_releases (cpt);
- if (releases->len > MAX_RELEASE_INFO_COUNT)
- g_ptr_array_set_size (releases, MAX_RELEASE_INFO_COUNT);
- }
-
return g_object_ref (cpt);
}
@@ -132,6 +123,97 @@ asc_parse_metainfo_data_simple (AscResult *cres, GBytes *bytes, const gchar *mi_
mi_basename);
}
+/**
+ * asc_process_metainfo_releases:
+ * @cres: an #AscResult instance.
+ * @unit: an #AscUnit where release information could be read from.
+ * @cpt: the #AsComponent to read release data for.
+ * @mi_filename: the metadata filename for the component, as found in the passed unit.
+ * @allow_net: set to %TRUE if network access should be allowed.
+ * @acurl: the #AsCurl to use for network access.
+ * @used_reldata: (out) (optional): Receive the release data that was used, if set.
+ *
+ * Reads an external release description file, either from a network location or from
+ * the given unit. Also performs further processing on the release information, like sorting
+ * releases or pruning old ones.
+ **/
+void
+asc_process_metainfo_releases (AscResult *cres,
+ AscUnit *unit,
+ AsComponent *cpt,
+ const gchar *mi_filename,
+ gboolean allow_net,
+ AsCurl *acurl,
+ GBytes **used_reldata)
+{
+ g_autoptr(GError) local_error = NULL;
+ g_autoptr(GBytes) relmd_bytes = NULL;
+
+ /* download external release metadata or fetch local release data */
+ if (as_component_get_releases_kind (cpt) == AS_RELEASES_KIND_EXTERNAL) {
+ g_autofree gchar *relmd_uri = NULL;
+
+ g_ptr_array_set_size (as_component_get_releases (cpt), 0);
+ if (allow_net && as_component_get_releases_url (cpt) != NULL) {
+ /* get the release data from a network location */
+ const gchar *releases_url = as_component_get_releases_url (cpt);
+
+ relmd_bytes = as_curl_download_bytes (acurl, releases_url, &local_error);
+ if (relmd_bytes == NULL) {
+ asc_result_add_hint (cres, NULL,
+ "metainfo-releases-download-failed",
+ "url", releases_url,
+ "msg", local_error->message,
+ NULL);
+ goto out;
+ }
+ relmd_uri = g_strdup (releases_url);
+ } else {
+ /* we need to find local release information */
+ g_autofree gchar *relfile_path = NULL;
+ g_autofree gchar *relfile_name = NULL;
+ g_autofree gchar *tmp = NULL;
+
+ relfile_name = g_strconcat (as_component_get_id (cpt), ".releases.xml", NULL);
+ tmp = g_path_get_dirname (mi_filename);
+ relfile_path = g_build_filename (tmp, "releases", relfile_name, NULL);
+
+ relmd_bytes = asc_unit_read_data (unit, relfile_path, &local_error);
+ if (relmd_bytes == NULL) {
+ asc_result_add_hint (cres, NULL,
+ "file-read-error",
+ "fname", relfile_path,
+ "msg", local_error->message,
+ NULL);
+ goto out;
+ }
+ relmd_uri = g_steal_pointer (&relfile_path);
+ }
+
+ if (!as_component_load_releases_from_bytes (cpt, relmd_bytes, &local_error)) {
+ asc_result_add_hint (cres, NULL,
+ "metainfo-releases-read-failed",
+ "path", relmd_uri,
+ "msg", local_error->message,
+ NULL);
+ goto out;
+ }
+ }
+
+ /* limit the amount of releases that we add to the output metadata.
+ * since releases are sorted with the newest one at the top, we will only
+ * remove the older ones. */
+ if (as_component_get_kind (cpt) != AS_COMPONENT_KIND_OPERATING_SYSTEM) {
+ GPtrArray *releases = as_component_get_releases (cpt);
+ if (releases->len > MAX_RELEASE_INFO_COUNT)
+ g_ptr_array_set_size (releases, MAX_RELEASE_INFO_COUNT);
+ }
+
+out:
+ if (used_reldata != NULL)
+ *used_reldata = g_steal_pointer (&relmd_bytes);
+}
+
/**
* asc_validate_metainfo_data_for_component:
* @cres: an #AscResult instance.
@@ -139,64 +221,93 @@ asc_parse_metainfo_data_simple (AscResult *cres, GBytes *bytes, const gchar *mi_
* @cpt: the loaded #AsComponent which we are validating
* @bytes: the data @cpt was constructed from.
* @mi_basename: the basename of the MetaInfo file we are analyzing.
+ * @relmd_bytes: (nullable): the release metadata for this component.
*
* Validates MetaInfo data for the given component and stores the validation result as issue hints
* in the given #AscResult.
* Both the result as well as the validator's state may be modified by this function.
**/
void
-asc_validate_metainfo_data_for_component (AscResult *cres, AsValidator *validator,
- AsComponent *cpt, GBytes *bytes, const gchar *mi_basename)
+asc_validate_metainfo_data_for_component (AscResult *cres,
+ AsValidator *validator,
+ AsComponent *cpt,
+ GBytes *bytes,
+ const gchar *mi_basename,
+ GBytes *relmd_bytes)
{
- g_autoptr(GList) issues = NULL;
+ GHashTable *issues_files;
+ GHashTableIter hiter;
+ gpointer hkey, hvalue;
/* don't check web URLs for validity, we catch those issues differently */
as_validator_set_check_urls (validator, FALSE);
/* remove issues from a potential previous use of this validator */
as_validator_clear_issues (validator);
+ as_validator_clear_release_data (validator);
+
+ /* add release data if we have any */
+ if (relmd_bytes != NULL) {
+ g_autoptr(GError) tmp_error = NULL;
+ g_autofree gchar *release_name = g_strconcat (as_component_get_id (cpt), ".releases.xml", NULL);
+ if (!as_validator_add_release_bytes (validator,
+ release_name,
+ relmd_bytes,
+ &tmp_error))
+ g_warning ("Failed to add release metadata for %s: %s",
+ as_component_get_id (cpt), tmp_error->message);
+ }
/* validate */
as_validator_validate_bytes (validator, bytes);
/* convert & register found issues */
- issues = as_validator_get_issues (validator);
- for (GList *l = issues; l != NULL; l = l->next) {
- g_autofree gchar *asv_tag = NULL;
- g_autofree gchar *location = NULL;
- glong line;
- const gchar *issue_hint;
- AsValidatorIssue *issue = AS_VALIDATOR_ISSUE (l->data);
-
- /* we have a special hint tag for legacy metadata,
- * with its proper "error" priority */
- if (g_strcmp0 (as_validator_issue_get_tag (issue), "metainfo-ancient") == 0) {
- asc_result_add_hint_simple (cres, cpt, "ancient-metadata");
- continue;
+ issues_files = as_validator_get_issues_per_file (validator);
+ g_hash_table_iter_init (&hiter, issues_files);
+ while (g_hash_table_iter_next (&hiter, &hkey, &hvalue)) {
+ const gchar *filename = (const gchar*) hkey;
+ const GPtrArray *issues = (const GPtrArray*) hvalue;
+
+ if (filename == NULL)
+ filename = mi_basename;
+
+ for (guint i = 0; i < issues->len; i++) {
+ g_autofree gchar *asv_tag = NULL;
+ g_autofree gchar *location = NULL;
+ glong line;
+ const gchar *issue_hint;
+ AsValidatorIssue *issue = AS_VALIDATOR_ISSUE (g_ptr_array_index (issues, i));
+
+ /* we have a special hint tag for legacy metadata,
+ * with its proper "error" priority */
+ if (g_strcmp0 (as_validator_issue_get_tag (issue), "metainfo-ancient") == 0) {
+ asc_result_add_hint_simple (cres, cpt, "ancient-metadata");
+ continue;
+ }
+
+ /* create a tag for asgen out of the AppStream validator tag by prefixing it */
+ asv_tag = g_strconcat ("asv-",
+ as_validator_issue_get_tag (issue),
+ NULL);
+
+ line = as_validator_issue_get_line (issue);
+ if (line >= 0)
+ location = g_strdup_printf ("%s:%ld", filename, line);
+ else
+ location = g_strdup (filename);
+
+ /* we don't need to do much here, with the tag generated here,
+ * the hint registry will automatically assign the right explanation
+ * text and severity to the issue. */
+ issue_hint = as_validator_issue_get_hint (issue);
+ if (issue_hint == NULL)
+ issue_hint = "";
+ asc_result_add_hint (cres, cpt,
+ asv_tag,
+ "location", location,
+ "hint", issue_hint,
+ NULL);
}
-
- /* create a tag for asgen out of the AppStream validator tag by prefixing it */
- asv_tag = g_strconcat ("asv-",
- as_validator_issue_get_tag (issue),
- NULL);
-
- line = as_validator_issue_get_line (issue);
- if (line >= 0)
- location = g_strdup_printf ("%s:%ld", mi_basename, line);
- else
- location = g_strdup (mi_basename);
-
- /* we don't need to do much here, with the tag generated here,
- * the hint registry will automatically assign the right explanation
- * text and severity to the issue. */
- issue_hint = as_validator_issue_get_hint (issue);
- if (issue_hint == NULL)
- issue_hint = "";
- asc_result_add_hint (cres, cpt,
- asv_tag,
- "location", location,
- "hint", issue_hint,
- NULL);
}
}
diff --git a/compose/asc-utils-metainfo.h b/compose/asc-utils-metainfo.h
index 32a9df68..bf9d5bdb 100644
--- a/compose/asc-utils-metainfo.h
+++ b/compose/asc-utils-metainfo.h
@@ -24,6 +24,7 @@
#include ]]> tag contains multiple ]]> tag contains multiple external (if the embedded is implicitly assumed for it).
+ external.
+ external as described for component XML.
+ The data described in this section is placed in a separate XML file with cid is the component ID of the component
+ the release information belongs to.
+ + PoMiDAQ is a recording software for UCLA Miniscopes for neuroscientific research. + It provides an easy way to record videos from Miniscopes, create Z-stacks to give an + overview of visible cells or tissue features and provides an online background subtraction + feature to gain an initial insight into cellular calcium activity while data is recorded. + Recorded data is encoded with the FFV1 codec by default, to allow for smaller, + lossless video files that are safe to archive. +
+This release adds the following features:
+This release fixes the following bugs:
+This release adds the following features:
+This release fixes the following bug:
+This release adds the following feature:
+This release fixes the following bugs:
+This release adds the following features:
+This release fixes the following bugs:
+