gitlab-ci: check if Application ID will cause keyalias collision

fdroid/fdroidserver#553
This commit is contained in:
Hans-Christoph Steiner 2018-08-29 14:42:57 +02:00
parent 46b9edd1ac
commit 8dade6ece0
2 changed files with 31 additions and 0 deletions

View file

@ -37,4 +37,5 @@ lint:
- echo "these images have EXIF that must be stripped:" - echo "these images have EXIF that must be stripped:"
- git --no-pager diff --stat - git --no-pager diff --stat
- git --no-pager diff --name-only --exit-code || export EXITVALUE=1 - git --no-pager diff --name-only --exit-code || export EXITVALUE=1
- ./tools/check-keyalias-collision.py || export EXITVALUE=1
- exit $EXITVALUE - exit $EXITVALUE

View file

@ -0,0 +1,30 @@
#!/usr/bin/env python3
import glob
import hashlib
import inspect
import os
import sys
def generate_keyalias(s):
m = hashlib.md5()
m.update(s.encode())
return m.hexdigest()[:8]
base = os.path.realpath(
os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
metadatafiles = sorted(glob.glob(base + '/metadata/*.txt')
+ glob.glob(base + '/metadata/*.yml'))
if not metadatafiles:
print('No metadata files found!')
sys.exit(1)
keyaliases = dict()
for f in metadatafiles:
appid = os.path.basename(f)[:-4]
keyalias = generate_keyalias(appid)
if keyalias in keyaliases:
print(appid, "keyalias conflicts with", keyaliases[keyalias])
sys.exit(1)
keyaliases[keyalias] = appid