mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 04:46:08 +00:00
* chore(i18n): translate every missing string in all locales Adds the 87 strings the bottom-screen Dashboard and in-game stats pages introduced to all 32 locales, plus the 51 older settings strings Japanese and the 50 Chinese locales were still missing. Every locale now has all 3456 translatable strings with the same placeholders as English. Also translates 36 entries that were still English where the language does not use the English word, and makes es-419 touch_app_id use the same %1$s placeholder as English. * chore(patches): drop comments from the lines downstream patches add Removes comment lines and trailing comments from lines our patches add, with hunk headers recounted. Lines that a later patch uses as context and the upstream backport 0123 are left as they are. The gamescope, FEX, proot and xodus series still apply to their pinned sources, and the patched trees differ only in those comments. test_hud_frames now finds the HUD writer by its first declaration. * docs: credit Greenlight, Better xCloud, viture-v2, GameNative and DiRTTelemetryErrorFix These were credited only in source headers and NOTICE files. * chore: remove source comments and unused functions Removes explanatory comments from first-party Kotlin, Java, C, C++, Rust, TypeScript, Python, shell, Gradle, CMake and workflow files. License and attribution headers stay, and vendored third-party trees, generated files and license files are untouched. A shellcheck directive is kept, and udevmon's fallthrough comments became fallthrough attributes. Syntax trees and token streams match the previous sources apart from the comments and Python docstrings. Module docstrings that argparse prints are kept, and device-smoke.sh prints the same --help text from a heredoc. Also removes 37 functions and 4 fields that nothing referenced. * chore: remove comments from the Syncthing integration and the latest main sources * docs: credit Syncthing and the syncthing-android fork * chore(i18n): translate the Syncthing strings in all locales The 107 strings the Syncthing integration added are now in all 32 locales. sync_web_path_locked names the Syncthing tab by its label. * docs: credit @xXJSONDeruloXx for the HUD metric readers The CPU, GPU load, thermal and battery readers come from their PerformanceHudView pull requests #777, #877, #991, #1406 and #1573. The FusionHUD credit line is unchanged. * docs: credit the HUD metric readers to @xXJSONDeruloXx's work
184 lines
6.5 KiB
Python
184 lines
6.5 KiB
Python
#!/usr/bin/python3
|
|
import hashlib
|
|
import json
|
|
import os
|
|
import re
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
import urllib.error
|
|
import urllib.request
|
|
|
|
RELEASES = "https://api.github.com/repos/%s/releases"
|
|
SOURCES = {
|
|
"ge": ("GloriousEggroll/proton-ge-custom", re.compile(r"aarch64\.tar\.(gz|xz)$")),
|
|
"cachyos": ("CachyOS/proton-cachyos", re.compile(r"arm64\.tar\.(gz|xz)$")),
|
|
"droiddeck": ("Droid-Deck/DroidDeck-Proton", re.compile(r"aarch64\.tar\.(gz|xz)$")),
|
|
}
|
|
USER_AGENT = "droiddeck-proton-extra"
|
|
NEED_BYTES = 4 * 1024 * 1024 * 1024
|
|
|
|
|
|
def log(*args):
|
|
print("droiddeck-proton-extra:", *args, flush=True)
|
|
|
|
|
|
def fetch_json(url):
|
|
req = urllib.request.Request(url, headers={
|
|
"User-Agent": USER_AGENT, "Accept": "application/vnd.github+json"})
|
|
with urllib.request.urlopen(req, timeout=60) as r:
|
|
return json.load(r)
|
|
|
|
|
|
def pick_asset(source):
|
|
repo, pattern = SOURCES[source]
|
|
for release in fetch_json(RELEASES % repo + "?per_page=15"):
|
|
if release.get("draft") or release.get("prerelease"):
|
|
continue
|
|
assets = {a["name"]: a["browser_download_url"] for a in release.get("assets", ())}
|
|
for name in sorted(assets):
|
|
if pattern.search(name):
|
|
sums = [u for n, u in assets.items()
|
|
if n.startswith(name.split(".tar")[0]) and "sha512" in n]
|
|
return release["tag_name"], assets[name], (sums[0] if sums else None)
|
|
return None, None, None
|
|
|
|
|
|
def release_asset(source, tag):
|
|
repo, pattern = SOURCES[source]
|
|
release = fetch_json(RELEASES % repo + "/tags/" + tag)
|
|
assets = {a["name"]: a["browser_download_url"] for a in release.get("assets", ())}
|
|
for name in sorted(assets):
|
|
if pattern.search(name):
|
|
sums = [u for n, u in assets.items()
|
|
if n.startswith(name.split(".tar")[0]) and "sha512" in n]
|
|
return tag, assets[name], (sums[0] if sums else None)
|
|
raise SystemExit("droiddeck-proton-extra: %s has no ARM64 asset" % tag)
|
|
|
|
|
|
def download(url, path):
|
|
log("downloading %s" % os.path.basename(path))
|
|
rc = subprocess.call([
|
|
"curl", "-fL", "--retry", "5", "--retry-delay", "3", "--retry-connrefused",
|
|
"-C", "-", "-A", USER_AGENT, "-o", path, url])
|
|
if rc != 0:
|
|
raise SystemExit("droiddeck-proton-extra: download failed (curl %d)" % rc)
|
|
log("downloaded %.0f MB" % (os.path.getsize(path) / 1048576.0))
|
|
|
|
|
|
def verify(path, sums_url):
|
|
if not sums_url:
|
|
log("no checksum published; skipping verification")
|
|
return
|
|
try:
|
|
req = urllib.request.Request(sums_url, headers={"User-Agent": USER_AGENT})
|
|
with urllib.request.urlopen(req, timeout=60) as r:
|
|
want = r.read().decode("utf-8", "replace").split()[0].lower()
|
|
except (urllib.error.URLError, IndexError, OSError) as e:
|
|
log("could not read the checksum (%s); skipping verification" % e)
|
|
return
|
|
h = hashlib.sha512()
|
|
with open(path, "rb") as f:
|
|
for chunk in iter(lambda: f.read(4 << 20), b""):
|
|
h.update(chunk)
|
|
if h.hexdigest() != want:
|
|
os.unlink(path)
|
|
raise SystemExit("droiddeck-proton-extra: checksum mismatch; the download was deleted")
|
|
log("checksum ok")
|
|
|
|
|
|
def extract(tarball, into):
|
|
os.makedirs(into, exist_ok=True)
|
|
log("unpacking (a few minutes; nothing is shown while tar runs)")
|
|
rc = subprocess.call(["tar", "-xf", tarball, "-C", into])
|
|
if rc != 0:
|
|
raise SystemExit("droiddeck-proton-extra: tar failed (%d)" % rc)
|
|
entries = [e for e in sorted(os.listdir(into)) if not e.startswith(".")]
|
|
for entry in entries:
|
|
path = os.path.join(into, entry)
|
|
if os.path.isdir(path) and os.path.isfile(os.path.join(path, "toolmanifest.vdf")):
|
|
return path
|
|
if len(entries) == 1 and os.path.isdir(os.path.join(into, entries[0])):
|
|
return os.path.join(into, entries[0])
|
|
raise SystemExit("droiddeck-proton-extra: no Proton tree in the archive")
|
|
|
|
|
|
def installed(tools):
|
|
out = []
|
|
for entry in sorted(os.listdir(tools)) if os.path.isdir(tools) else ():
|
|
if entry.startswith("."):
|
|
continue
|
|
if os.path.isfile(os.path.join(tools, entry, "toolmanifest.vdf")):
|
|
out.append(entry)
|
|
return out
|
|
|
|
|
|
def main():
|
|
argv = sys.argv[1:]
|
|
if not argv:
|
|
raise SystemExit(__doc__ or "usage: droiddeck-proton-extra <steam root> ge|cachyos|droiddeck|<url>")
|
|
steam_root = argv.pop(0)
|
|
tools = os.path.join(steam_root, "compatibilitytools.d")
|
|
os.makedirs(tools, exist_ok=True)
|
|
|
|
if not argv or argv[0] in ("--list", "-l"):
|
|
for name in installed(tools):
|
|
log("installed: %s" % name)
|
|
return
|
|
|
|
what = argv.pop(0)
|
|
tag = None
|
|
if argv and argv[0] in ("--tag", "-t"):
|
|
argv.pop(0)
|
|
tag = argv.pop(0) if argv else None
|
|
|
|
local = None
|
|
if what in SOURCES:
|
|
tag, url, sums = release_asset(what, tag) if tag else pick_asset(what)
|
|
if not url:
|
|
raise SystemExit("droiddeck-proton-extra: no ARM64 build published for %s" % what)
|
|
log("%s -> %s" % (what, tag))
|
|
elif what.startswith("http"):
|
|
url, sums = what, None
|
|
elif os.path.isfile(what):
|
|
local, url, sums = what, None, None
|
|
log("using %s" % what)
|
|
else:
|
|
raise SystemExit(
|
|
"droiddeck-proton-extra: expected ge, cachyos, droiddeck, a URL or a tarball path, got %r" % what)
|
|
|
|
free = shutil.disk_usage(tools).free
|
|
if free < NEED_BYTES:
|
|
raise SystemExit("droiddeck-proton-extra: needs about %d GB free, has %.1f GB" % (
|
|
NEED_BYTES // (1024 ** 3), free / float(1024 ** 3)))
|
|
|
|
shutil.rmtree(os.path.join(tools, ".bannerlator-download"), ignore_errors=True)
|
|
staging = os.path.join(tools, ".droiddeck-download")
|
|
os.makedirs(staging, exist_ok=True)
|
|
if local:
|
|
tarball = local
|
|
else:
|
|
tarball = os.path.join(staging, os.path.basename(url.split("?")[0]))
|
|
download(url, tarball)
|
|
verify(tarball, sums)
|
|
|
|
unpacked = os.path.join(staging, "unpacked")
|
|
shutil.rmtree(unpacked, ignore_errors=True)
|
|
tree = extract(tarball, unpacked)
|
|
name = os.path.basename(tree)
|
|
final = os.path.join(tools, name)
|
|
if os.path.exists(final):
|
|
shutil.rmtree(final, ignore_errors=True)
|
|
os.rename(tree, final)
|
|
if local:
|
|
shutil.rmtree(os.path.join(staging, "unpacked"), ignore_errors=True)
|
|
else:
|
|
shutil.rmtree(staging, ignore_errors=True)
|
|
log("installed %s" % name)
|
|
|
|
subprocess.call(["steam-compatibility", steam_root])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|