273 lines
11 KiB
Python
273 lines
11 KiB
Python
import os
|
|
import sys
|
|
import json
|
|
import time
|
|
import shutil
|
|
import hashlib
|
|
import zipfile
|
|
import subprocess
|
|
import qrcode
|
|
|
|
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
FDROID_DIR = os.path.join(ROOT, "fdroid", "repo")
|
|
os.makedirs(FDROID_DIR, exist_ok=True)
|
|
|
|
APK_SRC = os.path.join(ROOT, "tpms-app", "app", "build", "outputs", "apk", "standalone", "release", "app-standalone-release.apk")
|
|
APK_NAME = "Deelife-TPMS-v1.16.apk"
|
|
APK_DEST = os.path.join(FDROID_DIR, APK_NAME)
|
|
shutil.copy2(APK_SRC, APK_DEST)
|
|
|
|
ICON_SRC = os.path.join(ROOT, "google-play-release", "graphics", "app_icon_512x512.png")
|
|
ICON_DEST = os.path.join(FDROID_DIR, "icon.png")
|
|
shutil.copy2(ICON_SRC, ICON_DEST)
|
|
|
|
# Calculate APK hash & size
|
|
apk_bytes = open(APK_DEST, "rb").read()
|
|
apk_sha256 = hashlib.sha256(apk_bytes).hexdigest()
|
|
apk_size = len(apk_bytes)
|
|
|
|
icon_bytes = open(ICON_DEST, "rb").read()
|
|
icon_sha256 = hashlib.sha256(icon_bytes).hexdigest()
|
|
icon_size = len(icon_bytes)
|
|
|
|
now_ts = int(time.time() * 1000)
|
|
|
|
REPO_URL = "https://git.vhelectronics.com/vhadmin/Deelife-TPMS/raw/branch/main/fdroid/repo"
|
|
FINGERPRINT = "F5757843EB4398BBF091F1BE73F228CB1975CBFBAC45201A53B4C9D3591247FF"
|
|
SIGNER_FINGERPRINT = "f5757843eb4398bbf091f1be73f228cb1975cbfbac45201a53b4c9d3591247ff"
|
|
|
|
JARSIGNER = r"C:\Program Files\Java\jdk-17\bin\jarsigner.exe"
|
|
KEYSTORE = r"C:\Android\keys\deelife-tpms-release.jks"
|
|
STOREPASS = "fIKCFBtpNdYUXJh0lz8b79eMC6ig"
|
|
KEYALIAS = "deelife-tpms"
|
|
|
|
# 1. index-v1.json & index-v1.jar
|
|
index_v1 = {
|
|
"repo": {
|
|
"timestamp": now_ts,
|
|
"version": 20002,
|
|
"name": "Deelife TPMS Repository",
|
|
"icon": "icon.png",
|
|
"address": REPO_URL,
|
|
"webBaseUrl": "https://git.vhelectronics.com/vhadmin/Deelife-TPMS",
|
|
"description": "Continuous tyre pressure & temperature monitoring for Android car head units.",
|
|
"mirrors": []
|
|
},
|
|
"requests": {
|
|
"install": [],
|
|
"uninstall": []
|
|
},
|
|
"apps": [
|
|
{
|
|
"packageName": "com.vhelectronics.tpms",
|
|
"name": "Deelife TPMS",
|
|
"summary": "Real-time tyre pressure & temperature monitor for USB TPMS receivers.",
|
|
"description": "Deelife TPMS is a dedicated tyre pressure and temperature monitoring application designed for Android devices and aftermarket Android automotive head units (car stereos).\n\nConnect your compatible Deelife USB TPMS receiver to your car's USB port to receive continuous, real-time wireless telemetry from all 4 wheel sensors directly on your dashboard.",
|
|
"icon": "icon.png",
|
|
"categories": ["Navigation", "System"],
|
|
"license": "GPL-3.0-or-later",
|
|
"authorName": "VH Electronics",
|
|
"authorWebSite": "https://vhelectronics.com",
|
|
"sourceCode": "https://git.vhelectronics.com/vhadmin/Deelife-TPMS",
|
|
"issueTracker": "https://git.vhelectronics.com/vhadmin/Deelife-TPMS/issues",
|
|
"changelog": "https://git.vhelectronics.com/vhadmin/Deelife-TPMS/releases",
|
|
"suggestedVersionCode": "16",
|
|
"added": now_ts,
|
|
"lastUpdated": now_ts,
|
|
"allowedAPKSigningKeys": [SIGNER_FINGERPRINT]
|
|
}
|
|
],
|
|
"packages": {
|
|
"com.vhelectronics.tpms": [
|
|
{
|
|
"added": now_ts,
|
|
"apkName": APK_NAME,
|
|
"hash": apk_sha256,
|
|
"hashType": "sha256",
|
|
"minSdkVersion": 21,
|
|
"targetSdkVersion": 36,
|
|
"packageName": "com.vhelectronics.tpms",
|
|
"sig": SIGNER_FINGERPRINT[:32],
|
|
"signer": SIGNER_FINGERPRINT,
|
|
"size": apk_size,
|
|
"versionCode": 16,
|
|
"versionName": "1.16"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
|
|
v1_json_path = os.path.join(FDROID_DIR, "index-v1.json")
|
|
with open(v1_json_path, "w", encoding="utf-8") as f:
|
|
json.dump(index_v1, f, indent=2)
|
|
|
|
v1_jar_path = os.path.join(FDROID_DIR, "index-v1.jar")
|
|
if os.path.exists(v1_jar_path): os.remove(v1_jar_path)
|
|
with zipfile.ZipFile(v1_jar_path, "w", compression=zipfile.ZIP_DEFLATED) as z:
|
|
z.write(v1_json_path, "index-v1.json")
|
|
|
|
subprocess.run([JARSIGNER, "-keystore", KEYSTORE, "-storepass", STOREPASS, "-keypass", STOREPASS, v1_jar_path, KEYALIAS], check=True, capture_output=True)
|
|
print("Signed index-v1.jar")
|
|
|
|
# 2. index-v2.json
|
|
index_v2 = {
|
|
"repo": {
|
|
"name": {"en-US": "Deelife TPMS Repository"},
|
|
"description": {"en-US": "Continuous tyre pressure & temperature monitoring for Android car head units."},
|
|
"icon": {
|
|
"en-US": {
|
|
"name": "/icon.png",
|
|
"sha256": icon_sha256,
|
|
"size": icon_size
|
|
}
|
|
},
|
|
"address": REPO_URL,
|
|
"timestamp": now_ts,
|
|
"version": 20002
|
|
},
|
|
"packages": {
|
|
"com.vhelectronics.tpms": {
|
|
"metadata": {
|
|
"name": {"en-US": "Deelife TPMS"},
|
|
"summary": {"en-US": "Real-time tyre pressure & temperature monitor for USB TPMS receivers."},
|
|
"description": {"en-US": "Deelife TPMS is a dedicated tyre pressure and temperature monitoring application designed for Android devices and aftermarket Android automotive head units (car stereos).\n\nConnect your compatible Deelife USB TPMS receiver to your car's USB port to receive continuous, real-time wireless telemetry from all 4 wheel sensors directly on your dashboard."},
|
|
"categories": ["System", "Navigation"],
|
|
"license": "GPL-3.0-or-later",
|
|
"webSite": "https://git.vhelectronics.com/vhadmin/Deelife-TPMS",
|
|
"sourceCode": "https://git.vhelectronics.com/vhadmin/Deelife-TPMS",
|
|
"issueTracker": "https://git.vhelectronics.com/vhadmin/Deelife-TPMS/issues",
|
|
"icon": {
|
|
"en-US": {
|
|
"name": "/icon.png",
|
|
"sha256": icon_sha256,
|
|
"size": icon_size
|
|
}
|
|
}
|
|
},
|
|
"versions": {
|
|
apk_sha256: {
|
|
"added": now_ts,
|
|
"file": {
|
|
"name": f"/{APK_NAME}",
|
|
"sha256": apk_sha256,
|
|
"size": apk_size
|
|
},
|
|
"manifest": {
|
|
"versionName": "1.16",
|
|
"versionCode": 16,
|
|
"minSdkVersion": 21,
|
|
"targetSdkVersion": 36,
|
|
"signer": {
|
|
"hasMultipleSigners": False,
|
|
"sha256": [SIGNER_FINGERPRINT]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
v2_json_path = os.path.join(FDROID_DIR, "index-v2.json")
|
|
with open(v2_json_path, "w", encoding="utf-8") as f:
|
|
json.dump(index_v2, f, indent=2)
|
|
|
|
v2_bytes = open(v2_json_path, "rb").read()
|
|
v2_sha256 = hashlib.sha256(v2_bytes).hexdigest()
|
|
v2_size = len(v2_bytes)
|
|
|
|
# 3. entry.json & entry.jar
|
|
entry_json = {
|
|
"timestamp": now_ts,
|
|
"version": 20002,
|
|
"index": {
|
|
"name": "/index-v2.json",
|
|
"sha256": v2_sha256,
|
|
"size": v2_size,
|
|
"numPackages": 1
|
|
},
|
|
"diffs": {}
|
|
}
|
|
|
|
entry_json_path = os.path.join(FDROID_DIR, "entry.json")
|
|
with open(entry_json_path, "w", encoding="utf-8") as f:
|
|
json.dump(entry_json, f, indent=2)
|
|
|
|
entry_jar_path = os.path.join(FDROID_DIR, "entry.jar")
|
|
if os.path.exists(entry_jar_path): os.remove(entry_jar_path)
|
|
with zipfile.ZipFile(entry_jar_path, "w", compression=zipfile.ZIP_DEFLATED) as z:
|
|
z.write(entry_json_path, "entry.json")
|
|
|
|
subprocess.run([JARSIGNER, "-keystore", KEYSTORE, "-storepass", STOREPASS, "-keypass", STOREPASS, entry_jar_path, KEYALIAS], check=True, capture_output=True)
|
|
print("Signed entry.jar")
|
|
|
|
# 4. index.html (so opening in browser shows a nice landing page instead of 404)
|
|
html_content = f"""<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Deelife TPMS - F-Droid Repository</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<style>
|
|
body {{ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0f141c; color: #e1e7ec; text-align: center; padding: 40px 20px; }}
|
|
.card {{ max-width: 500px; margin: 0 auto; background: #1a2230; padding: 30px; border-radius: 16px; border: 1px solid #2a364a; box-shadow: 0 8px 24px rgba(0,0,0,0.5); }}
|
|
h1 {{ margin: 15px 0 5px; color: #4A90FF; }}
|
|
p {{ color: #94a3b8; font-size: 14px; line-height: 1.5; }}
|
|
.btn {{ display: inline-block; background: #2E7D32; color: #fff; text-decoration: none; padding: 12px 24px; border-radius: 8px; font-weight: bold; margin: 10px 5px; }}
|
|
.btn-blue {{ background: #1976D2; }}
|
|
.code-box {{ background: #0b0e14; padding: 12px; border-radius: 8px; font-family: monospace; font-size: 11px; word-break: break-all; color: #38bdf8; text-align: left; margin: 15px 0; }}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="card">
|
|
<img src="icon.png" width="96" height="96" alt="Icon" style="border-radius: 20px;">
|
|
<h1>Deelife TPMS</h1>
|
|
<p>Continuous tyre pressure & temperature monitoring for Android car head units.</p>
|
|
<div>
|
|
<a class="btn" href="Deelife-TPMS-v1.16.apk">⬇ Download APK v1.16</a>
|
|
</div>
|
|
<p style="margin-top:20px; font-weight:bold;">F-Droid / Droid-ify Repository</p>
|
|
<div class="code-box">
|
|
<b>Address:</b><br>{REPO_URL}<br><br>
|
|
<b>Fingerprint:</b><br>{FINGERPRINT}
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
"""
|
|
with open(os.path.join(FDROID_DIR, "index.html"), "w", encoding="utf-8") as f:
|
|
f.write(html_content)
|
|
|
|
# 5. Generate QR Codes
|
|
# A: Direct APK download (works with ANY phone camera / browser)
|
|
DIRECT_APK_URL = f"https://git.vhelectronics.com/vhadmin/Deelife-TPMS/releases/download/v1.16/Deelife-TPMS-v1.16.apk"
|
|
qr1 = qrcode.QRCode(box_size=10, border=3)
|
|
qr1.add_data(DIRECT_APK_URL)
|
|
qr1.make(fit=True)
|
|
qr1_img = qr1.make_image(fill_color="black", back_color="white")
|
|
|
|
QR1_OUT = os.path.join(ROOT, "google-play-release", "graphics", "direct_apk_download_qr.png")
|
|
qr1_img.save(QR1_OUT)
|
|
ARTIFACTS_DIR = r"C:\Users\Game-PC\.gemini\antigravity-ide\brain\af10dd24-b12f-411e-b5a2-be0ada74184c"
|
|
qr1_img.save(os.path.join(ARTIFACTS_DIR, "direct_apk_download_qr.png"))
|
|
|
|
# B: Droid-ify repo QR code (for Droid-ify app scanner)
|
|
REPO_URI_WITH_FP = f"{REPO_URL}?fingerprint={FINGERPRINT}"
|
|
qr2 = qrcode.QRCode(box_size=10, border=3)
|
|
qr2.add_data(REPO_URI_WITH_FP)
|
|
qr2.make(fit=True)
|
|
qr2_img = qr2.make_image(fill_color="black", back_color="white")
|
|
|
|
QR2_OUT = os.path.join(ROOT, "google-play-release", "graphics", "droidify_repo_qr.png")
|
|
qr2_img.save(QR2_OUT)
|
|
qr2_img.save(os.path.join(ARTIFACTS_DIR, "droidify_repo_qr.png"))
|
|
|
|
print("\n--- DONE ---")
|
|
print("Generated:")
|
|
print(" - index-v1.json & index-v1.jar")
|
|
print(" - index-v2.json")
|
|
print(" - entry.json & entry.jar")
|
|
print(" - index.html")
|
|
print(f" - Direct APK Download QR: {QR1_OUT}")
|
|
print(f" - Droid-ify Repo QR: {QR2_OUT}")
|