Merge branch 'master' into 'docs-numpy'

# Conflicts:
#   fdroidserver/update.py
This commit is contained in:
Hans-Christoph Steiner 2021-06-25 07:25:10 +00:00
commit 578ff7069f
3 changed files with 24 additions and 27 deletions

View file

@ -1367,23 +1367,17 @@ def scan_repo_files(apkcache, repodir, knownapks, use_date_from_file=False):
return repo_files, cachechanged
def scan_apk(apk_file):
"""Scan an APK file and returns dictionary with metadata of the APK.
def scan_apk(apk_file, require_signature=True):
"""
Scans an APK file and returns dictionary with metadata of the APK.
Attention: This does *not* verify that the APK signature is correct.
Parameters
----------
apk_file
The (ideally absolute) path to the APK file
Raises
------
BuildException
Returns
-------
A dict containing APK metadata
:param apk_file: The (ideally absolute) path to the APK file
:param require_signature: Raise an exception is there is no valid
signature. Default to Ture.
:raises BuildException
:return A dict containing APK metadata
"""
apk = {
'hash': common.sha256sum(apk_file),
@ -1408,12 +1402,14 @@ def scan_apk(apk_file):
# Get the signature, or rather the signing key fingerprints
logging.debug('Getting signature of {0}'.format(os.path.basename(apk_file)))
apk['sig'] = getsig(apk_file)
if not apk['sig']:
raise BuildException(_("Failed to get APK signing key fingerprint"))
apk['signer'] = common.apk_signer_fingerprint(os.path.join(os.getcwd(),
apk_file))
if not apk.get('signer'):
raise BuildException(_("Failed to get APK signing key fingerprint"))
if require_signature:
if not apk['sig']:
raise BuildException(_("Failed to get APK signing key fingerprint"))
apk['signer'] = common.apk_signer_fingerprint(
os.path.join(os.getcwd(), apk_file)
)
if not apk.get('signer'):
raise BuildException(_("Failed to get APK signing key fingerprint"))
# Get size of the APK
apk['size'] = os.path.getsize(apk_file)