1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-05 18:50:09 +02:00

Made the build process incremental, unless --clean is specified

This commit is contained in:
Ciaran Gultnieks 2011-01-04 23:58:44 +00:00
parent 3a01ce9146
commit f125a9848b

View File

@ -39,26 +39,49 @@ parser.add_option("-v", "--verbose", action="store_true", default=False,
help="Spew out even more information than normal")
parser.add_option("-p", "--package", default=None,
help="Build only the specified package")
parser.add_option("-c", "--clean", action="store_true", default=False,
help="Clean mode - build everything from scratch")
(options, args) = parser.parse_args()
# Get all apps...
apps = read_metadata()
unsigned_dir = 'unsigned'
if os.path.exists(unsigned_dir):
shutil.rmtree(unsigned_dir)
os.mkdir(unsigned_dir)
#Clear and/or create the 'built' directory, depending on mode:
built_dir = 'built'
if options.clean:
if os.path.exists(built_dir):
shutil.rmtree(built_dir)
if not os.path.exists(built_dir):
os.mkdir(built_dir)
for app in apps:
if (app['disabled'] is None and app['repo'] != ''
and app['repotype'] != '' and (options.package is None or
options.package == app['id'])):
options.package == app['id']) and len(app['builds']) > 0):
print "About to build " + app['id']
print "Processing " + app['id']
build_dir = 'build_' + app['id']
got_source = False
for thisbuild in app['builds']:
dest = os.path.join(built_dir, app['id'] + '_' +
thisbuild['vercode'] + '.apk')
dest_unsigned = dest + "_unsigned"
if os.path.exists(dest):
print "Version " + thisbuild['version'] + " already exists"
else:
print "Building version " + thisbuild['version']
if not got_source:
got_source = True
# Remove the build directory if it already exists...
if os.path.exists(build_dir):
shutil.rmtree(build_dir)
@ -81,9 +104,6 @@ for app in apps:
print "Invalid repo type " + app['repotype'] + " in " + app['id']
sys.exit(1)
for thisbuild in app['builds']:
print "Building version " + thisbuild['version']
# Optionally, the actual app source can be in a subdirectory...
if thisbuild.has_key('subdir'):
@ -158,7 +178,7 @@ for app in apps:
#Build the source tarball right before we build the relase...
tarname = app['id'] + '_' + thisbuild['vercode'] + '_src'
tarball = tarfile.open(os.path.join(unsigned_dir,
tarball = tarfile.open(os.path.join(built_dir,
tarname + '.tar.gz'), "w:gz")
tarball.add(build_dir, tarname)
tarball.close()
@ -208,11 +228,9 @@ for app in apps:
print "Unexpected version/version code in output"
sys.exit(1)
# Copy the unsigned apk to our 'unsigned' directory to be
# dealt with later...
dest = os.path.join(unsigned_dir, app['id'] + '_' +
thisbuild['vercode'] + '.apk')
shutil.copyfile(src, dest)
# Copy the unsigned apk to our 'built' directory for further
# processing...
shutil.copyfile(src, dest_unsigned)
# Figure out the key alias name we'll use. Only the first 8
# characters are significant, so we'll use the first 8 from
@ -252,7 +270,7 @@ for app in apps:
# Sign the application...
p = subprocess.Popen(['jarsigner', '-keystore', keystore,
'-storepass', keystorepass, '-keypass', keypass,
dest, keyalias], stdout=subprocess.PIPE)
dest_unsigned, keyalias], stdout=subprocess.PIPE)
output = p.communicate()[0]
print output
if p.returncode != 0:
@ -260,16 +278,14 @@ for app in apps:
sys.exit(1)
# Zipalign it...
tmpfile = dest + ".tmp"
os.rename(dest, tmpfile)
p = subprocess.Popen(['zipalign', '-v', '4',
tmpfile, dest], stdout=subprocess.PIPE)
dest_unsigned, dest], stdout=subprocess.PIPE)
output = p.communicate()[0]
print output
if p.returncode != 0:
print "Failed to align application"
sys.exit(1)
os.remove(tmpfile)
os.remove(dest_unsigned)
print "Finished."