PDA

View Full Version : Qt Installer Framework - Reading downloaded package version



Laureta
7th April 2015, 19:37
Hi all,

I posted this few hours ago in the Qt Tools forum (http://www.qtcentre.org/threads/62155-Qt-Installer-Framework-Reading-downloaded-package-version), but I think here, having more movement, I can get some help.

There seems to be very few folks using this tool (Qt Installer Framework), but I'll ask before migrating to a third party tool.
Using QtIFW-1.5.0, so far I am able to generate an online installer for my Qt application on Windows. The installer downloads the appropriate package from my web server and performs some operations defined in the control script installscript.qs, e.g. writing some keys into registry and creating a desktop shortcut with an icon:


Component.prototype.createOperations = function()
{
try {

// call the base create operations function

component.createOperations();

// Add some keys to registry;

var userProfile = installer.environmentVariable("USERPROFILE");
installer.setValue("UserProfile", userProfile);
var reg = installer.environmentVariable("SystemRoot") + "\\System32\\reg.exe";
var key= "HKCU\\Software\\Company\\Product";
component.addOperation("Execute", reg, "ADD", key, "/f");
component.addOperation("Execute", reg, "ADD", key, "/v", "productId", "/t", "REG_BINARY");

// Add a desktop shortcut with icon:
component.addOperation("CreateShortcut", "@TargetDir@\\MyExecutable.exe", "@UserProfile@\\Desktop\\MyExecutable.lnk",
"workingDirectory=@TargetDir@", "iconPath=@TargetDir@\\MyIcon.ico");

} catch (e) {

print(e);

}
}
All right, but another key I need to write into registry is the package VERSION NUMBER, defined in the installer configuration file config.xml in tag <Version></Version>
How can I get this value from installscript.qs ? I read --I'd said more: studied-- the docs https://doc-snapshots.qt.io/qtifw-master/scripting-component.html and https://doc-snapshots.qt.io/qtifw-master/scripting-installer.html and I have not found any reference to version, except:

boolean versionMatches(string version, string requirement)
which is useless for me, because you have to know the version, which is precisely what I find.

So any help would be appreciated.

ChrisW67
7th April 2015, 21:42
I have never tried to use the tool, so this is a wild guess.

Is the "Version" available through the value() function of either class?

Laureta
9th April 2015, 15:16
Is the "Version" available through the value() function of either class?
Finally, I found the way --asking elsewhere:

var version = installer.value("ProductVersion");
As you can see, the variable name (ProductVersion) does not match the Tag name (Version). Is there any quick guide with the config variables accessible from the installation script?

ChrisW67
9th April 2015, 20:28
http://doc.qt.io/qtinstallerframework/scripting.html#predefined-variables

Laureta
10th April 2015, 08:18
I have read this documentation dozens of times without seeing it! Thank You.