Debian Codegraph @

scripts/windows/choco/choco_packager.py

raw symbols SCIP
1 # Because choco is a special case and I'm too lazy to make my
2 # packaging script robust enough, so whatever, hard-code time.
3
4 import hashlib
5 import sys
6 from string import Template
7 import os
8
9 args = sys.argv
10 deployment_file_path_64 = args[1]
11 version = args[2]
12 nuspec_template = args[3]
13 ps1_template = args[4]
14 generated_nuspec = args[5]
15 generated_ps1 = args[6]
16 generated_ps1_dir = args[7]
17
18 print("Generating Chocolatey package for:")
19 print(" 64-bit: %s" % deployment_file_path_64)
20 print(" VERSION: %s" % version)
21 print(" NUSPEC TEMPLATE: %s" % nuspec_template)
22 print(" PS1 TEMPLATE: %s" % ps1_template)
23 print(" GENERATED NUSPEC: %s" % generated_nuspec)
24 print(" GENERATED PS1: %s" % generated_ps1)
25 print(" GENERATED PS1 DIR: %s" % generated_ps1_dir)
26
27 with open(deployment_file_path_64, "rb") as deployment_file_64:
28 hash_64 = hashlib.sha1(deployment_file_64.read()).hexdigest()
29
30 print("Generated hash for 64-bit program: %s" % str(hash_64))
31
32 with open(nuspec_template, "r") as template_file:
33 template = Template(template_file.read())
34 substitute = template.safe_substitute(version=version)
35 print("\n================== Generated nuspec file ==================\n")
36 print(substitute)
37 print("\n============================================================\n")
38
39 with open(generated_nuspec, "w") as generated_file:
40 generated_file.write(substitute)
41
42 os.makedirs(generated_ps1_dir)
43 with open(ps1_template, "r") as template_file:
44 template = Template(template_file.read())
45 substitute = template.safe_substitute(version=version, hash_64=hash_64)
46 print(
47 "\n================== Generated chocolatey-install file ==================\n"
48 )
49 print(substitute)
50 print("\n============================================================\n")
51
52 with open(generated_ps1, "w") as generated_file:
53 generated_file.write(substitute)