15

我目前正在使用 Qt Installer Framework 并设法建立了一个在线存储库。我想知道的是:

框架是否提供某种“自动更新”机制,例如每次程序/系统启动时检查更新的插件/服务?
检查更新就足够了,因为安装本身可以使用维护工具完成。

关于这个话题,我能找到的只有这句话:

最终用户可以在初始安装后使用维护工具从服务器安装其他组件,并在服务器上发布更新后立即接收内容的自动更新

从这里:http ://doc.qt.io/qtinstallerframework/ifw-overview.html#choosing-installer-type

谢谢你的帮助!

编辑:建议
基于这个问题接受的答案,我创建了一个小型库来使用安装程序框架自动检查更新 - https://github.com/Skycoder42/QtAutoUpdater

4

4 回答 4

22

我所做的是使用 QProcess 运行维护工具,然后检查输出。它有一种模式,它不运行 GUI,但仅在可用时输出更新信息。

请注意,当应用程序启动时,我将工作目录设置为应用程序的路径,因此我可以只运行维护工具。

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();
于 2015-12-16T23:13:20.083 回答
3

在最新的 Qt Installer Framework 4.1--checkupdates中不返回任何内容,使用chorcheck-updates代替。

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
于 2021-07-22T14:12:29.497 回答
2

我刚刚在 GitHub 上找到了一个非常好的实现:

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

它负责处理 Windows、MacOS 和 Linux。+ 它是为在 QML / Qt Quick 绑定中使用而编写的(+ 示例)。

它有一些日文注释,但已获得 Apache 2.0 许可,因此可以自由使用(遵循 Apache 2.0 要求)。

于 2019-01-17T13:31:53.297 回答
0

指南中有一节介绍了如何执行此操作,但他们称其为促进更新而不是自动更新,即 doc.qt.io 上的 IFW 更新

于 2015-12-16T20:00:03.460 回答