generate_update_json.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. #!/usr/bin/env python3
  2. import datetime
  3. import hashlib
  4. import json
  5. import os
  6. from subprocess import Popen
  7. OPENMPT_VERSION_MAJORMAJOR = os.environ['OPENMPT_VERSION_MAJORMAJOR']
  8. OPENMPT_VERSION_MAJOR = os.environ['OPENMPT_VERSION_MAJOR']
  9. OPENMPT_VERSION_MINOR = os.environ['OPENMPT_VERSION_MINOR']
  10. OPENMPT_VERSION_MINORMINOR = os.environ['OPENMPT_VERSION_MINORMINOR']
  11. SVNVERSION = os.environ['SVNVERSION']
  12. IS_RELEASE = True if OPENMPT_VERSION_MINORMINOR == "00" else False
  13. if IS_RELEASE:
  14. download_base_url = "https://download.openmpt.org/archive/openmpt/"
  15. announcement_url = "https://openmpt.org/openmpt-" + OPENMPT_VERSION_MAJORMAJOR + "-" + OPENMPT_VERSION_MAJOR + "-" + OPENMPT_VERSION_MINOR + "-" + OPENMPT_VERSION_MINORMINOR + "-released"
  16. changelog_url = "https://openmpt.org/release_notes/History.txt"
  17. else:
  18. download_base_url = "https://builds.openmpt.org/builds/auto/openmpt/pkg.win/"
  19. announcement_url = "https://builds.openmpt.org/builds/auto/openmpt/pkg.win/"
  20. changelog_url = "https://source.openmpt.org/browse/openmpt/?op=revision&rev=" + SVNVERSION
  21. os.chdir(os.path.dirname(os.path.abspath(__file__)))
  22. os.chdir("..")
  23. plainversion = OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR
  24. version = OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR if IS_RELEASE else OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-" + SVNVERSION
  25. def hash_file_sha512(filename):
  26. sha512 = hashlib.sha512()
  27. with open(filename, "rb") as f:
  28. sha512.update(f.read())
  29. return sha512.hexdigest()
  30. def hash_file_sha3_512(filename):
  31. sha3_512 = hashlib.sha3_512()
  32. with open(filename, "rb") as f:
  33. sha3_512.update(f.read())
  34. return sha3_512.hexdigest()
  35. update = {
  36. "url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-Setup.exe",
  37. "checksums": {
  38. "SHA-512": hash_file_sha512("installer/OpenMPT-" + plainversion + "-Setup.exe"),
  39. "SHA3-512": hash_file_sha3_512("installer/OpenMPT-" + plainversion + "-Setup.exe"),
  40. },
  41. "filename": "OpenMPT-" + version + "-Setup.exe",
  42. "autoupdate_installer": {
  43. "arguments": [ "/SP-", "/SILENT", "/NOCANCEL", "/AUTOUPDATE=yes" ]
  44. },
  45. "autoupdate_archive": None
  46. }
  47. with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-Setup.update.json", "wb") as f:
  48. f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
  49. f.close()
  50. update = {
  51. "url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-x86.zip",
  52. "checksums": {
  53. "SHA-512": hash_file_sha512("installer/OpenMPT-" + plainversion + "-portable-x86.zip"),
  54. "SHA3-512": hash_file_sha3_512("installer/OpenMPT-" + plainversion + "-portable-x86.zip"),
  55. },
  56. "filename": "OpenMPT-" + version + "-portable-x86.zip",
  57. "autoupdate_installer": None,
  58. "autoupdate_archive": {
  59. "subfolder": "",
  60. "restartbinary": "OpenMPT.exe"
  61. }
  62. }
  63. with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-x86.update.json", "wb") as f:
  64. f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
  65. f.close()
  66. update = {
  67. "url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-x86-legacy.zip",
  68. "checksums": {
  69. "SHA-512": hash_file_sha512("installer/OpenMPT-" + plainversion + "-portable-x86-legacy.zip"),
  70. "SHA3-512": hash_file_sha3_512("installer/OpenMPT-" + plainversion + "-portable-x86-legacy.zip"),
  71. },
  72. "filename": "OpenMPT-" + version + "-portable-x86-legacy.zip",
  73. "autoupdate_installer": None,
  74. "autoupdate_archive": {
  75. "subfolder": "",
  76. "restartbinary": "OpenMPT.exe"
  77. }
  78. }
  79. with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-x86-legacy.update.json", "wb") as f:
  80. f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
  81. f.close()
  82. update = {
  83. "url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-amd64.zip",
  84. "checksums": {
  85. "SHA-512": hash_file_sha512("installer/OpenMPT-" + plainversion + "-portable-amd64.zip"),
  86. "SHA3-512": hash_file_sha3_512("installer/OpenMPT-" + plainversion + "-portable-amd64.zip"),
  87. },
  88. "filename": "OpenMPT-" + version + "-portable-amd64.zip",
  89. "autoupdate_installer": None,
  90. "autoupdate_archive": {
  91. "subfolder": "",
  92. "restartbinary": "OpenMPT.exe"
  93. }
  94. }
  95. with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-amd64.update.json", "wb") as f:
  96. f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
  97. f.close()
  98. update = {
  99. "url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-amd64-legacy.zip",
  100. "checksums": {
  101. "SHA-512": hash_file_sha512("installer/OpenMPT-" + plainversion + "-portable-amd64-legacy.zip"),
  102. "SHA3-512": hash_file_sha3_512("installer/OpenMPT-" + plainversion + "-portable-amd64-legacy.zip"),
  103. },
  104. "filename": "OpenMPT-" + version + "-portable-amd64-legacy.zip",
  105. "autoupdate_installer": None,
  106. "autoupdate_archive": {
  107. "subfolder": "",
  108. "restartbinary": "OpenMPT.exe"
  109. }
  110. }
  111. with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-amd64-legacy.update.json", "wb") as f:
  112. f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
  113. f.close()
  114. update = {
  115. "url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-arm.zip",
  116. "checksums": {
  117. "SHA-512": hash_file_sha512("installer/OpenMPT-" + plainversion + "-portable-arm.zip"),
  118. "SHA3-512": hash_file_sha3_512("installer/OpenMPT-" + plainversion + "-portable-arm.zip"),
  119. },
  120. "filename": "OpenMPT-" + version + "-portable-arm.zip",
  121. "autoupdate_installer": None,
  122. "autoupdate_archive": {
  123. "subfolder": "",
  124. "restartbinary": "OpenMPT.exe"
  125. }
  126. }
  127. with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-arm.update.json", "wb") as f:
  128. f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
  129. f.close()
  130. update = {
  131. "url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-arm64.zip",
  132. "checksums": {
  133. "SHA-512": hash_file_sha512("installer/OpenMPT-" + plainversion + "-portable-arm64.zip"),
  134. "SHA3-512": hash_file_sha3_512("installer/OpenMPT-" + plainversion + "-portable-arm64.zip"),
  135. },
  136. "filename": "OpenMPT-" + version + "-portable-arm64.zip",
  137. "autoupdate_installer": None,
  138. "autoupdate_archive": {
  139. "subfolder": "",
  140. "restartbinary": "OpenMPT.exe"
  141. }
  142. }
  143. with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-arm64.update.json", "wb") as f:
  144. f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
  145. f.close()
  146. update = {
  147. "OpenMPT " + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR: {
  148. "version": version,
  149. "date": datetime.datetime.utcnow().isoformat(),
  150. "announcement_url": announcement_url,
  151. "changelog_url": changelog_url,
  152. "downloads": {
  153. "installer": {
  154. "url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-Setup.update.json",
  155. "download_url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-Setup.exe",
  156. "type": "installer",
  157. "can_autoupdate": True,
  158. "autoupdate_minversion": "1.30.00.08",
  159. "os": "windows",
  160. "required_windows_version": { "version_major":6, "version_minor":1, "servicepack_major":1, "servicepack_minor":0, "build":0, "wine_major":1, "wine_minor":8, "wine_update":0 },
  161. "required_architectures": { "x86":True },
  162. "supported_architectures": { "x86":True,"amd64":True,"arm":True,"arm64":True },
  163. "required_processor_features": { "x86":{"sse2":True}, "amd64":{"sse2":True} }
  164. },
  165. "portable-x86": {
  166. "url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-x86.update.json",
  167. "download_url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-x86.zip",
  168. "type": "archive",
  169. "can_autoupdate": True,
  170. "autoupdate_minversion": "1.30.00.08",
  171. "os": "windows",
  172. "required_windows_version": { "version_major":10, "version_minor":0, "servicepack_major":0, "servicepack_minor":0, "build":0, "wine_major":1, "wine_minor":8, "wine_update":0 },
  173. "required_architectures": {},
  174. "supported_architectures": { "x86":True },
  175. "required_processor_features": { "x86":{"sse2":True} }
  176. },
  177. "portable-x86-legacy": {
  178. "url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-x86-legacy.update.json",
  179. "download_url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-x86-legacy.zip",
  180. "type": "archive",
  181. "can_autoupdate": True,
  182. "autoupdate_minversion": "1.30.00.08",
  183. "os": "windows",
  184. "required_windows_version": { "version_major":6, "version_minor":1, "servicepack_major":0, "servicepack_minor":0, "build":0, "wine_major":1, "wine_minor":8, "wine_update":0 },
  185. "required_architectures": {},
  186. "supported_architectures": { "x86":True },
  187. "required_processor_features": { "x86":{"sse2":True} }
  188. },
  189. "portable-amd64": {
  190. "url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-amd64.update.json",
  191. "download_url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-amd64.zip",
  192. "type": "archive",
  193. "can_autoupdate": True,
  194. "autoupdate_minversion": "1.30.00.08",
  195. "os": "windows",
  196. "required_windows_version": { "version_major":10, "version_minor":0, "servicepack_major":0, "servicepack_minor":0, "build":0, "wine_major":1, "wine_minor":8, "wine_update":0 },
  197. "required_architectures": {},
  198. "supported_architectures": { "amd64":True },
  199. "required_processor_features": { "amd64":{"sse2":True} }
  200. },
  201. "portable-amd64-legacy": {
  202. "url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-amd64-legacy.update.json",
  203. "download_url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-amd64-legacy.zip",
  204. "type": "archive",
  205. "can_autoupdate": True,
  206. "autoupdate_minversion": "1.30.00.08",
  207. "os": "windows",
  208. "required_windows_version": { "version_major":6, "version_minor":1, "servicepack_major":0, "servicepack_minor":0, "build":0, "wine_major":1, "wine_minor":8, "wine_update":0 },
  209. "required_architectures": {},
  210. "supported_architectures": { "amd64":True },
  211. "required_processor_features": { "amd64":{"sse2":True} }
  212. },
  213. "portable-arm": {
  214. "url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-arm.update.json",
  215. "download_url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-arm.zip",
  216. "type": "archive",
  217. "can_autoupdate": True,
  218. "autoupdate_minversion": "1.30.00.08",
  219. "os": "windows",
  220. "required_windows_version": { "version_major":10, "version_minor":0, "servicepack_major":0, "servicepack_minor":0, "build":0, "wine_major":1, "wine_minor":8, "wine_update":0 },
  221. "required_architectures": {},
  222. "supported_architectures": { "arm":True },
  223. "required_processor_features": { "arm":{} }
  224. },
  225. "portable-arm64": {
  226. "url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-arm64.update.json",
  227. "download_url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-arm64.zip",
  228. "type": "archive",
  229. "can_autoupdate": True,
  230. "autoupdate_minversion": "1.30.00.08",
  231. "os": "windows",
  232. "required_windows_version": { "version_major":10, "version_minor":0, "servicepack_major":0, "servicepack_minor":0, "build":0, "wine_major":1, "wine_minor":8, "wine_update":0 },
  233. "required_architectures": {},
  234. "supported_architectures": { "arm64":True },
  235. "required_processor_features": { "arm64":{} }
  236. }
  237. }
  238. }
  239. }
  240. with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-update.json", "wb") as f:
  241. f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
  242. f.close()
  243. def sign_file(filename):
  244. p = Popen(["bin/release/vs2019-win7-static/amd64/updatesigntool.exe", "sign", "jws", "auto", filename, filename + ".jws.json"])
  245. p.communicate()
  246. sign_file("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-Setup.update.json")
  247. sign_file("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-x86.update.json")
  248. sign_file("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-x86-legacy.update.json")
  249. sign_file("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-amd64.update.json")
  250. sign_file("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-amd64-legacy.update.json")
  251. sign_file("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-arm.update.json")
  252. sign_file("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-arm64.update.json")
  253. pdumpkey = Popen(["bin/release/vs2019-win7-static/amd64/updatesigntool.exe", "dumpkey", "auto", "installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-update-publickey.jwk.json"])
  254. pdumpkey.communicate()