mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 22:42:29 +03:00
Merge branch 'scan_apk' into 'master'
add require_signature param to scan_apk See merge request fdroid/fdroidserver!973
This commit is contained in:
commit
a8847207aa
1 changed files with 11 additions and 7 deletions
|
@ -1342,13 +1342,15 @@ def scan_repo_files(apkcache, repodir, knownapks, use_date_from_file=False):
|
||||||
return repo_files, cachechanged
|
return repo_files, cachechanged
|
||||||
|
|
||||||
|
|
||||||
def scan_apk(apk_file):
|
def scan_apk(apk_file, require_signature=True):
|
||||||
"""
|
"""
|
||||||
Scans an APK file and returns dictionary with metadata of the APK.
|
Scans an APK file and returns dictionary with metadata of the APK.
|
||||||
|
|
||||||
Attention: This does *not* verify that the APK signature is correct.
|
Attention: This does *not* verify that the APK signature is correct.
|
||||||
|
|
||||||
:param apk_file: The (ideally absolute) path to the APK file
|
: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
|
:raises BuildException
|
||||||
:return A dict containing APK metadata
|
:return A dict containing APK metadata
|
||||||
"""
|
"""
|
||||||
|
@ -1375,12 +1377,14 @@ def scan_apk(apk_file):
|
||||||
# Get the signature, or rather the signing key fingerprints
|
# Get the signature, or rather the signing key fingerprints
|
||||||
logging.debug('Getting signature of {0}'.format(os.path.basename(apk_file)))
|
logging.debug('Getting signature of {0}'.format(os.path.basename(apk_file)))
|
||||||
apk['sig'] = getsig(apk_file)
|
apk['sig'] = getsig(apk_file)
|
||||||
if not apk['sig']:
|
if require_signature:
|
||||||
raise BuildException(_("Failed to get APK signing key fingerprint"))
|
if not apk['sig']:
|
||||||
apk['signer'] = common.apk_signer_fingerprint(os.path.join(os.getcwd(),
|
raise BuildException(_("Failed to get APK signing key fingerprint"))
|
||||||
apk_file))
|
apk['signer'] = common.apk_signer_fingerprint(
|
||||||
if not apk.get('signer'):
|
os.path.join(os.getcwd(), apk_file)
|
||||||
raise BuildException(_("Failed to get APK signing key fingerprint"))
|
)
|
||||||
|
if not apk.get('signer'):
|
||||||
|
raise BuildException(_("Failed to get APK signing key fingerprint"))
|
||||||
|
|
||||||
# Get size of the APK
|
# Get size of the APK
|
||||||
apk['size'] = os.path.getsize(apk_file)
|
apk['size'] = os.path.getsize(apk_file)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue