Add core detection and scheduler adapters
This commit is contained in:
1 parent
f06ad804a5
commit
06a4e67e80
28 files changed
+1440
-2
No files matched your search
@@ -0,0 +1,48 @@
|
||||
"""Build a genuine Spigot test server using official BuildTools."""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
TOOL_URL = "https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar"
|
||||
|
||||
|
||||
def sha256(path):
|
||||
with path.open("rb") as stream:
|
||||
return hashlib.file_digest(stream, "sha256").hexdigest()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--java", type=lambda value: Path(value).resolve(), required=True)
|
||||
parser.add_argument("--version", choices=("1.21.1", "1.21.4", "1.21.8", "1.21.11"), required=True)
|
||||
args = parser.parse_args()
|
||||
directory = ROOT / ".test-servers" / "spigot" / args.version
|
||||
build = directory / "buildtools"
|
||||
build.mkdir(parents=True, exist_ok=True)
|
||||
jar = build / "BuildTools.jar"
|
||||
if not jar.is_file():
|
||||
partial = build / "BuildTools.download"
|
||||
subprocess.run(["curl", "-fsSL", "--retry", "2", "--connect-timeout", "10",
|
||||
"--max-time", "120", TOOL_URL, "-o", str(partial)], check=True)
|
||||
partial.replace(jar)
|
||||
log = build / "build.log"
|
||||
with log.open("wb") as output:
|
||||
subprocess.run([str(args.java), "-Dfile.encoding=UTF-8", "-Xmx3G", "-jar", str(jar),
|
||||
"--rev", args.version, "--compile", "SPIGOT", "--nogui"],
|
||||
cwd=build, stdout=output, stderr=subprocess.STDOUT, check=True)
|
||||
final = directory / "server.jar"
|
||||
shutil.copy2(build / f"spigot-{args.version}.jar", final)
|
||||
data = {"core": "spigot", "version": args.version, "buildtools_url": TOOL_URL,
|
||||
"buildtools_sha256": sha256(jar), "server_sha256": sha256(final),
|
||||
"build_log": str(log)}
|
||||
(directory / "source.json").write_text(json.dumps(data, indent=2), encoding="utf-8")
|
||||
print(final)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user