GH-1060 remove some old updater bits and pieces

This commit is contained in:
Petr Mrázek 2015-06-07 23:42:22 +02:00
parent 38e42ad794
commit 166813cb91
15 changed files with 28 additions and 169 deletions

View File

@ -17,9 +17,6 @@ Config::Config()
NOTIFICATION_URL = "@MultiMC_NOTIFICATION_URL@";
FULL_VERSION_STR = "@MultiMC_VERSION_MAJOR@.@MultiMC_VERSION_MINOR@.@MultiMC_VERSION_BUILD@";
UPDATER_DRY_RUN = @MultiMC_UPDATER_DRY_RUN_value@;
UPDATER_FORCE_LOCAL = @MultiMC_UPDATER_FORCE_LOCAL_value@;
GIT_COMMIT = "@MultiMC_GIT_COMMIT@";
VERSION_STR = "@MultiMC_VERSION_STRING@";
NEWS_RSS_URL = "@MultiMC_NEWS_RSS_URL@";

View File

@ -35,12 +35,6 @@ public:
/// Used for matching notifications
QString FULL_VERSION_STR;
/// enabled for updater dry run
bool UPDATER_DRY_RUN;
/// enabled for updater dry run
bool UPDATER_FORCE_LOCAL;
/// The commit hash of this build
QString GIT_COMMIT;

View File

@ -75,22 +75,6 @@ if(MultiMC_UPDATER)
message(STATUS "Updater is enabled. Channel list URL: ${MultiMC_CHANLIST_URL}")
endif()
#### Updater-related build config options ####
option(MultiMC_UPDATER_DRY_RUN "Enable updater dry-run mode -- for updater development." OFF)
option(MultiMC_UPDATER_FORCE_LOCAL "Do not download updated updater -- for updater development." OFF)
if(MultiMC_UPDATER_DRY_RUN)
set(MultiMC_UPDATER_DRY_RUN_value "true")
else()
set(MultiMC_UPDATER_DRY_RUN_value "false")
endif()
if(MultiMC_UPDATER_FORCE_LOCAL)
set(MultiMC_UPDATER_FORCE_LOCAL_value "true")
else()
set(MultiMC_UPDATER_FORCE_LOCAL_value "false")
endif()
######## Configure header ########
configure_file("${PROJECT_SOURCE_DIR}/BuildConfig.cpp.in" "${PROJECT_BINARY_DIR}/BuildConfig.cpp")

View File

@ -933,9 +933,6 @@ void MainWindow::updateAvailable(GoUpdate::Status status)
case UPDATE_NOW:
downloadUpdates(status);
break;
case UPDATE_ONEXIT:
downloadUpdates(status, true);
break;
}
}
@ -985,13 +982,9 @@ void MainWindow::notificationsChanged()
MMC->settings()->set("ShownNotifications", intListToString(shownNotifications));
}
void MainWindow::downloadUpdates(GoUpdate::Status status, bool installOnExit)
void MainWindow::downloadUpdates(GoUpdate::Status status)
{
qDebug() << "Downloading updates.";
// TODO: If the user chooses to update on exit, we should download updates in the
// background.
// Doing so is a bit complicated, because we'd have to make sure it finished downloading
// before actually exiting MultiMC.
ProgressDialog updateDlg(this);
status.rootPath = MMC->rootPath;
@ -999,13 +992,7 @@ void MainWindow::downloadUpdates(GoUpdate::Status status, bool installOnExit)
// If the task succeeds, install the updates.
if (updateDlg.exec(&updateTask))
{
UpdateFlags baseFlags = None;
if (BuildConfig.UPDATER_DRY_RUN)
baseFlags |= DryRun;
if (installOnExit)
MMC->installUpdates(updateTask.updateFilesDir(), baseFlags | OnExit);
else
MMC->installUpdates(updateTask.updateFilesDir(), baseFlags | RestartOnFinish);
MMC->installUpdates(updateTask.updateFilesDir());
}
else
{

View File

@ -177,7 +177,7 @@ slots:
/*!
* Runs the DownloadTask and installs updates.
*/
void downloadUpdates(GoUpdate::Status status, bool installOnExit = false);
void downloadUpdates(GoUpdate::Status status);
protected:
bool eventFilter(QObject *obj, QEvent *ev);

View File

@ -583,61 +583,27 @@ std::shared_ptr<JavaVersionList> MultiMC::javalist()
return m_javalist;
}
void MultiMC::installUpdates(const QString updateFilesDir, UpdateFlags flags)
void MultiMC::installUpdates(const QString updateFilesDir)
{
// if we are going to update on exit, save the params now
if (flags & OnExit)
{
m_updateOnExitPath = updateFilesDir;
m_updateOnExitFlags = flags & ~OnExit;
return;
}
// otherwise if there already were some params for on exit update, clear them and continue
else if (m_updateOnExitPath.size())
{
m_updateOnExitFlags = None;
m_updateOnExitPath.clear();
}
qDebug() << "Installing updates.";
#ifdef WINDOWS
QString finishCmd = applicationFilePath();
QString updaterBinary = PathCombine(applicationDirPath(), "updater.exe");
#elif LINUX
QString finishCmd = PathCombine(root(), "MultiMC");
QString updaterBinary = PathCombine(applicationDirPath(), "updater");
#elif OSX
QString finishCmd = applicationFilePath();
QString updaterBinary = PathCombine(applicationDirPath(), "updater");
#else
#error Unsupported operating system.
#endif
QStringList args;
// ./updater --install-dir $INSTALL_DIR --package-dir $UPDATEFILES_DIR --script
// $UPDATEFILES_DIR/file_list.xml --wait $PID --mode main
args << "--install-dir" << root();
args << "--package-dir" << updateFilesDir;
args << "--script" << PathCombine(updateFilesDir, "file_list.xml");
args << "--wait" << QString::number(applicationPid());
if (flags & DryRun)
args << "--dry-run";
if (flags & RestartOnFinish)
{
args << "--finish-cmd" << finishCmd;
args << "--finish-dir" << dataPath;
}
qDebug() << "Running updater with command" << updaterBinary << args.join(" ");
QFile::setPermissions(updaterBinary, (QFileDevice::Permission)0x7755);
if (!QProcess::startDetached(updaterBinary, args /*, root()*/))
{
qCritical() << "Failed to start the updater process!";
return;
}
ENV.destroy();
// Now that we've started the updater, quit MultiMC.
quit();
args << "--finish-cmd" << finishCmd;
args << "--finish-dir" << dataPath;
qDebug() << "Running updater with args" << args.join(" ");
}
void MultiMC::setIconTheme(const QString& name)
@ -657,10 +623,6 @@ void MultiMC::onExit()
{
m_instances->saveGroupList();
}
if (m_updateOnExitPath.size())
{
installUpdates(m_updateOnExitPath, m_updateOnExitFlags);
}
ENV.destroy();
if(logFile)
{

View File

@ -29,16 +29,6 @@ class TranslationDownloader;
#endif
#define MMC (static_cast<MultiMC *>(QCoreApplication::instance()))
enum UpdateFlag
{
None = 0x0,
RestartOnFinish = 0x1,
DryRun = 0x2,
OnExit = 0x4
};
Q_DECLARE_FLAGS(UpdateFlags, UpdateFlag);
Q_DECLARE_OPERATORS_FOR_FLAGS(UpdateFlags);
class MultiMC : public QApplication
{
// friends for the purpose of limiting access to deprecated stuff
@ -115,7 +105,7 @@ public:
}
// APPLICATION ONLY
void installUpdates(const QString updateFilesDir, UpdateFlags flags = None);
void installUpdates(const QString updateFilesDir);
/*!
* Opens a json file using either a system default editor, or, if note empty, the editor
@ -173,9 +163,6 @@ private:
QMap<QString, std::shared_ptr<BaseProfilerFactory>> m_profilers;
QMap<QString, std::shared_ptr<BaseDetachedToolFactory>> m_tools;
QString m_updateOnExitPath;
UpdateFlags m_updateOnExitFlags = None;
QString rootPath;
QString staticDataPath;
QString dataPath;

View File

@ -21,7 +21,6 @@ UpdateDialog::UpdateDialog(bool hasUpdate, QWidget *parent) : QDialog(parent), u
{
ui->label->setText(tr("No %1 updates found. You are running the latest version.").arg(channel));
ui->btnUpdateNow->setDisabled(true);
ui->btnUpdateOnExit->setDisabled(true);
}
loadChangelog();
}
@ -129,8 +128,3 @@ void UpdateDialog::on_btnUpdateNow_clicked()
{
done(UPDATE_NOW);
}
void UpdateDialog::on_btnUpdateOnExit_clicked()
{
done(UPDATE_ONEXIT);
}

View File

@ -28,7 +28,6 @@ enum UpdateAction
{
UPDATE_LATER = QDialog::Rejected,
UPDATE_NOW = QDialog::Accepted,
UPDATE_ONEXIT = 2
};
class UpdateDialog : public QDialog
@ -43,7 +42,6 @@ private:
Ui::UpdateDialog *ui;
public slots:
void on_btnUpdateNow_clicked();
void on_btnUpdateOnExit_clicked();
void on_btnUpdateLater_clicked();
/// Starts loading the changelog

View File

@ -46,8 +46,8 @@
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Bitstream Vera Sans'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:22pt;&quot;&gt;Loading changelog...&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Oxygen-Sans'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Bitstream Vera Sans'; font-size:22pt;&quot;&gt;Loading changelog...&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
@ -69,13 +69,6 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnUpdateOnExit">
<property name="text">
<string>Update after MultiMC closes</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnUpdateLater">
<property name="sizePolicy">
@ -96,7 +89,6 @@ p, li { white-space: pre-wrap; }
<tabstops>
<tabstop>changelogBrowser</tabstop>
<tabstop>btnUpdateNow</tabstop>
<tabstop>btnUpdateOnExit</tabstop>
<tabstop>btnUpdateLater</tabstop>
</tabstops>
<resources>

View File

@ -35,11 +35,6 @@ DownloadTask::DownloadTask(Status status, QObject *parent)
m_updateFilesDir.setAutoRemove(false);
}
void DownloadTask::setUseLocalUpdater(bool useLocal)
{
m_keepLocalUpdater = useLocal;
}
void DownloadTask::executeTask()
{
loadVersionInfo();
@ -130,7 +125,7 @@ void DownloadTask::processDownloadedVersionInfo()
NetJobPtr netJob (new NetJob("Update Files"));
// fill netJob and operationList
if (!processFileLists(m_currentVersionFileList, m_newVersionFileList, m_status.rootPath, m_updateFilesDir.path(), netJob, operationList, m_keepLocalUpdater))
if (!processFileLists(m_currentVersionFileList, m_newVersionFileList, m_status.rootPath, m_updateFilesDir.path(), netJob, operationList))
{
emitFailed(tr("Failed to process update lists..."));
return;

View File

@ -61,8 +61,6 @@ protected:
Status m_status;
bool m_keepLocalUpdater;
/*!
* Temporary directory to store update files in.
* This will be set to not auto delete. Task will fail if this fails to be created.

View File

@ -73,8 +73,7 @@ bool processFileLists
const QString &rootPath,
const QString &tempPath,
NetJobPtr job,
OperationList &ops,
bool useLocalUpdater
OperationList &ops
)
{
// First, if we've loaded the current version's file list, we need to iterate through it and
@ -175,9 +174,6 @@ bool processFileLists
// yep. this file actually needs an upgrade. PROCEED.
qDebug() << "Found file" << realEntryPath << " that needs updating.";
// if it's the updater we want to treat it separately
bool isUpdater = entry.path.endsWith("updater") || entry.path.endsWith("updater.exe");
// Go through the sources list and find one to use.
// TODO: Make a NetAction that takes a source list and tries each of them until one
// works. For now, we'll just use the first http one.
@ -192,32 +188,12 @@ bool processFileLists
// path with slashes replaced by underscores.
QString dlPath = PathCombine(tempPath, QString(entry.path).replace("/", "_"));
if (isUpdater)
{
if(useLocalUpdater)
{
qDebug() << "Skipping updater download and using local version.";
}
else
{
auto cache_entry = ENV.metacache()->resolveEntry("root", entry.path);
qDebug() << "Updater will be in " << cache_entry->getFullPath();
// force check.
cache_entry->stale = true;
auto download = CacheDownload::make(QUrl(source.url), cache_entry);
job->addNetAction(download);
}
}
else
{
// We need to download the file to the updatefiles folder and add a task
// to copy it to its install path.
auto download = MD5EtagDownload::make(source.url, dlPath);
download->m_expected_md5 = entry.md5;
job->addNetAction(download);
ops.append(Operation::CopyOp(dlPath, entry.path, entry.mode));
}
// We need to download the file to the updatefiles folder and add a task
// to copy it to its install path.
auto download = MD5EtagDownload::make(source.url, dlPath);
download->m_expected_md5 = entry.md5;
job->addNetAction(download);
ops.append(Operation::CopyOp(dlPath, entry.path, entry.mode));
}
}
return true;

View File

@ -66,10 +66,14 @@ typedef QList<VersionFileEntry> VersionFileList;
*/
struct Operation
{
static Operation CopyOp(QString fsource, QString fdest, int fmode=0644) { return Operation{OP_COPY, fsource, fdest, fmode}; }
static Operation MoveOp(QString fsource, QString fdest, int fmode=0644) { return Operation{OP_MOVE, fsource, fdest, fmode}; }
static Operation DeleteOp(QString file) { return Operation{OP_DELETE, file, "", 0644}; }
static Operation ChmodOp(QString file, int fmode) { return Operation{OP_CHMOD, file, "", fmode}; }
static Operation CopyOp(QString fsource, QString fdest, int fmode=0644)
{
return Operation{OP_COPY, fsource, fdest, fmode};
}
static Operation DeleteOp(QString file)
{
return Operation{OP_DELETE, file, "", 0644};
}
// FIXME: for some types, some of the other fields are irrelevant!
bool operator==(const Operation &u2) const
@ -82,8 +86,6 @@ struct Operation
{
OP_COPY,
OP_DELETE,
OP_MOVE,
OP_CHMOD,
} type;
//! The file to operate on. If this is a DELETE or CHMOD operation, this is the file that will be modified.
@ -118,8 +120,7 @@ bool processFileLists
const QString &rootPath,
const QString &tempPath,
NetJobPtr job,
OperationList &ops,
bool useLocalUpdater
OperationList &ops
);
/*!

View File

@ -46,12 +46,6 @@ QDebug operator<<(QDebug dbg, const Operation::Type &t)
case Operation::OP_DELETE:
dbg << "OP_DELETE";
break;
case Operation::OP_MOVE:
dbg << "OP_MOVE";
break;
case Operation::OP_CHMOD:
dbg << "OP_CHMOD";
break;
}
return dbg.maybeSpace();
}
@ -199,7 +193,7 @@ slots:
OperationList operations;
processFileLists(currentVersion, newVersion, QCoreApplication::applicationDirPath(), tempFolder, new NetJob("Dummy"), operations, false);
processFileLists(currentVersion, newVersion, QCoreApplication::applicationDirPath(), tempFolder, new NetJob("Dummy"), operations);
qDebug() << (operations == expectedOperations);
qDebug() << operations;
qDebug() << expectedOperations;