1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-04 02:00:11 +02:00

Lots of build system improvements and fixes

This commit is contained in:
Ciaran Gultnieks 2012-09-08 09:56:20 +01:00
parent fdc6331eeb
commit 09e296d2de
6 changed files with 66 additions and 57 deletions

View File

@ -44,7 +44,7 @@ end
end end
%w{addon-google_apis-google-7 addon-google_apis-google-16}.each do |sdk| %w{addon-google_apis-google-7 addon-google_apis-google-15 addon-google_apis-google-16}.each do |sdk|
script "add_addon_#{sdk}" do script "add_addon_#{sdk}" do
interpreter "bash" interpreter "bash"

View File

@ -33,7 +33,7 @@ from common import BuildException
from common import VCSException from common import VCSException
def build_server(app, thisbuild, build_dir, output_dir): def build_server(app, thisbuild, vcs, build_dir, output_dir, sdk_path):
"""Do a build on the build server.""" """Do a build on the build server."""
import ssh import ssh
@ -152,7 +152,10 @@ def build_server(app, thisbuild, build_dir, output_dir):
ftp.chdir('metadata') ftp.chdir('metadata')
ftp.put(os.path.join('metadata', app['id'] + '.txt'), ftp.put(os.path.join('metadata', app['id'] + '.txt'),
app['id'] + '.txt') app['id'] + '.txt')
ftp.chdir('..') # And patches if there are any...
if os.path.exists(os.path.join('metadata', app['id'])):
send_dir(os.path.join('metadata', app['id']))
ftp.chdir('/home/vagrant')
# Create the build directory... # Create the build directory...
ftp.mkdir('build') ftp.mkdir('build')
ftp.chdir('build') ftp.chdir('build')
@ -162,8 +165,7 @@ def build_server(app, thisbuild, build_dir, output_dir):
send_dir(build_dir) send_dir(build_dir)
# Copy any extlibs that are required... # Copy any extlibs that are required...
if thisbuild.has_key('extlibs'): if thisbuild.has_key('extlibs'):
ftp.chdir('build') ftp.chdir('/home/vagrant/build/extlib')
ftp.chdir('extlib')
for lib in thisbuild['extlibs'].split(';'): for lib in thisbuild['extlibs'].split(';'):
lp = lib.split('/') lp = lib.split('/')
for d in lp[:-1]: for d in lp[:-1]:
@ -172,22 +174,20 @@ def build_server(app, thisbuild, build_dir, output_dir):
ftp.put(os.path.join('build/extlib', lib), lp[-1]) ftp.put(os.path.join('build/extlib', lib), lp[-1])
for _ in lp[:-1]: for _ in lp[:-1]:
ftp.chdir('..') ftp.chdir('..')
ftp.chdir('..')
ftp.chdir('..')
# Copy any srclibs that are required... # Copy any srclibs that are required...
srclibpaths = []
if thisbuild.has_key('srclibs'): if thisbuild.has_key('srclibs'):
ftp.chdir('build')
ftp.chdir('extlib')
for lib in thisbuild['srclibs'].split(';'): for lib in thisbuild['srclibs'].split(';'):
lp = lib.split('@').split('/') name, _ = lib.split('@')
for d in lp[:-1]: srclibpaths.append((name, common.getsrclib(lib, 'build/extlib', sdk_path)))
ftp.mkdir(d) # If one was used for the main source, add that too.
ftp.chdir(d) basesrclib = vcs.getsrclib()
ftp.put(os.path.join('build/extlib', lib), lp[-1]) if basesrclib:
for _ in lp[:-1]: srclibpaths.append(basesrclib)
ftp.chdir('..') print "Sending srclibs:"
ftp.chdir('..') for _, lib in srclibpaths:
ftp.chdir('..') ftp.chdir('/home/vagrant/build/extlib')
send_dir(lib)
# Execute the build script... # Execute the build script...
print "Starting build..." print "Starting build..."
@ -409,7 +409,7 @@ def trybuild(app, thisbuild, build_dir, output_dir, extlib_dir, tmp_dir,
# grabbing the source now. # grabbing the source now.
vcs.gotorevision(thisbuild['commit']) vcs.gotorevision(thisbuild['commit'])
build_server(app, thisbuild, build_dir, output_dir) build_server(app, thisbuild, vcs, build_dir, output_dir, sdk_path)
else: else:
build_local(app, thisbuild, vcs, build_dir, output_dir, extlib_dir, tmp_dir, install, force, verbose) build_local(app, thisbuild, vcs, build_dir, output_dir, extlib_dir, tmp_dir, install, force, verbose)
return True return True
@ -534,7 +534,7 @@ def main():
build_dir = 'build/' + app['id'] build_dir = 'build/' + app['id']
# Set up vcs interface and make sure we have the latest code... # Set up vcs interface and make sure we have the latest code...
vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir) vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir, sdk_path)
for thisbuild in app['builds']: for thisbuild in app['builds']:
try: try:

View File

@ -38,7 +38,7 @@ from common import VCSException
# caution, because it's inappropriate for many projects. # caution, because it's inappropriate for many projects.
# Returns (None, "a message") if this didn't work, or (version, vercode) for # Returns (None, "a message") if this didn't work, or (version, vercode) for
# the details of the current version. # the details of the current version.
def check_tags(app): def check_tags(app, sdk_path):
try: try:
@ -48,7 +48,7 @@ def check_tags(app):
return (None, 'Tags update mode only works for git repositories currently') return (None, 'Tags update mode only works for git repositories currently')
# Set up vcs interface and make sure we have the latest code... # Set up vcs interface and make sure we have the latest code...
vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir) vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir, sdk_path)
vcs.gotorevision('origin/master') vcs.gotorevision('origin/master')
if len(app['builds']) == 0: if len(app['builds']) == 0:
@ -91,7 +91,7 @@ def check_tags(app):
# caution, because it's inappropriate for many projects. # caution, because it's inappropriate for many projects.
# Returns (None, "a message") if this didn't work, or (version, vercode) for # Returns (None, "a message") if this didn't work, or (version, vercode) for
# the details of the current version. # the details of the current version.
def check_repomanifest(app): def check_repomanifest(app, sdk_path):
try: try:
@ -101,7 +101,7 @@ def check_repomanifest(app):
return (None, 'RepoManifest update mode only works for git repositories currently') return (None, 'RepoManifest update mode only works for git repositories currently')
# Set up vcs interface and make sure we have the latest code... # Set up vcs interface and make sure we have the latest code...
vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir) vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir, sdk_path)
vcs.gotorevision('origin/master') vcs.gotorevision('origin/master')
if len(app['builds']) == 0: if len(app['builds']) == 0:
@ -201,9 +201,9 @@ def main():
if mode == 'Market': if mode == 'Market':
(version, vercode) = check_market(app) (version, vercode) = check_market(app)
elif mode == 'Tags': elif mode == 'Tags':
(version, vercode) = check_tags(app) (version, vercode) = check_tags(app, sdk_path)
elif mode == 'RepoManifest': elif mode == 'RepoManifest':
(version, vercode) = check_repomanifest(app) (version, vercode) = check_repomanifest(app, sdk_path)
elif mode == 'None': elif mode == 'None':
version = None version = None
vercode = 'Checking disabled' vercode = 'Checking disabled'

View File

@ -22,23 +22,25 @@ import subprocess
import time import time
import operator import operator
def getvcs(vcstype, remote, local): def getvcs(vcstype, remote, local, sdk_path):
if vcstype == 'git': if vcstype == 'git':
return vcs_git(remote, local) return vcs_git(remote, local, sdk_path)
elif vcstype == 'svn': elif vcstype == 'svn':
return vcs_svn(remote, local) return vcs_svn(remote, local, sdk_path)
elif vcstype == 'git-svn': elif vcstype == 'git-svn':
return vcs_gitsvn(remote, local) return vcs_gitsvn(remote, local, sdk_path)
elif vcstype == 'hg': elif vcstype == 'hg':
return vcs_hg(remote, local) return vcs_hg(remote, local, sdk_path)
elif vcstype == 'bzr': elif vcstype == 'bzr':
return vcs_bzr(remote, local) return vcs_bzr(remote, local, sdk_path)
elif vcstype == 'srclib': elif vcstype == 'srclib':
return vcs_srclib(remote, local) return vcs_srclib(remote, local, sdk_path)
raise VCSException("Invalid vcs type " + vcstype) raise VCSException("Invalid vcs type " + vcstype)
class vcs: class vcs:
def __init__(self, remote, local): def __init__(self, remote, local, sdk_path):
self.sdk_path = sdk_path
# It's possible to sneak a username and password in with # It's possible to sneak a username and password in with
# the remote address... (this really only applies to svn # the remote address... (this really only applies to svn
@ -329,7 +331,7 @@ class vcs_srclib(vcs):
else: else:
srclib = self.remote srclib = self.remote
path = None path = None
libdir = getsrclib(srclib + '@' + rev, extlib_dir) libdir = getsrclib(srclib + '@' + rev, extlib_dir, self.sdk_path)
self.srclib = (srclib, libdir) self.srclib = (srclib, libdir)
if path: if path:
libdir = os.path.join(libdir, path) libdir = os.path.join(libdir, path)
@ -685,23 +687,24 @@ class MetaDataException(Exception):
# Returns the path to it. # Returns the path to it.
# TODO: These are currently just hard-coded in this method. It will be a # TODO: These are currently just hard-coded in this method. It will be a
# metadata-driven system eventually, but not yet. # metadata-driven system eventually, but not yet.
def getsrclib(spec, extlib_dir): def getsrclib(spec, extlib_dir, sdk_path):
name, ref = spec.split('@') name, ref = spec.split('@')
if name == 'GreenDroid': if name == 'GreenDroid':
sdir = os.path.join(extlib_dir, 'GreenDroid') sdir = os.path.join(extlib_dir, 'GreenDroid')
vcs = getvcs('git', vcs = getvcs('git',
'https://github.com/cyrilmottier/GreenDroid.git', sdir) 'https://github.com/cyrilmottier/GreenDroid.git', sdir, sdk_path)
vcs.gotorevision(ref) vcs.gotorevision(ref)
return os.path.join(sdir, 'GreenDroid') return os.path.join(sdir, 'GreenDroid')
if name == 'ActionBarSherlock': if name == 'ActionBarSherlock':
sdir = os.path.join(extlib_dir, 'ActionBarSherlock') sdir = os.path.join(extlib_dir, 'ActionBarSherlock')
vcs = getvcs('git', vcs = getvcs('git',
'https://github.com/JakeWharton/ActionBarSherlock.git', sdir) 'https://github.com/JakeWharton/ActionBarSherlock.git', sdir, sdk_path)
vcs.gotorevision(ref) vcs.gotorevision(ref)
libdir = os.path.join(sdir, 'library') libdir = os.path.join(sdir, 'library')
if subprocess.call(['android', 'update', 'project', '-p', if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
'update', 'project', '-p',
libdir]) != 0: libdir]) != 0:
raise BuildException('Error updating ActionBarSherlock project') raise BuildException('Error updating ActionBarSherlock project')
return libdir return libdir
@ -709,9 +712,10 @@ def getsrclib(spec, extlib_dir):
if name == 'ViewPagerIndicator': if name == 'ViewPagerIndicator':
sdir = os.path.join(extlib_dir, 'ViewPagerIndicator') sdir = os.path.join(extlib_dir, 'ViewPagerIndicator')
vcs = getvcs('git', vcs = getvcs('git',
'https://github.com/mariotaku/viewpagerindicator.git', sdir) 'https://github.com/mariotaku/viewpagerindicator.git', sdir, sdk_path)
vcs.gotorevision(ref) vcs.gotorevision(ref)
if subprocess.call(['android', 'update', 'project', '-p', if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
'update', 'project', '-p',
sdir]) != 0: sdir]) != 0:
raise BuildException('Error updating ViewPagerIndicator project') raise BuildException('Error updating ViewPagerIndicator project')
return sdir return sdir
@ -719,10 +723,11 @@ def getsrclib(spec, extlib_dir):
if name == 'UITableView': if name == 'UITableView':
sdir = os.path.join(extlib_dir, 'UITableView') sdir = os.path.join(extlib_dir, 'UITableView')
vcs = getvcs('git', vcs = getvcs('git',
'https://github.com/thiagolocatelli/android-uitableview.git', sdir) 'https://github.com/thiagolocatelli/android-uitableview.git', sdir, sdk_path)
vcs.gotorevision(ref) vcs.gotorevision(ref)
libdir = os.path.join(sdir, 'android-uitableview') libdir = os.path.join(sdir, 'android-uitableview')
if subprocess.call(['android', 'update', 'project', '-p', if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
'update', 'project', '-p',
libdir]) != 0: libdir]) != 0:
raise BuildException('Error updating UITableView project') raise BuildException('Error updating UITableView project')
return libdir return libdir
@ -730,13 +735,14 @@ def getsrclib(spec, extlib_dir):
if name == 'ViewPagerTabs': if name == 'ViewPagerTabs':
sdir = os.path.join(extlib_dir, 'ViewPagerTabs') sdir = os.path.join(extlib_dir, 'ViewPagerTabs')
vcs = getvcs('git', vcs = getvcs('git',
'https://github.com/astuetz/android-viewpagertabs.git', sdir) 'https://github.com/astuetz/android-viewpagertabs.git', sdir, sdk_path)
vcs.gotorevision(ref) vcs.gotorevision(ref)
pp = open(os.path.join(sdir, 'project.properties'), 'w') pp = open(os.path.join(sdir, 'project.properties'), 'w')
pp.write('android.library=true\n') pp.write('android.library=true\n')
pp.write('target=android-15\n') pp.write('target=android-15\n')
pp.close() pp.close()
if subprocess.call(['android', 'update', 'project', '-p', if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
'update', 'project', '-p',
sdir]) != 0: sdir]) != 0:
raise BuildException('Error updating ViewPagerTabs project') raise BuildException('Error updating ViewPagerTabs project')
return sdir return sdir
@ -744,10 +750,11 @@ def getsrclib(spec, extlib_dir):
if name == 'ActionBar': if name == 'ActionBar':
sdir = os.path.join(extlib_dir, 'ActionBar') sdir = os.path.join(extlib_dir, 'ActionBar')
vcs = getvcs('git', vcs = getvcs('git',
'https://github.com/johannilsson/android-actionbar.git', sdir) 'https://github.com/johannilsson/android-actionbar.git', sdir, sdk_path)
vcs.gotorevision(ref) vcs.gotorevision(ref)
libdir = os.path.join(sdir, 'actionbar') libdir = os.path.join(sdir, 'actionbar')
if subprocess.call(['android', 'update', 'project', '-p', if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
'update', 'project', '-p',
libdir]) != 0: libdir]) != 0:
raise BuildException('Error updating ActionBar project') raise BuildException('Error updating ActionBar project')
return libdir return libdir
@ -755,10 +762,11 @@ def getsrclib(spec, extlib_dir):
if name == 'ActionBarNW': if name == 'ActionBarNW':
sdir = os.path.join(extlib_dir, 'ActionBarNW') sdir = os.path.join(extlib_dir, 'ActionBarNW')
vcs = getvcs('git', vcs = getvcs('git',
'https://github.com/NightWhistler/android-actionbar.git', sdir) 'https://github.com/NightWhistler/android-actionbar.git', sdir, sdk_path)
vcs.gotorevision(ref) vcs.gotorevision(ref)
libdir = os.path.join(sdir, 'actionbar') libdir = os.path.join(sdir, 'actionbar')
if subprocess.call(['android', 'update', 'project', '-p', if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
'update', 'project', '-p',
libdir]) != 0: libdir]) != 0:
raise BuildException('Error updating ActionBarNW project') raise BuildException('Error updating ActionBarNW project')
return libdir return libdir
@ -766,10 +774,11 @@ def getsrclib(spec, extlib_dir):
if name == 'FacebookSDK': if name == 'FacebookSDK':
sdir = os.path.join(extlib_dir, 'FacebookSDK') sdir = os.path.join(extlib_dir, 'FacebookSDK')
vcs = getvcs('git', vcs = getvcs('git',
'git://github.com/facebook/facebook-android-sdk.git', sdir) 'git://github.com/facebook/facebook-android-sdk.git', sdir, sdk_path)
vcs.gotorevision(ref) vcs.gotorevision(ref)
libdir = os.path.join(sdir, 'facebook') libdir = os.path.join(sdir, 'facebook')
if subprocess.call(['android', 'update', 'project', '-p', if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
'update', 'project', '-p',
libdir]) != 0: libdir]) != 0:
raise BuildException('Error updating FacebookSDK project') raise BuildException('Error updating FacebookSDK project')
return libdir return libdir
@ -777,14 +786,14 @@ def getsrclib(spec, extlib_dir):
if name == 'OI': if name == 'OI':
sdir = os.path.join(extlib_dir, 'OI') sdir = os.path.join(extlib_dir, 'OI')
vcs = getvcs('git-svn', vcs = getvcs('git-svn',
'http://openintents.googlecode.com/svn/trunk/', sdir) 'http://openintents.googlecode.com/svn/trunk/', sdir, sdk_path)
vcs.gotorevision(ref) vcs.gotorevision(ref)
return sdir return sdir
if name == 'JOpenDocument': if name == 'JOpenDocument':
sdir = os.path.join(extlib_dir, 'JOpenDocument') sdir = os.path.join(extlib_dir, 'JOpenDocument')
vcs = getvcs('git', vcs = getvcs('git',
'https://github.com/andiwand/JOpenDocument.git', sdir) 'https://github.com/andiwand/JOpenDocument.git', sdir, sdk_path)
vcs.gotorevision(ref) vcs.gotorevision(ref)
shutil.rmtree(os.path.join(sdir, 'bin')) shutil.rmtree(os.path.join(sdir, 'bin'))
return sdir return sdir
@ -792,7 +801,7 @@ def getsrclib(spec, extlib_dir):
if name == 'BitcoinJWallet': if name == 'BitcoinJWallet':
sdir = os.path.join(extlib_dir, 'BitcoinJWallet') sdir = os.path.join(extlib_dir, 'BitcoinJWallet')
vcs = getvcs('git', vcs = getvcs('git',
'https://code.google.com/r/andreasschildbach-bitcoinj/', sdir) 'https://code.google.com/r/andreasschildbach-bitcoinj/', sdir, sdk_path)
vcs.gotorevision(ref) vcs.gotorevision(ref)
if subprocess.call(['mvn3', 'install'], cwd=sdir) != 0: if subprocess.call(['mvn3', 'install'], cwd=sdir) != 0:
raise BuildException("Maven build failed for BitcoinJWallet srclib") raise BuildException("Maven build failed for BitcoinJWallet srclib")
@ -990,7 +999,7 @@ def prepare_source(vcs, app, build, build_dir, extlib_dir, sdk_path, ndk_path, j
if build.has_key('srclibs'): if build.has_key('srclibs'):
for lib in build['srclibs'].split(';'): for lib in build['srclibs'].split(';'):
name, _ = lib.split('@') name, _ = lib.split('@')
srclibpaths.append((name, getsrclib(lib, extlib_dir))) srclibpaths.append((name, getsrclib(lib, extlib_dir, sdk_path)))
basesrclib = vcs.getsrclib() basesrclib = vcs.getsrclib()
# If one was used for the main source, add that too. # If one was used for the main source, add that too.
if basesrclib: if basesrclib:

View File

@ -212,7 +212,7 @@ def main():
src_dir = os.path.join(tmp_dir, 'importer') src_dir = os.path.join(tmp_dir, 'importer')
if os.path.exists(src_dir): if os.path.exists(src_dir):
shutil.rmtree(src_dir) shutil.rmtree(src_dir)
vcs = common.getvcs(repotype, repo, src_dir) vcs = common.getvcs(repotype, repo, src_dir, sdk_path)
vcs.gotorevision(None) vcs.gotorevision(None)
if options.subdir: if options.subdir:
root_dir = os.path.join(src_dir, options.subdir) root_dir = os.path.join(src_dir, options.subdir)

View File

@ -84,7 +84,7 @@ def main():
build_dir = 'build/' + app['id'] build_dir = 'build/' + app['id']
# Set up vcs interface and make sure we have the latest code... # Set up vcs interface and make sure we have the latest code...
vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir) vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir, sdk_path)
for thisbuild in app['builds']: for thisbuild in app['builds']: