def apk_parse_release_filename(apkname):
+ """Parses the name of an APK file according the F-Droids APK naming
+ scheme and returns the tokens.
+
+ WARNING: Returned values don't necessarily represent the APKs actual
+ properties, the are just paresed from the file name.
+
+ :returns: A triplet containing (appid, versionCode, signer), where appid
+ should be the package name, versionCode should be the integer
+ represion of the APKs version and signer should be the first 7 hex
+ digists of the sha256 signing key fingerprint which was used to sign
+ this APK.
+ """
m = apk_release_filename_with_sigfp.match(apkname)
if m:
return m.group('appid'), m.group('vercode'), m.group('sigfp')
Extracts the first 7 hexadecimal digits of sha256 signing-key fingerprint
for a given pkcs7 signature.
- :param sig: Contents of an APK signature.
+ :param sig: Contents of an APK signing certificate.
:returns: shortened signing-key fingerprint.
"""
return signer_fingerprint(sig)[:7]
def apk_implant_signatures(apkpath, signaturefile, signedfile, manifest):
- """Implats a signature from out metadata into an APK.
+ """Implats a signature from metadata into an APK.
Note: this changes there supplied APK in place. So copy it if you
need the original to be preserved.
def v1_sort_packages(packages, repodir, fdroid_signing_key_fingerprints):
+ """Sorts the supplied list to ensure a deterministic sort order for
+ package entries in the index file. This sort-order also expresses
+ installation preference to the clients.
+ (First in this list = first to install)
+
+ :param packages: list of packages which need to be sorted before but into index file.
+ """
GROUP_DEV_SIGNED = 1
GROUP_FDROID_SIGNED = 2
packages.sort(key=v1_sort_keys)
-def make_v0(apps, apks, repodir, repodict, requestsdict):
+def make_v0(apps, apks, repodir, repodict, requestsdict, fdroid_signing_key_fingerprints):
"""
aka index.jar aka index.xml
"""
root.appendChild(element)
element.setAttribute('packageName', packageName)
- fdroid_signed = load_sigkeys(repodir)
-
for appid, appdict in apps.items():
app = metadata.App(appdict)
if apk.get('versionCode') and apk.get('packageName') == appid:
apksbyversion[apk['versionCode']].append(apk)
for versionCode, apksforver in apksbyversion.items():
- fdroidsig = fdroid_signed.get(appid, {}).get('signer')
+ fdroidsig = fdroid_signing_key_fingerprints.get(appid, {}).get('signer')
fdroid_signed_apk = None
name_match_apk = None
for x in apksforver: