mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-14 15:02:51 +03:00
- Make use of enhanced BuildExceptions
- Add logfiles - Add --stop mode to break on exceptions
This commit is contained in:
parent
4cd621f939
commit
200073b0f9
1 changed files with 23 additions and 6 deletions
29
build.py
29
build.py
|
@ -36,13 +36,14 @@ from common import VCSException
|
||||||
#Read configuration...
|
#Read configuration...
|
||||||
execfile('config.py')
|
execfile('config.py')
|
||||||
|
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||||
help="Spew out even more information than normal")
|
help="Spew out even more information than normal")
|
||||||
parser.add_option("-p", "--package", default=None,
|
parser.add_option("-p", "--package", default=None,
|
||||||
help="Build only the specified package")
|
help="Build only the specified package")
|
||||||
|
parser.add_option("-s", "--stop", action="store_true", default=False,
|
||||||
|
help="Make the build stop on exceptions")
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
# Get all apps...
|
# Get all apps...
|
||||||
|
@ -51,6 +52,11 @@ apps = common.read_metadata(options.verbose)
|
||||||
failed_apps = {}
|
failed_apps = {}
|
||||||
build_succeeded = []
|
build_succeeded = []
|
||||||
|
|
||||||
|
log_dir = 'logs'
|
||||||
|
if not os.path.isdir(log_dir):
|
||||||
|
print "Creating log directory"
|
||||||
|
os.makedirs(log_dir)
|
||||||
|
|
||||||
output_dir = 'repo'
|
output_dir = 'repo'
|
||||||
if not os.path.isdir(output_dir):
|
if not os.path.isdir(output_dir):
|
||||||
print "Creating output directory"
|
print "Creating output directory"
|
||||||
|
@ -135,17 +141,17 @@ for app in apps:
|
||||||
if thisbuild.has_key('maven'):
|
if thisbuild.has_key('maven'):
|
||||||
p = subprocess.Popen(['mvn', 'clean', 'install',
|
p = subprocess.Popen(['mvn', 'clean', 'install',
|
||||||
'-Dandroid.sdk.path=' + sdk_path],
|
'-Dandroid.sdk.path=' + sdk_path],
|
||||||
cwd=root_dir, stdout=subprocess.PIPE)
|
cwd=root_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
else:
|
else:
|
||||||
if thisbuild.has_key('antcommand'):
|
if thisbuild.has_key('antcommand'):
|
||||||
antcommand = thisbuild['antcommand']
|
antcommand = thisbuild['antcommand']
|
||||||
else:
|
else:
|
||||||
antcommand = 'release'
|
antcommand = 'release'
|
||||||
p = subprocess.Popen(['ant', antcommand], cwd=root_dir,
|
p = subprocess.Popen(['ant', antcommand], cwd=root_dir,
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
output = p.communicate()[0]
|
output, error = p.communicate()
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
raise BuildException("Build failed for %s:%s (%s)" % (app['id'], thisbuild['version'], output.strip()))
|
raise BuildException("Build failed for %s:%s" % (app['id'], thisbuild['version']), output.strip(), error.strip())
|
||||||
elif options.verbose:
|
elif options.verbose:
|
||||||
print output
|
print output
|
||||||
print "Build successful"
|
print "Build successful"
|
||||||
|
@ -267,12 +273,21 @@ for app in apps:
|
||||||
os.remove(dest_unsigned)
|
os.remove(dest_unsigned)
|
||||||
build_succeeded.append(app)
|
build_succeeded.append(app)
|
||||||
except BuildException as be:
|
except BuildException as be:
|
||||||
|
if options.stop:
|
||||||
|
raise
|
||||||
print "Could not build app %s due to BuildException: %s" % (app['id'], be)
|
print "Could not build app %s due to BuildException: %s" % (app['id'], be)
|
||||||
|
logfile = open(os.path.join(log_dir, app['id'] + '.log'), 'a+')
|
||||||
|
logfile.write(str(be))
|
||||||
|
logfile.close
|
||||||
failed_apps[app['id']] = be
|
failed_apps[app['id']] = be
|
||||||
except VCSException as vcse:
|
except VCSException as vcse:
|
||||||
|
if options.stop:
|
||||||
|
raise
|
||||||
print "VCS error while building app %s: %s" % (app['id'], vcse)
|
print "VCS error while building app %s: %s" % (app['id'], vcse)
|
||||||
failed_apps[app['id']] = vcse
|
failed_apps[app['id']] = vcse
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if options.stop:
|
||||||
|
raise
|
||||||
print "Could not build app %s due to unknown error: %s" % (app['id'], e)
|
print "Could not build app %s due to unknown error: %s" % (app['id'], e)
|
||||||
failed_apps[app['id']] = e
|
failed_apps[app['id']] = e
|
||||||
|
|
||||||
|
@ -280,9 +295,11 @@ for app in build_succeeded:
|
||||||
print "success: %s" % (app['id'])
|
print "success: %s" % (app['id'])
|
||||||
|
|
||||||
for fa in failed_apps:
|
for fa in failed_apps:
|
||||||
print "Build for app %s failed: %s" % (fa, failed_apps[fa])
|
print "Build for app %s failed:\n%s" % (fa, failed_apps[fa])
|
||||||
|
|
||||||
print "Finished."
|
print "Finished."
|
||||||
|
if len(build_succeeded) > 0:
|
||||||
|
print str(len(failed_apps)) + ' builds succeeded'
|
||||||
if len(failed_apps) > 0:
|
if len(failed_apps) > 0:
|
||||||
print str(len(failed_apps)) + ' builds failed'
|
print str(len(failed_apps)) + ' builds failed'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue