mergerepo_c: Add --simple-md-filenames and --unique-md-filenames options. (RhBug...
authorTomas Mlcoch <tmlcoch@redhat.com>
Thu, 11 Apr 2013 13:14:24 +0000 (15:14 +0200)
committerTomas Mlcoch <tmlcoch@redhat.com>
Thu, 11 Apr 2013 13:14:24 +0000 (15:14 +0200)
createrepo_c.bash
src/mergerepo_c.c

index 8e00a9a..324fc9f 100644 (file)
@@ -98,7 +98,8 @@ _cr_mergerepo()
 
     COMPREPLY=( $( compgen -W '--version --help --repo --archlist --database
         --no-database --verbose --outputdir --nogroups --noupdateinfo
-        --compress-type --method --all --noarch-repo --koji --groupfile
+        --compress-type --method --all --noarch-repo --unique-md-filenames
+        --simple-md-filenames --koji --groupfile
         --blocked' -- "$2" ) )
 } &&
 complete -F _cr_mergerepo -o filenames mergerepo_c
index 15367e9..e986b6f 100644 (file)
@@ -123,6 +123,8 @@ struct CmdOptions {
     char *merge_method_str;
     gboolean all;
     char *noarch_repo_url;
+    gboolean unique_md_filenames;
+    gboolean simple_md_filenames;
 
     // Koji mergerepos specific options
     gboolean koji;
@@ -145,7 +147,9 @@ struct CmdOptions {
 struct CmdOptions _cmd_options = {
         .db_compression_type = DEFAULT_DB_COMPRESSION_TYPE,
         .groupfile_compression_type = DEFAULT_GROUPFILE_COMPRESSION_TYPE,
-        .merge_method = MM_DEFAULT
+        .merge_method = MM_DEFAULT,
+        .unique_md_filenames = TRUE,
+        .simple_md_filenames = FALSE,
     };
 
 
@@ -180,6 +184,12 @@ static GOptionEntry cmd_entries[] =
     { "noarch-repo", 0, 0, G_OPTION_ARG_FILENAME, &(_cmd_options.noarch_repo_url),
       "Packages with noarch architecture will be replaced by package from this "
       "repo if exists in it.", "URL" },
+    { "unique-md-filenames", 0, 0, G_OPTION_ARG_NONE, &(_cmd_options.unique_md_filenames),
+      "Include the file's checksum in the metadata filename, helps HTTP caching (default).",
+      NULL },
+    { "simple-md-filenames", 0, 0, G_OPTION_ARG_NONE, &(_cmd_options.simple_md_filenames),
+      "Do not include the file's checksum in the metadata filename.", NULL },
+
     // -- Options related to Koji-mergerepos behaviour
     { "koji", 'k', 0, G_OPTION_ARG_NONE, &(_cmd_options.koji),
        "Enable koji mergerepos behaviour.", NULL},
@@ -336,6 +346,11 @@ check_arguments(struct CmdOptions *options)
         }
     }
 
+    // Check simple filenames
+    if (options->simple_md_filenames) {
+        options->unique_md_filenames = FALSE;
+    }
+
     // Koji arguments
     if (options->blocked) {
         if (!options->koji) {
@@ -1231,16 +1246,18 @@ dump_merged_metadata(GHashTable *merged_hashtable,
 
     // Add checksums into files names
 
-    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);
+    if (cmd_options->unique_md_filenames) {
+        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