mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-19 16:20:01 -04:00
Triforce v0.3.4
The slowdown in fights and the controller whose buttons stopped arriving are fixed; the checks' file names; groundwork for Linux. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
"""Linux builder updates, the same way Windows installs (builder/setup/setup.c, scripts/make_setup_parts.py).
|
||||
|
||||
A release publishes hookshot-linux.txt. Each part is a zip named by its SHA-256 and kept on the linux-parts release, so a
|
||||
A release publishes triforce-linux.txt. Each part is a zip named by its SHA-256 and kept on the linux-parts release, so a
|
||||
part whose files did not change is not downloaded again. The player's copy lives at
|
||||
$XDG_DATA_HOME/hookshot/builder/versions/<tag> (AppRun at its root, the same layout as the AppImage). An unchanged part
|
||||
$XDG_DATA_HOME/triforce/builder/versions/<tag> (AppRun at its root, the same layout as the AppImage). An unchanged part
|
||||
is copied from the builder that is running now (the mounted AppImage, or the version installed last time).
|
||||
|
||||
tag <tag>
|
||||
@@ -22,9 +22,16 @@ import zipfile
|
||||
|
||||
from part_links import SYSROOT_PART, is_absolute_link, relative_sysroot_link
|
||||
|
||||
LIST_NAME = "hookshot-linux.txt"
|
||||
LATEST_LIST = "https://github.com/NotRexed/Hookshot/releases/latest/download/" + LIST_NAME
|
||||
LATEST_API = "https://api.github.com/repos/NotRexed/Hookshot/releases/latest"
|
||||
LIST_NAME = "triforce-linux.txt"
|
||||
REPO = "ruckus7382sfgsgdf/CBeta0.2" # (Triforce's releases)
|
||||
LATEST_LIST = "https://github.com/%s/releases/latest/download/%s" % (REPO, LIST_NAME)
|
||||
# (Triforce: the newest release, pre-releases too, as the Windows side asks: /releases/latest skips pre-releases, and
|
||||
# every Triforce release so far is one. The answer is a list of one release)
|
||||
LATEST_API = "https://api.github.com/repos/%s/releases?per_page=1" % REPO
|
||||
# (the game folder's names, nx2/make_game.py's; Hookshot's after them, for a folder that still has those)
|
||||
GAME_NAMES = ("triforce", "hookshot")
|
||||
VERSION_FILES = ("triforce_version.txt", "hookshot_version.txt")
|
||||
KEPT_EXEFS = (".triforce_exefs", ".hookshot_exefs")
|
||||
|
||||
|
||||
class Part(object):
|
||||
@@ -48,7 +55,7 @@ class Manifest(object):
|
||||
|
||||
def data_root():
|
||||
base = os.environ.get("HOOKSHOT_BUILDER_HOME") or os.environ.get("XDG_DATA_HOME") or os.path.expanduser("~/.local/share")
|
||||
return os.path.join(base, "hookshot", "builder")
|
||||
return os.path.join(base, "triforce", "builder")
|
||||
|
||||
|
||||
def parse_list(text, local=True):
|
||||
@@ -173,29 +180,34 @@ def game_version(folder):
|
||||
"""The release a folder was built with, when it still has the game files an update builds from."""
|
||||
if not folder:
|
||||
return None, False
|
||||
kept = os.path.isdir(os.path.join(folder, ".hookshot_exefs")) and os.path.isdir(os.path.join(folder, "romfs"))
|
||||
kept = (any(os.path.isdir(os.path.join(folder, name)) for name in KEPT_EXEFS)
|
||||
and os.path.isdir(os.path.join(folder, "romfs")))
|
||||
version = None
|
||||
try:
|
||||
with open(os.path.join(folder, "hookshot_version.txt"), encoding="utf-8") as f:
|
||||
for line in f:
|
||||
if line.startswith("version="):
|
||||
version = line[8:].strip() or None
|
||||
break
|
||||
except OSError:
|
||||
pass
|
||||
for name in VERSION_FILES:
|
||||
try:
|
||||
with open(os.path.join(folder, name), encoding="utf-8") as f:
|
||||
for line in f:
|
||||
if line.startswith("version="):
|
||||
version = line[8:].strip() or None
|
||||
break
|
||||
except OSError:
|
||||
continue
|
||||
break
|
||||
return version, kept
|
||||
|
||||
|
||||
def game_exe(folder):
|
||||
"""bin/hookshot under the launcher, or hookshot in a folder built before the launcher."""
|
||||
if not folder:
|
||||
"""bin/triforce under the launcher, or triforce in a folder built without one (Hookshot's names after them)."""
|
||||
if not folder or not os.path.isfile(os.path.join(folder, "image.bin")):
|
||||
return None
|
||||
nested = os.path.join(folder, "bin", "hookshot")
|
||||
if os.path.isfile(nested) and os.path.isfile(os.path.join(folder, "image.bin")):
|
||||
return nested
|
||||
flat = os.path.join(folder, "hookshot")
|
||||
if os.path.isfile(flat) and os.path.isfile(os.path.join(folder, "image.bin")):
|
||||
return flat
|
||||
for name in GAME_NAMES: # (under the launcher first: beside image.bin that name is the launcher itself)
|
||||
nested = os.path.join(folder, "bin", name)
|
||||
if os.path.isfile(nested):
|
||||
return nested
|
||||
for name in GAME_NAMES:
|
||||
flat = os.path.join(folder, name)
|
||||
if os.path.isfile(flat):
|
||||
return flat
|
||||
return None
|
||||
|
||||
|
||||
@@ -218,7 +230,7 @@ def _https(url):
|
||||
|
||||
def _request(url, timeout, limit=MAX_DOWNLOAD):
|
||||
# (no second argument: Request's second is the POST body, and a str body failed every download before connecting)
|
||||
req = urllib.request.Request(_https(url), headers={"User-Agent": "Hookshot", "Accept": "application/vnd.github+json"})
|
||||
req = urllib.request.Request(_https(url), headers={"User-Agent": "Triforce", "Accept": "application/vnd.github+json"})
|
||||
with urllib.request.urlopen(req, timeout=timeout) as response:
|
||||
return _read_at_most(response, limit)
|
||||
|
||||
@@ -238,7 +250,7 @@ def _api_download(url):
|
||||
for asset in json.loads(info.decode("utf-8")).get("assets", []):
|
||||
if asset.get("name") == name:
|
||||
req = urllib.request.Request(_https(asset.get("url")), headers={
|
||||
"User-Agent": "Hookshot", "Accept": "application/octet-stream"})
|
||||
"User-Agent": "Triforce", "Accept": "application/octet-stream"})
|
||||
with urllib.request.urlopen(req, timeout=120) as response:
|
||||
return _read_at_most(response, MAX_DOWNLOAD)
|
||||
return None
|
||||
@@ -276,6 +288,8 @@ def latest_tag(get=None):
|
||||
try:
|
||||
import json
|
||||
body = json.loads(get(LATEST_API).decode("utf-8"))
|
||||
if isinstance(body, list): # (releases?per_page=1: the newest first)
|
||||
body = body[0] if body else {}
|
||||
tag = body.get("tag_name")
|
||||
if tag:
|
||||
return tag
|
||||
@@ -529,6 +543,18 @@ def fetch_manifest(get=None):
|
||||
if override:
|
||||
with open(override, encoding="utf-8") as handle:
|
||||
return parse_list(handle.read())
|
||||
# (Triforce: the newest release's own list, by its tag, so a pre-release is found; /releases/latest is the fallback)
|
||||
try:
|
||||
import json
|
||||
body = json.loads(get(LATEST_API).decode("utf-8"))
|
||||
if isinstance(body, list):
|
||||
body = body[0] if body else {}
|
||||
tag = body.get("tag_name") or ""
|
||||
if tag and all(ch.isalnum() or ch in "._-" for ch in tag):
|
||||
url = "https://github.com/%s/releases/download/%s/%s" % (REPO, tag, LIST_NAME)
|
||||
return parse_list(get(url).decode("utf-8"), local=False)
|
||||
except Exception:
|
||||
pass
|
||||
return parse_list(get(LATEST_LIST).decode("utf-8"), local=False)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user