DSH-Arch-Setup/test/cloudflared-artifact.test.py
Шурупов Илья Викторович cf9443753e Add one-command Arch DSH setup
Package the portable DSH profiles, local plugins, desktop integration, Firefox wrapper, and ownership-aware installer lifecycle. Bundle checksum-pinned OpenVSCode, editor extensions, translation assets, and cloudflared so unreliable upstream artifact downloads cannot break a clean installation.
2026-09-12 19:13:36 +03:00

20 lines
935 B
Python

import hashlib
import os
import subprocess
from pathlib import Path
repository = Path(__file__).resolve().parent.parent
version, relative, expected_hash = (repository / "manifests" / "cloudflared.tsv").read_text().strip().split("\t")
binary = repository / relative
actual_hash = hashlib.sha256(binary.read_bytes()).hexdigest()
if actual_hash != expected_hash:
raise RuntimeError("cloudflared checksum mismatch")
if os.stat(binary).st_mode & 0o111 == 0:
raise RuntimeError("cloudflared is not executable")
actual_version = subprocess.check_output([binary, "--version"], text=True).split()[2]
if actual_version != version:
raise RuntimeError("cloudflared version mismatch")
license_file = repository / "vendor" / "dsh-ui-translate" / "THIRD_PARTY_LICENSES" / "Apache-2.0.txt"
if "Apache License" not in license_file.read_text():
raise RuntimeError("Apache-2.0 license missing")
print("cloudflared artifact test passed")