Add installer
This commit is contained in:
parent
c9bc8aa8c1
commit
a2a5cafc5f
73 changed files with 4354 additions and 488 deletions
|
|
@ -0,0 +1,115 @@
|
|||
|
||||
function appName()
|
||||
{
|
||||
return installer.value("Name")
|
||||
}
|
||||
|
||||
function serviceName()
|
||||
{
|
||||
return (appName() + "-service")
|
||||
}
|
||||
|
||||
function appExecutableFileName()
|
||||
{
|
||||
if (runningOnWindows()) {
|
||||
return appName() + ".exe";
|
||||
} else {
|
||||
return appName();
|
||||
}
|
||||
}
|
||||
|
||||
function runningOnWindows()
|
||||
{
|
||||
return (systemInfo.kernelType === "winnt");
|
||||
}
|
||||
|
||||
function runningOnMacOS()
|
||||
{
|
||||
return (systemInfo.kernelType === "darwin");
|
||||
}
|
||||
|
||||
function vcRuntimeIsInstalled()
|
||||
{
|
||||
return (installer.findPath("msvcp140.dll", [installer.value("RootDir")+ "\\Windows\\System32\\"]).length !== 0)
|
||||
}
|
||||
|
||||
function Component()
|
||||
{
|
||||
component.loaded.connect(this, Component.prototype.componentLoaded);
|
||||
installer.installationFinished.connect(this, Component.prototype.installationFinishedPageIsShown);
|
||||
installer.finishButtonClicked.connect(this, Component.prototype.installationFinished);
|
||||
}
|
||||
|
||||
Component.prototype.componentLoaded = function ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Component.prototype.installationFinishedPageIsShown = function()
|
||||
{
|
||||
if (installer.isInstaller() && installer.status === QInstaller.Success) {
|
||||
gui.clickButton(buttons.FinishButton);
|
||||
}
|
||||
}
|
||||
|
||||
Component.prototype.createOperations = function()
|
||||
{
|
||||
component.createOperations();
|
||||
|
||||
if (runningOnWindows()) {
|
||||
|
||||
component.addOperation("CreateShortcut", "@TargetDir@/" + appExecutableFileName(),
|
||||
QDesktopServices.storageLocation(QDesktopServices.DesktopLocation) + "/" + appName() + ".lnk",
|
||||
"workingDirectory=@TargetDir@", "iconPath=@TargetDir@\\" + appExecutableFileName(), "iconId=0");
|
||||
|
||||
|
||||
component.addElevatedOperation("CreateShortcut", "@TargetDir@/" + appExecutableFileName(),
|
||||
installer.value("AllUsersStartMenuProgramsPath") + "/" + appName() + ".lnk",
|
||||
"workingDirectory=@TargetDir@", "iconPath=@TargetDir@\\" + appExecutableFileName(), "iconId=0");
|
||||
|
||||
if (!vcRuntimeIsInstalled()) {
|
||||
component.addElevatedOperation("Execute", "@TargetDir@\\" + "vc_redist.x86.exe", "/install", "/quiet", "/norestart", "/log", "vc_redist_2017_x86.log");
|
||||
} else {
|
||||
console.log("Microsoft Visual C++ 2017 Redistributable already installed");
|
||||
}
|
||||
|
||||
component.addElevatedOperation("Execute",
|
||||
["sc", "create", serviceName(), "binpath=", installer.value("TargetDir").replace(/\//g, '\\') + "\\" + serviceName() + ".exe",
|
||||
"start=", "auto", "depend=", "BFE/nsi"],
|
||||
"UNDOEXECUTE", ["post-uninstall.exe"]);
|
||||
|
||||
} else if (runningOnMacOS()) {
|
||||
component.addElevatedOperation("Execute", "@TargetDir@/post_install.sh", "UNDOEXECUTE", "@TargetDir@/post_uninstall.sh");
|
||||
}
|
||||
}
|
||||
|
||||
Component.prototype.installationFinished = function()
|
||||
{
|
||||
var command = "";
|
||||
var args = [];
|
||||
|
||||
if ((installer.status === QInstaller.Success) && (installer.isInstaller() || installer.isUpdater())) {
|
||||
|
||||
if (!installer.gainAdminRights()) {
|
||||
console.log("Fatal error! Cannot get admin rights!")
|
||||
return
|
||||
}
|
||||
|
||||
if (runningOnWindows()) {
|
||||
command = "@TargetDir@/" + appExecutableFileName()
|
||||
|
||||
var status1 = installer.execute("net", ["start", serviceName()])
|
||||
console.log(("%1 started with status: %2 ").arg(serviceName()).arg(status1))
|
||||
|
||||
var status2 = installer.execute("sc", ["failure", serviceName(), "reset=", "100", "actions=", "restart/2000/restart/2000/restart/2000"])
|
||||
console.log(("Changed settings for %1 with status: %2 ").arg(serviceName()).arg(status2))
|
||||
|
||||
} else if (runningOnMacOS()) {
|
||||
command = "/Applications/" + appName() + ".app/Contents/MacOS/" + appName();
|
||||
}
|
||||
|
||||
installer.dropAdminRights()
|
||||
|
||||
processStatus = installer.executeDetached(command, args, installer.value("TargetDir"));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue