aboutsummaryrefslogtreecommitdiff
path: root/Src/external_dependencies/openmpt-trunk/installer/generate_update_json.py
blob: 12491437b4ae34c63ebc7ad474ec948a29d229e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
#!/usr/bin/env python3

import datetime
import hashlib
import json
import os

from subprocess import Popen

OPENMPT_VERSION_MAJORMAJOR = os.environ['OPENMPT_VERSION_MAJORMAJOR']
OPENMPT_VERSION_MAJOR = os.environ['OPENMPT_VERSION_MAJOR']
OPENMPT_VERSION_MINOR = os.environ['OPENMPT_VERSION_MINOR']
OPENMPT_VERSION_MINORMINOR = os.environ['OPENMPT_VERSION_MINORMINOR']
SVNVERSION = os.environ['SVNVERSION']
IS_RELEASE = True if OPENMPT_VERSION_MINORMINOR == "00" else False

if IS_RELEASE:
	download_base_url = "https://download.openmpt.org/archive/openmpt/"
	announcement_url = "https://openmpt.org/openmpt-" + OPENMPT_VERSION_MAJORMAJOR + "-" + OPENMPT_VERSION_MAJOR + "-" + OPENMPT_VERSION_MINOR + "-" + OPENMPT_VERSION_MINORMINOR + "-released"
	changelog_url = "https://openmpt.org/release_notes/History.txt"
else:
	download_base_url = "https://builds.openmpt.org/builds/auto/openmpt/pkg.win/"
	announcement_url = "https://builds.openmpt.org/builds/auto/openmpt/pkg.win/"
	changelog_url = "https://source.openmpt.org/browse/openmpt/?op=revision&rev=" + SVNVERSION

os.chdir(os.path.dirname(os.path.abspath(__file__)))
os.chdir("..")

plainversion = OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR
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

def hash_file_sha512(filename):
	sha512 = hashlib.sha512()
	with open(filename, "rb") as f:
		sha512.update(f.read())
	return sha512.hexdigest()
def hash_file_sha3_512(filename):
	sha3_512 = hashlib.sha3_512()
	with open(filename, "rb") as f:
		sha3_512.update(f.read())
	return sha3_512.hexdigest()

update = {
	"url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-Setup.exe",
	"checksums": {
		"SHA-512": hash_file_sha512("installer/OpenMPT-" + plainversion + "-Setup.exe"),
		"SHA3-512": hash_file_sha3_512("installer/OpenMPT-" + plainversion + "-Setup.exe"),
	},
	"filename": "OpenMPT-" + version + "-Setup.exe",
	"autoupdate_installer": {
		"arguments": [ "/SP-", "/SILENT", "/NOCANCEL", "/AUTOUPDATE=yes" ]
	},
	"autoupdate_archive": None
}
with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-Setup.update.json", "wb") as f:
	f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
	f.close()

update = {
	"url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-x86.zip",
	"checksums": {
		"SHA-512": hash_file_sha512("installer/OpenMPT-" + plainversion + "-portable-x86.zip"),
		"SHA3-512": hash_file_sha3_512("installer/OpenMPT-" + plainversion + "-portable-x86.zip"),
	},
	"filename": "OpenMPT-" + version + "-portable-x86.zip",
	"autoupdate_installer": None,
	"autoupdate_archive": {
		"subfolder": "",
		"restartbinary": "OpenMPT.exe"
	}
}
with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-x86.update.json", "wb") as f:
	f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
	f.close()

update = {
	"url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-x86-legacy.zip",
	"checksums": {
		"SHA-512": hash_file_sha512("installer/OpenMPT-" + plainversion + "-portable-x86-legacy.zip"),
		"SHA3-512": hash_file_sha3_512("installer/OpenMPT-" + plainversion + "-portable-x86-legacy.zip"),
	},
	"filename": "OpenMPT-" + version + "-portable-x86-legacy.zip",
	"autoupdate_installer": None,
	"autoupdate_archive": {
		"subfolder": "",
		"restartbinary": "OpenMPT.exe"
	}
}
with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-x86-legacy.update.json", "wb") as f:
	f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
	f.close()

update = {
	"url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-amd64.zip",
	"checksums": {
		"SHA-512": hash_file_sha512("installer/OpenMPT-" + plainversion + "-portable-amd64.zip"),
		"SHA3-512": hash_file_sha3_512("installer/OpenMPT-" + plainversion + "-portable-amd64.zip"),
	},
	"filename": "OpenMPT-" + version + "-portable-amd64.zip",
	"autoupdate_installer": None,
	"autoupdate_archive": {
		"subfolder": "",
		"restartbinary": "OpenMPT.exe"
	}
}
with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-amd64.update.json", "wb") as f:
	f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
	f.close()

update = {
	"url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-amd64-legacy.zip",
	"checksums": {
		"SHA-512": hash_file_sha512("installer/OpenMPT-" + plainversion + "-portable-amd64-legacy.zip"),
		"SHA3-512": hash_file_sha3_512("installer/OpenMPT-" + plainversion + "-portable-amd64-legacy.zip"),
	},
	"filename": "OpenMPT-" + version + "-portable-amd64-legacy.zip",
	"autoupdate_installer": None,
	"autoupdate_archive": {
		"subfolder": "",
		"restartbinary": "OpenMPT.exe"
	}
}
with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-amd64-legacy.update.json", "wb") as f:
	f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
	f.close()

update = {
	"url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-arm.zip",
	"checksums": {
		"SHA-512": hash_file_sha512("installer/OpenMPT-" + plainversion + "-portable-arm.zip"),
		"SHA3-512": hash_file_sha3_512("installer/OpenMPT-" + plainversion + "-portable-arm.zip"),
	},
	"filename": "OpenMPT-" + version + "-portable-arm.zip",
	"autoupdate_installer": None,
	"autoupdate_archive": {
		"subfolder": "",
		"restartbinary": "OpenMPT.exe"
	}
}
with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-arm.update.json", "wb") as f:
	f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
	f.close()

update = {
	"url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-arm64.zip",
	"checksums": {
		"SHA-512": hash_file_sha512("installer/OpenMPT-" + plainversion + "-portable-arm64.zip"),
		"SHA3-512": hash_file_sha3_512("installer/OpenMPT-" + plainversion + "-portable-arm64.zip"),
	},
	"filename": "OpenMPT-" + version + "-portable-arm64.zip",
	"autoupdate_installer": None,
	"autoupdate_archive": {
		"subfolder": "",
		"restartbinary": "OpenMPT.exe"
	}
}
with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-arm64.update.json", "wb") as f:
	f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
	f.close()



update = {
	"OpenMPT " + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR: {
		"version": version,
		"date": datetime.datetime.utcnow().isoformat(),
		"announcement_url": announcement_url,
		"changelog_url": changelog_url,
		"downloads": {
			"installer": {
				"url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-Setup.update.json",
				"download_url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-Setup.exe",
				"type": "installer",
				"can_autoupdate": True,
				"autoupdate_minversion": "1.30.00.08",
				"os": "windows",
				"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 },
				"required_architectures": { "x86":True },
				"supported_architectures": { "x86":True,"amd64":True,"arm":True,"arm64":True },
				"required_processor_features": { "x86":{"sse2":True}, "amd64":{"sse2":True} }
			},
			"portable-x86": {
				"url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-x86.update.json",
				"download_url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-x86.zip",
				"type": "archive",
				"can_autoupdate": True,
				"autoupdate_minversion": "1.30.00.08",
				"os": "windows",
				"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 },
				"required_architectures": {},
				"supported_architectures": { "x86":True },
				"required_processor_features": { "x86":{"sse2":True} }
			},
			"portable-x86-legacy": {
				"url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-x86-legacy.update.json",
				"download_url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-x86-legacy.zip",
				"type": "archive",
				"can_autoupdate": True,
				"autoupdate_minversion": "1.30.00.08",
				"os": "windows",
				"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 },
				"required_architectures": {},
				"supported_architectures": { "x86":True },
				"required_processor_features": { "x86":{"sse2":True} }
			},
			"portable-amd64": {
				"url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-amd64.update.json",
				"download_url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-amd64.zip",
				"type": "archive",
				"can_autoupdate": True,
				"autoupdate_minversion": "1.30.00.08",
				"os": "windows",
				"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 },
				"required_architectures": {},
				"supported_architectures": { "amd64":True },
				"required_processor_features": { "amd64":{"sse2":True} }
			},
			"portable-amd64-legacy": {
				"url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-amd64-legacy.update.json",
				"download_url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-amd64-legacy.zip",
				"type": "archive",
				"can_autoupdate": True,
				"autoupdate_minversion": "1.30.00.08",
				"os": "windows",
				"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 },
				"required_architectures": {},
				"supported_architectures": { "amd64":True },
				"required_processor_features": { "amd64":{"sse2":True} }
			},
			"portable-arm": {
				"url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-arm.update.json",
				"download_url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-arm.zip",
				"type": "archive",
				"can_autoupdate": True,
				"autoupdate_minversion": "1.30.00.08",
				"os": "windows",
				"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 },
				"required_architectures": {},
				"supported_architectures": { "arm":True },
				"required_processor_features": { "arm":{} }
			},
			"portable-arm64": {
				"url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-arm64.update.json",
				"download_url": download_base_url + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "/OpenMPT-" + version + "-portable-arm64.zip",
				"type": "archive",
				"can_autoupdate": True,
				"autoupdate_minversion": "1.30.00.08",
				"os": "windows",
				"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 },
				"required_architectures": {},
				"supported_architectures": { "arm64":True },
				"required_processor_features": { "arm64":{} }
			}
		}
	}
}

with open("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-update.json", "wb") as f:
	f.write((json.dumps(update, ensure_ascii=False, indent=1)).encode('utf-8'))
	f.close()

def sign_file(filename):
	p = Popen(["bin/release/vs2019-win7-static/amd64/updatesigntool.exe", "sign", "jws", "auto", filename, filename + ".jws.json"])
	p.communicate()

sign_file("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-Setup.update.json")
sign_file("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-x86.update.json")
sign_file("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-x86-legacy.update.json")
sign_file("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-amd64.update.json")
sign_file("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-amd64-legacy.update.json")
sign_file("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-arm.update.json")
sign_file("installer/" + "OpenMPT-" + OPENMPT_VERSION_MAJORMAJOR + "." + OPENMPT_VERSION_MAJOR + "." + OPENMPT_VERSION_MINOR + "." + OPENMPT_VERSION_MINORMINOR + "-portable-arm64.update.json")

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"])
pdumpkey.communicate()