From 81c6ba764689d0d3a08ec0b13b08234b3c76c6c2 Mon Sep 17 00:00:00 2001 From: Tomas Mlcoch Date: Mon, 3 Jun 2013 16:53:42 +0200 Subject: [PATCH] createrepo_c+mergerepo_c: Fix bug with repomd gen. --- src/createrepo_c.c | 18 +++++++++--------- src/mergerepo_c.c | 20 ++++++++++---------- src/repomd.h | 10 +++++++--- src/xml_dump.h | 8 ++++++-- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/createrepo_c.c b/src/createrepo_c.c index eaaabac..706d488 100644 --- a/src/createrepo_c.c +++ b/src/createrepo_c.c @@ -1005,9 +1005,9 @@ main(int argc, char **argv) cr_Repomd *repomd_obj = cr_repomd_new(); - cr_RepomdRecord *pri_xml_rec = cr_repomd_record_new(pri_xml_filename, "primary"); - cr_RepomdRecord *fil_xml_rec = cr_repomd_record_new(fil_xml_filename, "filelists"); - cr_RepomdRecord *oth_xml_rec = cr_repomd_record_new(oth_xml_filename, "other"); + cr_RepomdRecord *pri_xml_rec = cr_repomd_record_new("primary", pri_xml_filename); + cr_RepomdRecord *fil_xml_rec = cr_repomd_record_new("filelists", fil_xml_filename); + cr_RepomdRecord *oth_xml_rec = cr_repomd_record_new("other", oth_xml_filename); cr_RepomdRecord *pri_db_rec = NULL; cr_RepomdRecord *fil_db_rec = NULL; cr_RepomdRecord *oth_db_rec = NULL; @@ -1026,8 +1026,8 @@ main(int argc, char **argv) // Groupfile if (groupfile) { - groupfile_rec = cr_repomd_record_new(groupfile, "group"); - compressed_groupfile_rec = cr_repomd_record_new(groupfile, "group_gz"); + groupfile_rec = cr_repomd_record_new("group", groupfile); + compressed_groupfile_rec = cr_repomd_record_new("group_gz", groupfile); cr_repomd_record_compress_and_fill(groupfile_rec, compressed_groupfile_rec, cmd_options->checksum_type, @@ -1039,7 +1039,7 @@ main(int argc, char **argv) // Updateinfo if (updateinfo) { - updateinfo_rec = cr_repomd_record_new(updateinfo, "updateinfo"); + updateinfo_rec = cr_repomd_record_new("updateinfo", updateinfo); cr_repomd_record_fill(updateinfo_rec, cmd_options->checksum_type, NULL); } @@ -1077,9 +1077,9 @@ main(int argc, char **argv) // Prepare repomd records - pri_db_rec = cr_repomd_record_new(pri_db_name, "primary_db"); - fil_db_rec = cr_repomd_record_new(fil_db_name, "filelists_db"); - oth_db_rec = cr_repomd_record_new(oth_db_name, "other_db"); + pri_db_rec = cr_repomd_record_new("primary_db", pri_db_name); + fil_db_rec = cr_repomd_record_new("filelists_db", fil_db_name); + oth_db_rec = cr_repomd_record_new("other_db", oth_db_name); cr_repomd_record_fill(pri_db_rec, cmd_options->checksum_type, NULL); cr_repomd_record_fill(fil_db_rec, cmd_options->checksum_type, NULL); diff --git a/src/mergerepo_c.c b/src/mergerepo_c.c index 690bc1f..98131c1 100644 --- a/src/mergerepo_c.c +++ b/src/mergerepo_c.c @@ -1162,9 +1162,9 @@ dump_merged_metadata(GHashTable *merged_hashtable, // Prepare repomd records - cr_RepomdRecord *pri_xml_rec = cr_repomd_record_new(pri_xml_filename, "primary"); - cr_RepomdRecord *fil_xml_rec = cr_repomd_record_new(fil_xml_filename, "filelists"); - cr_RepomdRecord *oth_xml_rec = cr_repomd_record_new(oth_xml_filename, "other"); + cr_RepomdRecord *pri_xml_rec = cr_repomd_record_new("primary", pri_xml_filename); + cr_RepomdRecord *fil_xml_rec = cr_repomd_record_new("filelists", fil_xml_filename); + cr_RepomdRecord *oth_xml_rec = cr_repomd_record_new("other", oth_xml_filename); cr_RepomdRecord *pri_db_rec = NULL; cr_RepomdRecord *fil_db_rec = NULL; cr_RepomdRecord *oth_db_rec = NULL; @@ -1184,8 +1184,8 @@ dump_merged_metadata(GHashTable *merged_hashtable, // Groupfile if (groupfile) { - groupfile_rec = cr_repomd_record_new(groupfile, "group"); - compressed_groupfile_rec = cr_repomd_record_new(groupfile, "group_gz"); + groupfile_rec = cr_repomd_record_new("group", groupfile); + compressed_groupfile_rec = cr_repomd_record_new("group_gz", groupfile); cr_repomd_record_compress_and_fill(groupfile_rec, compressed_groupfile_rec, CR_CHECKSUM_SHA256, @@ -1197,7 +1197,7 @@ dump_merged_metadata(GHashTable *merged_hashtable, // Update info if (!cmd_options->noupdateinfo) { - update_info_rec = cr_repomd_record_new(update_info_filename, "updateinfo"); + update_info_rec = cr_repomd_record_new("updateinfo", update_info_filename); cr_repomd_record_fill(update_info_rec, CR_CHECKSUM_SHA256, NULL); } @@ -1206,7 +1206,7 @@ dump_merged_metadata(GHashTable *merged_hashtable, if (cmd_options->koji) { gchar *pkgorigins_path = g_strconcat(cmd_options->tmp_out_repo, "pkgorigins.gz", NULL); - pkgorigins_rec = cr_repomd_record_new(pkgorigins_path, "origin"); + pkgorigins_rec = cr_repomd_record_new("origin", pkgorigins_path); cr_repomd_record_fill(pkgorigins_rec, CR_CHECKSUM_SHA256, NULL); g_free(pkgorigins_path); } @@ -1250,9 +1250,9 @@ dump_merged_metadata(GHashTable *merged_hashtable, remove(oth_db_filename); // Prepare repomd records - pri_db_rec = cr_repomd_record_new(pri_db_c_filename, "primary_db"); - fil_db_rec = cr_repomd_record_new(fil_db_c_filename, "filelists_db"); - oth_db_rec = cr_repomd_record_new(oth_db_c_filename, "other_db"); + pri_db_rec = cr_repomd_record_new("primary_db", pri_db_c_filename); + fil_db_rec = cr_repomd_record_new("filelists_db", fil_db_c_filename); + oth_db_rec = cr_repomd_record_new("other_db", oth_db_c_filename); g_free(pri_db_filename); g_free(fil_db_filename); diff --git a/src/repomd.h b/src/repomd.h index 6b8b5ba..4d46afd 100644 --- a/src/repomd.h +++ b/src/repomd.h @@ -39,6 +39,8 @@ extern "C" { * cr_Repomd *md = cr_repomd_new(); * cr_RepomdRecord *rec; * + * cr_xml_dump_init(); + * * // Set some repomd stuff * cr_repomd_set_revision(md, "007"); * cr_repomd_add_repo_tag(md, "repotag"); @@ -46,18 +48,20 @@ extern "C" { * cr_repomd_add_distro_tag(md, "foocpeid", "data"); * * // Create record for new metadata file - * rec = cr_repomd_record_new("/foo/bar/repodata/primary.xml.xz"); + * rec = cr_repomd_record_new("primary", "/foo/bar/repodata/primary.xml.xz"); * // Calculate all needed parameters (uncompresed size, checksum, ...) * cr_repomd_record_fill(rec, CR_CHECKSUM_SHA256); * // Rename source file - insert checksum into the filename * cr_repomd_record_rename_file(rec) * // Append the record into the repomd - * cr_repomd_set_record(md, rec, "primary"); + * cr_repomd_set_record(md, rec); * * // Get repomd.xml content - * // Note: cr_xml_dump_init() shoud be once called before dump * xml = cr_repomd_xml_dump(md); + * + * // Cleanup * cr_repomd_free(md); + * cr_xml_dump_cleanup(); * \endcode * * \addtogroup repomd diff --git a/src/xml_dump.h b/src/xml_dump.h index aa48471..0a41adb 100644 --- a/src/xml_dump.h +++ b/src/xml_dump.h @@ -33,12 +33,13 @@ extern "C" { * cr_Package *pkg; * struct cr_XmlStruct xml; * + * cr_xml_dump_init(); + * cr_package_parser_init(); + * * pkg = cr_package_from_rpm("path/to/rpm.rpm", CR_CHECKSUM_SHA256, * "repodata/rpm.rpm", NULL, 10, NULL); * - * cr_xml_dump_init(); * xml = cr_xml_dump(pkg, NULL); - * cr_xml_dump_cleanup(); * * cr_package_free(pkg); * @@ -49,6 +50,9 @@ extern "C" { * free(xml.primary); * free(xml.filelists); * free(xml.other); + * + * cr_package_parser_cleanup(); + * cr_xml_dump_cleanup(); * \endcode * * \addtogroup xml_dump -- 2.7.4