From 7ec977bae68c193f82c7e03f8032a1667c384dfd Mon Sep 17 00:00:00 2001 From: Tomas Mlcoch Date: Mon, 11 Jun 2012 14:31:29 +0200 Subject: [PATCH] Add support for different compression for groupfile into the repomd module --- src/createrepo_c.c | 6 ++++-- src/mergerepo_c.c | 3 ++- src/repomd.c | 18 +++++++++++------- src/repomd.h | 4 +++- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/createrepo_c.c b/src/createrepo_c.c index 34ae6cd..e2c253c 100644 --- a/src/createrepo_c.c +++ b/src/createrepo_c.c @@ -404,8 +404,9 @@ int main(int argc, char **argv) { const char *compression_suffix = NULL; CompressionType used_compression = GZ_COMPRESSION; + CompressionType groupfile_compression = GZ_COMPRESSION; if (cmd_options->xz_compression) { - used_compression = XZ_COMPRESSION; + groupfile_compression = XZ_COMPRESSION; } compression_suffix = get_suffix(used_compression); @@ -700,7 +701,8 @@ int main(int argc, char **argv) { struct repomdResult *repomd_res = xml_repomd(out_dir, cmd_options->unique_md_filenames, pri_xml_name, fil_xml_name, oth_xml_name, NULL, NULL, NULL, groupfile_name, NULL, - &(cmd_options->checksum_type)); + &(cmd_options->checksum_type), + groupfile_compression); gchar *repomd_path = g_strconcat(out_repo, "repomd.xml", NULL); FILE *frepomd = fopen(repomd_path, "w"); diff --git a/src/mergerepo_c.c b/src/mergerepo_c.c index 33f55d8..dfd5850 100644 --- a/src/mergerepo_c.c +++ b/src/mergerepo_c.c @@ -611,7 +611,8 @@ int dump_merged_metadata(GHashTable *merged_hashtable, long packages, gchar *gro struct repomdResult *repomd_res = xml_repomd(cmd_options->out_dir, 1, pri_xml_name, fil_xml_name, oth_xml_name, NULL, NULL, - NULL, groupfile, ui_xml_name, NULL); + NULL, groupfile, ui_xml_name, NULL, + cmd_options->compression_type); if (repomd_res) { if (repomd_res->repomd_xml) { gchar *repomd_path = g_strconcat(cmd_options->out_repo, "repomd.xml", NULL); diff --git a/src/repomd.c b/src/repomd.c index bc205f1..c3c9023 100644 --- a/src/repomd.c +++ b/src/repomd.c @@ -280,7 +280,8 @@ int fill_missing_data(const char *base_path, struct repomdData *md, ChecksumType void process_groupfile(const char *base_path, struct repomdData *groupfile, - struct repomdData *cgroupfile, ChecksumType *checksum_type) + struct repomdData *cgroupfile, ChecksumType *checksum_type, + CompressionType groupfile_compression) { if (!groupfile || !(groupfile->location_href) || !strlen(groupfile->location_href) || !cgroupfile) { return; @@ -300,7 +301,9 @@ void process_groupfile(const char *base_path, struct repomdData *groupfile, // Paths - gchar *clocation_href = g_strconcat(groupfile->location_href, ".gz", NULL); + const char *suffix = get_suffix(groupfile_compression); + + gchar *clocation_href = g_strconcat(groupfile->location_href, suffix, NULL); cgroupfile->location_href = g_string_chunk_insert(cgroupfile->chunk, clocation_href); g_free(clocation_href); @@ -324,7 +327,7 @@ void process_groupfile(const char *base_path, struct repomdData *groupfile, CW_FILE *cw_compressed; cw_plain = cw_open(path, CW_MODE_READ, NO_COMPRESSION); - cw_compressed = cw_open(cpath, CW_MODE_WRITE, GZ_COMPRESSION); + cw_compressed = cw_open(cpath, CW_MODE_WRITE, groupfile_compression); while ((readed = cw_read(cw_plain, buf, BUFFER_SIZE)) > 0) { if (cw_write(cw_compressed, buf, (unsigned int) readed) == CW_ERR) { @@ -545,7 +548,7 @@ struct repomdResult *xml_repomd_2(const char *path, int rename_to_unique, struct struct repomdData *pri_sqlite, struct repomdData *fil_sqlite, struct repomdData *oth_sqlite, struct repomdData *groupfile, struct repomdData *cgroupfile, struct repomdData *update_info, - ChecksumType *checksum_type) + ChecksumType *checksum_type, CompressionType groupfile_compression) { if (!path) { return NULL; @@ -564,7 +567,7 @@ struct repomdResult *xml_repomd_2(const char *path, int rename_to_unique, struct fill_missing_data(path, oth_sqlite, checksum_type); fill_missing_data(path, update_info, checksum_type); - process_groupfile(path, groupfile, cgroupfile, checksum_type); + process_groupfile(path, groupfile, cgroupfile, checksum_type, groupfile_compression); // Include checksum in the metadata filename @@ -612,7 +615,8 @@ struct repomdResult *xml_repomd(const char *path, int rename_to_unique, const ch const char *fil_xml, const char *oth_xml, const char *pri_sqlite, const char *fil_sqlite, const char *oth_sqlite, const char *groupfile, - const char *update_info, ChecksumType *checksum_type) + const char *update_info, ChecksumType *checksum_type, + CompressionType groupfile_compression) { if (!path) { return NULL; @@ -669,7 +673,7 @@ struct repomdResult *xml_repomd(const char *path, int rename_to_unique, const ch pri_xml_rd, fil_xml_rd, oth_xml_rd, pri_sqlite_rd, fil_sqlite_rd, oth_sqlite_rd, groupfile_rd, cgroupfile_rd, update_info_rd, - checksum_type); + checksum_type, groupfile_compression); free_repomddata(pri_xml_rd); free_repomddata(fil_xml_rd); diff --git a/src/repomd.h b/src/repomd.h index b6af4b9..a3297d2 100644 --- a/src/repomd.h +++ b/src/repomd.h @@ -21,6 +21,7 @@ #include #include +#include "compression_wrapper.h" #include "package.h" /** \defgroup repomd Repomd API. @@ -68,6 +69,7 @@ struct repomdResult *xml_repomd(const char *path, int rename_to_unique, const ch const char *fil_xml, const char *oth_xml, const char *pri_sqlite, const char *fil_sqlite, const char *oth_sqlite, const char *groupfile, - const char *update_info, ChecksumType *checksum_type); + const char *update_info, ChecksumType *checksum_type, + CompressionType groupfile_compression); #endif /* __C_CREATEREPOLIB_REPOMD_H__ */ -- 2.7.4