Skip to content

Commit

Permalink
Fix warning and perform remove before extract (#1715)
Browse files Browse the repository at this point in the history
* Fix warning and perform remove before extract

* Formatted

* Add sleep for windows

---------

Co-authored-by: iakov <[email protected]>
  • Loading branch information
MinyazevR and iakov authored Jun 2, 2024
1 parent d9af3ca commit ff0956c
Showing 1 changed file with 53 additions and 50 deletions.
103 changes: 53 additions & 50 deletions installer/packages/qreal-base/ru.qreal.root/meta/installscript.qs
Original file line number Diff line number Diff line change
Expand Up @@ -53,56 +53,6 @@ var directoryNotEmpty = [
// "Каталог установки должен быть пустым."];
"\u041a\u0430\u0442\u0430\u043b\u043e\u0433 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c."];



// Constructor
function Component()
{
// Executable names must be lower-case product name with hyphens instead of spaces
installer.executableName = installer.value("ProductName").toLowerCase().replace(/\s/g, "-");
installer.linkExtension = installer.value("os") === "win" ? ".lnk" : "";
installer.execExtension = installer.value("os") === "win" ? ".vbs" : installer.value("os") === "mac" ? ".app" : "";
installer.maintenanceName = "maintenance" + (installer.value("os") === "win" ? ".exe" : installer.execExtension);
installer.shouldDeinstallPrevious = false;

component.loaded.connect(this, Component.prototype.installerLoaded);
installer.setDefaultPageVisible(QInstaller.TargetDirectory, false);
}

Component.prototype.createOperations = function()
{
if (installer.shouldDeinstallPrevious) {
component.addOperation("Execute", Dir.toNativeSeparator("@TargetDir@/" + installer.maintenanceName));
if (installer.value("os") == "win") {
var timeoutBatch = "ping localhost -n 4 > nul";
component.addOperation("Execute", "cmd", "/c", timeoutBatch);
var joinBatch = "for /l %N in () do (tasklist | find \"cscript\" >nul && ping localhost -n 2 >nul || exit 0) ";
component.addOperation("Execute", "cmd", "/c", joinBatch);
}
}
component.createOperations();
if (installer.value("os") == "win") {
component.addOperation("CreateShortcut"
, "@TargetDir@\\" + installer.executableName + installer.execExtension
, "@StartMenuDir@\\@ProductName@ @Version@" + installer.linkExtension
, "iconPath=@TargetDir@\\trik-studio.ico");
component.addOperation("CreateShortcut"
, "@TargetDir@\\" + installer.maintenanceName
, "@StartMenuDir@\\Uninstall @ProductName@" + installer.linkExtension);
component.addOperation("Execute"
, "@TargetDir@\\" + installer.executableName + ".cmd"
, "--clear-conf");
} else if (installer.value("os") == "mac") {
component.addOperation("Execute"
, "@TargetDir@/" + installer.value("ProductName") + ".app/Contents/MacOS/" + installer.executableName, "--clear-conf");
} else {
component.addOperation("Execute"
, "bash"
, "-c"
, "LD_LIBRARY_PATH=@TargetDir@ @TargetDir@/" + installer.executableName + installer.execExtension + " --platform minimal --clear-conf");
}
}

// Utility function like QString QDir::toNativeSeparators(const QString & pathName)
var Dir = new function () {
this.toNativeSeparator = function (path) {
Expand Down Expand Up @@ -176,6 +126,59 @@ var Dir = new function () {
}
};


// Constructor
function Component()
{
// Executable names must be lower-case product name with hyphens instead of spaces
installer.executableName = installer.value("ProductName").toLowerCase().replace(/\s/g, "-");
installer.linkExtension = installer.value("os") === "win" ? ".lnk" : "";
installer.execExtension = installer.value("os") === "win" ? ".vbs" : installer.value("os") === "mac" ? ".app" : "";
installer.maintenanceName = "maintenance" + (installer.value("os") === "win" ? ".exe" : installer.execExtension);
installer.shouldDeinstallPrevious = false;

component.loaded.connect(this, Component.prototype.installerLoaded);
installer.setDefaultPageVisible(QInstaller.TargetDirectory, false);

installer.installationStarted.connect(function() {
if (installer.shouldDeinstallPrevious) {
installer.performOperation("Execute", Dir.toNativeSeparator("@TargetDir@/" + installer.maintenanceName));
if (installer.value("os") == "win") {
var timeoutBatch = "ping localhost -n 4 > nul";
installer.performOperation("Execute", ["cmd", "/c", timeoutBatch]);
var joinBatch = "for /I %N in () do (tasklist | find \"cscript\" >nul && ping localhost -n 2 >nul || exit 0) ";
installer.performOperation("Execute", ["cmd", "/c", joinBatch]);
}
}
});
}

Component.prototype.createOperations = function()
{
component.createOperations();
if (installer.value("os") == "win") {
component.addOperation("CreateShortcut"
, "@TargetDir@\\" + installer.executableName + installer.execExtension
, "@StartMenuDir@\\@ProductName@ @Version@" + installer.linkExtension
, "iconPath=@TargetDir@\\trik-studio.ico");
component.addOperation("CreateShortcut"
, "@TargetDir@\\" + installer.maintenanceName
, "@StartMenuDir@\\Uninstall @ProductName@" + installer.linkExtension);
component.addOperation("Execute"
, "@TargetDir@\\" + installer.executableName + ".cmd"
, "--clear-conf");
} else if (installer.value("os") == "mac") {
component.addOperation("Execute"
, "@TargetDir@/" + installer.value("ProductName") + ".app/Contents/MacOS/" + installer.executableName, "--clear-conf");
} else {
component.addOperation("Execute"
, "bash"
, "-c"
, "LD_LIBRARY_PATH=@TargetDir@ @TargetDir@/" + installer.executableName + installer.execExtension + " --platform minimal --clear-conf");
}
}


// Called as soon as the component was loaded
Component.prototype.installerLoaded = function()
{
Expand Down

0 comments on commit ff0956c

Please sign in to comment.