import sys
import os
-import shutil
import re
import urllib2
import time
try:
- build_dir = 'build/' + app['id']
+ if app['Repo Type'] == 'srclib':
+ build_dir = os.path.join('build', 'srclib')
+ repotype = common.getsrclibvcs(app['Repo'])
+ else:
+ build_dir = os.path.join('build/', app['id'])
+ repotype = app['Repo Type']
- if app['Repo Type'] not in ('git', 'git-svn'):
+ if repotype not in ('git', 'git-svn'):
return (None, 'Tags update mode only works for git and git-svn repositories currently')
# Set up vcs interface and make sure we have the latest code...
vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir, sdk_path)
- if app['Repo Type'] == 'git':
- vcs.gotorevision(None)
- elif app['Repo Type'] == 'git-svn':
- vcs.gotorevision(None)
+
+ if app['Repo Type'] == 'srclib':
+ build_dir = os.path.join(build_dir, app['Repo'])
+
+ vcs.gotorevision(None)
if len(app['builds']) == 0:
return (None, "Can't use Tags with no builds defined")
- app_dir = build_dir
if 'subdir' in app['builds'][-1]:
- app_dir = os.path.join(app_dir, app['builds'][-1]['subdir'])
+ build_dir = os.path.join(build_dir, app['builds'][-1]['subdir'])
hver = None
hcode = "0"
vcs.gotorevision(tag)
# Only process tags where the manifest exists...
- if os.path.exists(app_dir + '/AndroidManifest.xml'):
- version, vercode, package = common.parse_androidmanifest(app_dir)
+ if os.path.exists(build_dir + '/AndroidManifest.xml'):
+ version, vercode, package = common.parse_androidmanifest(build_dir)
if package and package == app['id'] and version and vercode:
if int(vercode) > int(hcode):
hcode = str(int(vercode))
try:
- build_dir = 'build/' + app['id']
+ if app['Repo Type'] == 'srclib':
+ build_dir = os.path.join('build', 'srclib')
+ repotype = common.getsrclibvcs(app['Repo'])
+ else:
+ build_dir = os.path.join('build/', app['id'])
+ repotype = app['Repo Type']
- if app['Repo Type'] == 'bzr':
+ if repotype == 'bzr':
return (None, 'RepoManifest update mode has not been ported to bzr repositories yet')
# Set up vcs interface and make sure we have the latest code...
vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir, sdk_path)
+ if app['Repo Type'] == 'srclib':
+ build_dir = os.path.join(build_dir, app['Repo'])
+
if vcs.repotype() == 'git':
if branch:
vcs.gotorevision('origin/'+branch)
vcs.gotorevision('origin/master')
pass
elif vcs.repotype() == 'git-svn':
- vcs.gotorevision('trunk')
+ vcs.gotorevision(None)
elif vcs.repotype() == 'svn':
vcs.gotorevision(None)
elif vcs.repotype() == 'hg':
if len(app['builds']) == 0:
return (None, "Can't use RepoManifest with no builds defined")
- app_dir = build_dir
if 'subdir' in app['builds'][-1]:
- app_dir = os.path.join(app_dir, app['builds'][-1]['subdir'])
+ build_dir = os.path.join(build_dir, app['builds'][-1]['subdir'])
- version, vercode, package = common.parse_androidmanifest(app_dir)
+ version, vercode, package = common.parse_androidmanifest(build_dir)
if not package:
return (None, "Couldn't find package ID")
if package != app['id']:
if vcstype == 'bzr':
return vcs_bzr(remote, local, sdk_path)
if vcstype == 'srclib':
- return vcs_srclib(remote, local, sdk_path)
+ return getsrclib(remote, local, sdk_path, raw=True)
raise VCSException("Invalid vcs type " + vcstype)
+def getsrclibvcs(name):
+ srclib_path = os.path.join('srclibs', name + ".txt")
+ return parse_srclib(srclib_path)['Repo Type']
+
class vcs:
def __init__(self, remote, local, sdk_path):
cwd=self.local) != 0:
raise VCSException("Bzr revert failed")
-class vcs_srclib(vcs):
-
- def repotype(self):
- return 'srclib'
-
- def gotorevisionx(self, rev):
-
- srclib_dir = 'build/srclib'
+ def __init__(self, remote, local, sdk_path):
- if os.path.exists(self.local):
- shutil.rmtree(self.local)
+ self.sdk_path = sdk_path
- if self.remote.find(':') != -1:
- srclib, path = self.remote.split(':')
+ index = remote.find('@')
+ if index != -1:
+ self.username = remote[:index]
+ remote = remote[index+1:]
+ index = self.username.find(':')
+ if index == -1:
+ raise VCSException("Password required with username")
+ self.password = self.username[index+1:]
+ self.username = self.username[:index]
else:
- srclib = self.remote
- path = None
- libdir = getsrclib(srclib + '@' + rev, srclib_dir, self.sdk_path)
- self.srclib = (srclib, libdir)
- if path:
- libdir = os.path.join(libdir, path)
- shutil.copytree(libdir, self.local)
- return self.local
+ self.username = None
+
+ self.remote = remote
+ self.local = local
+ self.refreshed = False
+ self.srclib = None
# Get the type expected for a given metadata field.
# Returns the path to it. Normally this is the path to be used when referencing
# it, which may be a subdirectory of the actual project. If you want the base
# directory of the project, pass 'basepath=True'.
-def getsrclib(spec, srclib_dir, sdk_path, basepath=False):
+def getsrclib(spec, srclib_dir, sdk_path, basepath=False, raw=False):
- name, ref = spec.split('@')
+ if raw:
+ name = spec
+ ref = None
+ else:
+ name, ref = spec.split('@')
srclib_path = os.path.join('srclibs', name + ".txt")
vcs = getvcs(srclib["Repo Type"], srclib["Repo"], sdir, sdk_path)
vcs.gotorevision(ref)
+ if raw:
+ return vcs
+
libdir = None
if srclib["Subdir"] is not None: