make sure indexes are sorted to minimize diffs between copies

With the binary transparency log stored in git, it makes that more readable
and as small as possible if the index files are fully sorted.  That will
reduce the differences between two copies of an index file to a bare
minimum.

If in the future we implement some kind of binary diff transfer, this will
also help there.
This commit is contained in:
Hans-Christoph Steiner 2017-04-03 11:29:21 +02:00
parent 7d4176dd50
commit 5ad3486741
2 changed files with 8 additions and 8 deletions

View File

@ -139,7 +139,7 @@ def make(apps, sortedids, apks, repodir, archive):
appsWithPackages[packageName] = newapp
break
requestsdict = dict()
requestsdict = collections.OrderedDict()
for command in ('install', 'uninstall'):
packageNames = []
key = command + '_list'
@ -199,7 +199,7 @@ def make_v1(apps, packages, repodir, repodict, requestsdict):
k = k[:1].lower() + k[1:]
d[k] = v
output_packages = dict()
output_packages = collections.OrderedDict()
output['packages'] = output_packages
for package in packages:
packageName = package['packageName']
@ -414,7 +414,7 @@ def make_v0(apps, apks, repodir, repodict, requestsdict):
if perm_name.startswith("android.permission."):
perm_name = perm_name[19:]
old_permissions.add(perm_name)
addElementNonEmpty('permissions', ','.join(old_permissions), doc, apkel)
addElementNonEmpty('permissions', ','.join(sorted(old_permissions)), doc, apkel)
for permission in sorted_permissions:
permel = doc.createElement('uses-permission')

View File

@ -690,7 +690,7 @@ def scan_repo_files(apkcache, repodir, knownapks, use_date_from_file=False):
if not usecache:
logging.debug("Processing " + name)
repo_file = {}
repo_file = collections.OrderedDict()
# TODO rename apkname globally to something more generic
repo_file['name'] = name
repo_file['apkName'] = name
@ -775,9 +775,9 @@ def scan_apk(apkcache, apkfilename, repodir, knownapks, use_date_from_apk):
if os.path.exists(os.path.join(repodir, srcfilename)):
apk['srcname'] = srcfilename
apk['size'] = os.path.getsize(apkfile)
apk['uses-permission'] = set()
apk['uses-permission-sdk-23'] = set()
apk['features'] = set()
apk['uses-permission'] = []
apk['uses-permission-sdk-23'] = []
apk['features'] = []
apk['icons_src'] = {}
apk['icons'] = {}
apk['antiFeatures'] = set()
@ -1065,7 +1065,7 @@ def scan_apks(apkcache, repodir, knownapks, use_date_from_apk=False):
os.makedirs(icon_dir)
apks = []
for apkfile in glob.glob(os.path.join(repodir, '*.apk')):
for apkfile in sorted(glob.glob(os.path.join(repodir, '*.apk'))):
apkfilename = apkfile[len(repodir) + 1:]
(skip, apk, cachechanged) = scan_apk(apkcache, apkfilename, repodir, knownapks, use_date_from_apk)
if skip: