diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2019-07-10 17:12:00 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2019-08-05 11:46:12 -0400 |
commit | e635c5b43df0ed6f28c05429dae126d645ac8717 (patch) | |
tree | 5879cb4d24a00a357264196bcb5bf48bd3500bc7 /branding/templates/windows/generate.py | |
parent | 92ea8778813ddffe6187e0ce300638fdefe1bf5e (diff) |
[feat] windows templates
Diffstat (limited to 'branding/templates/windows/generate.py')
-rwxr-xr-x | branding/templates/windows/generate.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/branding/templates/windows/generate.py b/branding/templates/windows/generate.py new file mode 100755 index 0000000..427b7a8 --- /dev/null +++ b/branding/templates/windows/generate.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3
+"""
+generate.py
+
+Generate a NSI installer for a given provider.
+"""
+
+import json
+import os
+from string import Template
+
+
+TEMPLATE = 'template.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
+
+
+here = os.path.split(os.path.realpath(__file__))[0]
+data = json.load(open(os.path.join(here, 'data.json')))
+data['extra_install_files'] = get_files('install')
+data['extra_uninstall_files'] = get_files('uninstall')
+
+import pprint
+pprint.pprint(data)
+
+INSTALLER = data['applicationName'] + '-installer.nsi'
+
+
+template = Template(open(TEMPLATE).read())
+with open(INSTALLER, 'w') as output:
+ output.write(template.safe_substitute(data))
+
+print("[+] NSIS installer script written to {path}".format(path=INSTALLER))
|