Change default file handling (RhBug: 1094539)
authorTomas Mlcoch <tmlcoch@redhat.com>
Tue, 6 May 2014 12:49:23 +0000 (14:49 +0200)
committerTomas Mlcoch <tmlcoch@redhat.com>
Tue, 6 May 2014 12:51:30 +0000 (14:51 +0200)
During update, the original createrepo leaves behind some files which
were originaly part of repodata (were listed in the repomd.xml)
and after the update they are not part of the repomd.xml but they
still exists in the repodata/ directory.

E.g. comps files (group files) - when you add a new group file
(using --groupfile) and use --update, the old groupfile remains
are in the repodata/.

This patch changes the approach and the files that are not
part of repomd.xml anymore are removed.

See: https://github.com/Tojaj/createrepo_c/wiki/New-File-Handling

src/cmd_parser.c
src/cmd_parser.h
src/createrepo_c.c
src/helpers.c
src/helpers.h

index 6b6f119..1f52ec1 100644 (file)
@@ -124,6 +124,8 @@ static GOptionEntry cmd_entries[] =
       "Which compression type to use.", "<compress_type>" },
     { "keep-all-metadata", 0, 0, G_OPTION_ARG_NONE, &(_cmd_options.keep_all_metadata),
       "Keep groupfile and updateinfo from source repo during update.", NULL },
+    { "compatibility", 0, 0, G_OPTION_ARG_NONE, &(_cmd_options.compatibility),
+      "Enforce maximal compatibility with classical createrepo.", NULL },
     { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL },
 };
 
index 5f19aeb..b3e0710 100644 (file)
@@ -72,6 +72,10 @@ struct CmdOptions {
                                      create the new one (empty) to serve as
                                      a lock and use a .repodata.date.pid for
                                      data generation. */
+    gboolean compatibility;     /*!< Enforce maximal compatibility with
+                                     createrepo. I.e. mimics some dump
+                                     behavior like perseve old comps file(s)
+                                     during update etc.*/
 
     /* Items filled by check_arguments() */
 
index 4155e82..1b55c26 100644 (file)
@@ -1525,6 +1525,7 @@ main(int argc, char **argv)
     ret = cr_old_metadata_retention(out_repo,
                                     tmp_out_repo,
                                     cmd_options->retain_old,
+                                    cmd_options->compatibility,
                                     &tmp_err);
     if (!ret) {
         g_critical("%s", tmp_err->message);
index dc01541..e95ebe8 100644 (file)
@@ -318,6 +318,7 @@ gboolean
 cr_old_metadata_retention(const char *old_repo,
                           const char *new_repo,
                           int retain_old,
+                          int compatibility,
                           GError **err)
 {
     gboolean ret = TRUE;
@@ -325,7 +326,6 @@ cr_old_metadata_retention(const char *old_repo,
     GDir *dirp = NULL;
     const gchar *filename;
     GError *tmp_err = NULL;
-    int compatibility_mode = 1;
 
     assert(!err || *err == NULL);
 
@@ -335,7 +335,7 @@ cr_old_metadata_retention(const char *old_repo,
     g_debug("Copying files from old repository to the new one");
 
     // Get list of file that should be skiped during copying
-    if (compatibility_mode)
+    if (compatibility)
         ret = cr_repodata_blacklist_classic(old_repo, retain_old, &blacklist, err);
     else
         ret = cr_repodata_blacklist(old_repo, retain_old, &blacklist, err);
index 62219c2..5647f7f 100644 (file)
@@ -40,6 +40,7 @@ gboolean
 cr_old_metadata_retention(const char *old_repo,
                           const char *new_repo,
                           int retain_old,
+                          int compatibility,
                           GError **err);
 
 /** Remove files related to repodata from the specified path.