File createrepo-0.9.9-sort-packages-before-writing-repodata.patch of Package createrepo
diff -ru a/createrepo/__init__.py b/createrepo/__init__.py
--- a/createrepo/__init__.py 2011-01-26 18:14:30.000000000 +0100
+++ b/createrepo/__init__.py 2012-01-25 16:05:55.627594528 +0100
@@ -24,6 +24,7 @@
from urlgrabber import grabber
import tempfile
import stat
+import re
import fcntl
import subprocess
@@ -504,6 +505,30 @@
" add it" % po
return po
+
+ def sortPackages(self, pkglist):
+ class PackageKey:
+ def __init__(self, package):
+ m = re.search(r"([^/]+)-([^/-]+-[^/-]+)\.([^/.]+)\.rpm$",
+ package)
+ if m:
+ self.n = m.group(1)
+ self.vr = m.group(2)
+ self.a = m.group(3)
+ else:
+ # give up on sorting
+ self.n = package
+ self.vr = 0
+ self.a = 0
+ def __lt__(self, other):
+ if self.n != other.n:
+ return self.n < other.n
+ if self.a != other.a:
+ return self.a < other.a
+ return self.vr < other.vr
+
+ return sorted(pkglist, key=PackageKey)
+
def writeMetadataDocs(self, pkglist=[], pkgpath=None):
@@ -515,6 +540,8 @@
else:
directory = pkgpath
+ pkglist = self.sortPackages(pkglist)
+
# for worker/forked model
# iterate the pkglist - see which ones are handled by --update and let them
# go on their merry way
Only in b/createrepo: .__init__.py.swp