mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 13:26:02 +00:00
Merge commit 'e1a7d527fd412b6bd78833e01fe80f515e324971' into merge/main-into-non-adreno-all
# Conflicts: # .github/workflows/build.yml # app/build.gradle # app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt # app/src/main/java/com/droiddeck/launcher/gpu/DriverPairs.kt # app/src/main/java/com/droiddeck/launcher/gpu/GpuInfo.kt # app/src/main/java/com/droiddeck/launcher/gpu/TurnipDriver.java # app/src/main/java/com/droiddeck/launcher/gpu/TurnipReleases.kt # app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java # app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt # app/src/main/java/com/droiddeck/launcher/session/SessionService.kt # app/src/main/res/values/strings.xml # app/src/test/java/com/droiddeck/launcher/ui/ComponentsPageProfileTest.kt # tools/build_local.sh # tools/gamescope/PATCHES.md # tools/gamescope/release.env # tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env # tools/linuxfs/preload/netif.c # tools/linuxfs/preload/opens.c # tools/release/runtime_inputs.py
This commit is contained in:
commit
e7b523d653
574 files changed
+41749
-2616
No files matched your search
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from check_authorship import BOT, COAUTHOR, check_revision
|
||||
|
||||
|
||||
def main():
|
||||
hook, *args = sys.argv[1:]
|
||||
payload = sys.stdin.buffer.read() if hook == "pre-push" else None
|
||||
if hook == "pre-push":
|
||||
checked = set()
|
||||
for line in payload.decode().splitlines():
|
||||
local_ref, local_sha, _, _ = line.split()
|
||||
if local_sha == "0" * 40 or local_sha in checked:
|
||||
continue
|
||||
checked.add(local_sha)
|
||||
_, errors = check_revision(local_sha)
|
||||
if errors:
|
||||
print("\n".join(errors), file=sys.stderr)
|
||||
return 1
|
||||
else:
|
||||
identity = subprocess.check_output(["git", "var", "GIT_AUTHOR_IDENT"], text=True)
|
||||
if BOT.search(identity):
|
||||
print("Bot commit author is forbidden: " + identity.strip(), file=sys.stderr)
|
||||
return 1
|
||||
message = Path(args[0])
|
||||
original = message.read_text(encoding="utf-8")
|
||||
cleaned = "".join(line for line in original.splitlines(keepends=True)
|
||||
if not (COAUTHOR.match(line) and BOT.search(line)))
|
||||
if cleaned != original:
|
||||
message.write_text(cleaned, encoding="utf-8")
|
||||
print("Removed bot co-author trailers; human credits preserved.", file=sys.stderr)
|
||||
legacy = Path(__file__).with_name("legacy-" + hook)
|
||||
if legacy.exists() and os.access(legacy, os.X_OK):
|
||||
return subprocess.run([str(legacy), *args], input=payload).returncode
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Reject bot authors and bot co-author trailers without executing reviewed code."""
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
BOT = re.compile(
|
||||
r"Claude|Anthropic|OpenAI|ChatGPT|GPT|Copilot|Cursor|Gemini|Codex|Devin|"
|
||||
r"Windsurf|Codeium|Amazon Q|Tabnine|Cody|\[bot\]|github-actions|"
|
||||
r"dependabot|renovate(?:\[bot\])?",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
COAUTHOR = re.compile(r"^\s*Co-authored-by\s*:", re.IGNORECASE)
|
||||
|
||||
|
||||
def commit_violations(commit, raw):
|
||||
header, separator, message = raw.partition(b"\n\n")
|
||||
if not separator:
|
||||
return [f"{commit}: invalid commit object"]
|
||||
authors = [line[7:] for line in header.splitlines() if line.startswith(b"author ")]
|
||||
if len(authors) != 1:
|
||||
return [f"{commit}: expected one author"]
|
||||
identity = authors[0].decode("utf-8", errors="replace")
|
||||
errors = []
|
||||
if BOT.search(identity):
|
||||
errors.append(f"{commit}: bot author: {identity}")
|
||||
for line in message.decode("utf-8", errors="replace").splitlines():
|
||||
if COAUTHOR.match(line) and BOT.search(line):
|
||||
errors.append(f"{commit}: bot co-author: {line.strip()}")
|
||||
return errors
|
||||
|
||||
|
||||
def event_violations(event):
|
||||
pr = event.get("pull_request", {})
|
||||
user = pr.get("user", {})
|
||||
errors = []
|
||||
if user.get("type") == "Bot" or BOT.search(user.get("login", "")):
|
||||
errors.append("pull request: bot authorship is forbidden")
|
||||
for field in ("title", "body"):
|
||||
for line in (pr.get(field) or "").splitlines():
|
||||
if COAUTHOR.match(line) and BOT.search(line):
|
||||
errors.append(f"pull request {field}: bot co-author trailer")
|
||||
return errors
|
||||
|
||||
|
||||
def check_revision(revision):
|
||||
commits = subprocess.check_output(["git", "rev-list", revision], text=True).splitlines()
|
||||
errors = []
|
||||
with subprocess.Popen(["git", "cat-file", "--batch"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) as process:
|
||||
for commit in commits:
|
||||
process.stdin.write((commit + "\n").encode("ascii"))
|
||||
process.stdin.flush()
|
||||
descriptor = process.stdout.readline().split()
|
||||
if len(descriptor) != 3 or descriptor[1] != b"commit":
|
||||
raise RuntimeError(f"Cannot read commit {commit}")
|
||||
size = int(descriptor[2])
|
||||
raw = process.stdout.read(size)
|
||||
if len(raw) != size or process.stdout.read(1) != b"\n":
|
||||
raise RuntimeError(f"Truncated commit {commit}")
|
||||
errors.extend(commit_violations(commit, raw))
|
||||
process.stdin.close()
|
||||
if process.wait() != 0:
|
||||
raise RuntimeError("git cat-file failed")
|
||||
return commits, errors
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("revision")
|
||||
parser.add_argument("--event")
|
||||
args = parser.parse_args()
|
||||
commits, errors = check_revision(args.revision)
|
||||
if args.event:
|
||||
with open(args.event, encoding="utf-8") as source:
|
||||
errors.extend(event_violations(json.load(source)))
|
||||
for error in errors:
|
||||
print(f"::error::{error}", file=sys.stderr)
|
||||
if errors:
|
||||
return 1
|
||||
print(f"Human authorship verified for {len(commits)} commits.")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Install shared worktree hooks while preserving existing executable hooks."""
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
MARKER = "# DroidDeck human authorship hook"
|
||||
|
||||
|
||||
def install():
|
||||
common = Path(subprocess.check_output(["git", "rev-parse", "--git-common-dir"], text=True).strip()).resolve()
|
||||
configured = subprocess.run(["git", "config", "--get", "core.hooksPath"], capture_output=True, text=True)
|
||||
hooks = Path(configured.stdout.strip()).resolve() if configured.returncode == 0 else common / "hooks"
|
||||
target = common / "authorship-hooks"
|
||||
hooks.mkdir(parents=True, exist_ok=True)
|
||||
target.mkdir(parents=True, exist_ok=True)
|
||||
for name in ("check_authorship.py", "authorship_hook.py"):
|
||||
shutil.copyfile(Path(__file__).with_name(name), target / name)
|
||||
for name in ("prepare-commit-msg", "commit-msg", "pre-push"):
|
||||
path = hooks / name
|
||||
if path.exists() and MARKER not in path.read_text(errors="replace"):
|
||||
legacy = target / ("legacy-" + name)
|
||||
if legacy.exists():
|
||||
raise RuntimeError(f"Refusing to replace existing saved hook: {legacy}")
|
||||
shutil.copy2(path, legacy)
|
||||
path.write_text(
|
||||
'#!/bin/sh\n' + MARKER + '\n'
|
||||
'exec python3 "$(git rev-parse --git-common-dir)/authorship-hooks/authorship_hook.py" '
|
||||
+ name + ' "$@"\n'
|
||||
)
|
||||
path.chmod(0o755)
|
||||
print(f"Human authorship hooks installed in {hooks}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
install()
|
||||
@@ -13,14 +13,24 @@ from zipfile import ZipFile
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
MANIFEST = Path('app/build/runtime-inputs.json')
|
||||
PACKS = Path('app/build/packs')
|
||||
# Runtime trees shipped as add-on packs (tools/packs/build.sh) rather than inside the APK.
|
||||
PACKED = {'assets/linuxfs/usr/local/lib/droiddeck-xbox/': 'xbox', 'assets/linuxfs/usr/local/lib/droiddeck-comet/': 'comet',
|
||||
'assets/directaudio/': 'directaudio'}
|
||||
PACKED_FILES = {'lib/arm64-v8a/libproot.so': ('proot', 'libproot.so'),
|
||||
'lib/arm64-v8a/libproot-loader.so': ('proot', 'libproot-loader.so')}
|
||||
PACKED_LIBRARIES = ['lib/arm64-v8a/libopencv_java4.so', 'lib/arm64-v8a/libmediapipe_tasks_jni.so']
|
||||
PACK_NAMES = ['proot', 'directaudio', 'tracking', 'xbox', 'comet']
|
||||
SOURCE_PATHS = ['app/build.gradle', 'app/src/main/cpp/fakeinput_steam.cpp', 'app/src/main/assets/pulseaudio.tzst',
|
||||
'tools/linuxfs', 'tools/proot', 'tools/aaudio-sink', 'tools/directaudio',
|
||||
'tools/gamescope/release.env', 'tools/droiddeck-esync/release.env',
|
||||
'tools/mangoapp', 'tools/msitools', 'tools/comet', 'tools/build_local.sh',
|
||||
'tools/powervr', 'tools/hybris', 'tools/dxvk', 'tools/vulkan-wsi',
|
||||
'tools/pipewire', 'tools/xbox',
|
||||
'tools/release/runtime_inputs.py', 'app/src/main/assets/desktop-removal',
|
||||
'tools/quest', 'tools/vr/src', 'tools/vr/driver_droiddeck', 'tools/vr/layer', 'tools/vr/build.sh',
|
||||
'app/src/main/cpp/waylandcomp/src/headpose_shm.h',
|
||||
'app/src/main/cpp/venc/venc_proto.h',
|
||||
'app/src/main/cpp/waylandcomp/src/spatialpose_shm.h',
|
||||
'app/src/main/cpp/adrenotools/src/hook/kgsl.h',
|
||||
'app/src/main/assets/graphics_driver/adrenotools-turnip25.1.0.tzst']
|
||||
@@ -69,7 +79,8 @@ def required():
|
||||
for name in ['turnip26.3.0-a6xx', 'turnip26.3.0-quest2']]
|
||||
paths += ['assets/linuxfs/' + name for name in ['libfakeinput.so', 'libblsession.so',
|
||||
'libblfastpath.so', 'libssbs.so', 'usr/local/bin/droiddeck-clipboard',
|
||||
'usr/local/bin/gamescope', 'usr/local/lib/droiddeck/uruntime']]
|
||||
'usr/local/bin/gamescope', 'usr/local/lib/droiddeck/uruntime',
|
||||
'usr/local/lib/droiddeck-pipewire.tzst']]
|
||||
for arch in ['x86_64', 'i386']:
|
||||
paths += ['assets/linuxfs/' + arch + '/' + lib for lib in ['libfakeinput.so', 'libblsession.so']]
|
||||
paths += ['assets/linuxfs/x86_64/' + lib for lib in
|
||||
@@ -93,6 +104,9 @@ def required():
|
||||
['mangoapp', 'libfmt.so.10', 'libspdlog.so.1.13', 'libglfw.so.3', 'libtraceevent.so.1', 'libtracefs.so.1']]
|
||||
paths += ['assets/linuxfs/usr/local/lib/droiddeck-comet/' + name for name in
|
||||
['comet', 'GalaxyCommunication.exe', 'update-permissions.exe', 'LICENSE', 'version']]
|
||||
paths += ['assets/linuxfs/usr/local/lib/droiddeck-xbox/' + name for name in
|
||||
['xodus-cli', 'xodus-service', 'version', 'backend.lock.json', 'runtime.lock.json', 'LICENSE.xodus', 'LICENSE.nexus', 'LICENSE.LGPL-2.1', 'LICENSE.nghttp2',
|
||||
'windows/xgameruntime.dll', 'windows/winhttp.dll', 'windows/windows.web.dll', 'windows/twinapi.appcore.dll', 'windows/libnghttp2.dll']]
|
||||
for driver in ['linux-wine11', 'linux-wine11-systhread']:
|
||||
paths += ['assets/directaudio/' + driver + '/' + name for name in
|
||||
['aarch64-unix/winedirectaudio.so', 'aarch64-windows/winedirectaudio.drv',
|
||||
@@ -167,10 +181,49 @@ def verify(root=ROOT):
|
||||
return data
|
||||
|
||||
|
||||
def pack_digests(root, name):
|
||||
path = root / PACKS / (name + '.tar.zst')
|
||||
if not path.is_file():
|
||||
raise ValueError('Missing add-on pack ' + name + '. Run tools/packs/build.sh app/build/packs.')
|
||||
process = subprocess.Popen(['zstd', '-dc', str(path)], stdout=subprocess.PIPE)
|
||||
digests = {}
|
||||
try:
|
||||
with tarfile.open(fileobj=process.stdout, mode='r|') as archive:
|
||||
for member in archive:
|
||||
if member.isfile():
|
||||
digests[member.name] = hashlib.sha256(archive.extractfile(member).read()).hexdigest()
|
||||
finally:
|
||||
process.stdout.close()
|
||||
if process.wait():
|
||||
raise ValueError('Invalid add-on pack ' + name)
|
||||
return digests
|
||||
|
||||
|
||||
def check_apk(apk, root=ROOT):
|
||||
data = verify(root)
|
||||
packs = {name: pack_digests(root, name) for name in PACK_NAMES}
|
||||
with ZipFile(apk) as package:
|
||||
names = set(package.namelist())
|
||||
for library in PACKED_LIBRARIES:
|
||||
if library in names:
|
||||
raise ValueError('APK still carries ' + library + ', which the tracking pack provides')
|
||||
if library.rsplit('/', 1)[1] not in packs['tracking']:
|
||||
raise ValueError('Tracking pack missing ' + library)
|
||||
for name, output in data['outputs'].items():
|
||||
if name in PACKED_FILES:
|
||||
pack, rel = PACKED_FILES[name]
|
||||
if name in names:
|
||||
raise ValueError('APK still carries ' + name + ', which the ' + pack + ' pack provides')
|
||||
if packs[pack].get(rel) != output['sha256']:
|
||||
raise ValueError('Add-on pack ' + pack + ' is missing or has a stale ' + name)
|
||||
continue
|
||||
prefix = next((p for p in PACKED if name.startswith(p)), None)
|
||||
if prefix:
|
||||
if name in names:
|
||||
raise ValueError('APK still carries ' + name + ', which the ' + PACKED[prefix] + ' pack provides')
|
||||
if packs[PACKED[prefix]].get(name[len(prefix):]) != output['sha256']:
|
||||
raise ValueError('Add-on pack ' + PACKED[prefix] + ' is missing or has a stale ' + name)
|
||||
continue
|
||||
try:
|
||||
content = package.read(name)
|
||||
except KeyError:
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Publish the APK result only after trusted source and metadata validation."""
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from check_authorship import check_revision, event_violations
|
||||
|
||||
|
||||
def api(path, *args):
|
||||
return json.loads(subprocess.check_output(["gh", "api", path, *args], text=True))
|
||||
|
||||
|
||||
def compilation_state(run, jobs):
|
||||
for job in jobs:
|
||||
if job["name"] in ("Compile and test APK", "Build APK"):
|
||||
if job["status"] != "completed":
|
||||
return "pending"
|
||||
return "success" if job["conclusion"] == "success" else "failure"
|
||||
return "failure" if run["status"] == "completed" else "pending"
|
||||
|
||||
|
||||
def fetch_source(ref, sha):
|
||||
subprocess.run(["git", "fetch", "--no-tags", "origin", ref], check=True)
|
||||
fetched = subprocess.check_output(["git", "rev-parse", "FETCH_HEAD"], text=True).strip()
|
||||
if fetched != sha:
|
||||
raise RuntimeError("Pull request changed while validating")
|
||||
|
||||
|
||||
def documentation_only(sha):
|
||||
base = subprocess.check_output(["git", "merge-base", "origin/main", sha], text=True).strip()
|
||||
paths = subprocess.check_output(["git", "diff", "--no-renames", "--name-only", "-z", base, sha]).split(b"\0")
|
||||
return all(path.endswith(b".md") or path in (b"LICENSE", b".gitignore") for path in paths if path)
|
||||
|
||||
|
||||
def main():
|
||||
with open(os.environ["GITHUB_EVENT_PATH"], encoding="utf-8") as source:
|
||||
event = json.load(source)
|
||||
repo = os.environ["GITHUB_REPOSITORY"]
|
||||
event_name = os.environ["GITHUB_EVENT_NAME"]
|
||||
pr_number = event.get("number") if event_name == "pull_request_target" else None
|
||||
if event_name == "workflow_dispatch":
|
||||
pr_number = int(event.get("inputs", {}).get("pr_number") or 0)
|
||||
run = event.get("workflow_run", {})
|
||||
expected = event.get("pull_request", {}).get("head", {}).get("sha")
|
||||
if event_name == "workflow_run":
|
||||
expected = run["head_sha"]
|
||||
if run["event"] == "pull_request":
|
||||
prs = api(f"repos/{repo}/commits/{expected}/pulls")
|
||||
pr_number = next((pr["number"] for pr in prs
|
||||
if pr["state"] == "open" and pr["head"]["sha"] == expected), None)
|
||||
if pr_number is None:
|
||||
print("Ignoring a superseded or closed pull request build")
|
||||
return
|
||||
elif run["head_branch"] != event["repository"]["default_branch"]:
|
||||
return
|
||||
if pr_number:
|
||||
pr = api(f"repos/{repo}/pulls/{pr_number}")
|
||||
sha = pr["head"]["sha"]
|
||||
if pr["state"] != "open" or (expected and sha != expected):
|
||||
print("Ignoring a superseded or closed pull request event")
|
||||
return
|
||||
ref = f"refs/pull/{pr_number}/head"
|
||||
source_event = "pull_request"
|
||||
else:
|
||||
pr = None
|
||||
sha = expected or event.get("after") or os.environ["GITHUB_SHA"]
|
||||
ref = sha
|
||||
source_event = "push"
|
||||
state = "failure"
|
||||
description = "APK source validation failed"
|
||||
target = f"https://github.com/{repo}/actions/runs/{os.environ['GITHUB_RUN_ID']}"
|
||||
try:
|
||||
fetch_source(ref, sha)
|
||||
commits, errors = check_revision(sha)
|
||||
if pr:
|
||||
errors.extend(event_violations({"pull_request": pr}))
|
||||
if errors:
|
||||
raise RuntimeError("\n".join(errors))
|
||||
print(f"Source and metadata validated for {len(commits)} commits")
|
||||
if pr and documentation_only(sha):
|
||||
state = "success"
|
||||
description = "Source validated; no APK source changes"
|
||||
return
|
||||
query = urlencode({"head_sha": sha, "event": source_event, "per_page": 20})
|
||||
runs = api(f"repos/{repo}/actions/workflows/build.yml/runs?{query}")["workflow_runs"]
|
||||
runs = [item for item in runs if item["head_sha"] == sha]
|
||||
if runs:
|
||||
latest = max(runs, key=lambda item: item["id"])
|
||||
jobs = api(f"repos/{repo}/actions/runs/{latest['id']}/jobs?per_page=100")["jobs"]
|
||||
state = compilation_state(latest, jobs)
|
||||
target = latest["html_url"]
|
||||
else:
|
||||
state = "pending"
|
||||
description = {"pending": "Source validated; awaiting APK compilation",
|
||||
"success": "Source validation and APK compilation passed",
|
||||
"failure": "APK compilation failed"}[state]
|
||||
finally:
|
||||
api(f"repos/{repo}/statuses/{sha}", "--method", "POST",
|
||||
"-f", "context=Build APK", "-f", f"state={state}",
|
||||
"-f", f"description={description}", "-f", f"target_url={target}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user