mirror of
https://github.com/freedoom/freedoom.git
synced 2025-09-01 13:25:46 -04:00
The `freedoom1.wad` and `freedoom2.wad` files are shipped in the same .zip, so we can just construct the URL once and be done with it.
74 lines
2 KiB
Python
Executable file
74 lines
2 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
import hashlib
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
# This script is pretty hard-coded to assuming the three IWADs and
|
|
# URLs present as of the Freedoom 0.9 release. Not much can be done
|
|
# about that, but it will have to be changed whenever the project
|
|
# expands or switches web host.
|
|
|
|
iwads = {
|
|
"freedm.wad": {"description": "Deathmatch IWAD", "name": "FreeDM"},
|
|
"freedoom1.wad": {
|
|
"description": "Ultimate Doom compatible IWAD",
|
|
"name": "Freedoom: Phase 1",
|
|
},
|
|
"freedoom2.wad": {
|
|
"description": "Doom II compatible IWAD",
|
|
"name": "Freedoom: Phase 2",
|
|
},
|
|
}
|
|
|
|
# Find the version to generate JSON for:
|
|
|
|
version = os.getenv("VERSION")
|
|
|
|
# Find the file to append objects to:
|
|
|
|
json_file = os.getenv("JSON")
|
|
|
|
if version is None:
|
|
sys.stderr.write("Version is not specified for release\n")
|
|
sys.exit(1)
|
|
if version.startswith("v"):
|
|
# Strip the leading "v" from versioning
|
|
version = version[1:]
|
|
|
|
if json_file is None:
|
|
sys.stderr.write("JSON file not specified!\n")
|
|
sys.exit(1)
|
|
|
|
for filename in iwads:
|
|
with open(os.path.join("wads", filename), "rb") as f:
|
|
data = f.read()
|
|
# TODO: MD5 is long-deprecated throughout the industry; this hash
|
|
# will be removed in a future version.
|
|
iwads[filename]["md5"] = hashlib.md5(data).hexdigest()
|
|
iwads[filename]["sha3"] = hashlib.sha3_512(data).hexdigest()
|
|
iwads[filename]["blake2b"] = hashlib.blake2b(data).hexdigest()
|
|
|
|
iwads[filename]["version"] = version
|
|
|
|
iwads["freedoom1.wad"]["url"] = (
|
|
"https://github.com/freedoom/freedoom/releases/download/v"
|
|
+ version
|
|
+ "/freedoom-"
|
|
+ version
|
|
+ ".zip"
|
|
)
|
|
iwads["freedoom2.wad"]["url"] = iwads["freedoom1.wad"]["url"]
|
|
iwads["freedm.wad"]["url"] = (
|
|
"https://github.com/freedoom/freedoom/releases/download/v"
|
|
+ version
|
|
+ "/freedm-"
|
|
+ version
|
|
+ ".zip"
|
|
)
|
|
|
|
with open(json_file, "w") as f:
|
|
json.dump(iwads, f, indent=2, sort_keys=True)
|
|
f.write("\n")
|