Commit e8306fbd authored by Hans-Christoph Steiner's avatar Hans-Christoph Steiner
Browse files

Merge branch 'master' into 'master'

fixes for `fdroid update` when dealing with lots of random APKs

Closes #515

See merge request !536
parents be54f1e8 60ee69b8
Pipeline #26018393 passed with stage
in 16 minutes and 37 seconds
......@@ -126,7 +126,7 @@ lint_format_safety_checks:
script:
- apk add --no-cache bash dash ca-certificates python3
- python3 -m ensurepip
- pip3 install pycodestyle pyflakes pylint safety
- pip3 install pycodestyle pyflakes 'pylint<2.0' safety
- export EXITVALUE=0
- ./hooks/pre-commit || export EXITVALUE=1
- safety check --full-report || export EXITVALUE=1
......
......@@ -146,7 +146,7 @@ __complete_install() {
__complete_update() {
opts="-c -v -q -b -i -I -e -w"
lopts="--create-metadata --verbose --quiet --buildreport
--interactive --icons --editor --wiki --pretty --clean --delete-unknown
--icons --wiki --pretty --clean --delete-unknown
--nosign --rename-apks --use-date-from-apk"
case "${prev}" in
-e|--editor)
......
......@@ -2009,7 +2009,7 @@ def ensure_final_value(packageName, arsc, value):
res_id = int('0x' + value[1:], 16)
res_id = arsc.get_id(packageName, res_id)[1]
returnValue = arsc.get_string(packageName, res_id)[1]
except ValueError:
except (ValueError, TypeError):
pass
return returnValue
......
......@@ -1081,6 +1081,11 @@ def scan_apk(apk_file):
def _get_apk_icons_src(apkfile, icon_name):
"""Extract the paths to the app icon in all available densities
The folder name is normally generated by the Android Tools, but
there is nothing that prevents people from using whatever DPI
names they make up. Android will just ignore them, so we should
too.
"""
icons_src = dict()
density_re = re.compile(r'^res/(.*)/{}\.(png|xml)$'.format(icon_name))
......@@ -1089,9 +1094,9 @@ def _get_apk_icons_src(apkfile, icon_name):
m = density_re.match(filename)
if m:
folder = m.group(1).split('-')
if len(folder) > 1 and folder[1].endswith('dpi'):
try:
density = screen_resolutions[folder[1]]
else:
except Exception:
density = '160'
icons_src[density] = m.group(0)
if icons_src.get('-1') is None and '160' in icons_src:
......@@ -1226,11 +1231,27 @@ def scan_apk_androguard(apk, apkfile):
raise BuildException(_("Invalid APK"))
apk['packageName'] = apkobject.get_package()
apk['versionCode'] = int(apkobject.get_androidversion_code())
xml = apkobject.get_android_manifest_xml()
androidmanifest_xml = apkobject.xml['AndroidManifest.xml']
if len(xml.nsmap) > 0:
# one of them surely will be the Android one, or its corrupt
xmlns = '{http://schemas.android.com/apk/res/android}'
else:
# strange but sometimes the namespace is blank. This seems to
# only happen with the Bromite/Chromium APKs
xmlns = '{}'
vcstr = androidmanifest_xml.get(xmlns + 'versionCode')
if vcstr.startswith('0x'):
apk['versionCode'] = int(vcstr, 16)
else:
apk['versionCode'] = int(vcstr)
apk['name'] = apkobject.get_app_name()
apk['versionName'] = common.ensure_final_value(apk['packageName'], arsc,
apkobject.get_androidversion_name())
androidmanifest_xml.get(xmlns + 'versionName'))
minSdkVersion = _sanitize_sdk_version(apkobject.get_min_sdk_version())
if minSdkVersion is not None:
......@@ -1251,7 +1272,8 @@ def scan_apk_androguard(apk, apkfile):
if resource_id:
icon_name = arsc.get_id(apk['packageName'], icon_id)[1]
else:
icon_name = os.path.splitext(os.path.basename(apkobject.get_app_icon()))[0]
# don't use 'anydpi' aka 0xFFFE aka 65534 since it is XML
icon_name = os.path.splitext(os.path.basename(apkobject.get_app_icon(max_dpi=65534 - 1)))[0]
apk['icons_src'] = _get_apk_icons_src(apkfile, icon_name)
arch_re = re.compile("^lib/(.*)/.*$")
......@@ -1260,14 +1282,9 @@ def scan_apk_androguard(apk, apkfile):
apk['nativecode'] = []
apk['nativecode'].extend(sorted(list(arch)))
xml = apkobject.get_android_manifest_xml()
xmlns = xml.nsmap.get('android')
if not xmlns:
xmlns = 'http://schemas.android.com/apk/res/android'
for item in xml.findall('uses-permission'):
name = str(item.attrib['{' + xmlns + '}name'])
maxSdkVersion = item.attrib.get('{' + xmlns + '}maxSdkVersion')
name = str(item.attrib[xmlns + 'name'])
maxSdkVersion = item.attrib.get(xmlns + 'maxSdkVersion')
maxSdkVersion = int(maxSdkVersion) if maxSdkVersion else None
permission = UsesPermission(
name,
......@@ -1282,8 +1299,8 @@ def scan_apk_androguard(apk, apkfile):
apk['uses-permission'].append(permission)
for item in xml.findall('uses-permission-sdk-23'):
name = str(item.attrib['{' + xmlns + '}name'])
maxSdkVersion = item.attrib.get('{' + xmlns + '}maxSdkVersion')
name = str(item.attrib[xmlns + 'name'])
maxSdkVersion = item.attrib.get(xmlns + 'maxSdkVersion')
maxSdkVersion = int(maxSdkVersion) if maxSdkVersion else None
permission_sdk_23 = UsesPermissionSdk23(
name,
......@@ -1292,7 +1309,7 @@ def scan_apk_androguard(apk, apkfile):
apk['uses-permission-sdk-23'].append(permission_sdk_23)
for item in xml.findall('uses-feature'):
key = '{' + xmlns + '}name'
key = xmlns + 'name'
if key not in item.attrib:
continue
feature = str(item.attrib[key])
......@@ -1300,7 +1317,7 @@ def scan_apk_androguard(apk, apkfile):
and feature != "android.hardware.screen.landscape":
if feature.startswith("android.feature."):
feature = feature[16:]
required = item.attrib.get('{' + xmlns + '}required')
required = item.attrib.get(xmlns + 'required')
if required is None or required == 'true':
apk['features'].append(feature)
......@@ -1851,13 +1868,8 @@ def main():
help=_("Delete APKs and/or OBBs without metadata from the repo"))
parser.add_argument("-b", "--buildreport", action="store_true", default=False,
help=_("Report on build data status"))
parser.add_argument("-i", "--interactive", default=False, action="store_true",
help=_("Interactively ask about things that need updating."))
parser.add_argument("-I", "--icons", action="store_true", default=False,
help=_("Resize all the icons exceeding the max pixel size and exit"))
parser.add_argument("-e", "--editor", default="/etc/alternatives/editor",
help=_("Specify editor to use in interactive mode. Default is {path}")
.format(path='/etc/alternatives/editor'))
parser.add_argument("-w", "--wiki", default=False, action="store_true",
help=_("Update the wiki"))
parser.add_argument("--pretty", action="store_true", default=False,
......
......@@ -5,9 +5,9 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: fdroidserver 1.0.0-95-gd7af22b\n"
"Project-Id-Version: fdroidserver 1.0.6-70-g54bc858\n"
"Report-Msgid-Bugs-To: https://gitlab.com/fdroid/fdroidserver/issues\n"
"POT-Creation-Date: 2018-02-13 09:01+0100\n"
"POT-Creation-Date: 2018-07-13 11:05+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -211,7 +211,7 @@ msgstr ""
msgid "Also warn about formatting issues, like rewritemeta -l"
msgstr ""
#: ../fdroidserver/common.py
#: ../fdroidserver/common.py ../fdroidserver/build.py
#, python-brace-format
msgid "Android SDK '{path}' does not have '{dirname}' installed!"
msgstr ""
......@@ -283,6 +283,10 @@ msgstr ""
msgid "Build generated by `fdroid import` - remove disable line once ready"
msgstr ""
#: ../fdroidserver/checkupdates.py
msgid "Build metadata git repo has uncommited changes!"
msgstr ""
#: ../fdroidserver/build.py
msgid "Build only the latest version of each package"
msgstr ""
......@@ -487,6 +491,10 @@ msgstr ""
msgid "Description of length {length} is over the {limit} char limit"
msgstr ""
#: ../fdroidserver/nightly.py
msgid "Do not deploy the new files to the repo"
msgstr ""
#: ../fdroidserver/mirror.py
#, python-brace-format
msgid "Do not include \"{path}\" in URL!"
......@@ -496,6 +504,10 @@ msgstr ""
msgid "Do not prompt for Android SDK path, just fail"
msgstr ""
#: ../fdroidserver/nightly.py
msgid "Do not remove the private keys generated from the keystore"
msgstr ""
#: ../fdroidserver/build.py
msgid "Don't create a source tarball, useful when testing a build"
msgstr ""
......@@ -785,11 +797,12 @@ msgid "Interact with the repo HTTP server"
msgstr ""
#: ../fdroidserver/update.py
msgid "Interactively ask about things that need updating."
msgid "Invalid APK"
msgstr ""
#: ../fdroidserver/update.py
msgid "Invalid APK"
#: ../fdroidserver/lint.py ../fdroidserver/checkupdates.py
#, python-brace-format
msgid "Invalid VercodeOperation: {field}"
msgstr ""
#: ../fdroidserver/metadata.py
......@@ -839,6 +852,11 @@ msgstr ""
msgid "Invalid package name {0}"
msgstr ""
#: ../fdroidserver/common.py
#, python-brace-format
msgid "Invalid redirect to non-HTTPS: {before} -> {after} "
msgstr ""
#: ../fdroidserver/metadata.py
#, python-brace-format
msgid "Invalid versionCode: \"{versionCode}\" is not an integer!"
......@@ -1015,6 +1033,10 @@ msgstr ""
msgid "Old APK signature failed to verify: {path}"
msgstr ""
#: ../fdroid
msgid "Old, deprecated name for fdroid deploy"
msgstr ""
#: ../fdroidserver/update.py
#, python-brace-format
msgid "Only PNG and JPEG are supported for graphics, found: {path}"
......@@ -1040,6 +1062,11 @@ msgstr ""
msgid "Override path for repo APKs (default: ./repo)"
msgstr ""
#: ../fdroidserver/index.py
#, python-brace-format
msgid "Overriding blank versionName in {apkfilename} from metadata: {version}"
msgstr ""
#: ../fdroidserver/common.py
#, python-brace-format
msgid "Parsing manifest at '{path}'"
......@@ -1214,6 +1241,10 @@ msgstr ""
msgid "Rewriting '{appid}' to '{path}'"
msgstr ""
#: ../fdroidserver/checkupdates.py
msgid "Run on git repo that has uncommitted changes"
msgstr ""
#: ../fdroidserver/lint.py
msgid "Run rewritemeta to fix formatting"
msgstr ""
......@@ -1325,19 +1356,6 @@ msgstr ""
msgid "Specify an identity file to provide to SSH for rsyncing"
msgstr ""
#: ../fdroidserver/update.py
msgid "Specify editor to use in interactive mode. Default "
msgstr ""
#, c-format
msgid "Specify editor to use in interactive mode. Default %s"
msgstr ""
#: ../fdroidserver/update.py
#, python-brace-format
msgid "Specify editor to use in interactive mode. Default is {path}"
msgstr ""
#: ../fdroidserver/build.py
msgid "Specify that we're running on the build server"
msgstr ""
......@@ -1552,6 +1570,21 @@ msgstr ""
msgid "Update the wiki"
msgstr ""
#: ../fdroidserver/checkupdates.py
#, python-brace-format
msgid "UpdateCheckData has invalid URL: {url}"
msgstr ""
#: ../fdroidserver/lint.py
#, python-brace-format
msgid "UpdateCheckData must use HTTPS URL: {url}"
msgstr ""
#: ../fdroidserver/lint.py
#, python-brace-format
msgid "UpdateCheckData not a valid URL: {url}"
msgstr ""
#: /usr/lib/python3.5/optparse.py /usr/lib/python3.6/optparse.py
msgid "Usage"
msgstr ""
......@@ -1589,6 +1622,11 @@ msgstr ""
msgid "Using Java's jarsigner, not recommended for verifying APKs! Use apksigner"
msgstr ""
#: ../fdroidserver/common.py
#, python-brace-format
msgid "Using androguard from \"{path}\""
msgstr ""
#: ../fdroidserver/init.py
#, python-brace-format
msgid "Using existing keystore \"{path}\""
......@@ -1603,6 +1641,10 @@ msgstr ""
msgid "Valid commands are:"
msgstr ""
#: ../fdroidserver/verify.py
msgid "Verify against locally cached copy rather than redownloading."
msgstr ""
#: ../fdroid
msgid "Verify the integrity of downloaded packages"
msgstr ""
......@@ -1727,6 +1769,11 @@ msgstr ""
msgid "deleting: repo/{apkfilename}"
msgstr ""
#: ../fdroidserver/common.py
#, python-brace-format
msgid "deployeded build logs to '{path}'"
msgstr ""
#: /usr/lib/python3.5/argparse.py /usr/lib/python3.6/argparse.py
#, python-format
msgid "dest= is required for options like %r"
......@@ -1751,6 +1798,11 @@ msgstr ""
msgid "expected one argument"
msgstr ""
#: ../fdroidserver/common.py
#, python-brace-format
msgid "failed deploying build logs to '{path}'"
msgstr ""
#: ../fdroid
msgid "fdroid [-h|--help|--version] <command> [<args>]"
msgstr ""
......@@ -1948,6 +2000,14 @@ msgstr ""
msgid "signed APK, either a file-path or HTTPS URL."
msgstr ""
#: ../fdroidserver/common.py
msgid "skip deploying full build logs: log content is empty"
msgstr ""
#: ../fdroidserver/common.py
msgid "skip deploying full build logs: not enabled in config"
msgstr ""
#: ../fdroidserver/update.py
#, python-brace-format
msgid "skipping source tarball: {path}"
......@@ -1957,6 +2017,11 @@ msgstr ""
msgid "srclibs missing name and/or @"
msgstr ""
#: ../fdroidserver/common.py
#, python-brace-format
msgid "supplied timestamp value '{timestamp}' is not a unix timestamp"
msgstr ""
#: /usr/lib/python3.5/argparse.py /usr/lib/python3.6/argparse.py
#, python-format
msgid "the following arguments are required: %s"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment