0

We are using the Qt Installer Framework to create our product installers. Most things are running quite smoothly, but there are still some unresolved issues.

Every time we are creating a new product version, which happens quite frequently, we have to update the content of the <Version> Tag inside the package.xml. But we also need to change the name of the link created by the installer in the installscript.qs, such that the client can distinguish among two parallel installed versions of the program.

E.g. here a link like MyApplication-2.1 should appear inside the startmenu after installation.

Component.prototype.createOperations = function()
{
    try {
        // call the base create operations function
        component.createOperations();
        component.addOperation("CreateShortcut", "@TargetDir@/bin/MyApplication-2.1-vc14.exe", "@StartMenuDir@/MyApplication-2.1.lnk");
    } catch (e) {
        print(e);
    }
}

Unfortunately, one cannot write @ProductVersion@ or @Version@, instead of 2.1, referring to the content of the <Version> Tag of the package.xml. Instead @ProductVersion@ and also @Version@ are seemingly referring to the content of the <Version> tag inside the config.xml, which is not the desired behavior.

My problem is now, that I need to synchronize every time the versions numbers, which seems to be quite error-prone. Are there some workarounds?

Aleph0
  • 5,816
  • 4
  • 29
  • 80
  • You can write a script to extract the `Version` from `packages.xml` and then create a variable for application name appending version and use that for `TargetDir` and `StartMenuDir` in `CreateShortcut`. – Azeem Jun 19 '17 at 08:43

1 Answers1

0

On Linux, I used sed, based on this:

In the qmake file I have set up to generate the installer:

# Generate version numbers in XML files
DATE_CMD="date --rfc-3339=date"
SED_DATE_CMD="find $$shell_path($$PWD) \\\( -name "package.xml" -or -name "config.xml" \\\) -exec sed -i \"s|@DATE@|`$$DATE_CMD`|g\" \"{}\" \;"
SED_VERSION_CMD="find $$shell_path($$PWD) \\\( -name "package.xml" -or -name "config.xml" \\\) -exec sed -i \"s|@VERSION@|$${VERSION}|g\" \"{}\" \;"
SED_DATE_UNDO="find $$shell_path($$PWD) \\\( -name "package.xml" -or -name "config.xml" \\\) -exec sed -i \"s|<ReleaseDate>`$$DATE_CMD`<|<ReleaseDate>@DATE@<|g\" \"{}\" \;"
SED_VERSION_UNDO="find $$shell_path($$PWD) \\\( -name "package.xml" -or -name "config.xml" \\\) -exec sed -i \"s|<Version>$${VERSION}<|<Version>@VERSION@<|g\" \"{}\" \;"

offlineInstaller.commands = \
    $$SED_VERSION_CMD && \
    $$SED_DATE_CMD && \
    $$QTIFWDIR/bin/binarycreator --offline-only \
        -c $$PWD/config/config.xml -p $$PWD/packages $$offlineInstaller.target && \
    $$SED_VERSION_UNDO && \
    $$SED_DATE_UNDO

This replaces the @VERSION@ and @DATE@ in the XML files, builds, then puts them back. A better solution might be to copy the files out of the source tree.

Yuriy
  • 61
  • 4
  • I see now your problem is a little different, but this can be adapted to have different VERSION variables in different packages. My frustration was the reverse of yours: I just wanted to use the product version, but QtIFW makes the package version mandatory. – Yuriy Jun 20 '17 at 13:53