1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-14 11:00:10 +01:00

Fix gradle patching in a more generic way

This commit is contained in:
Daniel Martí 2014-02-28 10:54:14 +01:00
parent 9d59184d94
commit d7ca28bbbe

View File

@ -1406,8 +1406,6 @@ def FDroidPopen(commands, cwd=None, shell=False):
def remove_signing_keys(build_dir): def remove_signing_keys(build_dir):
comment = re.compile(r'[ ]*//') comment = re.compile(r'[ ]*//')
signing_configs = re.compile(r'^[\t ]*signingConfigs[ \t]*{[ \t]*$') signing_configs = re.compile(r'^[\t ]*signingConfigs[ \t]*{[ \t]*$')
r_open = re.compile(r'.*{[\t ]*$')
r_close = re.compile(r'.*}[\t ]*$')
line_matches = [ line_matches = [
re.compile(r'^[\t ]*signingConfig [^ ]*$'), re.compile(r'^[\t ]*signingConfig [^ ]*$'),
re.compile(r'android.signingConfigs.'), re.compile(r'android.signingConfigs.'),
@ -1417,7 +1415,6 @@ def remove_signing_keys(build_dir):
for root, dirs, files in os.walk(build_dir): for root, dirs, files in os.walk(build_dir):
if 'build.gradle' in files: if 'build.gradle' in files:
path = os.path.join(root, 'build.gradle') path = os.path.join(root, 'build.gradle')
changed = False
with open(path, "r") as o: with open(path, "r") as o:
lines = o.readlines() lines = o.readlines()
@ -1426,39 +1423,37 @@ def remove_signing_keys(build_dir):
with open(path, "w") as o: with open(path, "w") as o:
for line in lines: for line in lines:
if comment.match(line): if comment.match(line):
pass continue
elif signing_configs.match(line):
opened = 1 if opened > 0:
changed = True opened += line.count('{')
elif opened > 0: opened -= line.count('}')
if r_open.match(line): continue
if signing_configs.match(line):
opened += 1 opened += 1
elif r_close.match(line): continue
opened -= 1
elif any(s.match(line) for s in line_matches): if any(s.match(line) for s in line_matches):
changed = True continue
else:
if opened == 0:
o.write(line) o.write(line)
if changed:
logging.info("Cleaned build.gradle of keysigning configs at %s" % path) logging.info("Cleaned build.gradle of keysigning configs at %s" % path)
for propfile in ('build.properties', 'default.properties', 'ant.properties'): for propfile in ('build.properties', 'default.properties', 'ant.properties'):
if propfile in files: if propfile in files:
path = os.path.join(root, propfile) path = os.path.join(root, propfile)
changed = False
with open(path, "r") as o: with open(path, "r") as o:
lines = o.readlines() lines = o.readlines()
with open(path, "w") as o: with open(path, "w") as o:
for line in lines: for line in lines:
if line.startswith('key.store'): if not line.startswith('key.store'):
changed = True
else:
o.write(line) o.write(line)
if changed:
logging.info("Cleaned %s of keysigning configs at %s" % (propfile,path)) logging.info("Cleaned %s of keysigning configs at %s" % (propfile,path))
def replace_config_vars(cmd): def replace_config_vars(cmd):