File createrepo-0.9.9-modifyrepo.patch of Package createrepo
--- modifyrepo.py
+++ modifyrepo.py
@@ -23,6 +23,7 @@
import os
import sys
+import re
#add ability to load createrepo module from subfolder
cmd_folder = os.path.dirname(os.path.abspath(__file__))
@@ -44,7 +45,6 @@
""" 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.checksum_type = 'sha'
if not os.path.exists(self.repomdxml):
raise MDError, '%s not found' % self.repomdxml
@@ -94,8 +94,11 @@
print "Wrote:", destmd
open_csum = checksum(self.checksum_type, metadata)
- #csum, destmd = checksum_and_rename(destmd, self.checksum_type)
- csum = checksum(self.checksum_type, destmd)
+ if self.unique_md_filenames:
+ csum, destmd = checksum_and_rename(destmd, self.checksum_type)
+ else:
+ csum = checksum(self.checksum_type, destmd)
+
base_destmd = os.path.basename(destmd)
@@ -131,6 +134,14 @@
# query options
parser.add_option("--mdtype", dest='mdtype',
help="specific datatype of the metadata, will be derived from the filename if not specified")
+ parser.add_option("-s", "--checksum", dest='sumtype',
+ help="specify the checksum type to use")
+ parser.add_option("--unique-md-filenames", dest="unique_md_filenames",
+ help="include the file's checksum in the filename, helps with proxies",
+ action="store_true")
+ parser.add_option("--simple-md-filenames", dest="simple_md_filenames",
+ help="do not include the file's checksum in the filename",
+ action="store_true")
parser.usage = "modifyrepo [options] <input_metadata> <output repodata>"
(opts, argsleft) = parser.parse_args(args)
@@ -144,6 +155,26 @@
except MDError, e:
print "Could not access repository: %s" % str(e)
return 1
+
+ try:
+ primarymd = repomd.repoobj.getData('primary')
+ if primarymd and primarymd.checksum and not opts.sumtype:
+ opts.sumtype = primarymd.checksum[0]
+ if primarymd and primarymd.location and primarymd.location[1] and \
+ not opts.simple_md_filenames and not opts.unique_md_filenames:
+ if not re.match(r'[0-9a-f]{32,}-', os.path.basename(primarymd.location[1])):
+ opts.simple_md_filenames = True
+ except Exception, e:
+ pass
+
+ if not opts.sumtype:
+ opts.sumtype = 'sha256'
+ if not opts.simple_md_filenames:
+ opts.unique_md_filenames = True
+
+ repomd.checksum_type = opts.sumtype
+ repomd.unique_md_filenames = opts.unique_md_filenames
+
try:
repomd.add(metadata, mdtype=opts.mdtype)
except MDError, e: