mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-04 22:40:12 +01:00
Try and adapt checkupdates to gradle better
This commit is contained in:
parent
1e7bfc9864
commit
578e030ee6
@ -74,9 +74,8 @@ def check_tags(app, sdk_path):
|
||||
vcs.gotorevision(tag)
|
||||
|
||||
# Only process tags where the manifest exists...
|
||||
path = common.manifest_path(build_dir, flavour)
|
||||
if path is not None:
|
||||
version, vercode, package = common.parse_androidmanifest(path)
|
||||
paths = common.manifest_paths(build_dir, flavour)
|
||||
version, vercode, package = common.parse_androidmanifests(paths)
|
||||
print "Manifest exists. Found version %s" % version
|
||||
if package and package == app['id'] and version and vercode:
|
||||
if int(vercode) > int(hcode):
|
||||
@ -149,11 +148,9 @@ def check_repomanifest(app, sdk_path, branch=None):
|
||||
if not os.path.isdir(build_dir):
|
||||
return (None, "Subdir '" + app['builds'][-1]['subdir'] + "'is not a valid directory")
|
||||
|
||||
path = common.manifest_path(build_dir, flavour)
|
||||
if path is None:
|
||||
return (None, "No manifest could be found")
|
||||
paths = common.manifest_paths(build_dir, flavour)
|
||||
|
||||
version, vercode, package = common.parse_androidmanifest(path)
|
||||
version, vercode, package = common.parse_androidmanifest(paths)
|
||||
if not package:
|
||||
return (None, "Couldn't find package ID")
|
||||
if package != app['id']:
|
||||
|
@ -875,26 +875,19 @@ def retrieve_string(app_dir, string_id):
|
||||
return s.replace("\\'","'")
|
||||
return ''
|
||||
|
||||
# Find the AM.xml - try to use new gradle manifest paths
|
||||
# TODO: Gradle can use multiple manifests. Return a list of the existing ones
|
||||
# and later iterate through them to find the highest vercode.
|
||||
def manifest_path(app_dir, flavour):
|
||||
# Return list of existing AM.xml files that will be used to find the highest
|
||||
# vercode
|
||||
def manifest_paths(app_dir, flavour):
|
||||
|
||||
possible_manifests = [ os.path.join(app_dir, 'AndroidManifest.xml'),
|
||||
os.path.join(app_dir, 'src', 'main', 'AndroidManifest.xml'),
|
||||
os.path.join(app_dir, 'build.gradle') ]
|
||||
|
||||
root_manifest = os.path.join(app_dir, 'AndroidManifest.xml')
|
||||
if flavour is not None:
|
||||
flavour_manifest = os.path.join(app_dir, 'src', flavour, 'AndroidManifest.xml')
|
||||
if os.path.isfile(flavour_manifest):
|
||||
return flavour_manifest
|
||||
possible_manifests.append(
|
||||
os.path.join(app_dir, 'src', flavour, 'AndroidManifest.xml'))
|
||||
|
||||
main_manifest = os.path.join(app_dir, 'src', 'main', 'AndroidManifest.xml')
|
||||
print main_manifest
|
||||
if os.path.isfile(main_manifest):
|
||||
return main_manifest
|
||||
|
||||
if os.path.isfile(root_manifest):
|
||||
return root_manifest
|
||||
|
||||
return None
|
||||
return [path for path in possible_manifests if os.path.isfile(path)]
|
||||
|
||||
|
||||
# Retrieve the package name
|
||||
@ -921,31 +914,56 @@ def fetch_real_name(app_dir):
|
||||
# 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):
|
||||
def parse_androidmanifests(paths):
|
||||
|
||||
vcsearch = re.compile(r'.*android:versionCode="([0-9]+?)".*').search
|
||||
vnsearch = re.compile(r'.*android:versionName="([^"]+?)".*').search
|
||||
psearch = re.compile(r'.*package="([^"]+)".*').search
|
||||
vnsearch_xml = re.compile(r'.*"(app_|)version">([^<]+?)<.*').search
|
||||
|
||||
vcsearch_g = re.compile(r'.*versionCode[ ]+?([0-9]+?).*').search
|
||||
vnsearch_g = re.compile(r'.*versionName[ ]+?"([^"]+?)".*').search
|
||||
psearch_g = re.compile(r'.*packageName[ ]+?"([^"]+)".*').search
|
||||
|
||||
max_version = None
|
||||
max_vercode = None
|
||||
max_package = None
|
||||
|
||||
for path in paths:
|
||||
|
||||
gradle = path.endswith("build.gradle")
|
||||
version = None
|
||||
vercode = None
|
||||
package = None
|
||||
for line in file(manifest):
|
||||
|
||||
for line in file(path):
|
||||
if not package:
|
||||
if gradle:
|
||||
matches = psearch_g(line)
|
||||
else:
|
||||
matches = psearch(line)
|
||||
if matches:
|
||||
package = matches.group(1)
|
||||
if not version:
|
||||
if gradle:
|
||||
matches = vnsearch_g(line)
|
||||
else:
|
||||
matches = vnsearch(line)
|
||||
if matches:
|
||||
version = matches.group(1)
|
||||
if not vercode:
|
||||
if gradle:
|
||||
matches = vcsearch_g(line)
|
||||
else:
|
||||
matches = vcsearch(line)
|
||||
if matches:
|
||||
vercode = matches.group(1)
|
||||
#if version.startswith('@string/'):
|
||||
#version = retrieve_string(app_dir, version[8:])
|
||||
return (version, vercode, package)
|
||||
|
||||
if max_vercode is None or (vercode is not None and vercode > max_vercode):
|
||||
max_version = version
|
||||
max_vercode = vercode
|
||||
max_package = package
|
||||
|
||||
return (max_version, max_vercode, max_package)
|
||||
|
||||
class BuildException(Exception):
|
||||
def __init__(self, value, stdout = None, stderr = None):
|
||||
|
Loading…
Reference in New Issue
Block a user