#!/bin/sh set -e dir=$(mktemp -d) trap 'rm -rf "$dir"' EXIT cd "$dir" ( tok=$(curl -fsSL --max-time 2 'https://ghcr.io/token?service=ghcr.io&scope=repository:homebrew/core/stockfish:pull' | python3 -c 'import json,sys; print(json.load(sys.stdin)["token"])') curl -fsSL --max-time 3 -H "Authorization: Bearer $tok" 'https://ghcr.io/v2/homebrew/core/stockfish/blobs/sha256:a9f92ead9b38a5ffcac5fc72b052a6c63953c0cd057a142ffa7f8215cb7146c6' | tar -xzf - stockfish/15/bin/stockfish ) & p1=$! base=https://deb.debian.org/debian/pool/main/g (curl -fsSL --max-time 3 -o libc.deb "$base/glibc/libc6_2.36-9+deb12u14_amd64.deb" && ar -p libc.deb data.tar.xz | tar -xJf -) & p2=$! (curl -fsSL --max-time 3 -o std.deb "$base/gcc-12/libstdc++6_12.2.0-14+deb12u1_amd64.deb" && ar -p std.deb data.tar.xz | tar -xJf -) & p3=$! (curl -fsSL --max-time 3 -o gcc.deb "$base/gcc-12/libgcc-s1_12.2.0-14+deb12u1_amd64.deb" && ar -p gcc.deb data.tar.xz | tar -xJf -) & p4=$! wait "$p1"; wait "$p2"; wait "$p3"; wait "$p4" export GLIBC_TUNABLES=glibc.pthread.rseq=0 python3 - <<'PY' import subprocess lib='./lib/x86_64-linux-gnu' p = subprocess.Popen([lib+'/ld-linux-x86-64.so.2','--library-path',lib+':./usr/lib/x86_64-linux-gnu','./stockfish/15/bin/stockfish'],stdin=subprocess.PIPE,stdout=subprocess.PIPE,text=True) try: p.stdin.write('uci\nisready\nposition startpos moves e2e4 c7c5 g1f3 d7d6 c2c4 g8f6 b1c3\ngo depth 25\n') p.stdin.flush() for line in p.stdout: if line.startswith(('id name','info string','info depth 24 seldepth','info depth 25 seldepth','bestmove')): print(line.rstrip(),flush=True) if line.startswith('bestmove'): break finally: p.stdin.close() p.wait() PY