mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-15 23:42:37 +03:00
Fall back to res/values to avoid @strings/app_name
This commit is contained in:
parent
7b394e6893
commit
f6fb7416c5
3 changed files with 29 additions and 16 deletions
|
@ -58,10 +58,9 @@ def check_tags(app, sdk_path):
|
||||||
if len(app['builds']) == 0:
|
if len(app['builds']) == 0:
|
||||||
return (None, "Can't use Tags with no builds defined")
|
return (None, "Can't use Tags with no builds defined")
|
||||||
|
|
||||||
manifest = build_dir
|
app_dir = build_dir
|
||||||
if 'subdir' in app['builds'][-1]:
|
if 'subdir' in app['builds'][-1]:
|
||||||
manifest = os.path.join(manifest, app['builds'][-1]['subdir'])
|
app_dir = os.path.join(app_dir, app['builds'][-1]['subdir'])
|
||||||
manifest = os.path.join(manifest, 'AndroidManifest.xml')
|
|
||||||
|
|
||||||
hver = None
|
hver = None
|
||||||
hcode = "0"
|
hcode = "0"
|
||||||
|
@ -70,8 +69,8 @@ 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...
|
||||||
if os.path.exists(manifest):
|
if os.path.exists(app_dir + '/AndroidManifest.xml'):
|
||||||
version, vercode, package = common.parse_androidmanifest(manifest)
|
version, vercode, package = common.parse_androidmanifest(app_dir)
|
||||||
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))
|
||||||
|
@ -116,12 +115,11 @@ def check_repomanifest(app, sdk_path, branch="master"):
|
||||||
if len(app['builds']) == 0:
|
if len(app['builds']) == 0:
|
||||||
return (None, "Can't use RepoManifest with no builds defined")
|
return (None, "Can't use RepoManifest with no builds defined")
|
||||||
|
|
||||||
manifest = build_dir
|
app_dir = build_dir
|
||||||
if 'subdir' in app['builds'][-1]:
|
if 'subdir' in app['builds'][-1]:
|
||||||
manifest = os.path.join(manifest, app['builds'][-1]['subdir'])
|
app_dir = os.path.join(app_dir, app['builds'][-1]['subdir'])
|
||||||
manifest = os.path.join(manifest, 'AndroidManifest.xml')
|
|
||||||
|
|
||||||
version, vercode, package = common.parse_androidmanifest(manifest)
|
version, vercode, package = common.parse_androidmanifest(app_dir)
|
||||||
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']:
|
||||||
|
|
|
@ -837,15 +837,16 @@ def description_html(lines,linkres):
|
||||||
# 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_androidmanifest(app_dir):
|
||||||
|
|
||||||
vcsearch = re.compile(r'.*android:versionCode="([^"]+)".*').search
|
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
|
psearch = re.compile(r'.*package="([^"]+)".*').search
|
||||||
|
vnsearch_xml = re.compile(r'.*"app_version">([\.0-9a-zA-Z]+)<.*').search
|
||||||
version = None
|
version = None
|
||||||
vercode = None
|
vercode = None
|
||||||
package = None
|
package = None
|
||||||
for line in file(manifest):
|
for line in file(app_dir + '/AndroidManifest.xml'):
|
||||||
if not package:
|
if not package:
|
||||||
matches = psearch(line)
|
matches = psearch(line)
|
||||||
if matches:
|
if matches:
|
||||||
|
@ -858,8 +859,23 @@ def parse_androidmanifest(manifest):
|
||||||
matches = vcsearch(line)
|
matches = vcsearch(line)
|
||||||
if matches:
|
if matches:
|
||||||
vercode = matches.group(1)
|
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)
|
return (version, vercode, package)
|
||||||
|
|
||||||
|
|
||||||
class BuildException(Exception):
|
class BuildException(Exception):
|
||||||
def __init__(self, value, stdout = None, stderr = None):
|
def __init__(self, value, stdout = None, stderr = None):
|
||||||
|
|
|
@ -223,13 +223,12 @@ def main():
|
||||||
root_dir = src_dir
|
root_dir = src_dir
|
||||||
|
|
||||||
# Check AndroidManiifest.xml exists...
|
# Check AndroidManiifest.xml exists...
|
||||||
manifest = os.path.join(root_dir, 'AndroidManifest.xml')
|
if not os.path.exists(root_dir + '/AndroidManifest.xml'):
|
||||||
if not os.path.exists(manifest):
|
|
||||||
print "AndroidManifest.xml did not exist in the expected location. Specify --subdir?"
|
print "AndroidManifest.xml did not exist in the expected location. Specify --subdir?"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Extract some information...
|
# Extract some information...
|
||||||
version, vercode, package = common.parse_androidmanifest(manifest)
|
version, vercode, package = common.parse_androidmanifest(root_dir)
|
||||||
if not package:
|
if not package:
|
||||||
print "Couldn't find package ID"
|
print "Couldn't find package ID"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue