mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-16 16:02:33 +03:00
Revert "Revert "Don't allow values other than 'yes' or 'no' on boolean fields, integrity fixes""
Yo dawg
This commit is contained in:
parent
080536467b
commit
47f31b72c0
2 changed files with 38 additions and 55 deletions
|
@ -347,22 +347,22 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
||||||
# We need to clean via the build tool in case the binary dirs are
|
# We need to clean via the build tool in case the binary dirs are
|
||||||
# different from the default ones
|
# different from the default ones
|
||||||
p = None
|
p = None
|
||||||
if 'maven' in thisbuild:
|
if thisbuild.get('maven', 'no') != 'no':
|
||||||
print "Cleaning Maven project..."
|
print "Cleaning Maven project..."
|
||||||
cmd = [config['mvn3'], 'clean', '-Dandroid.sdk.path=' + config['sdk_path']]
|
cmd = [config['mvn3'], 'clean', '-Dandroid.sdk.path=' + config['sdk_path']]
|
||||||
|
|
||||||
if '@' in thisbuild['maven']:
|
if '@' in thisbuild['maven']:
|
||||||
maven_dir = os.path.join(root_dir, thisbuild['maven'].split('@')[1])
|
maven_dir = os.path.join(root_dir, thisbuild['maven'].split('@',1)[1])
|
||||||
else:
|
else:
|
||||||
maven_dir = root_dir
|
maven_dir = root_dir
|
||||||
|
|
||||||
p = FDroidPopen(cmd, cwd=maven_dir)
|
p = FDroidPopen(cmd, cwd=maven_dir)
|
||||||
elif 'gradle' in thisbuild:
|
elif thisbuild.get('gradle', 'no') != 'no':
|
||||||
print "Cleaning Gradle project..."
|
print "Cleaning Gradle project..."
|
||||||
cmd = [config['gradle'], 'clean']
|
cmd = [config['gradle'], 'clean']
|
||||||
|
|
||||||
if '@' in thisbuild['gradle']:
|
if '@' in thisbuild['gradle']:
|
||||||
gradle_dir = os.path.join(root_dir, thisbuild['gradle'].split('@')[1])
|
gradle_dir = os.path.join(root_dir, thisbuild['gradle'].split('@',1)[1])
|
||||||
else:
|
else:
|
||||||
gradle_dir = root_dir
|
gradle_dir = root_dir
|
||||||
|
|
||||||
|
@ -454,11 +454,11 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
||||||
|
|
||||||
p = None
|
p = None
|
||||||
# Build the release...
|
# Build the release...
|
||||||
if 'maven' in thisbuild:
|
if thisbuild.get('maven', 'no') != 'no':
|
||||||
print "Building Maven project..."
|
print "Building Maven project..."
|
||||||
|
|
||||||
if '@' in thisbuild['maven']:
|
if '@' in thisbuild['maven']:
|
||||||
maven_dir = os.path.join(root_dir, thisbuild['maven'].split('@')[1])
|
maven_dir = os.path.join(root_dir, thisbuild['maven'].split('@',1)[1])
|
||||||
else:
|
else:
|
||||||
maven_dir = root_dir
|
maven_dir = root_dir
|
||||||
|
|
||||||
|
@ -482,7 +482,9 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
||||||
|
|
||||||
p = FDroidPopen(mvncmd, cwd=maven_dir)
|
p = FDroidPopen(mvncmd, cwd=maven_dir)
|
||||||
|
|
||||||
elif 'gradle' in thisbuild:
|
bindir = os.path.join(root_dir, 'target')
|
||||||
|
|
||||||
|
elif thisbuild.get('gradle', 'no') != 'no':
|
||||||
print "Building Gradle project..."
|
print "Building Gradle project..."
|
||||||
if '@' in thisbuild['gradle']:
|
if '@' in thisbuild['gradle']:
|
||||||
flavour = thisbuild['gradle'].split('@')[0]
|
flavour = thisbuild['gradle'].split('@')[0]
|
||||||
|
@ -534,6 +536,8 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
||||||
cmd += ['release']
|
cmd += ['release']
|
||||||
p = FDroidPopen(cmd, cwd=root_dir)
|
p = FDroidPopen(cmd, cwd=root_dir)
|
||||||
|
|
||||||
|
bindir = os.path.join(root_dir, 'bin')
|
||||||
|
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
raise BuildException("Build failed for %s:%s" % (app['id'], thisbuild['version']), p.stdout, p.stderr)
|
raise BuildException("Build failed for %s:%s" % (app['id'], thisbuild['version']), p.stdout, p.stderr)
|
||||||
print "Successfully built version " + thisbuild['version'] + ' of ' + app['id']
|
print "Successfully built version " + thisbuild['version'] + ' of ' + app['id']
|
||||||
|
@ -544,11 +548,8 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
||||||
# Find the apk name in the output...
|
# Find the apk name in the output...
|
||||||
if 'bindir' in thisbuild:
|
if 'bindir' in thisbuild:
|
||||||
bindir = os.path.join(build_dir, thisbuild['bindir'])
|
bindir = os.path.join(build_dir, thisbuild['bindir'])
|
||||||
elif 'maven' in thisbuild:
|
|
||||||
bindir = os.path.join(root_dir, 'target')
|
if thisbuild.get('maven', 'no') != 'no':
|
||||||
else:
|
|
||||||
bindir = os.path.join(root_dir, 'bin')
|
|
||||||
if 'maven' in thisbuild:
|
|
||||||
stdout_apk = '\n'.join([
|
stdout_apk = '\n'.join([
|
||||||
line for line in p.stdout.splitlines() if any(a in line for a in ('.apk','.ap_'))])
|
line for line in p.stdout.splitlines() if any(a in line for a in ('.apk','.ap_'))])
|
||||||
m = re.match(r".*^\[INFO\] .*apkbuilder.*/([^/]*)\.apk",
|
m = re.match(r".*^\[INFO\] .*apkbuilder.*/([^/]*)\.apk",
|
||||||
|
@ -563,7 +564,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
||||||
raise BuildException('Failed to find output')
|
raise BuildException('Failed to find output')
|
||||||
src = m.group(1)
|
src = m.group(1)
|
||||||
src = os.path.join(bindir, src) + '.apk'
|
src = os.path.join(bindir, src) + '.apk'
|
||||||
elif 'gradle' in thisbuild:
|
elif thisbuild.get('gradle', 'no') != 'no':
|
||||||
dd = build_dir
|
dd = build_dir
|
||||||
if 'subdir' in thisbuild:
|
if 'subdir' in thisbuild:
|
||||||
dd = os.path.join(dd, thisbuild['subdir'])
|
dd = os.path.join(dd, thisbuild['subdir'])
|
||||||
|
@ -606,7 +607,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
||||||
vercode = re.match(pat, line).group(1)
|
vercode = re.match(pat, line).group(1)
|
||||||
pat = re.compile(".*versionName='([^']*)'.*")
|
pat = re.compile(".*versionName='([^']*)'.*")
|
||||||
version = re.match(pat, line).group(1)
|
version = re.match(pat, line).group(1)
|
||||||
if thisbuild.get('novcheck', 'no') == "yes":
|
if thisbuild['novcheck']:
|
||||||
vercode = thisbuild['vercode']
|
vercode = thisbuild['vercode']
|
||||||
version = thisbuild['version']
|
version = thisbuild['version']
|
||||||
if not version or not vercode:
|
if not version or not vercode:
|
||||||
|
|
|
@ -523,6 +523,7 @@ def parse_metadata(metafile):
|
||||||
for p in parts[3:]:
|
for p in parts[3:]:
|
||||||
pk, pv = p.split('=', 1)
|
pk, pv = p.split('=', 1)
|
||||||
thisbuild[pk.strip()] = pv
|
thisbuild[pk.strip()] = pv
|
||||||
|
|
||||||
return thisbuild
|
return thisbuild
|
||||||
|
|
||||||
def add_comments(key):
|
def add_comments(key):
|
||||||
|
@ -532,6 +533,7 @@ def parse_metadata(metafile):
|
||||||
thisinfo['comments'].append((key, comment))
|
thisinfo['comments'].append((key, comment))
|
||||||
del curcomments[:]
|
del curcomments[:]
|
||||||
|
|
||||||
|
|
||||||
thisinfo = {}
|
thisinfo = {}
|
||||||
if metafile:
|
if metafile:
|
||||||
if not isinstance(metafile, file):
|
if not isinstance(metafile, file):
|
||||||
|
@ -684,6 +686,20 @@ def parse_metadata(metafile):
|
||||||
mode = 0
|
mode = 0
|
||||||
add_comments(None)
|
add_comments(None)
|
||||||
|
|
||||||
|
# These can only contain 'yes' or 'no'
|
||||||
|
for key in ('submodules', 'oldsdkloc', 'forceversion', 'forcevercode', 'fixtrans', 'fixapos', 'novcheck'):
|
||||||
|
for build in thisinfo['builds']:
|
||||||
|
if key not in build:
|
||||||
|
build[key] = False
|
||||||
|
continue
|
||||||
|
if build[key] == 'yes':
|
||||||
|
build[key] = True
|
||||||
|
elif build[key] == 'no':
|
||||||
|
build[key] = False
|
||||||
|
else:
|
||||||
|
raise MetaDataException("Invalid value %s assigned to boolean build flag %s"
|
||||||
|
% (build[key], key))
|
||||||
|
|
||||||
# Mode at end of file should always be 0...
|
# Mode at end of file should always be 0...
|
||||||
if mode == 1:
|
if mode == 1:
|
||||||
raise MetaDataException(field + " not terminated in " + metafile.name)
|
raise MetaDataException(field + " not terminated in " + metafile.name)
|
||||||
|
@ -1359,7 +1375,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
|
||||||
raise BuildException('Missing subdir ' + root_dir)
|
raise BuildException('Missing subdir ' + root_dir)
|
||||||
|
|
||||||
# Initialise submodules if requred...
|
# Initialise submodules if requred...
|
||||||
if build.get('submodules', 'no') == 'yes':
|
if build['submodules']:
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print "Initialising submodules..."
|
print "Initialising submodules..."
|
||||||
vcs.initsubmodules()
|
vcs.initsubmodules()
|
||||||
|
@ -1449,7 +1465,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
|
||||||
props += '\n'
|
props += '\n'
|
||||||
# Fix old-fashioned 'sdk-location' by copying
|
# Fix old-fashioned 'sdk-location' by copying
|
||||||
# from sdk.dir, if necessary...
|
# from sdk.dir, if necessary...
|
||||||
if build.get('oldsdkloc', 'no') == "yes":
|
if build['oldsdkloc']:
|
||||||
sdkloc = re.match(r".*^sdk.dir=(\S+)$.*", props,
|
sdkloc = re.match(r".*^sdk.dir=(\S+)$.*", props,
|
||||||
re.S|re.M).group(1)
|
re.S|re.M).group(1)
|
||||||
props += "sdk-location=%s\n" % sdkloc
|
props += "sdk-location=%s\n" % sdkloc
|
||||||
|
@ -1467,7 +1483,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
flavour = None
|
flavour = None
|
||||||
if 'gradle' in build:
|
if build.get('gradle', 'no') != 'no':
|
||||||
flavour = build['gradle'].split('@')[0]
|
flavour = build['gradle'].split('@')[0]
|
||||||
if flavour in ['main', 'yes', '']:
|
if flavour in ['main', 'yes', '']:
|
||||||
flavour = None
|
flavour = None
|
||||||
|
@ -1482,7 +1498,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
|
||||||
raise BuildException("Failed to remove debuggable flags")
|
raise BuildException("Failed to remove debuggable flags")
|
||||||
|
|
||||||
# Insert version code and number into the manifest if necessary...
|
# Insert version code and number into the manifest if necessary...
|
||||||
if 'forceversion' in build:
|
if build['forceversion']:
|
||||||
print "Changing the version name..."
|
print "Changing the version name..."
|
||||||
for path in manifest_paths(root_dir, flavour):
|
for path in manifest_paths(root_dir, flavour):
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
|
@ -1497,7 +1513,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
|
||||||
's/versionName[ ]*=[ ]*"[^"]*"/versionName = "' + build['version'] + '"/g',
|
's/versionName[ ]*=[ ]*"[^"]*"/versionName = "' + build['version'] + '"/g',
|
||||||
path]) != 0:
|
path]) != 0:
|
||||||
raise BuildException("Failed to amend build.gradle")
|
raise BuildException("Failed to amend build.gradle")
|
||||||
if 'forcevercode' in build:
|
if build['forcevercode']:
|
||||||
print "Changing the version code..."
|
print "Changing the version code..."
|
||||||
for path in manifest_paths(root_dir, flavour):
|
for path in manifest_paths(root_dir, flavour):
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
|
@ -1524,7 +1540,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
|
||||||
subprocess.call('rm -rf ' + dest, shell=True)
|
subprocess.call('rm -rf ' + dest, shell=True)
|
||||||
|
|
||||||
# Fix apostrophes translation files if necessary...
|
# Fix apostrophes translation files if necessary...
|
||||||
if build.get('fixapos', 'no') == 'yes':
|
if build['fixapos']:
|
||||||
for root, dirs, files in os.walk(os.path.join(root_dir, 'res')):
|
for root, dirs, files in os.walk(os.path.join(root_dir, 'res')):
|
||||||
for filename in files:
|
for filename in files:
|
||||||
if filename.endswith('.xml'):
|
if filename.endswith('.xml'):
|
||||||
|
@ -1535,7 +1551,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
|
||||||
raise BuildException("Failed to amend " + filename)
|
raise BuildException("Failed to amend " + filename)
|
||||||
|
|
||||||
# Fix translation files if necessary...
|
# Fix translation files if necessary...
|
||||||
if build.get('fixtrans', 'no') == 'yes':
|
if build['fixtrans']:
|
||||||
for root, dirs, files in os.walk(os.path.join(root_dir, 'res')):
|
for root, dirs, files in os.walk(os.path.join(root_dir, 'res')):
|
||||||
for filename in files:
|
for filename in files:
|
||||||
if filename.endswith('.xml'):
|
if filename.endswith('.xml'):
|
||||||
|
@ -1624,40 +1640,6 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
raise BuildException("Error running prebuild command for %s:%s" %
|
raise BuildException("Error running prebuild command for %s:%s" %
|
||||||
(app['id'], build['version']), p.stdout, p.stderr)
|
(app['id'], build['version']), p.stdout, p.stderr)
|
||||||
print "Applying generic clean-ups..."
|
|
||||||
|
|
||||||
if build.get('anal-tics', 'no') == 'yes':
|
|
||||||
fp = os.path.join(root_dir, 'src', 'com', 'google', 'android', 'apps', 'analytics')
|
|
||||||
os.makedirs(fp)
|
|
||||||
with open(os.path.join(fp, 'GoogleAnalyticsTracker.java'), 'w') as f:
|
|
||||||
f.write("""
|
|
||||||
package com.google.android.apps.analytics;
|
|
||||||
public class GoogleAnalyticsTracker {
|
|
||||||
private static GoogleAnalyticsTracker instance;
|
|
||||||
private GoogleAnalyticsTracker() {
|
|
||||||
}
|
|
||||||
public static GoogleAnalyticsTracker getInstance() {
|
|
||||||
if(instance == null)
|
|
||||||
instance = new GoogleAnalyticsTracker();
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
public void start(String i,int think ,Object not) {
|
|
||||||
}
|
|
||||||
public void dispatch() {
|
|
||||||
}
|
|
||||||
public void stop() {
|
|
||||||
}
|
|
||||||
public void setProductVersion(String uh, String hu) {
|
|
||||||
}
|
|
||||||
public void trackEvent(String that,String just,String aint,int happening) {
|
|
||||||
}
|
|
||||||
public void trackPageView(String nope) {
|
|
||||||
}
|
|
||||||
public void setCustomVar(int mind,String your,String own,int business) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
""")
|
|
||||||
|
|
||||||
|
|
||||||
return (root_dir, srclibpaths)
|
return (root_dir, srclibpaths)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue