/**************************************************************************** ** ** Copyright (C) 2024 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the release tools of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3 as published by the Free Software ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ // constructor function Component() { installer.valueChanged.connect(this, Component.prototype.reactOnTargetDirChange); // Update the location of the license server executable Component.prototype.reactOnTargetDirChange("TargetDir", installer.value("TargetDir")); } Component.prototype.beginInstallation = function() { if (installer.value("os") === "win") component.addStopProcessForUpdateRequest(component.qtlicdBinPath); } Component.prototype.reactOnTargetDirChange = function(key, value) { if (key == "TargetDir") { component.licenseServiceInstallationPath = "Tools/LicenseService"; component.qtlicdBinPath = installer.value("TargetDir") + "/" + component.licenseServiceInstallationPath + "/qtlicd"; if (installer.value("os") == "win") { component.qtlicdBinPath = installer.toNativeSeparators(component.qtlicdBinPath); component.qtlicdBinPath += ".exe"; } } } // local scope function Component.prototype.installQtlicdConfigFile= function(licenseServiceInstallationPath) { // TODO: This should origin via API discovery in future const productionCloudUrl = "https://qls.qt.io"; // qtlicd.ini destination var qtlicdConfDstPath = QDesktopServices.storageLocation(QDesktopServices.AppDataLocation); // QDesktopServices concatenates "" into the path, which we want to remove qtlicdConfDstPath = qtlicdConfDstPath.substring(0, qtlicdConfDstPath.lastIndexOf("/")); qtlicdConfDstPath += "/Qt/qtlicd/qtlicd.ini"; var qtlicdConfDstFolder = qtlicdConfDstPath.substring(0, qtlicdConfDstPath.lastIndexOf("/")); var qtlicdConfSrcPath = installer.value("TargetDir") + "/" + licenseServiceInstallationPath + "/qtlicd.ini"; var qtlicensetoolPath = installer.value("TargetDir") + "/" + licenseServiceInstallationPath + "/qtlicensetool"; if (installer.value("os") == "win") { qtlicdConfDstFolder = installer.toNativeSeparators(qtlicdConfDstFolder); qtlicdConfDstPath = installer.toNativeSeparators(qtlicdConfDstPath); qtlicdConfSrcPath = installer.toNativeSeparators(qtlicdConfSrcPath); qtlicensetoolPath = installer.toNativeSeparators(qtlicensetoolPath) + ".exe"; } if (installer.fileExists(qtlicdConfDstPath)) { // The qtlicd.ini file already exists in the destination location so we can not overwrite it with // the new version, as the current version may have the 'hw_id' already set and the user may have // changed e.g. the 'server_addr', which we do not want to overwrite with the default value as it may be // the user's on-premises instance instead. // We migrate the new/missing options only. console.log("Updating existing qtlicd.ini: " + qtlicdConfDstPath); component.addOperation("Execute", "{0}", qtlicensetoolPath, "--migrate-settings", qtlicdConfSrcPath, "UNDOEXECUTE"); // Qt installer integration accepts the Terms and Conditions automatically component.addOperation("LineReplace", qtlicdConfDstPath, "terms_and_conditions_accepted=", "terms_and_conditions_accepted=true"); } else { // The qtlicd.ini file does not exist in the intended destination location so we prepare one. // First we patch the source qtlicd.ini file with correct values. console.log("Installing qtlicd.ini into: " + qtlicdConfDstPath); component.addOperation("LineReplace", qtlicdConfSrcPath, "server_addr=", "server_addr=" + productionCloudUrl); // Workaround for [QLS-886] - patch the CA path to remove redundant quotation marks from the value // TODO: can be removed after fixed to config file skeleton component.addOperation("LineReplace", qtlicdConfSrcPath, "ca_bundle_path=", "ca_bundle_path=auto"); // Qt installer integration accepts the Terms and Conditions automatically component.addOperation("LineReplace", qtlicdConfSrcPath, "terms_and_conditions_accepted=", "terms_and_conditions_accepted=true"); // Move the patched source qtlicd.ini file in destination place if (installer.value("os") == "win") { var windir = installer.environmentVariable("WINDIR"); var cmdLocation = windir + "\\system32\\cmd.exe"; component.addOperation("Execute", "{0,1}", cmdLocation, "/C", "mkdir", qtlicdConfDstFolder, "UNDOEXECUTE"); component.addOperation("Execute", "{0}", cmdLocation, "/C", "move", "/y", qtlicdConfSrcPath, qtlicdConfDstPath, "UNDOEXECUTE"); } else if (installer.value("os") == "mac") { component.addOperation("Execute", "{0}", "mkdir", "-p", qtlicdConfDstFolder, "UNDOEXECUTE"); component.addOperation("Execute", "{0}", "mv", qtlicdConfSrcPath, qtlicdConfDstPath, "UNDOEXECUTE"); } else if (installer.value("os") == "x11" ) { component.addOperation("Execute", "{0}", "mkdir", "-p", qtlicdConfDstFolder, "UNDOEXECUTE"); component.addOperation("Execute", "{0}", "mv", qtlicdConfSrcPath, qtlicdConfDstPath, "UNDOEXECUTE"); } } } Component.prototype.createOperations = function() { component.createOperations(); const licenseServiceInstallationPath = "Tools/LicenseService"; try { Component.prototype.installQtlicdConfigFile(licenseServiceInstallationPath); } catch (e) { console.log("Failed to install qtlicd.ini settings: " + e); } // Register the qtlicd(.exe) location in the installations.ini file (next to qtlicd.ini file) var qtlicdBinPath = installer.value("TargetDir") + "/" + licenseServiceInstallationPath + "/qtlicd"; if (installer.value("os") == "win") { qtlicdBinPath = installer.toNativeSeparators(qtlicdBinPath); qtlicdBinPath += ".exe"; } component.qtlicdBinPath = qtlicdBinPath; component.addOperation("Execute", [qtlicdBinPath, // path of the Service executable "--register", // command to register itself's location in the installations.ini file "installer", // optional: source of the registration, i.e. the "Qt Installer" in this case "UNDOEXECUTE", "{0}", qtlicdBinPath, "--unregister" // remove it's location from the installations.ini when uninstalling ]); }