mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-14 02:50:12 +01:00
Don't accept empty icons; Don't add <icon> xml element if none is present
This commit is contained in:
parent
8bab7a06ce
commit
e069da3562
@ -296,7 +296,7 @@ def scan_apks(apps, apkcache, repodir, knownapks):
|
|||||||
vercode_pat = re.compile(".*versionCode='([0-9]*)'.*")
|
vercode_pat = re.compile(".*versionCode='([0-9]*)'.*")
|
||||||
vername_pat = re.compile(".*versionName='([^']*)'.*")
|
vername_pat = re.compile(".*versionName='([^']*)'.*")
|
||||||
label_pat = re.compile(".*label='(.*?)'(\n| [a-z]*?=).*")
|
label_pat = re.compile(".*label='(.*?)'(\n| [a-z]*?=).*")
|
||||||
icon_pat = re.compile(".*icon='([^']*)'.*")
|
icon_pat = re.compile(".*icon='([^']+?)'.*")
|
||||||
sdkversion_pat = re.compile(".*'([0-9]*)'.*")
|
sdkversion_pat = re.compile(".*'([0-9]*)'.*")
|
||||||
string_pat = re.compile(".*'([^']*)'.*")
|
string_pat = re.compile(".*'([^']*)'.*")
|
||||||
for apkfile in glob.glob(os.path.join(repodir, '*.apk')):
|
for apkfile in glob.glob(os.path.join(repodir, '*.apk')):
|
||||||
@ -344,7 +344,9 @@ def scan_apks(apps, apkcache, repodir, knownapks):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
elif line.startswith("application:"):
|
elif line.startswith("application:"):
|
||||||
thisinfo['name'] = re.match(label_pat, line).group(1)
|
thisinfo['name'] = re.match(label_pat, line).group(1)
|
||||||
thisinfo['iconsrc'] = re.match(icon_pat, line).group(1)
|
match = re.match(icon_pat, line)
|
||||||
|
if match:
|
||||||
|
thisinfo['iconsrc'] = match.group(1)
|
||||||
elif line.startswith("sdkVersion:"):
|
elif line.startswith("sdkVersion:"):
|
||||||
thisinfo['sdkversion'] = re.match(sdkversion_pat, line).group(1)
|
thisinfo['sdkversion'] = re.match(sdkversion_pat, line).group(1)
|
||||||
elif line.startswith("native-code:"):
|
elif line.startswith("native-code:"):
|
||||||
@ -396,19 +398,20 @@ def scan_apks(apps, apkcache, repodir, knownapks):
|
|||||||
thisinfo['sig'] = output[7:].strip()
|
thisinfo['sig'] = output[7:].strip()
|
||||||
|
|
||||||
# Extract the icon file...
|
# Extract the icon file...
|
||||||
apk = zipfile.ZipFile(apkfile, 'r')
|
if 'iconsrc' in thisinfo:
|
||||||
thisinfo['icon'] = (thisinfo['id'] + '.' +
|
apk = zipfile.ZipFile(apkfile, 'r')
|
||||||
str(thisinfo['versioncode']) + '.png')
|
thisinfo['icon'] = (thisinfo['id'] + '.' +
|
||||||
iconpath = os.path.join(icon_dir, thisinfo['icon'])
|
str(thisinfo['versioncode']) + '.png')
|
||||||
try:
|
iconpath = os.path.join(icon_dir, thisinfo['icon'])
|
||||||
iconfile = open(iconpath, 'wb')
|
try:
|
||||||
iconfile.write(apk.read(thisinfo['iconsrc']))
|
iconfile = open(iconpath, 'wb')
|
||||||
iconfile.close()
|
iconfile.write(apk.read(thisinfo['iconsrc']))
|
||||||
except:
|
iconfile.close()
|
||||||
print "WARNING: Error retrieving icon file"
|
except:
|
||||||
apk.close()
|
print "WARNING: Error retrieving icon file"
|
||||||
|
apk.close()
|
||||||
|
|
||||||
resize_icon(iconpath)
|
resize_icon(iconpath)
|
||||||
|
|
||||||
# Record in known apks, getting the added date at the same time..
|
# Record in known apks, getting the added date at the same time..
|
||||||
added = knownapks.recordapk(thisinfo['apkname'], thisinfo['id'])
|
added = knownapks.recordapk(thisinfo['apkname'], thisinfo['id'])
|
||||||
@ -516,7 +519,8 @@ def make_index(apps, apks, repodir, archive, categories):
|
|||||||
addElement('lastupdated', time.strftime('%Y-%m-%d', app['lastupdated']), doc, apel)
|
addElement('lastupdated', time.strftime('%Y-%m-%d', app['lastupdated']), doc, apel)
|
||||||
addElement('name', app['Name'], doc, apel)
|
addElement('name', app['Name'], doc, apel)
|
||||||
addElement('summary', app['Summary'], doc, apel)
|
addElement('summary', app['Summary'], doc, apel)
|
||||||
addElement('icon', app['icon'], doc, apel)
|
if app['icon'] is not None:
|
||||||
|
addElement('icon', app['icon'], doc, apel)
|
||||||
def linkres(link):
|
def linkres(link):
|
||||||
for app in apps:
|
for app in apps:
|
||||||
if app['id'] == link:
|
if app['id'] == link:
|
||||||
@ -785,13 +789,13 @@ def main():
|
|||||||
if bestver == 0:
|
if bestver == 0:
|
||||||
if app['Name'] is None:
|
if app['Name'] is None:
|
||||||
app['Name'] = app['id']
|
app['Name'] = app['id']
|
||||||
app['icon'] = ''
|
app['icon'] = None
|
||||||
if app['Disabled'] is None:
|
if app['Disabled'] is None:
|
||||||
print "WARNING: Application " + app['id'] + " has no packages"
|
print "WARNING: Application " + app['id'] + " has no packages"
|
||||||
else:
|
else:
|
||||||
if app['Name'] is None:
|
if app['Name'] is None:
|
||||||
app['Name'] = bestapk['name']
|
app['Name'] = bestapk['name']
|
||||||
app['icon'] = bestapk['icon']
|
app['icon'] = bestapk['icon'] if 'icon' in bestapk else None
|
||||||
|
|
||||||
# Sort the app list by name, then the web site doesn't have to by default.
|
# Sort the app list by name, then the web site doesn't have to by default.
|
||||||
# (we had to wait until we'd scanned the apks to do this, because mostly the
|
# (we had to wait until we'd scanned the apks to do this, because mostly the
|
||||||
@ -851,7 +855,8 @@ def main():
|
|||||||
for app in apps:
|
for app in apps:
|
||||||
if app['id'] == appid:
|
if app['id'] == appid:
|
||||||
data += app['Name'] + "\t"
|
data += app['Name'] + "\t"
|
||||||
data += app['icon'] + "\t"
|
if app['icon'] is not None:
|
||||||
|
data += app['icon'] + "\t"
|
||||||
data += app['License'] + "\n"
|
data += app['License'] + "\n"
|
||||||
break
|
break
|
||||||
f = open(os.path.join(repodirs[0], 'latestapps.dat'), 'w')
|
f = open(os.path.join(repodirs[0], 'latestapps.dat'), 'w')
|
||||||
|
Loading…
Reference in New Issue
Block a user