1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-09 00:40:11 +01:00

Improve xml string extracting support

* Shield ourselves from newlines that would break metadata files
* Properly use string resources for version names
This commit is contained in:
Daniel Martí 2015-06-18 17:54:56 +02:00
parent 52c2ca1fe7
commit 5aa9e2289d
2 changed files with 7 additions and 19 deletions

View File

@ -366,13 +366,6 @@ def fetch_autoname(app, tag):
else: else:
logging.debug("...couldn't get autoname") logging.debug("...couldn't get autoname")
if app['Current Version'].startswith('@string/'):
cv = common.version_name(app['Current Version'], app_dir, flavours)
if app['Current Version'] != cv:
app['Current Version'] = cv
if not commitmsg:
commitmsg = "Fix CV of {0}".format(common.getappname(app))
return commitmsg return commitmsg

View File

@ -894,6 +894,10 @@ def retrieve_string(app_dir, string, xmlfiles=None):
return '' return ''
def retrieve_string_singleline(app_dir, string, xmlfiles=None):
return retrieve_string(app_dir, string, xmlfiles).replace('\n', ' ').strip()
# Return list of existing files that will be used to find the highest vercode # Return list of existing files that will be used to find the highest vercode
def manifest_paths(app_dir, flavours): def manifest_paths(app_dir, flavours):
@ -923,24 +927,13 @@ def fetch_real_name(app_dir, flavours):
if "{http://schemas.android.com/apk/res/android}label" not in app.attrib: if "{http://schemas.android.com/apk/res/android}label" not in app.attrib:
continue continue
label = app.attrib["{http://schemas.android.com/apk/res/android}label"].encode('utf-8') label = app.attrib["{http://schemas.android.com/apk/res/android}label"].encode('utf-8')
result = retrieve_string(app_dir, label) result = retrieve_string_singleline(app_dir, label)
if result: if result:
result = result.strip() result = result.strip()
return result return result
return None return None
# Retrieve the version name
def version_name(original, app_dir, flavours):
for path in manifest_paths(app_dir, flavours):
if not has_extension(path, 'xml'):
continue
string = retrieve_string(app_dir, original)
if string:
return string
return original
def get_library_references(root_dir): def get_library_references(root_dir):
libraries = [] libraries = []
proppath = os.path.join(root_dir, 'project.properties') proppath = os.path.join(root_dir, 'project.properties')
@ -1030,6 +1023,8 @@ def parse_androidmanifests(paths, ignoreversions=None):
package = xml.attrib["package"].encode('utf-8') package = xml.attrib["package"].encode('utf-8')
if "{http://schemas.android.com/apk/res/android}versionName" in xml.attrib: if "{http://schemas.android.com/apk/res/android}versionName" in xml.attrib:
version = xml.attrib["{http://schemas.android.com/apk/res/android}versionName"].encode('utf-8') version = xml.attrib["{http://schemas.android.com/apk/res/android}versionName"].encode('utf-8')
base_dir = os.path.dirname(path)
version = retrieve_string_singleline(base_dir, version)
if "{http://schemas.android.com/apk/res/android}versionCode" in xml.attrib: if "{http://schemas.android.com/apk/res/android}versionCode" in xml.attrib:
a = xml.attrib["{http://schemas.android.com/apk/res/android}versionCode"].encode('utf-8') a = xml.attrib["{http://schemas.android.com/apk/res/android}versionCode"].encode('utf-8')
if string_is_integer(a): if string_is_integer(a):