chiark / gitweb /
sort repo index data to make index.xml generation reproducible
authorHans-Christoph Steiner <hans@eds.org>
Tue, 29 Nov 2016 14:55:07 +0000 (15:55 +0100)
committerHans-Christoph Steiner <hans@eds.org>
Fri, 24 Feb 2017 10:01:01 +0000 (11:01 +0100)
This makes it easy to test that the code is still generating the exact same
index.xml.  It also might help the ZIP compression work better in index.jar

fdroidserver/update.py

index 60904f55c16d334dc43c464eb756f1ca0fa989c8..b47398c4e6915fd1afde7c2d6b01852a77fe055c 100644 (file)
@@ -1028,7 +1028,7 @@ def make_index(apps, sortedids, apks, repodir, archive):
 
     mirrorcheckfailed = False
     mirrors = []
-    for mirror in config.get('mirrors', []):
+    for mirror in sorted(config.get('mirrors', [])):
         base = os.path.basename(urllib.parse.urlparse(mirror).path.rstrip('/'))
         if config.get('nonstandardwebroot') is not True and base != 'fdroid':
             logging.error("mirror '" + mirror + "' does not end with 'fdroid'!")
@@ -1237,28 +1237,29 @@ def make_index(apps, sortedids, apks, repodir, archive):
                 addElement('sig', apk['sig'], doc, apkel)
 
                 old_permissions = set()
-                for perm in apk['uses-permission']:
+                sorted_permissions = sorted(apk['uses-permission'])
+                for perm in sorted_permissions:
                     perm_name = perm.name
                     if perm_name.startswith("android.permission."):
                         perm_name = perm_name[19:]
                     old_permissions.add(perm_name)
                 addElementNonEmpty('permissions', ','.join(old_permissions), doc, apkel)
 
-                for permission in apk['uses-permission']:
+                for permission in sorted_permissions:
                     permel = doc.createElement('uses-permission')
                     permel.setAttribute('name', permission.name)
                     if permission.maxSdkVersion is not None:
                         permel.setAttribute('maxSdkVersion', permission.maxSdkVersion)
                         apkel.appendChild(permel)
-                for permission_sdk_23 in apk['uses-permission-sdk-23']:
+                for permission_sdk_23 in sorted(apk['uses-permission-sdk-23']):
                     permel = doc.createElement('uses-permission-sdk-23')
                     permel.setAttribute('name', permission_sdk_23.name)
                     if permission_sdk_23.maxSdkVersion is not None:
                         permel.setAttribute('maxSdkVersion', permission_sdk_23.maxSdkVersion)
                         apkel.appendChild(permel)
                 if 'nativecode' in apk:
-                    addElement('nativecode', ','.join(apk['nativecode']), doc, apkel)
-                addElementNonEmpty('features', ','.join(apk['features']), doc, apkel)
+                    addElement('nativecode', ','.join(sorted(apk['nativecode'])), doc, apkel)
+                addElementNonEmpty('features', ','.join(sorted(apk['features'])), doc, apkel)
 
         if current_version_file is not None \
                 and config['make_current_version_link'] \
@@ -1331,7 +1332,7 @@ def make_index(apps, sortedids, apks, repodir, archive):
 def make_categories_txt(repodir, categories):
     '''Write a category list in the repo to allow quick access'''
     catdata = ''
-    for cat in categories:
+    for cat in sorted(categories):
         catdata += cat + '\n'
     with open(os.path.join(repodir, 'categories.txt'), 'w', encoding='utf8') as f:
         f.write(catdata)