1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-09-17 10:40:12 +02:00

Fall back to res/values to avoid @strings/app_name

This commit is contained in:
Daniel Martí 2013-05-14 20:50:40 +02:00
parent 7b394e6893
commit f6fb7416c5
3 changed files with 29 additions and 16 deletions

View File

@ -58,10 +58,9 @@ def check_tags(app, sdk_path):
if len(app['builds']) == 0:
return (None, "Can't use Tags with no builds defined")
manifest = build_dir
app_dir = build_dir
if 'subdir' in app['builds'][-1]:
manifest = os.path.join(manifest, app['builds'][-1]['subdir'])
manifest = os.path.join(manifest, 'AndroidManifest.xml')
app_dir = os.path.join(app_dir, app['builds'][-1]['subdir'])
hver = None
hcode = "0"
@ -70,8 +69,8 @@ def check_tags(app, sdk_path):
vcs.gotorevision(tag)
# Only process tags where the manifest exists...
if os.path.exists(manifest):
version, vercode, package = common.parse_androidmanifest(manifest)
if os.path.exists(app_dir + '/AndroidManifest.xml'):
version, vercode, package = common.parse_androidmanifest(app_dir)
if package and package == app['id'] and version and vercode:
if int(vercode) > int(hcode):
hcode = str(int(vercode))
@ -116,12 +115,11 @@ def check_repomanifest(app, sdk_path, branch="master"):
if len(app['builds']) == 0:
return (None, "Can't use RepoManifest with no builds defined")
manifest = build_dir
app_dir = build_dir
if 'subdir' in app['builds'][-1]:
manifest = os.path.join(manifest, app['builds'][-1]['subdir'])
manifest = os.path.join(manifest, 'AndroidManifest.xml')
app_dir = os.path.join(app_dir, app['builds'][-1]['subdir'])
version, vercode, package = common.parse_androidmanifest(manifest)
version, vercode, package = common.parse_androidmanifest(app_dir)
if not package:
return (None, "Couldn't find package ID")
if package != app['id']:

View File

@ -837,15 +837,16 @@ def description_html(lines,linkres):
# 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_androidmanifest(app_dir):
vcsearch = re.compile(r'.*android:versionCode="([^"]+)".*').search
vnsearch = re.compile(r'.*android:versionName="([^"]+)".*').search
vnsearch = re.compile(r'.*android:versionName="([\.0-9a-zA-Z]+)".*').search
psearch = re.compile(r'.*package="([^"]+)".*').search
vnsearch_xml = re.compile(r'.*"app_version">([\.0-9a-zA-Z]+)<.*').search
version = None
vercode = None
package = None
for line in file(manifest):
for line in file(app_dir + '/AndroidManifest.xml'):
if not package:
matches = psearch(line)
if matches:
@ -858,9 +859,24 @@ def parse_androidmanifest(manifest):
matches = vcsearch(line)
if matches:
vercode = matches.group(1)
if version:
return (version, vercode, package)
for xmlfile in glob.glob(app_dir + '/res/values/strings*transl*.xml'):
for line in file(xmlfile):
if not version:
matches = vnsearch_xml(line)
if matches:
version = matches.group(1)
if not version:
for line in file(app_dir + '/res/values/strings.xml'):
if not version:
matches = vnsearch_xml(line)
if matches:
version = matches.group(1)
if not version:
version = "None"
return (version, vercode, package)
class BuildException(Exception):
def __init__(self, value, stdout = None, stderr = None):
self.value = value

View File

@ -223,13 +223,12 @@ def main():
root_dir = src_dir
# Check AndroidManiifest.xml exists...
manifest = os.path.join(root_dir, 'AndroidManifest.xml')
if not os.path.exists(manifest):
if not os.path.exists(root_dir + '/AndroidManifest.xml'):
print "AndroidManifest.xml did not exist in the expected location. Specify --subdir?"
sys.exit(1)
# Extract some information...
version, vercode, package = common.parse_androidmanifest(manifest)
version, vercode, package = common.parse_androidmanifest(root_dir)
if not package:
print "Couldn't find package ID"
sys.exit(1)