LD-Converter/tools/verify_release.py

93 lines
3.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Yayınlanan OTA manifestini ve kurulum dosyasını doğrular.
Kullanım: python verify_release.py
"""
import json
import os
import sys
import urllib.request
MANIFEST_URL = "https://ttmadethat.shop/updates/ld-converter/latest.json"
HEADERS = {"User-Agent": "LDConverterReleaseCheck/1.0"}
HERE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DIST = os.path.join(HERE, "dist-updates")
def main() -> int:
problems = []
with urllib.request.urlopen(urllib.request.Request(MANIFEST_URL, headers=HEADERS), timeout=30) as response:
raw = response.read()
if raw[:3] == b"\xef\xbb\xbf":
problems.append("manifest UTF-8 BOM iceriyor (Tauri guncelleyici okuyamaz)")
raw = raw[3:]
try:
data = json.loads(raw.decode("utf-8"))
except Exception as exc: # noqa: BLE001
print(f"MANIFEST_PARSE_FAIL: {exc}")
return 1
version = data.get("version", "")
platform = (data.get("platforms") or {}).get("windows-x86_64") or {}
url = platform.get("url", "")
signature = platform.get("signature", "")
print(f"VERSION={version}")
print(f"URL={url}")
print(f"SIGNATURE_LEN={len(signature)}")
print(f"NOTES_LEN={len(data.get('notes') or '')}")
if not url:
problems.append("manifest icinde indirme adresi yok")
setup_name = os.path.basename(url) if url else ""
display_name = setup_name.replace("_x64-setup.exe", "").replace("-", " ") + "_x64-setup.exe"
for candidate in {setup_name, display_name}:
if not candidate:
continue
local_signature_path = os.path.join(DIST, candidate + ".sig")
if os.path.exists(local_signature_path):
with open(local_signature_path, encoding="utf-8") as handle:
local_signature = handle.read().strip()
if local_signature != signature.strip():
problems.append(f"imza yerel dosyayla eslesmiyor: {candidate}")
else:
print(f"SIGNATURE_MATCH=yes ({candidate})")
break
if url:
request = urllib.request.Request(url, method="HEAD", headers=HEADERS)
with urllib.request.urlopen(request, timeout=60) as response:
remote_size = int(response.headers.get("Content-Length") or 0)
print(f"SETUP_STATUS={response.status} HEAD_SIZE={remote_size}")
if remote_size == 0:
with urllib.request.urlopen(urllib.request.Request(url, headers=HEADERS), timeout=180) as full:
remote_size = len(full.read())
print(f"SETUP_DOWNLOAD_SIZE={remote_size}")
local_setup = os.path.join(DIST, setup_name or display_name)
if os.path.exists(local_setup):
local_size = os.path.getsize(local_setup)
if local_size != remote_size:
problems.append(f"boyut uyusmuyor (yerel {local_size}, sunucu {remote_size})")
else:
print("SIZE_MATCH=yes")
else:
problems.append(f"yerel kurulum dosyasi yok: {local_setup}")
if problems:
print("PROBLEMS:")
for item in problems:
print(f" - {item}")
return 1
print("RELEASE_OK")
return 0
if __name__ == "__main__":
sys.exit(main())