[Rpm-metadata] modifyrepo.py

zpavlas at osuosl.org zpavlas at osuosl.org
Thu Apr 11 08:52:31 UTC 2013


 modifyrepo.py |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 0f65ec014b9c56a751c2729c3c559a52e24b1dea
Author: Zdenek Pavlas <zpavlas at redhat.com>
Date:   Thu Apr 11 10:35:45 2013 +0200

    modifyrepo: fix --compress option bug. BZ 950724
    
    We were compressing files added to the repository even when
    the --compress option was not specified.  It's even documented
    in modifyrepo man page examples.
    
    Fix the bug that caused this, and change the default to True
    to minimize possible breakage.  Also add --no-compress option
    to turn it off.

diff --git a/modifyrepo.py b/modifyrepo.py
index b6129b7..e7c34c0 100755
--- a/modifyrepo.py
+++ b/modifyrepo.py
@@ -44,7 +44,6 @@ class RepoMetadata:
         """ Parses the repomd.xml file existing in the given repo directory. """
         self.repodir = os.path.abspath(repo)
         self.repomdxml = os.path.join(self.repodir, 'repomd.xml')
-        self.compress = False
         self.compress_type = _available_compression[-1] # best available
 
         if not os.path.exists(self.repomdxml):
@@ -113,7 +112,7 @@ class RepoMetadata:
 
         do_compress = False
         ## Compress the metadata and move it into the repodata
-        if self.compress or not mdname.split('.')[-1] in ('gz', 'bz2', 'xz'):
+        if self.compress and mdname.split('.')[-1] not in ('gz', 'bz2', 'xz'):
             do_compress = True
             mdname += '.' + self.compress_type
         mdtype = self._get_mdtype(mdname, mdtype)
@@ -177,8 +176,10 @@ def main(args):
                       help="specific datatype of the metadata, will be derived from the filename if not specified")
     parser.add_option("--remove", action="store_true",
                       help="remove specified file from repodata")
-    parser.add_option("--compress", action="store_true", default=False,
-                      help="compress the new repodata before adding it to the repo")
+    parser.add_option("--compress", action="store_true", default=True,
+                      help="compress the new repodata before adding it to the repo (default)")
+    parser.add_option("--no-compress", action="store_false", dest="compress",
+                      help="do not compress the new repodata before adding it to the repo")
     parser.add_option("--compress-type", dest='compress_type', default='gz',
                       help="compression format to use")
     parser.add_option("-s", "--checksum", default='sha256', dest='sumtype',


More information about the Rpm-metadata mailing list