mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-18 12:08:38 +00:00
A Steam Deck tester had 1.2 GB free in /home, where the setup put its 1.3 GB of generated C and objects (~/.cache/totk-setup) and RADV its shader cache (up to 1 GB, about 35 MB a minute at the title screen), while the game goes to the SD card. The setup's temp is now .setup-temp in the install folder (--temp changes it; the empty-folder check leaves it out), and totk points MESA_SHADER_CACHE_DIR at mesa-cache beside itself unless it is set. A scan of every ELF file in the release folder showed the bundled LLVM and the cryptography wheel need glibc 2.34, not the 2.31 the docs gave: make_release_linux.py now checks that floor (check_glibc), the setup's check stops below it (check.glibc_old) instead of failing on a compiler that cannot start, and the docs give both floors. The Linux notes also record the testers' results, that the Deck has the host-import extension too, and its software ASTC decoding.
85 lines
3.7 KiB
Python
85 lines
3.7 KiB
Python
"""Command line: python -m installer --base FILE --update FILE --keys FILE --lang CODE --dest DIR [--root DIR]
|
|
[--temp DIR] [--verify]
|
|
|
|
A first install needs every option. On a folder with totk-install.json (resume after a cancel or failure, or update
|
|
with a newer release) only --dest is needed: --lang defaults to the recorded language, and the game files are needed
|
|
only when the extraction has to run again. Prints JSON events on stdout (events.py). Exit code: 0 done, 1 failed,
|
|
2 bad command line, 3 cancelled (Ctrl+C or Ctrl+Break).
|
|
"""
|
|
import argparse
|
|
import hashlib
|
|
import signal
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
from . import layout as layouts
|
|
from . import state as statefile
|
|
from .events import Reporter
|
|
from .runner import Context, run_steps
|
|
from .steps import all_steps
|
|
|
|
EXIT = {'ok': 0, 'failed': 1, 'cancelled': 3}
|
|
|
|
|
|
class Parser(argparse.ArgumentParser):
|
|
def error(self, message):
|
|
Reporter().error('cli.usage', {'detail': message})
|
|
sys.exit(2)
|
|
|
|
|
|
# The temp folder inside the install folder when the layout names none (the Linux release); the check step does not
|
|
# count it when it requires an empty install folder
|
|
TEMP_IN_DEST = '.setup-temp'
|
|
|
|
|
|
def temp_folder(base, dest):
|
|
"""One temp folder per install folder, so two installs never share generated files."""
|
|
tag = hashlib.sha256(str(dest).lower().encode()).hexdigest()[:8]
|
|
return base / f'{dest.name or "root"}-{tag}'
|
|
|
|
|
|
def cancel(signum, frame):
|
|
raise KeyboardInterrupt
|
|
|
|
|
|
def main(argv=None):
|
|
ap = Parser(prog='python -m installer', description=__doc__.splitlines()[0])
|
|
ap.add_argument('--base', type=Path, help='base game, XCI or NSP')
|
|
ap.add_argument('--update', type=Path, help='1.2.1 or 1.4.3 update NSP')
|
|
ap.add_argument('--keys', type=Path, help='prod.keys')
|
|
ap.add_argument('--lang', help='game language, a Switch language code (en-US, en-GB, ja, de, ru, ...)')
|
|
ap.add_argument('--dest', type=Path, required=True, help='install folder')
|
|
ap.add_argument('--root', type=Path, help='release folder or repository (default: the folder above installer/)')
|
|
ap.add_argument('--temp', type=Path, help='temp folder (default: temp/ of the release on Windows, .setup-temp in '
|
|
'the install folder on Linux, build/install-temp in a repository)')
|
|
ap.add_argument('--verify', action='store_true', help='hash every kept file, also those this release made')
|
|
args = ap.parse_args(argv)
|
|
|
|
# The window cancels with Ctrl+Break to the installer's process group (CREATE_NEW_PROCESS_GROUP), which also reaches
|
|
# the tools it runs; Python's default for it ends the process without recording anything.
|
|
for name in ('SIGBREAK', 'SIGTERM'):
|
|
if hasattr(signal, name):
|
|
signal.signal(getattr(signal, name), cancel)
|
|
layout = layouts.find(args.root)
|
|
dest = args.dest.resolve()
|
|
base = args.temp or layout.temp
|
|
temp = temp_folder(base.resolve(), dest) if base else dest / TEMP_IN_DEST
|
|
log = temp / 'logs' / time.strftime('install-%Y%m%d-%H%M%S.log')
|
|
rep = Reporter(log_path=log)
|
|
t0 = time.monotonic()
|
|
try:
|
|
state = statefile.load(dest)
|
|
except statefile.StateError as e:
|
|
rep.error(e.id, {'path': str(e.path)})
|
|
rep.emit('end', result='failed', seconds=0)
|
|
return 1
|
|
ctx = Context(layout, dest, temp, rep, args, state=state, verify=args.verify)
|
|
steps = all_steps()
|
|
rep.emit('start', release=layout.release, mode=ctx.mode, dev=layout.dev, dest=str(dest), log=str(log),
|
|
steps=[s.id for s in steps])
|
|
result = run_steps(steps, ctx)
|
|
rep.emit('end', result=result, seconds=round(time.monotonic() - t0, 1))
|
|
rep.close()
|
|
return EXIT[result]
|