🏏 alt-store index: incorporate review feedback

This commit is contained in:
Michael Pöhn 2024-04-23 17:28:30 +02:00
parent f2118b35a3
commit d00a87ed6c
No known key found for this signature in database
GPG key ID: 725F386C05529A5A
4 changed files with 28 additions and 14 deletions

View file

@ -4155,7 +4155,6 @@ def is_repo_file(filename, for_gpg_signing=False):
if isinstance(filename, str):
filename = filename.encode('utf-8', errors="surrogateescape")
ignore_files = [
b'altstore-index.json',
b'entry.jar',
b'index-v1.jar',
b'index.css',
@ -4166,7 +4165,12 @@ def is_repo_file(filename, for_gpg_signing=False):
b'index_unsigned.jar',
]
if not for_gpg_signing:
ignore_files += [b'entry.json', b'index-v1.json', b'index-v2.json']
ignore_files += [
b'altstore-index.json',
b'entry.json',
b'index-v1.json',
b'index-v2.json',
]
return (
os.path.isfile(filename)

View file

@ -130,7 +130,7 @@ def make(apps, apks, repodir, archive):
apks,
common.config,
repodir,
indent=2 if common.options.pretty else None
pretty=common.options.pretty,
)
@ -1759,14 +1759,14 @@ def get_public_key_from_jar(jar):
return public_key, public_key_fingerprint
def make_altstore(apps, apks, config, repodir, indent=None):
"""
Assemble altstore-index.json for iOS (.ipa) apps.
def make_altstore(apps, apks, config, repodir, pretty=False):
"""Assemble altstore-index.json for iOS (.ipa) apps.
builds index files based on:
https://faq.altstore.io/distribute-your-apps/make-a-source
https://faq.altstore.io/distribute-your-apps/updating-apps
"""
indent = 2 if pretty else None
# for now alt-store support is english only
for lang in ['en']:
@ -1825,7 +1825,9 @@ def make_altstore(apps, apks, config, repodir, indent=None):
# populate 'versions'
for apk in apks:
if apk['packageName'] == packageName and apk.get('apkName', '').lower().endswith('.ipa'):
if apk['packageName'] == packageName and apk.get(
'apkName', ''
).lower().endswith('.ipa'):
v = {
"version": apk["versionName"],
"date": apk["added"].isoformat(),

View file

@ -629,13 +629,20 @@ def parse_ipa(ipa_path, file_size, sha256):
if info.filename.endswith("/embedded.mobileprovision"):
print("parsing", info.filename)
with ipa_zip.open(info) as mopro_file:
mopro_content_info = asn1crypto.cms.ContentInfo.load(mopro_file.read())
mopro_content_info = asn1crypto.cms.ContentInfo.load(
mopro_file.read()
)
mopro_payload_info = mopro_content_info['content']
mopro_payload = mopro_payload_info['encap_content_info']['content'].native
mopro_payload = mopro_payload_info['encap_content_info'][
'content'
].native
mopro = biplist.readPlistFromString(mopro_payload)
# https://faq.altstore.io/distribute-your-apps/make-a-source#entitlements-array-of-strings
for entitlement in mopro.get('Entitlements', {}).keys():
if entitlement not in ["com.app.developer.team-identifier", 'application-identifier']:
if entitlement not in [
"com.app.developer.team-identifier",
'application-identifier'
]:
ipa["ipa_entitlements"].add(entitlement)
return ipa
@ -666,8 +673,7 @@ def scan_repo_for_ipas(apkcache, repodir, knownapks):
file_size = os.stat(ipa_path).st_size
if file_size == 0:
raise FDroidException(_('{path} is zero size!')
.format(path=ipa_path))
raise FDroidException(_('{path} is zero size!').format(path=ipa_path))
sha256 = common.sha256sum(ipa_path)
ipa = apkcache.get(ipa_name, {})
@ -1420,7 +1426,9 @@ def insert_localized_ios_app_metadata(apps_with_packages):
for metadata_file in (lang_dir).iterdir():
key = FASTLANE_IOS_MAP.get(metadata_file.name)
if key:
fdroidserver.update._set_localized_text_entry(app, locale, key, metadata_file)
fdroidserver.update._set_localized_text_entry(
app, locale, key, metadata_file
)
screenshots = fdroidserver.update.discover_ios_screenshots(fastlane_dir)
fdroidserver.update.copy_ios_screenshots_to_repo(screenshots, package_name)

View file

@ -875,7 +875,7 @@ class AltstoreIndexTest(unittest.TestCase):
apks,
config,
repodir,
2,
True,
)
with open(repodir / "altstore-index.json", 'r') as f: