Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Installer Framework: Auto Update

I'm currently using the Qt Installer Framework and managed to set up an online repository. What I want to know is:

Does the Framework provide some kind of "auto-update" mechanism, e.g. a plugin/service that checks for updates every time the program/system starts?
Check for updates would be enough, since the installation itself can be done using the maintanance tool.

All I could find about this topic was this small sentence:

End users can use the maintenance tool to install additional components from the server after the initial installation, as well as to receive automatic updates to content as soon as the updates are published on the server.

from here: http://doc.qt.io/qtinstallerframework/ifw-overview.html#choosing-installer-type

Thanks for your help!

Edit: Suggestion
Based on this question's accepted answere I created a small library to automatically check for updates using the installer framework - https://github.com/Skycoder42/QtAutoUpdater

like image 363
Felix Avatar asked Dec 16 '15 17:12

Felix


3 Answers

What I do, is run the maintenance tool using QProcess, and then check the output. It has a mode where it doesn't run the GUI but only outputs update information if available.

Note that I set the working directory to the application's path when the applications starts, so I can just run maintenancetool.

QProcess process;
process.start("maintenancetool --checkupdates");

// Wait until the update tool is finished
process.waitForFinished();

if(process.error() != QProcess::UnknownError)
{
    qDebug() << "Error checking for updates";
    return false;
}

// Read the output
QByteArray data = process.readAllStandardOutput();

// No output means no updates available
// Note that the exit code will also be 1, but we don't use that
// Also note that we should parse the output instead of just checking if it is empty if we want specific update info
if(data.isEmpty())
{
    qDebug() << "No updates available";
    return false;
}

// Call the maintenance tool binary
// Note: we start it detached because this application need to close for the update
QStringList args("--updater");
bool success = QProcess::startDetached("maintenancetool", args);

// Close the application
qApp->closeAllWindows();
like image 91
Jeroen Dierckx Avatar answered Sep 28 '22 07:09

Jeroen Dierckx


In the latest Qt Installer Framework 4.1 --checkupdates returns nothing, use ch or check-updates instead.

Commands:
  in, install - install default or selected packages - <pkg ...>
  ch, check-updates - show available updates information on maintenance tool
  up, update - update all or selected packages - <pkg ...>
  rm, remove - uninstall packages and their child components - <pkg ...>
  li, list - list currently installed packages - <regexp>
  se, search - search available packages - <regexp>
  co, create-offline - create offline installer from selected packages - <pkg ...>
  pr, purge - uninstall all packages and remove entire program directory
like image 33
Gleb Ignatev Avatar answered Sep 28 '22 09:09

Gleb Ignatev


I just found a pretty nice implementation on GitHub:

https://github.com/ioriayane/TheArtOfQt2/blob/master/src/HelloWorld/maintenancetool.cpp

It takes care of handling Windows, MacOS and Linux. + It is written to use in QML / Qt Quick bindings (+ example).

It has some Japanese comments, but is Apache 2.0 licensed, so freely to use (following Apache 2.0 requirement).

like image 20
Bartel Avatar answered Sep 28 '22 07:09

Bartel