2021-11-15 03:39:57 +00:00
|
|
|
#!/usr/bin/env nix-shell
|
2022-01-02 22:03:54 +00:00
|
|
|
#!nix-shell -I nixpkgs=../../../../ -i python3 -p "python3.withPackages (ps: with ps; [ requests nix-prefetch-github ])" -p "git"
|
2021-11-15 03:39:57 +00:00
|
|
|
|
|
|
|
import json
|
|
|
|
import sys
|
2022-01-02 22:03:54 +00:00
|
|
|
import subprocess
|
2021-11-15 03:39:57 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
SCRIPT_PATH = Path(__file__).absolute().parent
|
|
|
|
HASHES_PATH = SCRIPT_PATH / "hashes.json"
|
|
|
|
CORES = {
|
|
|
|
"atari800": {"repo": "libretro-atari800"},
|
|
|
|
"beetle-gba": {"repo": "beetle-gba-libretro"},
|
|
|
|
"beetle-lynx": {"repo": "beetle-lynx-libretro"},
|
|
|
|
"beetle-ngp": {"repo": "beetle-ngp-libretro"},
|
|
|
|
"beetle-pce-fast": {"repo": "beetle-pce-fast-libretro"},
|
|
|
|
"beetle-pcfx": {"repo": "beetle-pcfx-libretro"},
|
|
|
|
"beetle-psx": {"repo": "beetle-psx-libretro"},
|
|
|
|
"beetle-saturn": {"repo": "beetle-saturn-libretro"},
|
2021-11-22 02:07:54 +00:00
|
|
|
"beetle-snes": {"repo": "beetle-bsnes-libretro"},
|
2021-11-15 03:39:57 +00:00
|
|
|
"beetle-supergrafx": {"repo": "beetle-supergrafx-libretro"},
|
|
|
|
"beetle-vb": {"repo": "beetle-vb-libretro"},
|
2021-11-22 02:07:54 +00:00
|
|
|
"beetle-wswan": {"repo": "beetle-wswan-libretro"},
|
2021-11-23 00:14:04 +00:00
|
|
|
"blastem": {"repo": "blastem"},
|
2021-11-15 03:39:57 +00:00
|
|
|
"bluemsx": {"repo": "bluemsx-libretro"},
|
2021-11-22 21:14:27 +00:00
|
|
|
"bsnes": {"repo": "bsnes-libretro"},
|
2021-11-22 21:50:00 +00:00
|
|
|
"bsnes-hd": {"repo": "bsnes-hd", "owner": "DerKoun"},
|
2021-11-15 03:39:57 +00:00
|
|
|
"bsnes-mercury": {"repo": "bsnes-mercury"},
|
2022-01-21 21:40:38 +00:00
|
|
|
"citra": {
|
|
|
|
"repo": "citra",
|
|
|
|
"fetch_submodules": True,
|
|
|
|
"deep_clone": True,
|
|
|
|
"leave_dot_git": True,
|
|
|
|
},
|
2022-01-23 16:06:05 +00:00
|
|
|
"citra-canary": {
|
|
|
|
"repo": "citra",
|
|
|
|
"fetch_submodules": True,
|
|
|
|
"deep_clone": True,
|
|
|
|
"leave_dot_git": True,
|
|
|
|
"rev": "canary",
|
|
|
|
},
|
2021-11-15 03:39:57 +00:00
|
|
|
"desmume": {"repo": "desmume"},
|
|
|
|
"desmume2015": {"repo": "desmume2015"},
|
|
|
|
"dolphin": {"repo": "dolphin"},
|
|
|
|
"dosbox": {"repo": "dosbox-libretro"},
|
|
|
|
"eightyone": {"repo": "81-libretro"},
|
|
|
|
"fbalpha2012": {"repo": "fbalpha2012"},
|
|
|
|
"fbneo": {"repo": "fbneo"},
|
|
|
|
"fceumm": {"repo": "libretro-fceumm"},
|
|
|
|
"flycast": {"repo": "flycast"},
|
|
|
|
"fmsx": {"repo": "fmsx-libretro"},
|
|
|
|
"freeintv": {"repo": "freeintv"},
|
|
|
|
"gambatte": {"repo": "gambatte-libretro"},
|
|
|
|
"genesis-plus-gx": {"repo": "Genesis-Plus-GX"},
|
|
|
|
"gpsp": {"repo": "gpsp"},
|
|
|
|
"gw": {"repo": "gw-libretro"},
|
|
|
|
"handy": {"repo": "libretro-handy"},
|
|
|
|
"hatari": {"repo": "hatari"},
|
|
|
|
"mame": {"repo": "mame"},
|
|
|
|
"mame2000": {"repo": "mame2000-libretro"},
|
|
|
|
"mame2003": {"repo": "mame2003-libretro"},
|
|
|
|
"mame2003-plus": {"repo": "mame2003-plus-libretro"},
|
|
|
|
"mame2010": {"repo": "mame2010-libretro"},
|
|
|
|
"mame2015": {"repo": "mame2015-libretro"},
|
|
|
|
"mame2016": {"repo": "mame2016-libretro"},
|
2021-11-22 16:45:32 +00:00
|
|
|
"melonds": {"repo": "melonds"},
|
2021-11-22 16:49:42 +00:00
|
|
|
"mesen": {"repo": "mesen"},
|
2021-11-22 17:02:42 +00:00
|
|
|
"mesen-s": {"repo": "mesen-s"},
|
2021-11-15 03:39:57 +00:00
|
|
|
"meteor": {"repo": "meteor-libretro"},
|
|
|
|
"mgba": {"repo": "mgba"},
|
|
|
|
"mupen64plus": {"repo": "mupen64plus-libretro-nx"},
|
|
|
|
"neocd": {"repo": "neocd_libretro"},
|
|
|
|
"nestopia": {"repo": "nestopia"},
|
|
|
|
"np2kai": {"repo": "NP2kai", "owner": "AZO234", "fetch_submodules": True},
|
|
|
|
"o2em": {"repo": "libretro-o2em"},
|
|
|
|
"opera": {"repo": "opera-libretro"},
|
|
|
|
"parallel-n64": {"repo": "parallel-n64"},
|
2021-11-27 19:05:34 +00:00
|
|
|
"pcsx2": {"repo": "pcsx2"},
|
2021-11-15 03:39:57 +00:00
|
|
|
"pcsx_rearmed": {"repo": "pcsx_rearmed"},
|
|
|
|
"picodrive": {"repo": "picodrive", "fetch_submodules": True},
|
2021-11-17 22:16:02 +00:00
|
|
|
"play": {"repo": "Play-", "owner": "jpd002", "fetch_submodules": True},
|
2021-11-15 03:39:57 +00:00
|
|
|
"ppsspp": {"repo": "ppsspp", "owner": "hrydgard", "fetch_submodules": True},
|
|
|
|
"prboom": {"repo": "libretro-prboom"},
|
|
|
|
"prosystem": {"repo": "prosystem-libretro"},
|
|
|
|
"quicknes": {"repo": "QuickNES_Core"},
|
|
|
|
"sameboy": {"repo": "sameboy"},
|
|
|
|
"scummvm": {"repo": "scummvm"},
|
|
|
|
"smsplus-gx": {"repo": "smsplus-gx"},
|
|
|
|
"snes9x": {"repo": "snes9x", "owner": "snes9xgit"},
|
|
|
|
"snes9x2002": {"repo": "snes9x2002"},
|
|
|
|
"snes9x2005": {"repo": "snes9x2005"},
|
|
|
|
"snes9x2010": {"repo": "snes9x2010"},
|
|
|
|
"stella": {"repo": "stella", "owner": "stella-emu"},
|
|
|
|
"stella2014": {"repo": "stella2014-libretro"},
|
2021-11-22 02:14:17 +00:00
|
|
|
"swanstation": {"repo": "swanstation"},
|
2021-11-15 03:39:57 +00:00
|
|
|
"tgbdual": {"repo": "tgbdual-libretro"},
|
|
|
|
"thepowdertoy": {"repo": "ThePowderToy"},
|
|
|
|
"tic80": {"repo": "tic-80", "fetch_submodules": True},
|
|
|
|
"vba-m": {"repo": "vbam-libretro"},
|
2021-11-22 02:07:54 +00:00
|
|
|
"vba-next": {"repo": "vba-next"},
|
2021-11-15 03:39:57 +00:00
|
|
|
"vecx": {"repo": "libretro-vecx"},
|
|
|
|
"virtualjaguar": {"repo": "virtualjaguar-libretro"},
|
|
|
|
"yabause": {"repo": "yabause"},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def info(*msg):
|
|
|
|
print(*msg, file=sys.stderr)
|
|
|
|
|
|
|
|
|
2022-01-02 22:03:54 +00:00
|
|
|
def get_repo_hash_fetchFromGitHub(
|
|
|
|
repo,
|
|
|
|
owner="libretro",
|
|
|
|
deep_clone=False,
|
|
|
|
fetch_submodules=False,
|
|
|
|
leave_dot_git=False,
|
2022-01-23 16:06:05 +00:00
|
|
|
rev=None,
|
2022-01-02 22:03:54 +00:00
|
|
|
):
|
|
|
|
extra_args = []
|
|
|
|
if deep_clone:
|
|
|
|
extra_args.append("--deep-clone")
|
|
|
|
if fetch_submodules:
|
|
|
|
extra_args.append("--fetch-submodules")
|
|
|
|
if leave_dot_git:
|
|
|
|
extra_args.append("--leave-dot-git")
|
2022-01-23 16:06:05 +00:00
|
|
|
if rev:
|
|
|
|
extra_args.append("--rev")
|
|
|
|
extra_args.append(rev)
|
2022-01-02 22:03:54 +00:00
|
|
|
result = subprocess.run(
|
|
|
|
["nix-prefetch-github", owner, repo, *extra_args],
|
|
|
|
check=True,
|
|
|
|
capture_output=True,
|
|
|
|
text=True,
|
2021-11-15 03:39:57 +00:00
|
|
|
)
|
2022-01-21 21:40:38 +00:00
|
|
|
j = json.loads(result.stdout)
|
|
|
|
# Remove False values
|
|
|
|
return {k: v for k, v in j.items() if v}
|
2021-11-15 03:39:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_repo_hash(fetcher="fetchFromGitHub", **kwargs):
|
|
|
|
if fetcher == "fetchFromGitHub":
|
|
|
|
return get_repo_hash_fetchFromGitHub(**kwargs)
|
|
|
|
else:
|
|
|
|
raise ValueError(f"Unsupported fetcher: {fetcher}")
|
|
|
|
|
|
|
|
|
2021-11-22 02:07:54 +00:00
|
|
|
def get_repo_hashes(cores_to_update=[]):
|
|
|
|
with open(HASHES_PATH) as f:
|
|
|
|
repo_hashes = json.loads(f.read())
|
2021-11-15 03:39:57 +00:00
|
|
|
|
|
|
|
for core, repo in CORES.items():
|
2021-11-22 02:07:54 +00:00
|
|
|
if core in cores_to_update:
|
|
|
|
info(f"Getting repo hash for '{core}'...")
|
|
|
|
repo_hashes[core] = get_repo_hash(**repo)
|
|
|
|
else:
|
|
|
|
info(f"Skipping '{core}'...")
|
2021-11-15 03:39:57 +00:00
|
|
|
|
|
|
|
return repo_hashes
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2021-11-22 02:07:54 +00:00
|
|
|
# If you don't want to update all cores, pass the name of the cores you
|
|
|
|
# want to update on the command line. E.g.:
|
|
|
|
# $ ./update.py citra snes9x
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
cores_to_update = sys.argv[1:]
|
|
|
|
else:
|
|
|
|
cores_to_update = CORES.keys()
|
|
|
|
|
|
|
|
repo_hashes = get_repo_hashes(cores_to_update)
|
2021-11-15 03:39:57 +00:00
|
|
|
info(f"Generating '{HASHES_PATH}'...")
|
|
|
|
with open(HASHES_PATH, "w") as f:
|
2021-11-22 02:07:54 +00:00
|
|
|
f.write(json.dumps(dict(sorted(repo_hashes.items())), indent=4))
|
2021-11-16 20:29:16 +00:00
|
|
|
f.write("\n")
|
2021-11-15 03:39:57 +00:00
|
|
|
info("Finished!")
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|