Py_RETURN_NONE;
}
+PyDoc_STRVAR(set_contenthash__doc__,
+"set_contenthash(contenthash, contenthash_type) -> None\n\n"
+"Set contenthash value and contenthash_type");
+
+static PyObject *
+set_contenthash(_RepomdObject *self, PyObject *args)
+{
+ char *contenthash, *contenthash_type;
+ if (!PyArg_ParseTuple(args, "zz:set_contenthash", &contenthash, &contenthash_type))
+ return NULL;
+ if (check_RepomdStatus(self))
+ return NULL;
+ cr_repomd_set_contenthash(self->repomd, contenthash, contenthash_type);
+ Py_RETURN_NONE;
+}
+
PyDoc_STRVAR(add_distro_tag__doc__,
"add_distro_tag(tag[, cpeid=None]) -> None\n\n"
"Add distro tag");
set_revision__doc__},
{"set_repoid", (PyCFunction)set_repoid, METH_VARARGS,
set_repoid__doc__},
+ {"set_contenthash", (PyCFunction)set_contenthash, METH_VARARGS,
+ set_contenthash__doc__},
{"add_distro_tag", (PyCFunction)add_distro_tag, METH_VARARGS|METH_KEYWORDS,
add_distro_tag__doc__},
{"add_repo_tag", (PyCFunction)add_repo_tag, METH_VARARGS,
"Repoid value", OFFSET(repoid)},
{"repoid_type", (getter)get_str, (setter)set_str,
"Repoid type value", OFFSET(repoid_type)},
+ {"contenthash", (getter)get_str, (setter)set_str,
+ "Contenthash value", OFFSET(contenthash)},
+ {"contenthash_type", (getter)get_str, (setter)set_str,
+ "contenthash type value", OFFSET(contenthash_type)},
{"repo_tags", (getter)get_list, (setter)set_list,
"List of repo tags", &(list_convertors[0])},
{"distro_tags", (getter)get_list, (setter)set_list,
}
void
+cr_repomd_set_contenthash(cr_Repomd *repomd, const char *hash, const char *type)
+{
+ if (!repomd) return;
+ repomd->contenthash = cr_safe_string_chunk_insert(repomd->chunk, hash);
+ repomd->contenthash_type = cr_safe_string_chunk_insert(repomd->chunk, type);
+}
+
+void
cr_repomd_add_distro_tag(cr_Repomd *repomd,
const char *cpeid,
const char *tag)
*/
typedef struct {
gchar *revision; /*!< Revison */
- gchar *repoid; /*!< RepoId */
- gchar *repoid_type; /*!< RepoId type ("sha256", ...) */
+ gchar *repoid; /*!< OBSOLETE, replaced by contenthash */
+ gchar *repoid_type; /*!< OBSOLETE, replaced by contenthash_type */
+ gchar *contenthash; /*!< Content hash */
+ gchar *contenthash_type; /*!< Content hash type ("sha256", ...) */
GSList *repo_tags; /*!< List of strings */
GSList *content_tags; /*!< List of strings */
GSList *distro_tags; /*!< List of cr_DistroTag* */
*/
void cr_repomd_set_revision(cr_Repomd *repomd, const char *revision);
-/** Set a repoid
+/** Set a repoid - OBSOLETE, use cr_repomd_set_contenthash instead
* @param repomd cr_Repomd object
- * @param type Type of hash function used to calculate repoid
* @param repoid RepoId
+ * @param type Type of hash function used to calculate repoid
*/
void cr_repomd_set_repoid(cr_Repomd *repomd,
const char *repoid,
const char *type);
+/** Set a contenthash
+ * @param repomd cr_Repomd object
+ * @param hash content hash
+ * @param type Type of hash function
+ */
+void cr_repomd_set_contenthash(cr_Repomd *repomd,
+ const char *hash,
+ const char *type);
+
/** Add distro tag.
* @param repomd cr_Repomd object
* @param cpeid cpeid string (could be NULL)
}
// **********************************
+ // Element: Contenthash
+ // **********************************
+
+ if (repomd->contenthash) {
+ xmlNodePtr contenthash_elem = cr_xmlNewTextChild(root,
+ NULL,
+ BAD_CAST "contenthash",
+ BAD_CAST repomd->contenthash);
+ if (repomd->contenthash_type)
+ cr_xmlNewProp(contenthash_elem,
+ BAD_CAST "type",
+ BAD_CAST repomd->contenthash_type);
+ }
+
+ // **********************************
// Element: Tags
// **********************************
STATE_REPOMD,
STATE_REVISION,
STATE_REPOID,
+ STATE_CONTENTHASH,
STATE_TAGS,
STATE_REPO,
STATE_CONTENT,
{ STATE_START, "repomd", STATE_REPOMD, 0 },
{ STATE_REPOMD, "revision", STATE_REVISION, 1 },
{ STATE_REPOMD, "repoid", STATE_REPOID, 1 },
+ { STATE_REPOMD, "contenthash", STATE_CONTENTHASH, 1 },
{ STATE_REPOMD, "tags", STATE_TAGS, 0 },
{ STATE_REPOMD, "data", STATE_DATA, 0 },
{ STATE_TAGS, "repo", STATE_REPO, 1 },
val);
break;
+ case STATE_CONTENTHASH:
+ assert(pd->repomd);
+ assert(!pd->repomdrecord);
+
+ val = cr_find_attr("type", attr);
+ if (val)
+ pd->repomd->contenthash_type = g_string_chunk_insert(
+ pd->repomd->chunk, val);
+ break;
+
case STATE_DISTRO:
assert(pd->repomd);
assert(!pd->repomdrecord);
pd->content);
break;
+ case STATE_CONTENTHASH:
+ assert(pd->repomd);
+ assert(!pd->repomdrecord);
+
+ pd->repomd->contenthash = g_string_chunk_insert(pd->repomd->chunk,
+ pd->content);
+ break;
+
case STATE_TAGS:
break;
self.assertEqual(md.revision, "foobar")
self.assertEqual(md.repoid, None);
- md.set_repoid("fooid", "sha256")
- self.assertEqual(md.repoid, "fooid")
+ md.set_repoid("barid", "sha256")
+ self.assertEqual(md.repoid, "barid")
+
+ self.assertEqual(md.contenthash, None);
+ md.set_contenthash("fooid", "sha256")
+ self.assertEqual(md.contenthash, "fooid")
self.assertEqual(md.distro_tags, [])
md.add_distro_tag("tag1")
"""<?xml version="1.0" encoding="UTF-8"?>
<repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
<revision>foobar</revision>
- <repoid type="sha256">fooid</repoid>
+ <repoid type="sha256">barid</repoid>
+ <contenthash type="sha256">fooid</contenthash>
<tags>
<content>contenttag</content>
<repo>repotag</repo>
self.assertEqual(len(md.records), 1)
md.repoid = None
+ md.contenthash = None
xml = md.xml_dump()
self.assertEqual(xml,