g_debug("Generating repomd.xml");
- cr_Repomd repomd_obj = cr_new_repomd();
+ cr_Repomd repomd_obj = cr_repomd_new();
- cr_RepomdRecord pri_xml_rec = cr_new_repomdrecord(pri_xml_filename);
- cr_RepomdRecord fil_xml_rec = cr_new_repomdrecord(fil_xml_filename);
- cr_RepomdRecord oth_xml_rec = cr_new_repomdrecord(oth_xml_filename);
+ cr_RepomdRecord pri_xml_rec = cr_repomd_record_new(pri_xml_filename);
+ cr_RepomdRecord fil_xml_rec = cr_repomd_record_new(fil_xml_filename);
+ cr_RepomdRecord oth_xml_rec = cr_repomd_record_new(oth_xml_filename);
cr_RepomdRecord pri_db_rec = NULL;
cr_RepomdRecord fil_db_rec = NULL;
cr_RepomdRecord oth_db_rec = NULL;
// XML
- cr_fill_repomdrecord(pri_xml_rec, cmd_options->checksum_type);
- cr_fill_repomdrecord(fil_xml_rec, cmd_options->checksum_type);
- cr_fill_repomdrecord(oth_xml_rec, cmd_options->checksum_type);
+ cr_repomd_record_fill(pri_xml_rec, cmd_options->checksum_type);
+ cr_repomd_record_fill(fil_xml_rec, cmd_options->checksum_type);
+ cr_repomd_record_fill(oth_xml_rec, cmd_options->checksum_type);
// Groupfile
if (groupfile) {
- groupfile_rec = cr_new_repomdrecord(groupfile);
- compressed_groupfile_rec = cr_new_repomdrecord(groupfile);
- cr_process_groupfile_repomdrecord(groupfile_rec,
+ groupfile_rec = cr_repomd_record_new(groupfile);
+ compressed_groupfile_rec = cr_repomd_record_new(groupfile);
+ cr_repomd_record_groupfile(groupfile_rec,
compressed_groupfile_rec,
cmd_options->checksum_type,
groupfile_compression);
// Updateinfo
if (updateinfo) {
- updateinfo_rec = cr_new_repomdrecord(updateinfo);
- cr_fill_repomdrecord(updateinfo_rec, cmd_options->checksum_type);
+ updateinfo_rec = cr_repomd_record_new(updateinfo);
+ cr_repomd_record_fill(updateinfo_rec, cmd_options->checksum_type);
}
// Prepare repomd records
- pri_db_rec = cr_new_repomdrecord(pri_db_name);
- fil_db_rec = cr_new_repomdrecord(fil_db_name);
- oth_db_rec = cr_new_repomdrecord(oth_db_name);
+ pri_db_rec = cr_repomd_record_new(pri_db_name);
+ fil_db_rec = cr_repomd_record_new(fil_db_name);
+ oth_db_rec = cr_repomd_record_new(oth_db_name);
- cr_fill_repomdrecord(pri_db_rec, cmd_options->checksum_type);
- cr_fill_repomdrecord(fil_db_rec, cmd_options->checksum_type);
- cr_fill_repomdrecord(oth_db_rec, cmd_options->checksum_type);
+ cr_repomd_record_fill(pri_db_rec, cmd_options->checksum_type);
+ cr_repomd_record_fill(fil_db_rec, cmd_options->checksum_type);
+ cr_repomd_record_fill(oth_db_rec, cmd_options->checksum_type);
g_free(pri_db_name);
g_free(fil_db_name);
// Add checksums into files names
if (cmd_options->unique_md_filenames) {
- cr_rename_repomdrecord_file(pri_xml_rec);
- cr_rename_repomdrecord_file(fil_xml_rec);
- cr_rename_repomdrecord_file(oth_xml_rec);
- cr_rename_repomdrecord_file(pri_db_rec);
- cr_rename_repomdrecord_file(fil_db_rec);
- cr_rename_repomdrecord_file(oth_db_rec);
- cr_rename_repomdrecord_file(groupfile_rec);
- cr_rename_repomdrecord_file(compressed_groupfile_rec);
- cr_rename_repomdrecord_file(updateinfo_rec);
+ cr_repomd_record_rename_file(pri_xml_rec);
+ cr_repomd_record_rename_file(fil_xml_rec);
+ cr_repomd_record_rename_file(oth_xml_rec);
+ cr_repomd_record_rename_file(pri_db_rec);
+ cr_repomd_record_rename_file(fil_db_rec);
+ cr_repomd_record_rename_file(oth_db_rec);
+ cr_repomd_record_rename_file(groupfile_rec);
+ cr_repomd_record_rename_file(compressed_groupfile_rec);
+ cr_repomd_record_rename_file(updateinfo_rec);
}
if (cmd_options->revision)
cr_repomd_set_revision(repomd_obj, cmd_options->revision);
- char *repomd_xml = cr_generate_repomd_xml(repomd_obj);
+ char *repomd_xml = cr_repomd_xml_dump(repomd_obj);
- cr_free_repomd(repomd_obj);
+ cr_repomd_free(repomd_obj);
// Write repomd.xml
// Prepare repomd records
- cr_RepomdRecord pri_xml_rec = cr_new_repomdrecord(pri_xml_filename);
- cr_RepomdRecord fil_xml_rec = cr_new_repomdrecord(fil_xml_filename);
- cr_RepomdRecord oth_xml_rec = cr_new_repomdrecord(oth_xml_filename);
+ cr_RepomdRecord pri_xml_rec = cr_repomd_record_new(pri_xml_filename);
+ cr_RepomdRecord fil_xml_rec = cr_repomd_record_new(fil_xml_filename);
+ cr_RepomdRecord oth_xml_rec = cr_repomd_record_new(oth_xml_filename);
cr_RepomdRecord pri_db_rec = NULL;
cr_RepomdRecord fil_db_rec = NULL;
cr_RepomdRecord oth_db_rec = NULL;
// XML
- cr_fill_repomdrecord(pri_xml_rec, CR_CHECKSUM_SHA256);
- cr_fill_repomdrecord(fil_xml_rec, CR_CHECKSUM_SHA256);
- cr_fill_repomdrecord(oth_xml_rec, CR_CHECKSUM_SHA256);
+ cr_repomd_record_fill(pri_xml_rec, CR_CHECKSUM_SHA256);
+ cr_repomd_record_fill(fil_xml_rec, CR_CHECKSUM_SHA256);
+ cr_repomd_record_fill(oth_xml_rec, CR_CHECKSUM_SHA256);
// Groupfile
if (groupfile) {
- groupfile_rec = cr_new_repomdrecord(groupfile);
- compressed_groupfile_rec = cr_new_repomdrecord(groupfile);
- cr_process_groupfile_repomdrecord(groupfile_rec,
+ groupfile_rec = cr_repomd_record_new(groupfile);
+ compressed_groupfile_rec = cr_repomd_record_new(groupfile);
+ cr_repomd_record_groupfile(groupfile_rec,
compressed_groupfile_rec,
CR_CHECKSUM_SHA256,
cmd_options->groupfile_compression_type);
// Update info
if (!cmd_options->noupdateinfo) {
- update_info_rec = cr_new_repomdrecord(update_info_filename);
- cr_fill_repomdrecord(update_info_rec, CR_CHECKSUM_SHA256);
+ update_info_rec = cr_repomd_record_new(update_info_filename);
+ cr_repomd_record_fill(update_info_rec, CR_CHECKSUM_SHA256);
}
if (cmd_options->koji) {
gchar *pkgorigins_path = g_strconcat(cmd_options->tmp_out_repo, "pkgorigins.gz", NULL);
- pkgorigins_rec = cr_new_repomdrecord(pkgorigins_path);
- cr_fill_repomdrecord(pkgorigins_rec, CR_CHECKSUM_SHA256);
+ pkgorigins_rec = cr_repomd_record_new(pkgorigins_path);
+ cr_repomd_record_fill(pkgorigins_rec, CR_CHECKSUM_SHA256);
g_free(pkgorigins_path);
}
remove(oth_db_filename);
// Prepare repomd records
- pri_db_rec = cr_new_repomdrecord(pri_db_c_filename);
- fil_db_rec = cr_new_repomdrecord(fil_db_c_filename);
- oth_db_rec = cr_new_repomdrecord(oth_db_c_filename);
+ pri_db_rec = cr_repomd_record_new(pri_db_c_filename);
+ fil_db_rec = cr_repomd_record_new(fil_db_c_filename);
+ oth_db_rec = cr_repomd_record_new(oth_db_c_filename);
g_free(pri_db_filename);
g_free(fil_db_filename);
g_free(fil_db_c_filename);
g_free(oth_db_c_filename);
- cr_fill_repomdrecord(pri_db_rec, CR_CHECKSUM_SHA256);
- cr_fill_repomdrecord(fil_db_rec, CR_CHECKSUM_SHA256);
- cr_fill_repomdrecord(oth_db_rec, CR_CHECKSUM_SHA256);
+ cr_repomd_record_fill(pri_db_rec, CR_CHECKSUM_SHA256);
+ cr_repomd_record_fill(fil_db_rec, CR_CHECKSUM_SHA256);
+ cr_repomd_record_fill(oth_db_rec, CR_CHECKSUM_SHA256);
}
// Add checksums into files names
- cr_rename_repomdrecord_file(pri_xml_rec);
- cr_rename_repomdrecord_file(fil_xml_rec);
- cr_rename_repomdrecord_file(oth_xml_rec);
- cr_rename_repomdrecord_file(pri_db_rec);
- cr_rename_repomdrecord_file(fil_db_rec);
- cr_rename_repomdrecord_file(oth_db_rec);
- cr_rename_repomdrecord_file(groupfile_rec);
- cr_rename_repomdrecord_file(compressed_groupfile_rec);
- cr_rename_repomdrecord_file(update_info_rec);
- cr_rename_repomdrecord_file(pkgorigins_rec);
+ cr_repomd_record_rename_file(pri_xml_rec);
+ cr_repomd_record_rename_file(fil_xml_rec);
+ cr_repomd_record_rename_file(oth_xml_rec);
+ cr_repomd_record_rename_file(pri_db_rec);
+ cr_repomd_record_rename_file(fil_db_rec);
+ cr_repomd_record_rename_file(oth_db_rec);
+ cr_repomd_record_rename_file(groupfile_rec);
+ cr_repomd_record_rename_file(compressed_groupfile_rec);
+ cr_repomd_record_rename_file(update_info_rec);
+ cr_repomd_record_rename_file(pkgorigins_rec);
// Gen repomd.xml content
- cr_Repomd repomd_obj = cr_new_repomd();
+ cr_Repomd repomd_obj = cr_repomd_new();
cr_repomd_set_record(repomd_obj, pri_xml_rec, "primary");
cr_repomd_set_record(repomd_obj, fil_xml_rec, "filelists");
cr_repomd_set_record(repomd_obj, oth_xml_rec, "other");
cr_repomd_set_record(repomd_obj, update_info_rec,"updateinfo");
cr_repomd_set_record(repomd_obj, pkgorigins_rec, "origin");
- char *repomd_xml = cr_generate_repomd_xml(repomd_obj);
+ char *repomd_xml = cr_repomd_xml_dump(repomd_obj);
- cr_free_repomd(repomd_obj);
+ cr_repomd_free(repomd_obj);
if (repomd_xml) {
gchar *repomd_path = g_strconcat(cmd_options->tmp_out_repo, "repomd.xml", NULL);
cr_RepomdRecord
-cr_new_repomdrecord(const char *path)
+cr_repomd_record_new(const char *path)
{
cr_RepomdRecord md = (cr_RepomdRecord) g_malloc0(sizeof(*md));
md->chunk = g_string_chunk_new(1024);
void
-cr_free_repomdrecord(cr_RepomdRecord md)
+cr_repomd_record_free(cr_RepomdRecord md)
{
if (!md)
return;
contentStat *
-get_compressed_content_stat(const char *filename, cr_ChecksumType checksum_type)
+cr_get_compressed_content_stat(const char *filename, cr_ChecksumType checksum_type)
{
if (!g_file_test(filename, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
return NULL;
int
-cr_fill_repomdrecord(cr_RepomdRecord md, cr_ChecksumType checksum_type)
+cr_repomd_record_fill(cr_RepomdRecord md, cr_ChecksumType checksum_type)
{
const char *checksum_str;
cr_ChecksumType checksum_t;
{
// File compressed by supported algorithm
contentStat *open_stat = NULL;
- open_stat = get_compressed_content_stat(path, checksum_t);
+ open_stat = cr_get_compressed_content_stat(path, checksum_t);
md->checksum_open_type = g_string_chunk_insert(md->chunk, checksum_str);
md->checksum_open = g_string_chunk_insert(md->chunk, open_stat->checksum);
if (!md->size_open) {
void
-cr_process_groupfile_repomdrecord(cr_RepomdRecord groupfile,
+cr_repomd_record_groupfile(cr_RepomdRecord groupfile,
cr_RepomdRecord cgroupfile,
cr_ChecksumType checksum_type,
cr_CompressionType groupfile_compression)
void
-dump_data_items(xmlNodePtr root, cr_RepomdRecord md, const xmlChar *type)
+cr_repomd_dump_data_items(xmlNodePtr root, cr_RepomdRecord md, const xmlChar *type)
{
xmlNodePtr data, node;
gchar str_buffer[STR_BUFFER_SIZE];
char *
-repomd_xml_dump(cr_Repomd repomd)
+cr_repomd_xml_dump(cr_Repomd repomd)
{
xmlDocPtr doc;
xmlNodePtr root;
GList *keys, *element;
+ // Set current time as revision if no revision specified
+
+ if (!repomd->revision) {
+ gchar *rev = g_strdup_printf("%ld", time(NULL));
+ cr_repomd_set_revision(repomd, rev);
+ g_free(rev);
+ }
// Start of XML document
for (element = keys; element; element = g_list_next(element)) {
char *type = element->data;
cr_RepomdRecord rec = g_hash_table_lookup(repomd->records, type);
- dump_data_items(root, rec, (const xmlChar *) type);
+ cr_repomd_dump_data_items(root, rec, (const xmlChar *) type);
}
g_list_free(keys);
void
-cr_rename_repomdrecord_file(cr_RepomdRecord md)
+cr_repomd_record_rename_file(cr_RepomdRecord md)
{
int x, len;
gchar *location_prefix = NULL;
cr_Repomd
-cr_new_repomd()
+cr_repomd_new()
{
cr_Repomd repomd = g_malloc0(sizeof(struct _cr_Repomd));
repomd->records = g_hash_table_new_full(g_str_hash,
g_str_equal,
g_free,
- (GDestroyNotify) cr_free_repomdrecord);
+ (GDestroyNotify) cr_repomd_record_free);
return repomd;
}
void
-cr_free_repomd(cr_Repomd repomd)
+cr_repomd_free(cr_Repomd repomd)
{
if (!repomd) return;
g_hash_table_destroy(repomd->records);
repomd->content_tags = g_slist_append(repomd->content_tags, g_strdup(tag));
}
-
-gchar *
-cr_generate_repomd_xml(cr_Repomd repomd)
-{
- if (!repomd->revision) {
- gchar *rev = g_strdup_printf("%ld", time(NULL));
- cr_repomd_set_revision(repomd, rev);
- g_free(rev);
- }
-
- return repomd_xml_dump(repomd);
-}
/** Creates (alloc) new cr_RepomdRecord object
* @param path path to the compressed file
*/
-cr_RepomdRecord cr_new_repomdrecord(const char *path);
+cr_RepomdRecord cr_repomd_record_new(const char *path);
/** Destroy cr_RepomdRecord object.
* NOTE: Do NOT use this function on objects attached to cr_Repomd
* (by cr_repomd_set_record).
* @param record cr_RepomdRecord object
*/
-void cr_free_repomdrecord(cr_RepomdRecord record);
+void cr_repomd_record_free(cr_RepomdRecord record);
/** Fill unfilled items in the cr_RepomdRecord (calculate checksums,
* get file size before/after compression, etc.).
- * Note: For groupfile you shoud use cr_process_groupfile_repomdrecord function.
+ * Note: For groupfile you shoud use cr_repomd_record_groupfile function.
* @param record cr_RepomdRecord object
* @param checksum_type type of checksum to use
*/
-int cr_fill_repomdrecord(cr_RepomdRecord record,
+int cr_repomd_record_fill(cr_RepomdRecord record,
cr_ChecksumType checksum_type);
-/** Analogue of cr_fill_repomdrecord but for groupfile.
+/** Analogue of cr_repomd_record_fill but for groupfile.
* Groupfile must be set with the path to existing non compressed groupfile.
* Compressed group file will be created and compressed_groupfile record
* updated.
* @param checksum_type type of checksums
* @param compression type of compression
*/
-void cr_process_groupfile_repomdrecord(cr_RepomdRecord groupfile,
+void cr_repomd_record_groupfile(cr_RepomdRecord groupfile,
cr_RepomdRecord compressed_groupfile,
cr_ChecksumType checksum_type,
cr_CompressionType compression);
/** Add a hash as prefix to the filename.
* @param record cr_RepomdRecord of file to be renamed
*/
-void cr_rename_repomdrecord_file(cr_RepomdRecord record);
+void cr_repomd_record_rename_file(cr_RepomdRecord record);
/** Create new empty cr_Repomd object wich represents content of repomd.xml.
*/
-cr_Repomd cr_new_repomd();
+cr_Repomd cr_repomd_new();
/** Set cr_Repomd record into cr_Repomd object.
* @param repomd cr_Repomd object
/** Frees cr_Repomd object and all its cr_RepomdRecord objects
* @param repomd cr_Repomd object
*/
-void cr_free_repomd(cr_Repomd repomd);
+void cr_repomd_free(cr_Repomd repomd);
/** Generate repomd.xml content.
+ * Don't forget to use cr_xml_dump_init() before call this function.
* @param repomd cr_Repomd object
* @return string with repomd.xml content
*/
-gchar *cr_generate_repomd_xml(cr_Repomd repomd);
+gchar *cr_repomd_xml_dump(cr_Repomd repomd);
/** @} */