Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTIFW - How to update maintenancetool.exe?



  • Hello,

    We use Qt Installer Frameworks version 3.2 since several months to deploy our updates and everything works fine :)
    In our case we have an online server that hosts our repositories and our application automatically detects if an update if available when we launch it.

    It works fine but we'd like to use the last version now: Qt Installer Frameworks version 4.1.0
    I tried to generate a new reposity with repogen.exe 4.1.0, but if I try to update my own application which uses maintenancetool.exe 3.2 my app is well updated but maintenancetool.exe is still in version 3.2.

    How do I have to do to automatically update maintenancetool (in my application folder) from version 3.2 to 4.1.0 for my customers?

    Thanks a lot.



  • You need to put installerbase(.exe) from bin folder to repository, mark the component as Essential and as ForcedInstallation (https://doc.qt.io/qtinstallerframework/ifw-component-description.html) and use the following script. In case you don't need to update the resource file you can skip the update.rcc part, in case those have changed you can get the updated resource by running binarycreator with -rcc -parameter.

    function Component()
    {
        installer.installationStarted.connect(this, Component.prototype.onInstallationStarted);
    }
    
    Component.prototype.onInstallationStarted = function()
    {
        if (component.updateRequested() || component.installationRequested()) {
            if (installer.value("os") == "win")
                component.installerbaseBinaryPath = "@TargetDir@/installerbase.exe";
            else if (installer.value("os") == "x11" || installer.value("os") == "mac")
                component.installerbaseBinaryPath = "@TargetDir@/.installerbase";
            installer.setInstallerBaseBinary(component.installerbaseBinaryPath);
    
            // update resource file if exists in the archive
            var updateResourceFilePath = "@TargetDir@/update.rcc";
            var normalizedUpdateResourceFilePath = updateResourceFilePath.replace(/@TargetDir@/, installer.value("TargetDir"));
            
            print("Updating resource file: " + normalizedUpdateResourceFilePath);
            installer.setValue("DefaultResourceReplacement", normalizedUpdateResourceFilePath);
            
        }
    }
    

Log in to reply