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

QtIF: Extract Update sequence



  • Hi,

    i would like to know what is the correct sequence of extracting new contents.
    I have an update and will updat emy installer via maintenance-tool. If i update a specific component, i have to stop a process so that is possible to update this component.

    The Update mechnism used the normal function?

    Component.prototype.createOperations = function()
    
    

    In https://doc.qt.io/qtinstallerframework/scripting.html#adding-operations-to-components :
    You might want to add custom operations after extracting the content, when copying files or patching file content, for example. You can create and add update operations to the installation from within a script using component::addOperation(). If you need to run an operation that requires administrative rights, use component::addElevatedOperation() instead.

    I do not really understand these sentences:
    Operations need to be added before the actual installation step. Override component::createOperations() to register custom operations for a component.
    These are two differnet senteces, because i implement my implementation logic AFTER extracting in createOperations.

    So i would like to know, how to this Operations need to be added before the actual installation step.

    What if i the content, e.g. a foo.exe, is delivered to a path, where the foo.exe is still used and have to be stopped before?
    When and where in the code i have to call these methods before the new content is delivered?

    function Component()
    {}
    
    
    Component.prototype.createOperations = function()
    {
            component.createOperations();		
    
    	if(installer.isUpdater())
    	{		
    		if(component.updateRequested())
    		{
    			// stop here the processes BEFORE the normal installation?!?!?!?
    		}		
    	}
    	else 
    	{	
    		// Installer AND Uninstaller and Updater-function?!
    	}
    		
    }
    
    
    Component.prototype.createOperationsForArchive = function(archive) {		
    	component.addOperation("Extract", archive, "@TargetDir@/foo");
    }
    

    Thank you for your help in advance.


  • Moderators

    Hi @Schenk,

    Can you clarify a bit as to what you mean here, I am not entirely sure what you need to achieve, so if you could give a scenario then I can understand a bi better. Thanks.



  • @AndyS Hi Andy,

    I want to stop my process, install/extract the content by the installer/updater and restart my process.

    i have an installation with an already running process. The update should update this process, which have to be stopped before it can be updated. When i want to update my installation with the maintanance.exe the log says, that this process should be stopped first of all and then retry. My problem is wehre to put these "Stopping"-routine in the script.

    I already tried:

    function Component()
    {}
    
    
    Component.prototype.createOperations = function()
    {
            component.createOperations();		
    	// STOP HERE - DOES NOT WORK!	
    }
    
    
    Component.prototype.createOperationsForArchive = function(archive) {		
           // STOP HERE - DOES NOT WORK!
    	component.addOperation("Extract", archive, "@TargetDir@/foo");
    }
    


  • Ok, issue solved. This behaviour is not described in the so-called documentation.
    You have to overwrite the beginInstallation-Method and there you can do whatever you want to do before the extraction of the new content.

    A good hint was the package installation script of the Qt Creator setup. There are serveral good hints which are not described in the api documentation.


  • Moderators

    I am glad that you have been able to solve it. I agree that the documentation needs some updating and this is something I am hoping to improve on at some point over the next weeks or so.



  • It is not the solution. At the beginning of the update mechinsm the beginInstasllation method is called, but no component-methods. The first method called is the UNDOEXECUTE routine.



  • The createOperatiosn method is executed backwards and it is exeuted the UNDOEXECUTE routine. So, is there no way than put my "routine" in the UNDO ECUTE of the installer for the update?



  • @Schenk
    have you tried setStopProcessForUpdateRequest(string process, boolean requested) ?
    https://doc.qt.io/qtinstallerframework/scripting-component.html#setStopProcessForUpdateRequest-method
    Edit:
    U can also try to popup an messagebox so that user stops process using stopProcessesForUpdates
    https://doc.qt.io/qtinstallerframework/noninteractive.html#message-boxes



  • @Ratzz Hi, ratzz,

    it is a windows service. Apart from stopping the service, maybe i want to save some files before uninstall/updater. But the updater execute the createOperations backwards and then the other stuff. So i need a entry point in the code, that i am able to save my files BEFORE the uninstalling.



  • @Schenk said in QtIF: Extract Update sequence:

    i want to save some files

    What sort of file? Why you want to save? currently where you save?



  • @Ratzz Files like config-files. I want to save them, because the application should run like before with the same config-files etc.



  • I tried to copy the files which i want to save before the uninstallation/update via UNDOEXECUTE, but there is no chance to save this files. They dissapear. Even if iy try the xcopy, xcopy etc., no file get saved.


Log in to reply