From 4d9d578902aae37d62ea3218efa2b062cb7f893f Mon Sep 17 00:00:00 2001
From: kali <kali@leap.se>
Date: Thu, 8 Oct 2020 03:04:25 +0200
Subject: [PATCH] [pkg] parametrize win/osx installer

---
 Makefile                                      |  46 +++----
 branding/qtinstaller/config/config.xml        |  14 --
 .../packages/root.win_x86_64/.gitignore       |   1 -
 .../root.win_x86_64/meta/installscript.js     |  77 -----------
 .../packages/root.win_x86_64/meta/package.xml |  10 --
 .../packages/root/meta/package.xml            |   7 -
 branding/scripts/gen-qtinstaller              | 121 ++++++++++++++++++
 .../templates/qtinstaller/config/config.xml   |  21 +--
 .../templates/qtinstaller/linux-data/readme   |   1 +
 .../{osx => osx-data}/post-install.py         |   0
 .../se.leap.bitmask-helper.plist              |   0
 .../{osx => osx-data}/uninstall.py            |   0
 .../packages/bitmaskvpn/meta/install.js       |  64 ++++++++-
 .../packages/bitmaskvpn/meta/package.xml      |   8 +-
 .../templates/qtinstaller/win-data/readme     |   1 +
 gui/providers/providers.json                  |   2 +-
 16 files changed, 213 insertions(+), 160 deletions(-)
 delete mode 100644 branding/qtinstaller/config/config.xml
 delete mode 100644 branding/qtinstaller/packages/root.win_x86_64/.gitignore
 delete mode 100644 branding/qtinstaller/packages/root.win_x86_64/meta/installscript.js
 delete mode 100644 branding/qtinstaller/packages/root.win_x86_64/meta/package.xml
 delete mode 100644 branding/qtinstaller/packages/root/meta/package.xml
 create mode 100755 branding/scripts/gen-qtinstaller
 create mode 100644 branding/templates/qtinstaller/linux-data/readme
 rename branding/templates/qtinstaller/{osx => osx-data}/post-install.py (100%)
 rename branding/templates/qtinstaller/{osx => osx-data}/se.leap.bitmask-helper.plist (100%)
 rename branding/templates/qtinstaller/{osx => osx-data}/uninstall.py (100%)
 create mode 100644 branding/templates/qtinstaller/win-data/readme

diff --git a/Makefile b/Makefile
index 53b3e8da..59751fff 100644
--- a/Makefile
+++ b/Makefile
@@ -24,14 +24,13 @@ UNAME = $(shell uname -s)
 PLATFORM ?= $(shell echo ${UNAME} | awk "{print tolower(\$$0)}")
 
 QTBUILD = build/qt
+INSTALLER = build/installer
 WININST_DATA = branding/qtinstaller/packages/root.win_x86_64/data/
-OSX_DATA = build/installer/packages/bitmaskvpn/data/
+OSX_DATA = ${INSTALLER}/packages/bitmaskvpn/data/
 OSX_CERT="Developer ID Installer: LEAP Encryption Access Project"
 MACDEPLOYQT_OPTS = -appstore-compliant -qmldir=gui/qml -always-overwrite
 # XXX expired cert -codesign="${OSX_CERT}"
 	
-# TODO converge both OSX/WINDOWS
-
 SCRIPTS = branding/scripts
 TEMPLATES = branding/templates
 
@@ -99,28 +98,41 @@ endif
 build_openvpn:
 	@[ -f $(OPENVPN_BIN) ] && echo "OpenVPN already built at" $(OPENVPN_BIN) || ./branding/thirdparty/openvpn/build_openvpn.sh
 
+debug_installer:
+	@VERSION=${VERSION} ${SCRIPTS}/gen-qtinstaller osx ${INSTALLER}
+
 build_installer: check_qtifw build
 	echo "mkdir osx data"	
 	@mkdir -p ${OSX_DATA}
-	@cp -r ${TEMPLATES}/qtinstaller/config build/installer/
-	@cp -r ${TEMPLATES}/qtinstaller/packages build/installer/
-	@cp -r ${TEMPLATES}/qtinstaller/installer.pro build/installer/
+	@cp -r ${TEMPLATES}/qtinstaller/packages ${INSTALLER}
+	@cp -r ${TEMPLATES}/qtinstaller/installer.pro ${INSTALLER}
+	@cp -r ${TEMPLATES}/qtinstaller/config ${INSTALLER}
 ifeq (${PLATFORM}, darwin)
 	@mkdir -p ${OSX_DATA}/helper
+	# TODO need to write this
+	@VERSION=${VERSION} ${SCRIPTS}/gen-qtinstaller osx ${INSTALLER}
 	@cp "${TEMPLATES}/osx/bitmask.pf.conf" ${OSX_DATA}/helper/bitmask.pf.conf
 	@cp "${TEMPLATES}/osx/client.up.sh" ${OSX_DATA}/
 	@cp "${TEMPLATES}/osx/client.down.sh" ${OSX_DATA}/
-	@cp "${TEMPLATES}/qtinstaller/osx/post-install.py" ${OSX_DATA}/
-	@cp "${TEMPLATES}/qtinstaller/osx/uninstall.py" ${OSX_DATA}/
-	@cp "${TEMPLATES}/qtinstaller/osx/se.leap.bitmask-helper.plist" ${OSX_DATA}/
+	@cp "${TEMPLATES}/qtinstaller/osx-data/post-install.py" ${OSX_DATA}/
+	@cp "${TEMPLATES}/qtinstaller/osx-data/uninstall.py" ${OSX_DATA}/
+	@cp "${TEMPLATES}/qtinstaller/osx-data/se.leap.bitmask-helper.plist" ${OSX_DATA}/
 	@cp build/bin/${PLATFORM}/bitmask-helper ${OSX_DATA}/
 	# FIXME our static openvpn build fails with an "Assertion failed at crypto.c". Needs to be fixed!!! - kali
+	# a working (old) version:
+	#@curl -L https://downloads.leap.se/thirdparty/osx/openvpn/openvpn -o build/${PROVIDER}/staging/openvpn-osx
 	#@cp $(OPENVPN_BIN) ${OSX_DATA}/openvpn.leap
 	@echo "WARNING: workaround for broken static build. Shipping homebrew dynamically linked instead"
 	@rm -f ${OSX_DATA}openvpn.leap && cp /usr/local/bin/openvpn ${OSX_DATA}openvpn.leap
 	@echo "[+] Running macdeployqt"
 	@macdeployqt ${QTBUILD}/release/${PROVIDER}-vpn.app ${MACDEPLOYQT_OPTS}
 	@cp -r "${QTBUILD}/release/${TARGET}.app"/ ${OSX_DATA}/
+endif
+ifeq (${PLATFORM}, windows)
+	@${SCRIPTS}/gen-qtinstaller windows ${INSTALLER}
+endif
+ifeq (${PLATFORM}, linux)
+	@${SCRIPTS}/gen-qtinstaller windows ${INSTALLER}
 endif
 	@echo "[+] All templates, binaries and libraries copied to build/installer."
 	@echo "[+] Now building the installer."
@@ -246,22 +258,6 @@ gen_pkg_win:
 	@cp -r ${TEMPLATES}/windows build/${PROVIDER}
 	@VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} ${SCRIPTS}/generate-win.py build/${PROVIDER}/windows/data.json
 	@cd build/${PROVIDER}/windows && python3 generate.py
-	# TODO create/copy build/PROVIDER/assets/
-	# TODO create/copy build/PROVIDER/staging/
-
-gen_pkg_osx:
-	@mkdir -p build/${PROVIDER}/osx/scripts
-	@mkdir -p build/${PROVIDER}/staging
-ifeq (,$(wildcard build/${PROVIDER}/assets))
-	@ln -s ../../branding/assets/default build/${PROVIDER}/assets
-endif
-ifeq (,$(wildcard build/${PROVIDER}/staging/openvpn-osx))
-	#@curl -L https://downloads.leap.se/thirdparty/osx/openvpn/openvpn -o build/${PROVIDER}/staging/openvpn-osx
-endif
-	@cp -r ${TEMPLATES}/osx build/${PROVIDER}
-	@VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} ${SCRIPTS}/generate-osx.py build/${PROVIDER}/osx/data.json
-	@cd build/${PROVIDER}/osx && python3 generate.py
-	@cd build/${PROVIDER}/osx/scripts && chmod +x preinstall postinstall
 
 gen_pkg_deb:
 	@cp -r ${TEMPLATES}/debian build/${PROVIDER}
diff --git a/branding/qtinstaller/config/config.xml b/branding/qtinstaller/config/config.xml
deleted file mode 100644
index 8ce9b2e0..00000000
--- a/branding/qtinstaller/config/config.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Installer>
-	<Name>DemoLibVPN-0.0.1</Name>
-	<Version>0.0.1</Version>
-	<Title>DemoLibVPN Installer</Title>
-	<Publisher>LEAP Encryption Access Project</Publisher>
-	<TargetDir>@ApplicationsDir@/DemoLibVPN</TargetDir>
-	<RunProgram>@TargetDir@/demolib-vpn.exe</RunProgram>
-	<RunProgramArguments>
-	</RunProgramArguments>
-        <StartMenuDir>DemoLibVPN</StartMenuDir>
-        <MaintenanceToolName>Uninstall-DemoLibVPN</MaintenanceToolName>
-        <AllowNonAsciiCharacters>false</AllowNonAsciiCharacters>
-</Installer>
diff --git a/branding/qtinstaller/packages/root.win_x86_64/.gitignore b/branding/qtinstaller/packages/root.win_x86_64/.gitignore
deleted file mode 100644
index 60baa9cb..00000000
--- a/branding/qtinstaller/packages/root.win_x86_64/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-data/*
diff --git a/branding/qtinstaller/packages/root.win_x86_64/meta/installscript.js b/branding/qtinstaller/packages/root.win_x86_64/meta/installscript.js
deleted file mode 100644
index 1598458c..00000000
--- a/branding/qtinstaller/packages/root.win_x86_64/meta/installscript.js
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-**
-** Copyright (C) 2020 LEAP Encryption Access Project.
-** 
-*/
-
-function cancelInstaller(message)
-{
-    installer.setDefaultPageVisible(QInstaller.Introduction, false);
-    installer.setDefaultPageVisible(QInstaller.TargetDirectory, false);
-    installer.setDefaultPageVisible(QInstaller.ComponentSelection, false);
-    installer.setDefaultPageVisible(QInstaller.ReadyForInstallation, false);
-    installer.setDefaultPageVisible(QInstaller.StartMenuSelection, false);
-    installer.setDefaultPageVisible(QInstaller.PerformInstallation, false);
-    installer.setDefaultPageVisible(QInstaller.LicenseCheck, false);
-
-    var abortText = "<font color='red'>" + message +"</font>";
-    installer.setValue("FinishedText", abortText);
-}
-function majorVersion(str)
-{
-    return parseInt(str.split(".", 1));
-}
-
-function Component()
-{
-    // Check whether OS is supported.
-    // start installer with -v to see debug output
-
-    console.log("OS: " + systemInfo.productType);
-    console.log("Kernel: " + systemInfo.kernelType + "/" + systemInfo.kernelVersion);
-
-    var validOs = false;
-
-    if (systemInfo.kernelType === "winnt") {
-        if (majorVersion(systemInfo.kernelVersion) >= 6)
-            validOs = true;
-    } else if (systemInfo.kernelType === "darwin") {
-        if (majorVersion(systemInfo.kernelVersion) >= 11)
-            validOs = true;
-    } else {
-        if (systemInfo.productType !== "ubuntu"
-                || systemInfo.productVersion !== "20.04") {
-            QMessageBox["warning"]("os.warning", "Installer",
-                                   "Note that the binaries are only tested on Ubuntu 20.04",
-                                   QMessageBox.Ok);
-        }
-        validOs = true;
-    }
-
-    if (!validOs) {
-        cancelInstaller("Installation on " + systemInfo.prettyProductName + " is not supported");
-        return;
-    }
-
-    console.log("CPU Architecture: " +  systemInfo.currentCpuArchitecture);
-
-    if ( systemInfo.kernelType === "winnt") {
-        installer.componentByName("root.win_x86_64").setValue("Default", "true");
-        installer.componentByName("root.win_x86_64").setValue("Virtual", "false");
-    }
-}
-
-Component.prototype.createOperations = function() 
-{
-	component.createOperations()
-	component.addElevatedOperation("Execute", "@TargetDir@/helper.exe", "install", "UNDOEXECUTE", "@TargetDir@/helper.exe", "remove");
-	component.addElevatedOperation("Execute", "@TargetDir@/helper.exe", "start", "UNDOEXECUTE", "@TargetDir@/helper.exe", "stop");
-        if (systemInfo.productType === "windows") {
-             console.log("Adding shortcut entries");
-             component.addElevatedOperation("Mkdir", "@StartMenuDir@");
-             component.addElevatedOperation("CreateShortcut", "@TargetDir@/demolib-vpn.exe", "@StartMenuDir@/DemoLibVPN.lnk", "workingDirectory=@TargetDir@", "iconPath=@TargetDir@/icon.ico", "description=Start DemoLibVPN");
-
-	     // TODO I think this one is not being created because the path doesn't exist yet. We might want to do this by hooking on the installation finished signal instead.
-             component.addElevatedOperation("CreateShortcut", "@TargetDir@/Uninstall-DemoLibVPN.exe", "@StartMenuDir@/Uninstall.lnk");
-        }
-}
diff --git a/branding/qtinstaller/packages/root.win_x86_64/meta/package.xml b/branding/qtinstaller/packages/root.win_x86_64/meta/package.xml
deleted file mode 100644
index 11d630f1..00000000
--- a/branding/qtinstaller/packages/root.win_x86_64/meta/package.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Package>
-	<DisplayName>DemoLibVPN For Windows</DisplayName>
-	<Description>Install DemoLibVPN</Description>
-	<Version>0.0.1-1</Version>
-	<ReleaseDate>2020-09-15</ReleaseDate>
-	<Default>true</Default>
-	<RequiresAdminRights>true</RequiresAdminRights>
-	<Script>installscript.js</Script>
-</Package>
diff --git a/branding/qtinstaller/packages/root/meta/package.xml b/branding/qtinstaller/packages/root/meta/package.xml
deleted file mode 100644
index b4ca25e2..00000000
--- a/branding/qtinstaller/packages/root/meta/package.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Package>
-	<DisplayName>DemoLibVPN</DisplayName>
-	<Version>0.0.1-1</Version>
-	<ReleaseDate>2020-09-15</ReleaseDate>
-	<Default>script</Default>
-</Package>
diff --git a/branding/scripts/gen-qtinstaller b/branding/scripts/gen-qtinstaller
new file mode 100755
index 00000000..419d958c
--- /dev/null
+++ b/branding/scripts/gen-qtinstaller
@@ -0,0 +1,121 @@
+#!/usr/bin/env python3
+
+import configparser
+import json
+import os
+import sys
+import time
+
+from string import Template
+
+from provider import getDefaultProvider
+from provider import getProviderData
+
+OS_CONFIG = {
+    'osx': """
+    <!-- osx -->
+    <TargetDir>@ApplicationsDir@/$APPNAME.app</TargetDir>
+    <StartMenuDir>$APPNAME.app</StartMenuDir>
+    <RunProgram>open</RunProgram>
+    <RunProgramDescription>Start $APPNAME now!</RunProgramDescription>
+      <RunProgramArguments>
+        <Argument>@TargetDir@</Argument>
+      </RunProgramArguments>
+    <WizardStyle>mac</WizardStyle>
+    <!-- end osx -->
+""",
+    'windows': """
+    <TargetDir>@ApplicationsDir@/DemoLibVPN</TargetDir>
+    <StartMenuDir>$APPNAME</StartMenuDir>
+
+    <RunProgram>@TargetDir@/$BINNAME.exe</RunProgram>
+    <RunProgramArguments>
+    </RunProgramArguments>
+    <!-- end windows -->
+"""
+}
+
+
+
+def getData():
+    config = configparser.ConfigParser()
+    configPath = os.path.join(here(), '../../branding/config/vendor.conf')
+    config.read(configPath)
+
+    provider = os.environ.get('PROVIDER')
+    if not provider:
+        provider = getDefaultProvider(config)
+    return getProviderData(provider, config)
+
+def generateQtInstallerBoilerplate(data, platform, outDir):
+    generateConfig(data, platform, outDir)
+    generatePackageMetadata(data, platform, outDir)
+
+def generateConfig(data, platform, outDir):
+    templateData = {
+        'APPNAME': data['applicationName'],
+        'BINNAME': data['binaryName'],
+        'VERSION': getVersion(),
+        'TIMESTAMP': time.strftime('%Y-%m-%d'),
+    }
+
+    platformStr = OS_CONFIG[platform]
+    platBlock = Template(platformStr).substitute(**templateData)
+    templateData['PLATFORM_BLOCK'] = platBlock
+
+    renderTemplate(
+         templatePath='../templates/qtinstaller/config/config.xml',
+         outPath=os.path.join(outDir, 'config/config.xml'),
+         data=templateData)
+
+def generatePackageMetadata(data, platform, outDir):
+    templateData = {
+        'APPNAME': data['applicationName'],
+        'BINNAME': data['binaryName'],
+        'VERSION': getVersion(),
+        'TIMESTAMP': time.strftime('%Y-%m-%d')
+    }
+    renderTemplate(
+         templatePath='../templates/qtinstaller/packages/bitmaskvpn/meta/package.xml',
+         outPath=os.path.join(outDir, 'packages/bitmaskvpn/meta/package.xml'),
+         data=templateData)
+
+    renderTemplate(
+         templatePath='../templates/qtinstaller/packages/bitmaskvpn/meta/install.js',
+         outPath=os.path.join(outDir, 'packages/bitmaskvpn/meta/install.js'),
+         data=templateData)
+
+def renderTemplate(templatePath=None, outPath=None, data=None):
+    with open(os.path.join(here(), templatePath), 'r') as f:
+        t = f.read()	
+    rendered = Template(t).substitute(**data)
+    os.makedirs(os.path.dirname(outPath), exist_ok=True)
+    with open(outPath, 'w') as out:
+        out.write(rendered)
+
+def here():
+    return os.path.abspath(os.path.dirname(__file__))
+
+def bail(msg=None):
+    if not msg:
+        print("ERROR: not enough arguments!")
+        print('Usage: {scriptname}.py <config> <output>'.format(
+            scriptname=SCRIPT_NAME))
+    else:
+        print(msg)
+    sys.exit(1)
+
+def getVersion():
+    return os.environ.get('VERSION', 'unknown')
+
+if __name__ == "__main__":
+    # TODO get from vendor - maybe just in provider module
+    VENDOR_PATH = os.environ.get('VENDOR_PATH')
+
+    if len(sys.argv) != 3:
+        bail()
+    platform = sys.argv[1]
+    outDir = sys.argv[2]
+    print("[+] Generating qtinstaller files...")
+    data = getData()
+    generateQtInstallerBoilerplate(data, platform, outDir)
diff --git a/branding/templates/qtinstaller/config/config.xml b/branding/templates/qtinstaller/config/config.xml
index 8b28be6b..c02b0a68 100644
--- a/branding/templates/qtinstaller/config/config.xml
+++ b/branding/templates/qtinstaller/config/config.xml
@@ -1,13 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Installer>
-
-    <Name>DemoLibVPN-0.0.1</Name>
-    <Version>0.0.1</Version>
-    <Title>DemoLibVPN Installer</Title>
+    <Name>$APPNAME-$VERSION</Name>
+    <Version>$VERSION</Version>
+    <Title>$APPNAME Installer ($VERSION)</Title>
     <Publisher>LEAP Encryption Access Project</Publisher>
-    <TargetDir>@ApplicationsDir@/DemoLibVPN.app</TargetDir>
-
-    <StartMenuDir>DemoLibVPN.app</StartMenuDir>
     <AllowNonAsciiCharacters>false</AllowNonAsciiCharacters>
 
     <!--
@@ -18,15 +14,8 @@
     </RemoteRepositories>
     -->
 
-    <MaintenanceToolName>Uninstall-DemoLibVPN</MaintenanceToolName>
+    <MaintenanceToolName>Uninstall-$APPNAME</MaintenanceToolName>
 
-    <!-- osx run -->
-    <RunProgram>open</RunProgram>
-    <RunProgramDescription>Start DemoLibVPN now!</RunProgramDescription>
-      <RunProgramArguments>
-        <Argument>@TargetDir@</Argument>
-      </RunProgramArguments>
-    <WizardStyle>mac</WizardStyle>
-    <!-- end osx run -->
+    $PLATFORM_BLOCK
 
 </Installer>
diff --git a/branding/templates/qtinstaller/linux-data/readme b/branding/templates/qtinstaller/linux-data/readme
new file mode 100644
index 00000000..e0390887
--- /dev/null
+++ b/branding/templates/qtinstaller/linux-data/readme
@@ -0,0 +1 @@
+linux-specific installer data
diff --git a/branding/templates/qtinstaller/osx/post-install.py b/branding/templates/qtinstaller/osx-data/post-install.py
similarity index 100%
rename from branding/templates/qtinstaller/osx/post-install.py
rename to branding/templates/qtinstaller/osx-data/post-install.py
diff --git a/branding/templates/qtinstaller/osx/se.leap.bitmask-helper.plist b/branding/templates/qtinstaller/osx-data/se.leap.bitmask-helper.plist
similarity index 100%
rename from branding/templates/qtinstaller/osx/se.leap.bitmask-helper.plist
rename to branding/templates/qtinstaller/osx-data/se.leap.bitmask-helper.plist
diff --git a/branding/templates/qtinstaller/osx/uninstall.py b/branding/templates/qtinstaller/osx-data/uninstall.py
similarity index 100%
rename from branding/templates/qtinstaller/osx/uninstall.py
rename to branding/templates/qtinstaller/osx-data/uninstall.py
diff --git a/branding/templates/qtinstaller/packages/bitmaskvpn/meta/install.js b/branding/templates/qtinstaller/packages/bitmaskvpn/meta/install.js
index 0bcaeef4..361e14d7 100644
--- a/branding/templates/qtinstaller/packages/bitmaskvpn/meta/install.js
+++ b/branding/templates/qtinstaller/packages/bitmaskvpn/meta/install.js
@@ -1,10 +1,64 @@
 /****************************************************************************
 **
-** Copyright (C) 2020 LEAP
+** Copyright (C) 2020 LEAP Encryption Access Project
 **
 ****************************************************************************/
 
+function majorVersion(str)
+{
+    return parseInt(str.split(".", 1));
+}
+
+function cancelInstaller(message)
+{
+    installer.setDefaultPageVisible(QInstaller.Introduction, false);
+    installer.setDefaultPageVisible(QInstaller.TargetDirectory, false);
+    installer.setDefaultPageVisible(QInstaller.ComponentSelection, false);
+    installer.setDefaultPageVisible(QInstaller.ReadyForInstallation, false);
+    installer.setDefaultPageVisible(QInstaller.StartMenuSelection, false);
+    installer.setDefaultPageVisible(QInstaller.PerformInstallation, false);
+    installer.setDefaultPageVisible(QInstaller.LicenseCheck, false);
+
+    var abortText = "<font color='red'>" + message +"</font>";
+    installer.setValue("FinishedText", abortText);
+}
+
 function Component() {
+    // Check whether OS is supported.
+    // start installer with -v to see debug output
+
+    console.log("OS: " + systemInfo.productType);
+    console.log("Kernel: " + systemInfo.kernelType + "/" + systemInfo.kernelVersion);
+
+    var validOs = false;
+
+    if (systemInfo.kernelType === "winnt") {
+        if (majorVersion(systemInfo.kernelVersion) >= 6)
+            validOs = true;
+    } else if (systemInfo.kernelType === "darwin") {
+        if (majorVersion(systemInfo.kernelVersion) >= 11)
+            validOs = true;
+    } else {
+        if (systemInfo.productType !== "ubuntu"
+                || systemInfo.productVersion !== "20.04") {
+            QMessageBox["warning"]("os.warning", "Installer",
+                                   "Note that the binaries are only tested on Ubuntu 20.04",
+                                   QMessageBox.Ok);
+        }
+        validOs = true;
+    }
+
+    if (!validOs) {
+        cancelInstaller("Installation on " + systemInfo.prettyProductName + " is not supported");
+        return;
+    }
+
+    console.log("CPU Architecture: " +  systemInfo.currentCpuArchitecture);
+
+    if ( systemInfo.kernelType === "winnt") {
+        installer.componentByName("root.win_x86_64").setValue("Default", "true");
+        installer.componentByName("root.win_x86_64").setValue("Virtual", "false");
+    }
 }
 
 Component.prototype.createOperations = function ()
@@ -31,7 +85,7 @@ Component.prototype.installationFinished = function()
 {
     console.log("DEBUG: running installationFinished");
     if (installer.isInstaller() && installer.status == QInstaller.Success) {
-        var argList = ["-a", "@TargetDir@/DemoLibVPN.app"];
+        var argList = ["-a", "@TargetDir@/$APPNAME.app"];
         try {
             installer.execute("touch", ["/tmp/install-finished"]);
             installer.execute("open", argList);
@@ -46,12 +100,12 @@ function postInstallWindows() {
     component.addElevatedOperation("Execute", "@TargetDir@/helper.exe", "start", "UNDOEXECUTE", "@TargetDir@/helper.exe", "stop");
     console.log("Adding shortcut entries");
     component.addElevatedOperation("Mkdir", "@StartMenuDir@");
-    component.addElevatedOperation("CreateShortcut", "@TargetDir@/demolib-vpn.exe", "@StartMenuDir@/DemoLibVPN.lnk", "workingDirectory=@TargetDir@", "iconPath=@TargetDir@/icon.ico", "description=Start DemoLibVPN");
+    component.addElevatedOperation("CreateShortcut", "@TargetDir@/$BINNAME.exe", "@StartMenuDir@/$APPNAME.lnk", "workingDirectory=@TargetDir@", "iconPath=@TargetDir@/icon.ico", "description=Start $APPNAME");
 
     // TODO I think this one is not being created because the path doesn't exist yet. We might want to do this by hooking on the installation finished signal instead.
     component.addElevatedOperation(
         "CreateShortcut",
-        "@TargetDir@/Uninstall-DemoLibVPN.exe",
+        "@TargetDir@/Uninstall-$APPNAME.exe",
         "@StartMenuDir@/Uninstall.lnk"
     );
 }
@@ -70,5 +124,5 @@ function postInstallOSX() {
 function postInstallLinux() {
     console.log("Post-installation for GNU/Linux");
     console.log("Maybe you want to use your package manager instead?");
-    component.addOperation("AppendFile", "/tmp/riseupvpn.log", "this is a test - written from the installer");
+    component.addOperation("AppendFile", "/tmp/bitmask-installer.log", "this is a test - written from the installer");
 }
diff --git a/branding/templates/qtinstaller/packages/bitmaskvpn/meta/package.xml b/branding/templates/qtinstaller/packages/bitmaskvpn/meta/package.xml
index b910e7f5..0e56f4f7 100644
--- a/branding/templates/qtinstaller/packages/bitmaskvpn/meta/package.xml
+++ b/branding/templates/qtinstaller/packages/bitmaskvpn/meta/package.xml
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Package>
-    <DisplayName>DemoLibVPN</DisplayName>
-    <Description>DemoLibVPN</Description>
-    <Version>0.20.9-1</Version>
-    <ReleaseDate>2020-10-01</ReleaseDate>
+    <DisplayName>$APPNAME</DisplayName>
+    <Description>$APPNAME</Description>
+    <Version>$VERSION</Version>
+    <ReleaseDate>$TIMESTAMP</ReleaseDate>
     <Default>false</Default>
     <RequiresAdminRights>true</RequiresAdminRights>
     <Script>install.js</Script>
diff --git a/branding/templates/qtinstaller/win-data/readme b/branding/templates/qtinstaller/win-data/readme
new file mode 100644
index 00000000..8938b549
--- /dev/null
+++ b/branding/templates/qtinstaller/win-data/readme
@@ -0,0 +1 @@
+windows-specific installer data
diff --git a/gui/providers/providers.json b/gui/providers/providers.json
index 848a0f0a..5c9b08b6 100644
--- a/gui/providers/providers.json
+++ b/gui/providers/providers.json
@@ -15,7 +15,7 @@
             "apiURL": "https://api.black.riseup.net/",
             "geolocationAPI": "https://api.black.riseup.net:9001/json",
             "caCertString": "-----BEGIN CERTIFICATE-----\nMIIFjTCCA3WgAwIBAgIBATANBgkqhkiG9w0BAQ0FADBZMRgwFgYDVQQKDA9SaXNl\ndXAgTmV0d29ya3MxGzAZBgNVBAsMEmh0dHBzOi8vcmlzZXVwLm5ldDEgMB4GA1UE\nAwwXUmlzZXVwIE5ldHdvcmtzIFJvb3QgQ0EwHhcNMTQwNDI4MDAwMDAwWhcNMjQw\nNDI4MDAwMDAwWjBZMRgwFgYDVQQKDA9SaXNldXAgTmV0d29ya3MxGzAZBgNVBAsM\nEmh0dHBzOi8vcmlzZXVwLm5ldDEgMB4GA1UEAwwXUmlzZXVwIE5ldHdvcmtzIFJv\nb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC76J4ciMJ8Sg0m\nTP7DF2DT9zNe0Csk4myoMFC57rfJeqsAlJCv1XMzBmXrw8wq/9z7XHv6n/0sWU7a\n7cF2hLR33ktjwODlx7vorU39/lXLndo492ZBhXQtG1INMShyv+nlmzO6GT7ESfNE\nLliFitEzwIegpMqxCIHXFuobGSCWF4N0qLHkq/SYUMoOJ96O3hmPSl1kFDRMtWXY\niw1SEKjUvpyDJpVs3NGxeLCaA7bAWhDY5s5Yb2fA1o8ICAqhowurowJpW7n5ZuLK\n5VNTlNy6nZpkjt1QycYvNycffyPOFm/Q/RKDlvnorJIrihPkyniV3YY5cGgP+Qkx\nHUOT0uLA6LHtzfiyaOqkXwc4b0ZcQD5Vbf6Prd20Ppt6ei0zazkUPwxld3hgyw58\nm/4UIjG3PInWTNf293GngK2Bnz8Qx9e/6TueMSAn/3JBLem56E0WtmbLVjvko+LF\nPM5xA+m0BmuSJtrD1MUCXMhqYTtiOvgLBlUm5zkNxALzG+cXB28k6XikXt6MRG7q\nhzIPG38zwkooM55yy5i1YfcIi5NjMH6A+t4IJxxwb67MSb6UFOwg5kFokdONZcwj\nshczHdG9gLKSBIvrKa03Nd3W2dF9hMbRu//STcQxOailDBQCnXXfAATj9pYzdY4k\nha8VCAREGAKTDAex9oXf1yRuktES4QIDAQABo2AwXjAdBgNVHQ4EFgQUC4tdmLVu\nf9hwfK4AGliaet5KkcgwDgYDVR0PAQH/BAQDAgIEMAwGA1UdEwQFMAMBAf8wHwYD\nVR0jBBgwFoAUC4tdmLVuf9hwfK4AGliaet5KkcgwDQYJKoZIhvcNAQENBQADggIB\nAGzL+GRnYu99zFoy0bXJKOGCF5XUXP/3gIXPRDqQf5g7Cu/jYMID9dB3No4Zmf7v\nqHjiSXiS8jx1j/6/Luk6PpFbT7QYm4QLs1f4BlfZOti2KE8r7KRDPIecUsUXW6P/\n3GJAVYH/+7OjA39za9AieM7+H5BELGccGrM5wfl7JeEz8in+V2ZWDzHQO4hMkiTQ\n4ZckuaL201F68YpiItBNnJ9N5nHr1MRiGyApHmLXY/wvlrOpclh95qn+lG6/2jk7\n3AmihLOKYMlPwPakJg4PYczm3icFLgTpjV5sq2md9bRyAg3oPGfAuWHmKj2Ikqch\nTd5CHKGxEEWbGUWEMP0s1A/JHWiCbDigc4Cfxhy56CWG4q0tYtnc2GMw8OAUO6Wf\nXu5pYKNkzKSEtT/MrNJt44tTZWbKV/Pi/N2Fx36my7TgTUj7g3xcE9eF4JV2H/sg\ntsK3pwE0FEqGnT4qMFbixQmc8bGyuakr23wjMvfO7eZUxBuWYR2SkcP26sozF9PF\ntGhbZHQVGZUTVPyvwahMUEhbPGVerOW0IYpxkm0x/eaWdTc4vPpf/rIlgbAjarnJ\nUN9SaWRlWKSdP4haujnzCoJbM7dU9bjvlGZNyXEekgeT0W2qFeGGp+yyUWw8tNsp\n0BuC1b7uW/bBn/xKm319wXVDvBgZgcktMolak39V7DVO\n-----END CERTIFICATE-----",
-            "timeStamp": "2020-10-06 20:40:13"
+            "timeStamp": "2020-10-08 18:10:13"
         }
     ]
 }
-- 
GitLab