mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-05 18:50:09 +02:00
Fix gradle checkupdates with tags and RM. new settings.
This commit is contained in:
parent
7d1f2b68b9
commit
d86a68b858
@ -5,6 +5,9 @@
|
|||||||
sdk_path = "/path/to/android-sdk-linux_86"
|
sdk_path = "/path/to/android-sdk-linux_86"
|
||||||
ndk_path = "/path/to/android-ndk-r8e"
|
ndk_path = "/path/to/android-ndk-r8e"
|
||||||
|
|
||||||
|
# Build tools version to be used
|
||||||
|
build_tools = "18.0.1"
|
||||||
|
|
||||||
# May be necessary for fdroid update; you may still need to make a symlink to
|
# May be necessary for fdroid update; you may still need to make a symlink to
|
||||||
# aapt in platform-tools
|
# aapt in platform-tools
|
||||||
aapt_path = "/path/to/android-sdk-linux_x86/build-tools/17.0.0/aapt"
|
aapt_path = "/path/to/android-sdk-linux_x86/build-tools/17.0.0/aapt"
|
||||||
@ -15,6 +18,12 @@ javacc_path = "/usr/share/java"
|
|||||||
#Command for running maven 3 (could be mvn, mvn3, or a full path)
|
#Command for running maven 3 (could be mvn, mvn3, or a full path)
|
||||||
mvn3 = "mvn3"
|
mvn3 = "mvn3"
|
||||||
|
|
||||||
|
# Gradle command
|
||||||
|
gradle = "gradle"
|
||||||
|
|
||||||
|
# Android gradle plugin version
|
||||||
|
gradle_plugin = "0.5.+"
|
||||||
|
|
||||||
repo_url = "https://f-droid.org/repo"
|
repo_url = "https://f-droid.org/repo"
|
||||||
repo_name = "F-Droid"
|
repo_name = "F-Droid"
|
||||||
repo_icon = "fdroid-icon.png"
|
repo_icon = "fdroid-icon.png"
|
||||||
|
@ -60,9 +60,12 @@ def check_tags(app, sdk_path):
|
|||||||
|
|
||||||
vcs.gotorevision(None)
|
vcs.gotorevision(None)
|
||||||
|
|
||||||
|
flavour = None
|
||||||
if len(app['builds']) > 0:
|
if len(app['builds']) > 0:
|
||||||
if 'subdir' in app['builds'][-1]:
|
if 'subdir' in app['builds'][-1]:
|
||||||
build_dir = os.path.join(build_dir, app['builds'][-1]['subdir'])
|
build_dir = os.path.join(build_dir, app['builds'][-1]['subdir'])
|
||||||
|
if 'gradle' in app['builds'][-1]:
|
||||||
|
flavour = app['builds'][-1]['gradle']
|
||||||
|
|
||||||
hver = None
|
hver = None
|
||||||
hcode = "0"
|
hcode = "0"
|
||||||
@ -71,10 +74,10 @@ 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)
|
path = common.manifest_path(build_dir, flavour, gradle,
|
||||||
print "Trying manifest at %s" % path
|
build_tools, gradle_plugin)
|
||||||
if os.path.exists(path):
|
if path is not None and os.path.exists(path):
|
||||||
version, vercode, package = common.parse_androidmanifest(build_dir)
|
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):
|
||||||
@ -141,11 +144,18 @@ def check_repomanifest(app, sdk_path, branch=None):
|
|||||||
if len(app['builds']) > 0:
|
if len(app['builds']) > 0:
|
||||||
if 'subdir' in app['builds'][-1]:
|
if 'subdir' in app['builds'][-1]:
|
||||||
build_dir = os.path.join(build_dir, app['builds'][-1]['subdir'])
|
build_dir = os.path.join(build_dir, app['builds'][-1]['subdir'])
|
||||||
|
if 'gradle' in app['builds'][-1]:
|
||||||
|
flavour = app['builds'][-1]['gradle']
|
||||||
|
|
||||||
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")
|
||||||
|
|
||||||
version, vercode, package = common.parse_androidmanifest(build_dir)
|
path = common.manifest_path(build_dir, flavour, gradle, build_tools,
|
||||||
|
gradle_plugin)
|
||||||
|
if path is None:
|
||||||
|
return (None, "Gradle flavour not found")
|
||||||
|
|
||||||
|
version, vercode, package = common.parse_androidmanifest(path)
|
||||||
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']:
|
||||||
@ -213,6 +223,7 @@ def check_market(app):
|
|||||||
def main():
|
def main():
|
||||||
|
|
||||||
#Read configuration...
|
#Read configuration...
|
||||||
|
globals()['gradle'] = "gradle"
|
||||||
execfile('config.py', globals())
|
execfile('config.py', globals())
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
@ -300,11 +311,11 @@ def main():
|
|||||||
if 'subdir' in app['builds'][-1]:
|
if 'subdir' in app['builds'][-1]:
|
||||||
app_dir = os.path.join(app_dir, app['builds'][-1]['subdir'])
|
app_dir = os.path.join(app_dir, app['builds'][-1]['subdir'])
|
||||||
|
|
||||||
new_name = common.fetch_real_name(app_dir)
|
#new_name = common.fetch_real_name(app_dir)
|
||||||
if new_name != app['Auto Name']:
|
#if new_name != app['Auto Name']:
|
||||||
app['Auto Name'] = new_name
|
#app['Auto Name'] = new_name
|
||||||
if not writeit:
|
#if not writeit:
|
||||||
writeit = True
|
#writeit = True
|
||||||
except Exception:
|
except Exception:
|
||||||
msg = "Auto Name failed for %s due to exception: %s" % (app['id'], traceback.format_exc())
|
msg = "Auto Name failed for %s due to exception: %s" % (app['id'], traceback.format_exc())
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import subprocess
|
|||||||
import time
|
import time
|
||||||
import operator
|
import operator
|
||||||
import cgi
|
import cgi
|
||||||
|
import fileinput
|
||||||
|
|
||||||
def getvcs(vcstype, remote, local, sdk_path):
|
def getvcs(vcstype, remote, local, sdk_path):
|
||||||
if vcstype == 'git':
|
if vcstype == 'git':
|
||||||
@ -875,12 +876,25 @@ def retrieve_string(app_dir, string_id):
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
# Find the AM.xml - try the new gradle method first.
|
# Find the AM.xml - try the new gradle method first.
|
||||||
def manifest_path(app_dir):
|
def manifest_path(app_dir, flavour, gradle, build_tools, gradle_plugin):
|
||||||
gradlepath = os.path.join(app_dir, 'src', 'main', 'AndroidManifest.xml')
|
|
||||||
if os.path.exists(gradlepath):
|
if flavour is None:
|
||||||
return gradlepath
|
return os.path.join(app_dir, 'AndroidManifest.xml')
|
||||||
rootpath = os.path.join(app_dir, 'AndroidManifest.xml')
|
|
||||||
return rootpath
|
if not os.path.exists(os.path.join(app_dir, 'src', flavour)):
|
||||||
|
return None
|
||||||
|
|
||||||
|
for line in fileinput.input(os.path.join(app_dir, 'build.gradle'), inplace=True):
|
||||||
|
if 'buildToolsVersion' in line:
|
||||||
|
print 'buildToolsVersion "%s"' % build_tools,
|
||||||
|
elif 'com.android.tools.build:gradle:' in line:
|
||||||
|
print "classpath 'com.android.tools.build:gradle:%s'" % gradle_plugin,
|
||||||
|
else:
|
||||||
|
print line,
|
||||||
|
|
||||||
|
subprocess.Popen([gradle, 'process'+flavour+'ReleaseManifest'], cwd=app_dir).communicate()
|
||||||
|
|
||||||
|
return os.path.join(app_dir, 'build', 'manifests', flavour, 'release', 'AndroidManifest.xml')
|
||||||
|
|
||||||
|
|
||||||
# Retrieve the package name
|
# Retrieve the package name
|
||||||
@ -907,7 +921,7 @@ 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(app_dir):
|
def parse_androidmanifest(manifest):
|
||||||
|
|
||||||
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
|
||||||
@ -916,7 +930,7 @@ def parse_androidmanifest(app_dir):
|
|||||||
version = None
|
version = None
|
||||||
vercode = None
|
vercode = None
|
||||||
package = None
|
package = None
|
||||||
for line in file(manifest_path(app_dir)):
|
for line in file(manifest):
|
||||||
if not package:
|
if not package:
|
||||||
matches = psearch(line)
|
matches = psearch(line)
|
||||||
if matches:
|
if matches:
|
||||||
@ -929,8 +943,8 @@ def parse_androidmanifest(app_dir):
|
|||||||
matches = vcsearch(line)
|
matches = vcsearch(line)
|
||||||
if matches:
|
if matches:
|
||||||
vercode = matches.group(1)
|
vercode = matches.group(1)
|
||||||
if version.startswith('@string/'):
|
#if version.startswith('@string/'):
|
||||||
version = retrieve_string(app_dir, version[8:])
|
#version = retrieve_string(app_dir, version[8:])
|
||||||
return (version, vercode, package)
|
return (version, vercode, package)
|
||||||
|
|
||||||
class BuildException(Exception):
|
class BuildException(Exception):
|
||||||
|
Loading…
Reference in New Issue
Block a user