[Rpm-metadata] repo metadata written in deterministic order

Florian La Roche laroche at redhat.com
Mon Oct 3 10:31:12 UTC 2005


The following patch for createrepo-0.4.3 makes the creation of
the xml content more deterministic. The last patches also remove
a few newlines, otherwise no data change at all.

greetings,

Florian La Roche



--- createrepo-0.4.1/dumpMetadata.py.lr	2005-10-03 09:25:21.917352873 +0200
+++ createrepo-0.4.1/dumpMetadata.py	2005-10-03 09:25:33.789511255 +0200
@@ -326,7 +326,9 @@
         except TypeError:
             del u  # move on to the next method
         else:
-            return u.keys()
+            ret = u.keys()
+            ret.sort()
+            return ret
     
         # We can't hash all the elements.  Second fastest is to sort,
         # which brings the equal elements together; then duplicates are
@@ -421,7 +423,7 @@
             for glob in self.filerc:
                 if glob.match(item):
                     returns[item] = 1
-        return returns
+        return returns.keys()
                     
     def usefulGhosts(self):
         """search for useful ghost file names"""
@@ -432,7 +434,7 @@
             for glob in self.filerc:
                 if glob.match(item):
                     returns[item] = 1
-        return returns
+        return returns.keys()
 
 
     def usefulDirs(self):
@@ -590,16 +592,22 @@
             if prereq == 1:
                 entry.newProp('pre', str(prereq))
         
-    for file in rpmObj.usefulFiles():
+    ff = rpmObj.usefulFiles()
+    ff.sort()
+    for file in ff:
         files = format.newChild(None, 'file', None)
         file = utf8String(file)
         files.addContent(file)
-    for directory in rpmObj.usefulDirs():
+    ff = rpmObj.usefulDirs()
+    ff.sort()
+    for directory in ff:
         files = format.newChild(None, 'file', None)
         directory = utf8String(directory)
         files.addContent(directory)
         files.newProp('type', 'dir')
-    for directory in rpmObj.usefulGhosts():
+    ff = rpmObj.usefulGhosts()
+    ff.sort()
+    for directory in ff:
         files = format.newChild(None, 'file', None)
         directory = utf8String(directory)
         files.addContent(directory)
--- createrepo-0.4.1/genpkgmetadata.py.lr	2005-10-03 09:25:28.464337299 +0200
+++ createrepo-0.4.1/genpkgmetadata.py	2005-10-03 09:25:37.454942670 +0200
@@ -238,6 +238,7 @@
     files = []
     files = getFileList('./', '.rpm', files)
     files = trimRpms(files, cmds['excludes'])
+    files.sort()
     pkgcount = len(files)
     
     # setup the base metadata doc
@@ -338,19 +339,19 @@
     # save them up to the tmp locations:
     if not cmds['quiet']:
         print _('Saving Primary metadata')
-    basefile.write('\n</metadata>')
+    basefile.write('</metadata>\n')
     basefile.close()
     basedoc.freeDoc()
     
     if not cmds['quiet']:
         print _('Saving file lists metadata')
-    flfile.write('\n</filelists>')
+    flfile.write('</filelists>\n')
     flfile.close()
     filesdoc.freeDoc()
     
     if not cmds['quiet']:
         print _('Saving other metadata')
-    otherfile.write('\n</otherdata>')
+    otherfile.write('</otherdata>\n')
     otherfile.close()
     otherdoc.freeDoc()
 



More information about the Rpm-metadata mailing list