diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2018-06-25 19:10:41 +0200 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2018-06-25 19:10:41 +0200 |
commit | 9547df797f7a12e2410df2e4a82e3436248a282f (patch) | |
tree | 211d493674eccf986d77cb5cad01277f313d7b7e /win/generate.py | |
parent | 14f278bc06ae528b1c50df81660f847c5d2ea870 (diff) |
[pkg] windows installer templates
Diffstat (limited to 'win/generate.py')
-rwxr-xr-x | win/generate.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/win/generate.py b/win/generate.py new file mode 100755 index 0000000..efc2108 --- /dev/null +++ b/win/generate.py @@ -0,0 +1,45 @@ +"""
+generate.py
+
+Generate a NSI installer for a given provider.
+"""
+
+from string import Template
+
+from provider import *
+
+
+TEMPLATE = 'template.nsi'
+INSTALLER = APP_NAME + '-installer.nsi'
+
+
+def get_files(which):
+ files = "\n"
+ if which == 'install':
+ action = "File "
+ elif which == 'uninstall':
+ action = "Delete $INSTDIR\\"
+ else:
+ action = ""
+
+ # TODO get relative path
+ for item in open('payload/' + which).readlines():
+ files += " {action}{item}".format(
+ action=action, item=item)
+ return files
+
+
+vardict = {
+ 'app_name': APP_NAME,
+ 'app_name_lower': APP_NAME.lower(),
+ 'url': URL,
+ 'extra_install_files': get_files('install'),
+ 'extra_uninstall_files': get_files('uninstall')
+}
+
+
+template = Template(open(TEMPLATE).read())
+with open(INSTALLER, 'w') as output:
+ output.write(template.safe_substitute(vardict))
+
+print("[+] NSIS installer script written to {path}".format(path=INSTALLER))
|