GH-4014 change updater to recognize new Qt 5.15.2 builds
This commit is contained in:
@ -91,7 +91,8 @@ using namespace Commandline;
|
||||
"This usually fixes the problem and you can move the application elsewhere afterwards.\n"\
|
||||
"\n"
|
||||
|
||||
static void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
namespace {
|
||||
void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
{
|
||||
const char *levels = "DWCFIS";
|
||||
const QString format("%1 %2 %3\n");
|
||||
@ -111,6 +112,43 @@ static void appDebugOutput(QtMsgType type, const QMessageLogContext &context, co
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
QString getIdealPlatform(QString currentPlatform) {
|
||||
auto info = Sys::getKernelInfo();
|
||||
switch(info.kernelType) {
|
||||
case Sys::KernelType::Darwin: {
|
||||
if(info.kernelMajor >= 17) {
|
||||
// macOS 10.13 or newer
|
||||
return "osx64-5.15.2";
|
||||
}
|
||||
else {
|
||||
// macOS 10.12 or older
|
||||
return "osx64";
|
||||
}
|
||||
}
|
||||
case Sys::KernelType::Windows: {
|
||||
if(info.kernelMajor == 6 && info.kernelMinor >= 1) {
|
||||
// Windows 7
|
||||
return "win32-5.15.2";
|
||||
}
|
||||
else if (info.kernelMajor > 6) {
|
||||
// Above Windows 7
|
||||
return "win32-5.15.2";
|
||||
}
|
||||
else {
|
||||
// Below Windows 7
|
||||
return "win32";
|
||||
}
|
||||
}
|
||||
case Sys::KernelType::Undetermined:
|
||||
case Sys::KernelType::Linux: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return currentPlatform;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
||||
{
|
||||
#if defined Q_OS_WIN32
|
||||
@ -678,7 +716,10 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
||||
// initialize the updater
|
||||
if(BuildConfig.UPDATER_ENABLED)
|
||||
{
|
||||
m_updateChecker.reset(new UpdateChecker(BuildConfig.CHANLIST_URL, BuildConfig.VERSION_CHANNEL, BuildConfig.VERSION_BUILD));
|
||||
auto platform = getIdealPlatform(BuildConfig.BUILD_PLATFORM);
|
||||
auto channelUrl = BuildConfig.UPDATER_BASE + platform + "/channels.json";
|
||||
qDebug() << "Initializing updater with platform: " << platform << " -- " << channelUrl;
|
||||
m_updateChecker.reset(new UpdateChecker(channelUrl, BuildConfig.VERSION_CHANNEL, BuildConfig.VERSION_BUILD));
|
||||
qDebug() << "<> Updater started.";
|
||||
}
|
||||
|
||||
|
@ -538,7 +538,7 @@ void AuthContext::onSTSAuthGenericDone(
|
||||
}
|
||||
|
||||
Katabasis::Token temp;
|
||||
if(!parseXTokenResponse(replyData, temp, "STSAuthGaneric")) {
|
||||
if(!parseXTokenResponse(replyData, temp, "STSAuthGeneric")) {
|
||||
qWarning() << "Could not parse authorization response for access to xbox API...";
|
||||
failResult(m_xboxProfileSucceeded);
|
||||
return;
|
||||
|
@ -58,8 +58,7 @@ MultiMCPage::MultiMCPage(QWidget *parent) : QWidget(parent), ui(new Ui::MultiMCP
|
||||
|
||||
if(BuildConfig.UPDATER_ENABLED)
|
||||
{
|
||||
QObject::connect(MMC->updateChecker().get(), &UpdateChecker::channelListLoaded, this,
|
||||
&MultiMCPage::refreshUpdateChannelList);
|
||||
QObject::connect(MMC->updateChecker().get(), &UpdateChecker::channelListLoaded, this, &MultiMCPage::refreshUpdateChannelList);
|
||||
|
||||
if (MMC->updateChecker()->hasChannels())
|
||||
{
|
||||
|
@ -170,4 +170,4 @@ OperationList DownloadTask::operations()
|
||||
return m_operations;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,12 @@
|
||||
#define API_VERSION 0
|
||||
#define CHANLIST_FORMAT 0
|
||||
|
||||
UpdateChecker::UpdateChecker(QString channelListUrl, QString currentChannel, int currentBuild)
|
||||
#include "BuildConfig.h"
|
||||
#include "sys.h"
|
||||
|
||||
UpdateChecker::UpdateChecker(QString channelUrl, QString currentChannel, int currentBuild)
|
||||
{
|
||||
m_channelListUrl = channelListUrl;
|
||||
m_channelUrl = channelUrl;
|
||||
m_currentChannel = currentChannel;
|
||||
m_currentBuild = currentBuild;
|
||||
}
|
||||
@ -48,8 +51,7 @@ void UpdateChecker::checkForUpdate(QString updateChannel, bool notifyNoUpdate)
|
||||
// later.
|
||||
if (!m_chanListLoaded)
|
||||
{
|
||||
qDebug() << "Channel list isn't loaded yet. Loading channel list and deferring "
|
||||
"update check.";
|
||||
qDebug() << "Channel list isn't loaded yet. Loading channel list and deferring update check.";
|
||||
m_checkUpdateWaiting = true;
|
||||
m_deferredUpdateChannel = updateChannel;
|
||||
updateChanList(notifyNoUpdate);
|
||||
@ -62,29 +64,43 @@ void UpdateChecker::checkForUpdate(QString updateChannel, bool notifyNoUpdate)
|
||||
return;
|
||||
}
|
||||
|
||||
m_updateChecking = true;
|
||||
|
||||
// Find the desired channel within the channel list and get its repo URL. If if cannot be
|
||||
// found, error.
|
||||
QString stableUrl;
|
||||
m_newRepoUrl = "";
|
||||
for (ChannelListEntry entry : m_channels)
|
||||
{
|
||||
if (entry.id == updateChannel)
|
||||
qDebug() << "channelEntry = " << entry.id;
|
||||
if(entry.id == "stable") {
|
||||
stableUrl = entry.url;
|
||||
}
|
||||
if (entry.id == updateChannel) {
|
||||
m_newRepoUrl = entry.url;
|
||||
if (entry.id == m_currentChannel)
|
||||
qDebug() << "is intended update channel: " << entry.id;
|
||||
}
|
||||
if (entry.id == m_currentChannel) {
|
||||
m_currentRepoUrl = entry.url;
|
||||
qDebug() << "is current update channel: " << entry.id;
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "m_repoUrl = " << m_newRepoUrl;
|
||||
|
||||
// If we didn't find our channel, error.
|
||||
if (m_newRepoUrl.isEmpty()) {
|
||||
qWarning() << "m_repoUrl was empty. defaulting to 'stable': " << stableUrl;
|
||||
m_newRepoUrl = stableUrl;
|
||||
}
|
||||
|
||||
// If nothing applies, error
|
||||
if (m_newRepoUrl.isEmpty())
|
||||
{
|
||||
qCritical() << "m_repoUrl is empty!";
|
||||
qCritical() << "failed to select any update repository for: " << updateChannel;
|
||||
emit updateCheckFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
m_updateChecking = true;
|
||||
|
||||
QUrl indexUrl = QUrl(m_newRepoUrl).resolved(QUrl("index.json"));
|
||||
|
||||
auto job = new NetJob("GoUpdate Repository Index");
|
||||
@ -174,7 +190,7 @@ void UpdateChecker::updateChanList(bool notifyNoUpdate)
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_channelListUrl.isEmpty())
|
||||
if (m_channelUrl.isEmpty())
|
||||
{
|
||||
qCritical() << "Failed to update channel list. No channel list URL set."
|
||||
<< "If you'd like to use MultiMC's update system, please pass the channel "
|
||||
@ -184,7 +200,7 @@ void UpdateChecker::updateChanList(bool notifyNoUpdate)
|
||||
|
||||
m_chanListLoading = true;
|
||||
NetJob *job = new NetJob("Update System Channel List");
|
||||
job->addNetAction(Net::Download::makeByteArray(QUrl(m_channelListUrl), &chanlistData));
|
||||
job->addNetAction(Net::Download::makeByteArray(QUrl(m_channelUrl), &chanlistData));
|
||||
connect(job, &NetJob::succeeded, [this, notifyNoUpdate]() { chanListDownloadFinished(notifyNoUpdate); });
|
||||
QObject::connect(job, &NetJob::failed, this, &UpdateChecker::chanListDownloadFailed);
|
||||
chanListJob.reset(job);
|
||||
|
@ -23,7 +23,7 @@ class UpdateChecker : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
UpdateChecker(QString channelListUrl, QString currentChannel, int currentBuild);
|
||||
UpdateChecker(QString channelUrl, QString currentChannel, int currentBuild);
|
||||
void checkForUpdate(QString updateChannel, bool notifyNoUpdate);
|
||||
|
||||
/*!
|
||||
@ -78,7 +78,7 @@ private:
|
||||
NetJobPtr chanListJob;
|
||||
QByteArray chanlistData;
|
||||
|
||||
QString m_channelListUrl;
|
||||
QString m_channelUrl;
|
||||
|
||||
QList<ChannelListEntry> m_channels;
|
||||
|
||||
|
Reference in New Issue
Block a user