Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installer: Fix issue with previous version remove #1715

Merged
merged 4 commits into from
Jun 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading