mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-16 16:02:33 +03:00
Try and adapt checkupdates to gradle better
This commit is contained in:
parent
1e7bfc9864
commit
578e030ee6
2 changed files with 65 additions and 50 deletions
|
@ -74,14 +74,13 @@ def check_tags(app, sdk_path):
|
||||||
vcs.gotorevision(tag)
|
vcs.gotorevision(tag)
|
||||||
|
|
||||||
# Only process tags where the manifest exists...
|
# Only process tags where the manifest exists...
|
||||||
path = common.manifest_path(build_dir, flavour)
|
paths = common.manifest_paths(build_dir, flavour)
|
||||||
if path is not None:
|
version, vercode, package = common.parse_androidmanifests(paths)
|
||||||
version, vercode, package = common.parse_androidmanifest(path)
|
print "Manifest exists. Found version %s" % version
|
||||||
print "Manifest exists. Found version %s" % version
|
if package and package == app['id'] and version and vercode:
|
||||||
if package and package == app['id'] and version and vercode:
|
if int(vercode) > int(hcode):
|
||||||
if int(vercode) > int(hcode):
|
hcode = str(int(vercode))
|
||||||
hcode = str(int(vercode))
|
hver = version
|
||||||
hver = version
|
|
||||||
|
|
||||||
if hver:
|
if hver:
|
||||||
return (hver, hcode)
|
return (hver, hcode)
|
||||||
|
@ -149,11 +148,9 @@ def check_repomanifest(app, sdk_path, branch=None):
|
||||||
if not os.path.isdir(build_dir):
|
if not os.path.isdir(build_dir):
|
||||||
return (None, "Subdir '" + app['builds'][-1]['subdir'] + "'is not a valid directory")
|
return (None, "Subdir '" + app['builds'][-1]['subdir'] + "'is not a valid directory")
|
||||||
|
|
||||||
path = common.manifest_path(build_dir, flavour)
|
paths = common.manifest_paths(build_dir, flavour)
|
||||||
if path is None:
|
|
||||||
return (None, "No manifest could be found")
|
|
||||||
|
|
||||||
version, vercode, package = common.parse_androidmanifest(path)
|
version, vercode, package = common.parse_androidmanifest(paths)
|
||||||
if not package:
|
if not package:
|
||||||
return (None, "Couldn't find package ID")
|
return (None, "Couldn't find package ID")
|
||||||
if package != app['id']:
|
if package != app['id']:
|
||||||
|
|
|
@ -875,26 +875,19 @@ def retrieve_string(app_dir, string_id):
|
||||||
return s.replace("\\'","'")
|
return s.replace("\\'","'")
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
# Find the AM.xml - try to use new gradle manifest paths
|
# Return list of existing AM.xml files that will be used to find the highest
|
||||||
# TODO: Gradle can use multiple manifests. Return a list of the existing ones
|
# vercode
|
||||||
# and later iterate through them to find the highest vercode.
|
def manifest_paths(app_dir, flavour):
|
||||||
def manifest_path(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:
|
if flavour is not None:
|
||||||
flavour_manifest = os.path.join(app_dir, 'src', flavour, 'AndroidManifest.xml')
|
possible_manifests.append(
|
||||||
if os.path.isfile(flavour_manifest):
|
os.path.join(app_dir, 'src', flavour, 'AndroidManifest.xml'))
|
||||||
return flavour_manifest
|
|
||||||
|
|
||||||
main_manifest = os.path.join(app_dir, 'src', 'main', 'AndroidManifest.xml')
|
return [path for path in possible_manifests if os.path.isfile(path)]
|
||||||
print main_manifest
|
|
||||||
if os.path.isfile(main_manifest):
|
|
||||||
return main_manifest
|
|
||||||
|
|
||||||
if os.path.isfile(root_manifest):
|
|
||||||
return root_manifest
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
# Retrieve the package name
|
# 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.
|
# Extract some information from the AndroidManifest.xml at the given path.
|
||||||
# Returns (version, vercode, package), any or all of which might be None.
|
# Returns (version, vercode, package), any or all of which might be None.
|
||||||
# All values returned are strings.
|
# All values returned are strings.
|
||||||
def parse_androidmanifest(manifest):
|
def parse_androidmanifests(paths):
|
||||||
|
|
||||||
vcsearch = re.compile(r'.*android:versionCode="([0-9]+?)".*').search
|
vcsearch = re.compile(r'.*android:versionCode="([0-9]+?)".*').search
|
||||||
vnsearch = re.compile(r'.*android:versionName="([^"]+?)".*').search
|
vnsearch = re.compile(r'.*android:versionName="([^"]+?)".*').search
|
||||||
psearch = re.compile(r'.*package="([^"]+)".*').search
|
psearch = re.compile(r'.*package="([^"]+)".*').search
|
||||||
vnsearch_xml = re.compile(r'.*"(app_|)version">([^<]+?)<.*').search
|
|
||||||
version = None
|
vcsearch_g = re.compile(r'.*versionCode[ ]+?([0-9]+?).*').search
|
||||||
vercode = None
|
vnsearch_g = re.compile(r'.*versionName[ ]+?"([^"]+?)".*').search
|
||||||
package = None
|
psearch_g = re.compile(r'.*packageName[ ]+?"([^"]+)".*').search
|
||||||
for line in file(manifest):
|
|
||||||
if not package:
|
max_version = None
|
||||||
matches = psearch(line)
|
max_vercode = None
|
||||||
if matches:
|
max_package = None
|
||||||
package = matches.group(1)
|
|
||||||
if not version:
|
for path in paths:
|
||||||
matches = vnsearch(line)
|
|
||||||
if matches:
|
gradle = path.endswith("build.gradle")
|
||||||
version = matches.group(1)
|
version = None
|
||||||
if not vercode:
|
vercode = None
|
||||||
matches = vcsearch(line)
|
package = None
|
||||||
if matches:
|
|
||||||
vercode = matches.group(1)
|
for line in file(path):
|
||||||
#if version.startswith('@string/'):
|
if not package:
|
||||||
#version = retrieve_string(app_dir, version[8:])
|
if gradle:
|
||||||
return (version, vercode, package)
|
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 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):
|
class BuildException(Exception):
|
||||||
def __init__(self, value, stdout = None, stderr = None):
|
def __init__(self, value, stdout = None, stderr = None):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue