class vcs:
def __init__(self, remote, local, sdk_path):
+
self.sdk_path = sdk_path
# It's possible to sneak a username and password in with
stdout=subprocess.PIPE, cwd=self.local)
return p.communicate()[0].splitlines()
+
class vcs_gitsvn(vcs):
def repotype(self):
self.userargs(), cwd=self.local) != 0:
raise VCSException("Svn update failed")
+
class vcs_hg(vcs):
def repotype(self):
cwd=self.local) != 0:
raise VCSException("Hg checkout failed")
+
class vcs_bzr(vcs):
def repotype(self):
shutil.copytree(libdir, self.local)
return self.local
+
# Get the type expected for a given metadata field.
def metafieldtype(name):
if name == 'Description':
return 'obsolete'
return 'string'
+
# Parse metadata for a single application.
#
# 'metafile' - the filename to read. The package id for the application comes
writecomments(None)
mf.close()
+
# Read all metadata. Returns a list of 'app' objects (which are dictionaries as
# returned by the parse_metadata function.
def read_metadata(verbose=False, xref=True):
self.ital = not self.ital
txt = txt[2:]
+
def linkify(self, txt):
linkified_plain = ''
linkified_html = ''
ps.end()
return ps.text_html
+
+
# Extract some information from the AndroidManifest.xml at the given path.
# Returns (version, vercode, package), any or all of which might be None.
# All values returned are strings.
def parse_androidmanifest(manifest):
+
vcsearch = re.compile(r'.*android:versionCode="([^"]+)".*').search
vnsearch = re.compile(r'.*android:versionName="([^"]+)".*').search
psearch = re.compile(r'.*package="([^"]+)".*').search
vercode = matches.group(1)
return (version, vercode, package)
+
class BuildException(Exception):
def __init__(self, value, stdout = None, stderr = None):
self.value = value
def __str__(self):
return repr(self.value)
+
# Get the specified source library.
# 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
# TODO: These are currently just hard-coded in this method. It will be a
# metadata-driven system eventually, but not yet.
def getsrclib(spec, extlib_dir, sdk_path, basepath=False):
+
name, ref = spec.split('@')
if name == 'GreenDroid':
raise BuildException('Unknown srclib ' + name)
+
# Prepare the source code for a particular build
# 'vcs' - the appropriate vcs object for the application
# 'app' - the application details from the metadata
# be a subdirectory of it.
# 'srclibpaths' is information on the srclibs being used
def prepare_source(vcs, app, build, build_dir, extlib_dir, sdk_path, ndk_path, javacc_path, mvn3, verbose=False):
+
# Optionally, the actual app source can be in a subdirectory...
if 'subdir' in build:
root_dir = os.path.join(build_dir, build['subdir'])
return (root_dir, srclibpaths)
+
# Scan the source code in the given directory (and all subdirectories)
# and return a list of potential problems.
def scan_source(build_dir, root_dir, thisbuild):
+
problems = []
# Common known non-free blobs:
return problems
+
class KnownApks:
def __init__(self):