Skip to content

Commit

Permalink
add support for v4 APK signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
muhomorr authored and thestinger committed Sep 2, 2024
1 parent 60c2e15 commit f6ad1ca
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compress-apks
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ maybe_zopfli() {

export -f maybe_zopfli

find "apps/packages" -regex '.+\.apk' |
find "apps/packages" -regex '.+\.\(apk\|apk\.idsig\)' |
parallel -q ::: maybe_brotli maybe_zopfli :::: -
15 changes: 15 additions & 0 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def remove_old_pkg_variants(orig_dict):

assert pkg_props["channel"] in ["alpha", "beta", "stable", "old"]

has_v4_sigs = None

for apk_name in sorted(filter(lambda n: n.endswith(".apk"), os.listdir(pkg_path))):
apk_path = os.path.join(pkg_path, apk_name)

Expand All @@ -155,6 +157,16 @@ def remove_old_pkg_variants(orig_dict):
assert os.path.getmtime(apk_path) == os.path.getmtime(apk_gz_path)
assert os.path.getmtime(apk_path) == os.path.getmtime(apk_br_path)

if os.path.isfile(apk_path + ".idsig"):
if has_v4_sigs is False:
# at least one previously encountered APK didn't have v4 sig
raise Exception("one or more APK is missing a v4 signature: " + pkg_path)
has_v4_sigs = True
else:
if has_v4_sigs:
raise Exception("v4 signature is missing for " + apk_path)
has_v4_sigs = False

apk_hash_path = apk_path + ".sha256"

if os.path.isfile(apk_hash_path):
Expand Down Expand Up @@ -198,6 +210,9 @@ def remove_old_pkg_variants(orig_dict):
if maybe_abi in abis_dict:
pkg_abis.add(abis_dict[maybe_abi])

if has_v4_sigs:
pkg_props["hasV4Signatures"] = True

if len(pkg_abis) != 0:
pkg_props["abis"] = list(pkg_abis)

Expand Down
7 changes: 7 additions & 0 deletions import-apks.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@
shutil.copyfile(path, dest_path)
print("copied to " + dest_path)

v4_sig_path = path + ".idsig"
if os.path.isfile(v4_sig_path):
if is_split:
shutil.copy(v4_sig_path, dest_dir)
else:
shutil.copyfile(v4_sig_path, dest_dir + "/base.apk.idsig")

0 comments on commit f6ad1ca

Please sign in to comment.