mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-16 16:02:33 +03:00
Improve checkupdates further, Auto Name works with gradle
This commit is contained in:
parent
1fcb56b946
commit
0ad09f6481
2 changed files with 32 additions and 31 deletions
|
@ -304,15 +304,18 @@ def main():
|
||||||
vcs = common.getvcs(app["Repo Type"], app["Repo"], app_dir, sdk_path)
|
vcs = common.getvcs(app["Repo Type"], app["Repo"], app_dir, 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]:
|
||||||
app_dir = os.path.join(app_dir, app['builds'][-1]['subdir'])
|
app_dir = os.path.join(app_dir, app['builds'][-1]['subdir'])
|
||||||
|
if 'gradle' in app['builds'][-1]:
|
||||||
|
flavour = app['builds'][-1]['gradle']
|
||||||
|
|
||||||
|
new_name = common.fetch_real_name(app_dir, flavour)
|
||||||
|
if new_name != app['Auto Name']:
|
||||||
|
app['Auto Name'] = new_name
|
||||||
|
writeit = True
|
||||||
|
|
||||||
#new_name = common.fetch_real_name(app_dir)
|
|
||||||
#if new_name != app['Auto Name']:
|
|
||||||
#app['Auto Name'] = new_name
|
|
||||||
#if not writeit:
|
|
||||||
#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())
|
||||||
|
|
||||||
|
|
|
@ -862,21 +862,19 @@ def description_html(lines,linkres):
|
||||||
ps.end()
|
ps.end()
|
||||||
return ps.text_html
|
return ps.text_html
|
||||||
|
|
||||||
def retrieve_string(app_dir, string_id):
|
def retrieve_string(xml_dir, string):
|
||||||
string_search = re.compile(r'.*"'+string_id+'".*>([^<]+?)<.*').search
|
print string
|
||||||
for xmlfile in glob.glob(os.path.join(
|
if not string.startswith('@string/'):
|
||||||
app_dir, 'res', 'values', '*.xml')):
|
return string.replace("\\'","'")
|
||||||
|
string_search = re.compile(r'.*"'+string[8:]+'".*>([^<]+?)<.*').search
|
||||||
|
for xmlfile in glob.glob(os.path.join(xml_dir, '*.xml')):
|
||||||
for line in file(xmlfile):
|
for line in file(xmlfile):
|
||||||
matches = string_search(line)
|
matches = string_search(line)
|
||||||
if matches:
|
if matches:
|
||||||
s = matches.group(1)
|
return retrieve_string(xml_dir, matches.group(1))
|
||||||
if s.startswith('@string/'):
|
|
||||||
return retrieve_string(app_dir, s[8:]);
|
|
||||||
return s.replace("\\'","'")
|
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
# Return list of existing AM.xml files that will be used to find the highest
|
# Return list of existing files that will be used to find the highest vercode
|
||||||
# vercode
|
|
||||||
def manifest_paths(app_dir, flavour):
|
def manifest_paths(app_dir, flavour):
|
||||||
|
|
||||||
possible_manifests = [ os.path.join(app_dir, 'AndroidManifest.xml'),
|
possible_manifests = [ os.path.join(app_dir, 'AndroidManifest.xml'),
|
||||||
|
@ -886,30 +884,30 @@ def manifest_paths(app_dir, flavour):
|
||||||
if flavour is not None:
|
if flavour is not None:
|
||||||
possible_manifests.append(
|
possible_manifests.append(
|
||||||
os.path.join(app_dir, 'src', flavour, 'AndroidManifest.xml'))
|
os.path.join(app_dir, 'src', flavour, 'AndroidManifest.xml'))
|
||||||
|
|
||||||
return [path for path in possible_manifests if os.path.isfile(path)]
|
return [path for path in possible_manifests if os.path.isfile(path)]
|
||||||
|
|
||||||
|
|
||||||
# Retrieve the package name
|
# Retrieve the package name
|
||||||
def fetch_real_name(app_dir):
|
def fetch_real_name(app_dir, flavour):
|
||||||
app_search = re.compile(r'.*<application.*').search
|
app_search = re.compile(r'.*<application.*').search
|
||||||
name_search = re.compile(r'.*android:label="([^"]+)".*').search
|
name_search = re.compile(r'.*android:label="([^"]+)".*').search
|
||||||
app_found = False
|
app_found = False
|
||||||
name = None
|
name = None
|
||||||
for line in file(manifest_path(app_dir)):
|
for f in manifest_paths(app_dir, flavour):
|
||||||
if not app_found:
|
print f
|
||||||
if app_search(line):
|
if not f.endswith(".xml"):
|
||||||
app_found = True
|
continue
|
||||||
if app_found:
|
xml_dir = os.path.join(f[:-19], 'res', 'values')
|
||||||
if name is not None:
|
for line in file(f):
|
||||||
break
|
if not app_found:
|
||||||
matches = name_search(line)
|
if app_search(line):
|
||||||
if matches:
|
app_found = True
|
||||||
name = matches.group(1)
|
if app_found:
|
||||||
|
matches = name_search(line)
|
||||||
|
if matches:
|
||||||
|
return retrieve_string(xml_dir, matches.group(1))
|
||||||
|
|
||||||
if name.startswith('@string/'):
|
return ''
|
||||||
return retrieve_string(app_dir, name[8:])
|
|
||||||
return name
|
|
||||||
|
|
||||||
# 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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue