mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-14 06:52:39 +03:00
Don't abort on build exceptions.
This commit is contained in:
parent
4ce764c676
commit
dee53ffb72
1 changed files with 358 additions and 370 deletions
76
build.py
76
build.py
|
@ -30,6 +30,8 @@ from xml.dom.minidom import Document
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
import common
|
import common
|
||||||
|
from common import BuildException
|
||||||
|
from common import VCSException
|
||||||
|
|
||||||
#Read configuration...
|
#Read configuration...
|
||||||
execfile('config.py')
|
execfile('config.py')
|
||||||
|
@ -76,7 +78,7 @@ for app in apps:
|
||||||
|
|
||||||
|
|
||||||
for thisbuild in app['builds']:
|
for thisbuild in app['builds']:
|
||||||
|
try:
|
||||||
dest = os.path.join(output_dir, app['id'] + '_' +
|
dest = os.path.join(output_dir, app['id'] + '_' +
|
||||||
thisbuild['vercode'] + '.apk')
|
thisbuild['vercode'] + '.apk')
|
||||||
dest_unsigned = os.path.join(tmp_dir, app['id'] + '_' +
|
dest_unsigned = os.path.join(tmp_dir, app['id'] + '_' +
|
||||||
|
@ -119,8 +121,7 @@ for app in apps:
|
||||||
parms.append('-t')
|
parms.append('-t')
|
||||||
parms.append(thisbuild['target'])
|
parms.append(thisbuild['target'])
|
||||||
if subprocess.call(parms, cwd=root_dir) != 0:
|
if subprocess.call(parms, cwd=root_dir) != 0:
|
||||||
print "Failed to update project"
|
raise BuildException("Failed to update project")
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# If the app has ant set up to sign the release, we need to switch
|
# If the app has ant set up to sign the release, we need to switch
|
||||||
# that off, because we want the unsigned apk...
|
# that off, because we want the unsigned apk...
|
||||||
|
@ -128,8 +129,7 @@ for app in apps:
|
||||||
if os.path.exists(os.path.join(root_dir, propfile)):
|
if os.path.exists(os.path.join(root_dir, propfile)):
|
||||||
if subprocess.call(['sed','-i','s/^key.store/#/',
|
if subprocess.call(['sed','-i','s/^key.store/#/',
|
||||||
propfile], cwd=root_dir) !=0:
|
propfile], cwd=root_dir) !=0:
|
||||||
print "Failed to amend %s" % propfile
|
raise BuildException("Failed to amend %s" % propfile)
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Update the local.properties file...
|
# Update the local.properties file...
|
||||||
locprops = os.path.join(root_dir, 'local.properties')
|
locprops = os.path.join(root_dir, 'local.properties')
|
||||||
|
@ -157,14 +157,12 @@ for app in apps:
|
||||||
if subprocess.call(['sed','-i','s/' + thisbuild['insertversion'] +
|
if subprocess.call(['sed','-i','s/' + thisbuild['insertversion'] +
|
||||||
'/' + thisbuild['version'] +'/g',
|
'/' + thisbuild['version'] +'/g',
|
||||||
'AndroidManifest.xml'], cwd=root_dir) !=0:
|
'AndroidManifest.xml'], cwd=root_dir) !=0:
|
||||||
print "Failed to amend manifest"
|
raise BuildException("Failed to amend manifest")
|
||||||
sys.exit(1)
|
|
||||||
if thisbuild.has_key('insertvercode'):
|
if thisbuild.has_key('insertvercode'):
|
||||||
if subprocess.call(['sed','-i','s/' + thisbuild['insertvercode'] +
|
if subprocess.call(['sed','-i','s/' + thisbuild['insertvercode'] +
|
||||||
'/' + thisbuild['vercode'] +'/g',
|
'/' + thisbuild['vercode'] +'/g',
|
||||||
'AndroidManifest.xml'], cwd=root_dir) !=0:
|
'AndroidManifest.xml'], cwd=root_dir) !=0:
|
||||||
print "Failed to amend manifest"
|
raise BuildException("Failed to amend manifest")
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Delete unwanted file...
|
# Delete unwanted file...
|
||||||
if thisbuild.has_key('rm'):
|
if thisbuild.has_key('rm'):
|
||||||
|
@ -179,8 +177,7 @@ for app in apps:
|
||||||
r"\([^\\]\)'@\1\\'" +
|
r"\([^\\]\)'@\1\\'" +
|
||||||
'@g',
|
'@g',
|
||||||
os.path.join(root, filename)]) != 0:
|
os.path.join(root, filename)]) != 0:
|
||||||
print "Failed to amend " + filename
|
raise BuildException("Failed to amend " + filename)
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Fix translation files if necessary...
|
# Fix translation files if necessary...
|
||||||
if thisbuild.get('fixtrans', 'no') == 'yes':
|
if thisbuild.get('fixtrans', 'no') == 'yes':
|
||||||
|
@ -225,8 +222,7 @@ for app in apps:
|
||||||
if thisbuild.has_key('prebuild'):
|
if thisbuild.has_key('prebuild'):
|
||||||
if subprocess.call(thisbuild['prebuild'],
|
if subprocess.call(thisbuild['prebuild'],
|
||||||
cwd=root_dir, shell=True) != 0:
|
cwd=root_dir, shell=True) != 0:
|
||||||
print "Error running pre-build command"
|
raise BuildException("Error running pre-build command")
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Apply patches if any
|
# Apply patches if any
|
||||||
if 'patch' in thisbuild:
|
if 'patch' in thisbuild:
|
||||||
|
@ -235,8 +231,7 @@ for app in apps:
|
||||||
patch_path = os.path.join('metadata', app['id'], patch)
|
patch_path = os.path.join('metadata', app['id'], patch)
|
||||||
if subprocess.call(['patch', '-p1',
|
if subprocess.call(['patch', '-p1',
|
||||||
'-i', os.path.abspath(patch_path)], cwd=build_dir) != 0:
|
'-i', os.path.abspath(patch_path)], cwd=build_dir) != 0:
|
||||||
print "Failed to apply patch %s" % patch_path
|
raise BuildException("Failed to apply patch %s" % patch_path)
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Special case init functions for funambol...
|
# Special case init functions for funambol...
|
||||||
if thisbuild.get('initfun', 'no') == "yes":
|
if thisbuild.get('initfun', 'no') == "yes":
|
||||||
|
@ -251,8 +246,7 @@ for app in apps:
|
||||||
'</taskdef>' +
|
'</taskdef>' +
|
||||||
'@g',
|
'@g',
|
||||||
'build.xml'], cwd=root_dir) !=0:
|
'build.xml'], cwd=root_dir) !=0:
|
||||||
print "Failed to amend build.xml"
|
raise BuildException("Failed to amend build.xml")
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if subprocess.call(['sed','-i','s@' +
|
if subprocess.call(['sed','-i','s@' +
|
||||||
'\${user.home}/funambol/build/android/build.properties' +
|
'\${user.home}/funambol/build/android/build.properties' +
|
||||||
|
@ -260,8 +254,7 @@ for app in apps:
|
||||||
'build.properties' +
|
'build.properties' +
|
||||||
'@g',
|
'@g',
|
||||||
'build.xml'], cwd=root_dir) !=0:
|
'build.xml'], cwd=root_dir) !=0:
|
||||||
print "Failed to amend build.xml"
|
raise BuildException("Failed to amend build.xml")
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
buildxml = os.path.join(root_dir, 'build.xml')
|
buildxml = os.path.join(root_dir, 'build.xml')
|
||||||
f = open(buildxml, 'r')
|
f = open(buildxml, 'r')
|
||||||
|
@ -290,8 +283,7 @@ for app in apps:
|
||||||
'platforms/android-8' +
|
'platforms/android-8' +
|
||||||
'@g',
|
'@g',
|
||||||
'build.xml'], cwd=root_dir) !=0:
|
'build.xml'], cwd=root_dir) !=0:
|
||||||
print "Failed to amend build.xml"
|
raise BuildException("Failed to amend build.xml")
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
shutil.copyfile(
|
shutil.copyfile(
|
||||||
os.path.join(root_dir, "build.properties.example"),
|
os.path.join(root_dir, "build.properties.example"),
|
||||||
|
@ -303,8 +295,7 @@ for app in apps:
|
||||||
'javacchome=' + javacc_path +
|
'javacchome=' + javacc_path +
|
||||||
'@g',
|
'@g',
|
||||||
'build.properties'], cwd=root_dir) !=0:
|
'build.properties'], cwd=root_dir) !=0:
|
||||||
print "Failed to amend build.properties"
|
raise BuildException("Failed to amend build.properties")
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if subprocess.call(['sed','-i','s@' +
|
if subprocess.call(['sed','-i','s@' +
|
||||||
'sdk-folder=.*'+
|
'sdk-folder=.*'+
|
||||||
|
@ -312,8 +303,7 @@ for app in apps:
|
||||||
'sdk-folder=' + sdk_path +
|
'sdk-folder=' + sdk_path +
|
||||||
'@g',
|
'@g',
|
||||||
'build.properties'], cwd=root_dir) !=0:
|
'build.properties'], cwd=root_dir) !=0:
|
||||||
print "Failed to amend build.properties"
|
raise BuildException("Failed to amend build.properties")
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if subprocess.call(['sed','-i','s@' +
|
if subprocess.call(['sed','-i','s@' +
|
||||||
'android.sdk.version.*'+
|
'android.sdk.version.*'+
|
||||||
|
@ -321,8 +311,7 @@ for app in apps:
|
||||||
'android.sdk.version=2.0' +
|
'android.sdk.version=2.0' +
|
||||||
'@g',
|
'@g',
|
||||||
'build.properties'], cwd=root_dir) !=0:
|
'build.properties'], cwd=root_dir) !=0:
|
||||||
print "Failed to amend build.properties"
|
raise BuildException("Failed to amend build.properties")
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
# Build the source tarball right before we build the release...
|
# Build the source tarball right before we build the release...
|
||||||
|
@ -340,8 +329,7 @@ for app in apps:
|
||||||
output = p.communicate()[0]
|
output = p.communicate()[0]
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
print output
|
print output
|
||||||
print "NDK build failed for %s:%s" % (app['id'], thisbuild['version'])
|
raise BuildException("NDK build failed for %s:%s" % (app['id'], thisbuild['version']))
|
||||||
sys.exit(1)
|
|
||||||
elif options.verbose:
|
elif options.verbose:
|
||||||
print output
|
print output
|
||||||
|
|
||||||
|
@ -360,8 +348,7 @@ for app in apps:
|
||||||
output = p.communicate()[0]
|
output = p.communicate()[0]
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
print output
|
print output
|
||||||
print "Build failed for %s:%s" % (app['id'], thisbuild['version'])
|
raise BuildException("Build failed for %s:%s" % (app['id'], thisbuild['version']))
|
||||||
sys.exit(1)
|
|
||||||
elif options.verbose:
|
elif options.verbose:
|
||||||
print output
|
print output
|
||||||
print "Build successful"
|
print "Build successful"
|
||||||
|
@ -407,8 +394,7 @@ for app in apps:
|
||||||
pat = re.compile(".*versionName='([^']*)'.*")
|
pat = re.compile(".*versionName='([^']*)'.*")
|
||||||
version = re.match(pat, line).group(1)
|
version = re.match(pat, line).group(1)
|
||||||
if version == None or vercode == None:
|
if version == None or vercode == None:
|
||||||
print "Could not find version information in build in output"
|
raise BuildException("Could not find version information in build in output")
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Some apps (e.g. Timeriffic) have had the bonkers idea of
|
# Some apps (e.g. Timeriffic) have had the bonkers idea of
|
||||||
# including the entire changelog in the version number. Remove
|
# including the entire changelog in the version number. Remove
|
||||||
|
@ -420,11 +406,10 @@ for app in apps:
|
||||||
|
|
||||||
if (version != thisbuild['version'] or
|
if (version != thisbuild['version'] or
|
||||||
vercode != thisbuild['vercode']):
|
vercode != thisbuild['vercode']):
|
||||||
print "Unexpected version/version code in output"
|
raise BuildException(("Unexpected version/version code in output"
|
||||||
print "APK:" + version + " / " + str(vercode)
|
"APK: %s / %s"
|
||||||
print ("Expected: " + thisbuild['version'] + " / " +
|
"Expected: %s / %s")
|
||||||
str(thisbuild['vercode']))
|
) % (version, str(vercode), thisbuild['version'], str(thisbuild['vercode']))
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Copy the unsigned apk to our temp directory for further
|
# Copy the unsigned apk to our temp directory for further
|
||||||
# processing...
|
# processing...
|
||||||
|
@ -462,8 +447,7 @@ for app in apps:
|
||||||
output = p.communicate()[0]
|
output = p.communicate()[0]
|
||||||
print output
|
print output
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
print "Failed to generate key"
|
raise BuildException("Failed to generate key")
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Sign the application...
|
# Sign the application...
|
||||||
p = subprocess.Popen(['jarsigner', '-keystore', keystore,
|
p = subprocess.Popen(['jarsigner', '-keystore', keystore,
|
||||||
|
@ -472,8 +456,7 @@ for app in apps:
|
||||||
output = p.communicate()[0]
|
output = p.communicate()[0]
|
||||||
print output
|
print output
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
print "Failed to sign application"
|
raise BuildException("Failed to sign application")
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Zipalign it...
|
# Zipalign it...
|
||||||
p = subprocess.Popen([os.path.join(sdk_path,'tools','zipalign'),
|
p = subprocess.Popen([os.path.join(sdk_path,'tools','zipalign'),
|
||||||
|
@ -482,9 +465,14 @@ for app in apps:
|
||||||
output = p.communicate()[0]
|
output = p.communicate()[0]
|
||||||
print output
|
print output
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
print "Failed to align application"
|
raise BuildException("Failed to align application")
|
||||||
sys.exit(1)
|
|
||||||
os.remove(dest_unsigned)
|
os.remove(dest_unsigned)
|
||||||
|
except BuildException as be:
|
||||||
|
print "Could not build app %s due to BuildException: %s" % (app['id'], be)
|
||||||
|
except VCSException as vcse:
|
||||||
|
print "VCS error while building app %s: %s" % (app['id'], vcse)
|
||||||
|
except Exception as e:
|
||||||
|
print "Could not build app %s due to unknown error: %s" % (app['id'], e)
|
||||||
|
|
||||||
print "Finished."
|
print "Finished."
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue