mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-14 06:52:39 +03:00
Made the build process incremental, unless --clean is specified
This commit is contained in:
parent
3a01ce9146
commit
f125a9848b
1 changed files with 223 additions and 207 deletions
56
build.py
56
build.py
|
@ -39,26 +39,49 @@ 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("-c", "--clean", action="store_true", default=False,
|
||||||
|
help="Clean mode - build everything from scratch")
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
# Get all apps...
|
# Get all apps...
|
||||||
apps = read_metadata()
|
apps = read_metadata()
|
||||||
|
|
||||||
unsigned_dir = 'unsigned'
|
#Clear and/or create the 'built' directory, depending on mode:
|
||||||
if os.path.exists(unsigned_dir):
|
built_dir = 'built'
|
||||||
shutil.rmtree(unsigned_dir)
|
if options.clean:
|
||||||
os.mkdir(unsigned_dir)
|
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:
|
for app in apps:
|
||||||
|
|
||||||
if (app['disabled'] is None and app['repo'] != ''
|
if (app['disabled'] is None and app['repo'] != ''
|
||||||
and app['repotype'] != '' and (options.package is None or
|
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']
|
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...
|
# Remove the build directory if it already exists...
|
||||||
if os.path.exists(build_dir):
|
if os.path.exists(build_dir):
|
||||||
shutil.rmtree(build_dir)
|
shutil.rmtree(build_dir)
|
||||||
|
@ -81,9 +104,6 @@ for app in apps:
|
||||||
print "Invalid repo type " + app['repotype'] + " in " + app['id']
|
print "Invalid repo type " + app['repotype'] + " in " + app['id']
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
for thisbuild in app['builds']:
|
|
||||||
|
|
||||||
print "Building version " + thisbuild['version']
|
|
||||||
|
|
||||||
# Optionally, the actual app source can be in a subdirectory...
|
# Optionally, the actual app source can be in a subdirectory...
|
||||||
if thisbuild.has_key('subdir'):
|
if thisbuild.has_key('subdir'):
|
||||||
|
@ -158,7 +178,7 @@ for app in apps:
|
||||||
|
|
||||||
#Build the source tarball right before we build the relase...
|
#Build the source tarball right before we build the relase...
|
||||||
tarname = app['id'] + '_' + thisbuild['vercode'] + '_src'
|
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")
|
tarname + '.tar.gz'), "w:gz")
|
||||||
tarball.add(build_dir, tarname)
|
tarball.add(build_dir, tarname)
|
||||||
tarball.close()
|
tarball.close()
|
||||||
|
@ -208,11 +228,9 @@ for app in apps:
|
||||||
print "Unexpected version/version code in output"
|
print "Unexpected version/version code in output"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Copy the unsigned apk to our 'unsigned' directory to be
|
# Copy the unsigned apk to our 'built' directory for further
|
||||||
# dealt with later...
|
# processing...
|
||||||
dest = os.path.join(unsigned_dir, app['id'] + '_' +
|
shutil.copyfile(src, dest_unsigned)
|
||||||
thisbuild['vercode'] + '.apk')
|
|
||||||
shutil.copyfile(src, dest)
|
|
||||||
|
|
||||||
# Figure out the key alias name we'll use. Only the first 8
|
# Figure out the key alias name we'll use. Only the first 8
|
||||||
# characters are significant, so we'll use the first 8 from
|
# characters are significant, so we'll use the first 8 from
|
||||||
|
@ -252,7 +270,7 @@ for app in apps:
|
||||||
# Sign the application...
|
# Sign the application...
|
||||||
p = subprocess.Popen(['jarsigner', '-keystore', keystore,
|
p = subprocess.Popen(['jarsigner', '-keystore', keystore,
|
||||||
'-storepass', keystorepass, '-keypass', keypass,
|
'-storepass', keystorepass, '-keypass', keypass,
|
||||||
dest, keyalias], stdout=subprocess.PIPE)
|
dest_unsigned, keyalias], stdout=subprocess.PIPE)
|
||||||
output = p.communicate()[0]
|
output = p.communicate()[0]
|
||||||
print output
|
print output
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
|
@ -260,16 +278,14 @@ for app in apps:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Zipalign it...
|
# Zipalign it...
|
||||||
tmpfile = dest + ".tmp"
|
|
||||||
os.rename(dest, tmpfile)
|
|
||||||
p = subprocess.Popen(['zipalign', '-v', '4',
|
p = subprocess.Popen(['zipalign', '-v', '4',
|
||||||
tmpfile, dest], stdout=subprocess.PIPE)
|
dest_unsigned, dest], stdout=subprocess.PIPE)
|
||||||
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"
|
print "Failed to align application"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
os.remove(tmpfile)
|
os.remove(dest_unsigned)
|
||||||
|
|
||||||
print "Finished."
|
print "Finished."
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue