diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-12-07 03:57:40 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-12-07 03:57:40 +0100 |
commit | 220e07aef4a34dca9f31ae0c5bb994e5c594125d (patch) | |
tree | 70821c6dbe7e6c2f66f231dcb1bad62a763638d7 /mmc_updater/src/UpdateInstaller.cpp | |
parent | 858916b951e92127c22503826b746d1e70c433f6 (diff) | |
parent | 7a6705030c36b2d6b94da1acd5bdf2311e4efeb7 (diff) | |
download | MultiMC-220e07aef4a34dca9f31ae0c5bb994e5c594125d.tar MultiMC-220e07aef4a34dca9f31ae0c5bb994e5c594125d.tar.gz MultiMC-220e07aef4a34dca9f31ae0c5bb994e5c594125d.tar.lz MultiMC-220e07aef4a34dca9f31ae0c5bb994e5c594125d.tar.xz MultiMC-220e07aef4a34dca9f31ae0c5bb994e5c594125d.zip |
Merge branch 'feature_updater' of github.com:MultiMC/MultiMC5 into feature_updater
Diffstat (limited to 'mmc_updater/src/UpdateInstaller.cpp')
-rw-r--r-- | mmc_updater/src/UpdateInstaller.cpp | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/mmc_updater/src/UpdateInstaller.cpp b/mmc_updater/src/UpdateInstaller.cpp index 23e1a4ca..ced6ff39 100644 --- a/mmc_updater/src/UpdateInstaller.cpp +++ b/mmc_updater/src/UpdateInstaller.cpp @@ -51,6 +51,11 @@ void UpdateInstaller::setForceElevated(bool elevated) m_forceElevated = elevated; } +void UpdateInstaller::setFinishCmd(const std::string& cmd) +{ + m_finishCmd = cmd; +} + std::list<std::string> UpdateInstaller::updaterArgs() const { std::list<std::string> args; @@ -266,7 +271,7 @@ void UpdateInstaller::revert() void UpdateInstaller::installFile(const UpdateScriptFile& file) { - std::string destPath = m_installDir + '/' + file.path; + std::string destPath = file.dest; std::string target = file.linkTarget; // backup the existing file if any @@ -279,23 +284,15 @@ void UpdateInstaller::installFile(const UpdateScriptFile& file) FileUtils::mkpath(destDir.c_str()); } - if (target.empty()) - { - std::string sourceFile = m_packageDir + '/' + FileUtils::fileName(file.path.c_str()); - if (!FileUtils::fileExists(sourceFile.c_str())) - { - throw "Source file does not exist: " + sourceFile; - } - FileUtils::copyFile(sourceFile.c_str(),destPath.c_str()); - - // set the permissions on the newly extracted file - FileUtils::chmod(destPath.c_str(),file.permissions); - } - else + std::string sourceFile = file.source; + if (!FileUtils::fileExists(sourceFile.c_str())) { - // create the symlink - FileUtils::createSymLink(destPath.c_str(),target.c_str()); + throw "Source file does not exist: " + sourceFile; } + FileUtils::copyFile(sourceFile.c_str(),destPath.c_str()); + + // set the permissions on the newly extracted file + FileUtils::chmod(destPath.c_str(),file.permissions); } void UpdateInstaller::installFiles() @@ -391,19 +388,9 @@ void UpdateInstaller::restartMainApp() { try { - std::string command; + std::string command = m_finishCmd; std::list<std::string> args; - for (std::vector<UpdateScriptFile>::const_iterator iter = m_script->filesToInstall().begin(); - iter != m_script->filesToInstall().end(); - iter++) - { - if (iter->isMainBinary) - { - command = m_installDir + '/' + iter->path; - } - } - if (!command.empty()) { LOG(Info,"Starting main application " + command); @@ -411,7 +398,7 @@ void UpdateInstaller::restartMainApp() } else { - LOG(Error,"No main binary specified in update script"); + LOG(Error,"No main binary specified"); } } catch (const std::exception& ex) |