From 4d9d578902aae37d62ea3218efa2b062cb7f893f Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 8 Oct 2020 03:04:25 +0200 Subject: [pkg] parametrize win/osx installer --- branding/qtinstaller/config/config.xml | 14 --- .../packages/root.win_x86_64/.gitignore | 1 - .../packages/root.win_x86_64/meta/installscript.js | 77 ------------- .../packages/root.win_x86_64/meta/package.xml | 10 -- .../qtinstaller/packages/root/meta/package.xml | 7 -- branding/scripts/gen-qtinstaller | 121 +++++++++++++++++++++ branding/templates/qtinstaller/config/config.xml | 21 +--- branding/templates/qtinstaller/linux-data/readme | 1 + .../templates/qtinstaller/osx-data/post-install.py | 103 ++++++++++++++++++ .../osx-data/se.leap.bitmask-helper.plist | 26 +++++ .../templates/qtinstaller/osx-data/uninstall.py | 70 ++++++++++++ branding/templates/qtinstaller/osx/post-install.py | 103 ------------------ .../qtinstaller/osx/se.leap.bitmask-helper.plist | 26 ----- branding/templates/qtinstaller/osx/uninstall.py | 70 ------------ .../packages/bitmaskvpn/meta/install.js | 64 ++++++++++- .../packages/bitmaskvpn/meta/package.xml | 8 +- branding/templates/qtinstaller/win-data/readme | 1 + 17 files changed, 390 insertions(+), 333 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 create mode 100755 branding/templates/qtinstaller/osx-data/post-install.py create mode 100644 branding/templates/qtinstaller/osx-data/se.leap.bitmask-helper.plist create mode 100755 branding/templates/qtinstaller/osx-data/uninstall.py delete mode 100755 branding/templates/qtinstaller/osx/post-install.py delete mode 100644 branding/templates/qtinstaller/osx/se.leap.bitmask-helper.plist delete mode 100755 branding/templates/qtinstaller/osx/uninstall.py create mode 100644 branding/templates/qtinstaller/win-data/readme (limited to 'branding') diff --git a/branding/qtinstaller/config/config.xml b/branding/qtinstaller/config/config.xml deleted file mode 100644 index 8ce9b2e..0000000 --- a/branding/qtinstaller/config/config.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - DemoLibVPN-0.0.1 - 0.0.1 - DemoLibVPN Installer - LEAP Encryption Access Project - @ApplicationsDir@/DemoLibVPN - @TargetDir@/demolib-vpn.exe - - - DemoLibVPN - Uninstall-DemoLibVPN - false - 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 60baa9c..0000000 --- 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 1598458..0000000 --- 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 = "" + message +""; - 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 11d630f..0000000 --- a/branding/qtinstaller/packages/root.win_x86_64/meta/package.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - DemoLibVPN For Windows - Install DemoLibVPN - 0.0.1-1 - 2020-09-15 - true - true - - diff --git a/branding/qtinstaller/packages/root/meta/package.xml b/branding/qtinstaller/packages/root/meta/package.xml deleted file mode 100644 index b4ca25e..0000000 --- a/branding/qtinstaller/packages/root/meta/package.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - DemoLibVPN - 0.0.1-1 - 2020-09-15 - script - diff --git a/branding/scripts/gen-qtinstaller b/branding/scripts/gen-qtinstaller new file mode 100755 index 0000000..419d958 --- /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': """ + + @ApplicationsDir@/$APPNAME.app + $APPNAME.app + open + Start $APPNAME now! + + @TargetDir@ + + mac + +""", + 'windows': """ + @ApplicationsDir@/DemoLibVPN + $APPNAME + + @TargetDir@/$BINNAME.exe + + + +""" +} + + + +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 '.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 8b28be6..c02b0a6 100644 --- a/branding/templates/qtinstaller/config/config.xml +++ b/branding/templates/qtinstaller/config/config.xml @@ -1,13 +1,9 @@ - - DemoLibVPN-0.0.1 - 0.0.1 - DemoLibVPN Installer + $APPNAME-$VERSION + $VERSION + $APPNAME Installer ($VERSION) LEAP Encryption Access Project - @ApplicationsDir@/DemoLibVPN.app - - DemoLibVPN.app false - Uninstall-DemoLibVPN + Uninstall-$APPNAME - - open - Start DemoLibVPN now! - - @TargetDir@ - - mac - + $PLATFORM_BLOCK diff --git a/branding/templates/qtinstaller/linux-data/readme b/branding/templates/qtinstaller/linux-data/readme new file mode 100644 index 0000000..e039088 --- /dev/null +++ b/branding/templates/qtinstaller/linux-data/readme @@ -0,0 +1 @@ +linux-specific installer data diff --git a/branding/templates/qtinstaller/osx-data/post-install.py b/branding/templates/qtinstaller/osx-data/post-install.py new file mode 100755 index 0000000..2c15845 --- /dev/null +++ b/branding/templates/qtinstaller/osx-data/post-install.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python + +# Post installation script for BitmaskVPN. +# Please note that this installation will install ONE single helper with administrative privileges. +# This means that, for the time being, you can only install ONE of the BitmaskVPN derivatives at the same time. +# This might change in the future. + +import os +import shutil +import sys +import subprocess + +HELPER = "bitmask-helper" +HELPER_PLIST = "/Library/LaunchDaemons/se.leap.bitmask-helper.plist" + +_dir = os.path.dirname(os.path.realpath(__file__)) + +def main(): + log = open(os.path.join(_dir, 'post-install.log'), 'w') + log.write('Checking for admin privileges...\n') + + _id = os.getuid() + if _id != 0: + err = "error: need to run as root. UID: %s\n" % str(_id) + logErr(log, err) + + # failure: sys.exit(1) + + if isHelperRunning(): + log.write("Trying to stop bitmask-helper...\n") + # if this fail, we can check if the HELPER_PLIST is there + ok = unloadHelper() + log.write("success: %s \n" % str(ok)) + + ok = fixHelperOwner(log) + log.write("chown helper: %s \n" % str(ok)) + + log.write("Copy launch daemon...\n") + copyLaunchDaemon() + + log.write("Trying to launch helper...\n") + out = launchHelper() + log.write("result: %s \n" % str(out)) + + grantPermissionsOnLogFolder() + + # all done + log.write('post-install script: done\n') + sys.exit(0) + + +def logErr(log, msg): + log.write(msg) + sys.exit(1) + +def isHelperRunning(): + ps = _getProcessList() + return HELPER in ps + +def unloadHelper(): + out = subprocess.call(["launchctl", "unload", HELPER_PLIST]) + out2 = subprocess.call(["pkill", "-9", "bitmask-helper"]) # just in case + return out == 0 + +def fixHelperOwner(log): + path = os.path.join(_dir, HELPER) + try: + os.chown(path, 0, 0) + except OSError as exc: + log.write(str(exc)) + return False + return True + +def copyLaunchDaemon(): + plist = "se.leap.bitmask-helper.plist" + path = os.path.join(_dir, plist) + _p = _dir.replace("/", "\/") + subprocess.call(["sed", "-i.back", "s/PATH/%s/" % _p, path]) + shutil.copy(path, HELPER_PLIST) + +def launchHelper(): + out = subprocess.call(["launchctl", "load", HELPER_PLIST]) + return out == 0 + +def grantPermissionsOnLogFolder(): + helperDir = os.path.join(_dir, 'helper') + try: + os.makedirs(helperDir) + except Exception: + pass + os.chown(helperDir, 0, 0) + +def _getProcessList(): + _out = [] + output = subprocess.Popen(["ps", "-ceA"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + stdout, stderr = output.communicate() + for line in stdout.split('\n'): + cmd = line.split(' ')[-1] + _out.append(cmd.strip()) + return _out + +if __name__ == "__main__": + main() diff --git a/branding/templates/qtinstaller/osx-data/se.leap.bitmask-helper.plist b/branding/templates/qtinstaller/osx-data/se.leap.bitmask-helper.plist new file mode 100644 index 0000000..c333aba --- /dev/null +++ b/branding/templates/qtinstaller/osx-data/se.leap.bitmask-helper.plist @@ -0,0 +1,26 @@ + + + + + WorkingDirectory + PATH + StandardOutPath + PATH/helper/bitmask-helper.log + StandardErrorPath + PATH/helper/bitmask-helper-err.log + GroupName + daemon + RunAtLoad + + SessionCreate + + KeepAlive + + ThrottleInterval + 5 + Label + se.leap.BitmaskHelper + Program + PATH/bitmask-helper + + diff --git a/branding/templates/qtinstaller/osx-data/uninstall.py b/branding/templates/qtinstaller/osx-data/uninstall.py new file mode 100755 index 0000000..7aa8a56 --- /dev/null +++ b/branding/templates/qtinstaller/osx-data/uninstall.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python + +# Uninstall script for BitmaskVPN. + +import os +import shutil +import sys +import subprocess + +HELPER = "bitmask-helper" +HELPER_PLIST = "/Library/LaunchDaemons/se.leap.bitmask-helper.plist" + +_dir = os.path.dirname(os.path.realpath(__file__)) + +def main(): + log = open(os.path.join('/tmp', 'bitmask-uninstall.log'), 'w') + log.write('Checking for admin privileges...\n') + + _id = os.getuid() + log.write("UID: %s\n" % str(_id)) + if int(_id) != 0: + err = "error: need to run as root. UID: %s\n" % str(_id) + logErr(log, err) + + # failure: sys.exit(1) + + log.write('Checking if helper is running') + + if isHelperRunning(): + log.write("Trying to stop bitmask-helper...\n") + # if this fail, we can check if the HELPER_PLIST is there + ok = unloadHelper() + log.write("success: %s \n" % str(ok)) + + log.write("Removing LaunchDaemon") + out = removeLaunchDaemon() + log.write("result: %s \n" % str(out)) + + # all done + log.write('uninstall script: done\n') + sys.exit(0) + + +def logErr(log, msg): + log.write(msg) + sys.exit(1) + +def isHelperRunning(): + ps = _getProcessList() + return HELPER in ps + +def unloadHelper(): + out = subprocess.call(["launchctl", "unload", HELPER_PLIST]) + out2 = subprocess.call(["pkill", "-9", "bitmask-helper"]) # just in case + return out == 0 + +def removeLaunchDaemon(): + return subprocess.call(["rm", "-f", HELPER_PLIST]) + +def _getProcessList(): + _out = [] + output = subprocess.Popen(["ps", "-ceA"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + stdout, stderr = output.communicate() + for line in stdout.split('\n'): + cmd = line.split(' ')[-1] + _out.append(cmd.strip()) + return _out + +if __name__ == "__main__": + main() diff --git a/branding/templates/qtinstaller/osx/post-install.py b/branding/templates/qtinstaller/osx/post-install.py deleted file mode 100755 index 2c15845..0000000 --- a/branding/templates/qtinstaller/osx/post-install.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env python - -# Post installation script for BitmaskVPN. -# Please note that this installation will install ONE single helper with administrative privileges. -# This means that, for the time being, you can only install ONE of the BitmaskVPN derivatives at the same time. -# This might change in the future. - -import os -import shutil -import sys -import subprocess - -HELPER = "bitmask-helper" -HELPER_PLIST = "/Library/LaunchDaemons/se.leap.bitmask-helper.plist" - -_dir = os.path.dirname(os.path.realpath(__file__)) - -def main(): - log = open(os.path.join(_dir, 'post-install.log'), 'w') - log.write('Checking for admin privileges...\n') - - _id = os.getuid() - if _id != 0: - err = "error: need to run as root. UID: %s\n" % str(_id) - logErr(log, err) - - # failure: sys.exit(1) - - if isHelperRunning(): - log.write("Trying to stop bitmask-helper...\n") - # if this fail, we can check if the HELPER_PLIST is there - ok = unloadHelper() - log.write("success: %s \n" % str(ok)) - - ok = fixHelperOwner(log) - log.write("chown helper: %s \n" % str(ok)) - - log.write("Copy launch daemon...\n") - copyLaunchDaemon() - - log.write("Trying to launch helper...\n") - out = launchHelper() - log.write("result: %s \n" % str(out)) - - grantPermissionsOnLogFolder() - - # all done - log.write('post-install script: done\n') - sys.exit(0) - - -def logErr(log, msg): - log.write(msg) - sys.exit(1) - -def isHelperRunning(): - ps = _getProcessList() - return HELPER in ps - -def unloadHelper(): - out = subprocess.call(["launchctl", "unload", HELPER_PLIST]) - out2 = subprocess.call(["pkill", "-9", "bitmask-helper"]) # just in case - return out == 0 - -def fixHelperOwner(log): - path = os.path.join(_dir, HELPER) - try: - os.chown(path, 0, 0) - except OSError as exc: - log.write(str(exc)) - return False - return True - -def copyLaunchDaemon(): - plist = "se.leap.bitmask-helper.plist" - path = os.path.join(_dir, plist) - _p = _dir.replace("/", "\/") - subprocess.call(["sed", "-i.back", "s/PATH/%s/" % _p, path]) - shutil.copy(path, HELPER_PLIST) - -def launchHelper(): - out = subprocess.call(["launchctl", "load", HELPER_PLIST]) - return out == 0 - -def grantPermissionsOnLogFolder(): - helperDir = os.path.join(_dir, 'helper') - try: - os.makedirs(helperDir) - except Exception: - pass - os.chown(helperDir, 0, 0) - -def _getProcessList(): - _out = [] - output = subprocess.Popen(["ps", "-ceA"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - stdout, stderr = output.communicate() - for line in stdout.split('\n'): - cmd = line.split(' ')[-1] - _out.append(cmd.strip()) - return _out - -if __name__ == "__main__": - main() diff --git a/branding/templates/qtinstaller/osx/se.leap.bitmask-helper.plist b/branding/templates/qtinstaller/osx/se.leap.bitmask-helper.plist deleted file mode 100644 index c333aba..0000000 --- a/branding/templates/qtinstaller/osx/se.leap.bitmask-helper.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - WorkingDirectory - PATH - StandardOutPath - PATH/helper/bitmask-helper.log - StandardErrorPath - PATH/helper/bitmask-helper-err.log - GroupName - daemon - RunAtLoad - - SessionCreate - - KeepAlive - - ThrottleInterval - 5 - Label - se.leap.BitmaskHelper - Program - PATH/bitmask-helper - - diff --git a/branding/templates/qtinstaller/osx/uninstall.py b/branding/templates/qtinstaller/osx/uninstall.py deleted file mode 100755 index 7aa8a56..0000000 --- a/branding/templates/qtinstaller/osx/uninstall.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python - -# Uninstall script for BitmaskVPN. - -import os -import shutil -import sys -import subprocess - -HELPER = "bitmask-helper" -HELPER_PLIST = "/Library/LaunchDaemons/se.leap.bitmask-helper.plist" - -_dir = os.path.dirname(os.path.realpath(__file__)) - -def main(): - log = open(os.path.join('/tmp', 'bitmask-uninstall.log'), 'w') - log.write('Checking for admin privileges...\n') - - _id = os.getuid() - log.write("UID: %s\n" % str(_id)) - if int(_id) != 0: - err = "error: need to run as root. UID: %s\n" % str(_id) - logErr(log, err) - - # failure: sys.exit(1) - - log.write('Checking if helper is running') - - if isHelperRunning(): - log.write("Trying to stop bitmask-helper...\n") - # if this fail, we can check if the HELPER_PLIST is there - ok = unloadHelper() - log.write("success: %s \n" % str(ok)) - - log.write("Removing LaunchDaemon") - out = removeLaunchDaemon() - log.write("result: %s \n" % str(out)) - - # all done - log.write('uninstall script: done\n') - sys.exit(0) - - -def logErr(log, msg): - log.write(msg) - sys.exit(1) - -def isHelperRunning(): - ps = _getProcessList() - return HELPER in ps - -def unloadHelper(): - out = subprocess.call(["launchctl", "unload", HELPER_PLIST]) - out2 = subprocess.call(["pkill", "-9", "bitmask-helper"]) # just in case - return out == 0 - -def removeLaunchDaemon(): - return subprocess.call(["rm", "-f", HELPER_PLIST]) - -def _getProcessList(): - _out = [] - output = subprocess.Popen(["ps", "-ceA"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - stdout, stderr = output.communicate() - for line in stdout.split('\n'): - cmd = line.split(' ')[-1] - _out.append(cmd.strip()) - return _out - -if __name__ == "__main__": - main() diff --git a/branding/templates/qtinstaller/packages/bitmaskvpn/meta/install.js b/branding/templates/qtinstaller/packages/bitmaskvpn/meta/install.js index 0bcaeef..361e14d 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 = "" + message +""; + 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 b910e7f..0e56f4f 100644 --- a/branding/templates/qtinstaller/packages/bitmaskvpn/meta/package.xml +++ b/branding/templates/qtinstaller/packages/bitmaskvpn/meta/package.xml @@ -1,9 +1,9 @@ - DemoLibVPN - DemoLibVPN - 0.20.9-1 - 2020-10-01 + $APPNAME + $APPNAME + $VERSION + $TIMESTAMP false true diff --git a/branding/templates/qtinstaller/win-data/readme b/branding/templates/qtinstaller/win-data/readme new file mode 100644 index 0000000..8938b54 --- /dev/null +++ b/branding/templates/qtinstaller/win-data/readme @@ -0,0 +1 @@ +windows-specific installer data -- cgit v1.2.3