diff options
Diffstat (limited to 'mmc_updater')
-rw-r--r-- | mmc_updater/src/UpdateInstaller.cpp | 15 | ||||
-rw-r--r-- | mmc_updater/src/UpdateInstaller.h | 2 | ||||
-rw-r--r-- | mmc_updater/src/UpdaterOptions.cpp | 5 | ||||
-rw-r--r-- | mmc_updater/src/UpdaterOptions.h | 1 | ||||
-rw-r--r-- | mmc_updater/src/main.cpp | 4 | ||||
-rw-r--r-- | mmc_updater/src/tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | mmc_updater/src/tests/TestUpdaterOptions.cpp | 68 | ||||
-rw-r--r-- | mmc_updater/src/tests/TestUpdaterOptions.h | 8 |
8 files changed, 26 insertions, 78 deletions
diff --git a/mmc_updater/src/UpdateInstaller.cpp b/mmc_updater/src/UpdateInstaller.cpp index aca23ff7..b29c5316 100644 --- a/mmc_updater/src/UpdateInstaller.cpp +++ b/mmc_updater/src/UpdateInstaller.cpp @@ -46,6 +46,11 @@ void UpdateInstaller::setFinishCmd(const std::string& cmd) m_finishCmd = cmd; } +void UpdateInstaller::setFinishDir(const std::string &dir) +{ + m_finishDir = dir; +} + std::list<std::string> UpdateInstaller::updaterArgs() const { std::list<std::string> args; @@ -63,6 +68,11 @@ std::list<std::string> UpdateInstaller::updaterArgs() const { args.push_back("--dry-run"); } + if (m_finishDir.size()) + { + args.push_back("--dir"); + args.push_back(m_finishDir); + } return args; } @@ -420,6 +430,11 @@ void UpdateInstaller::restartMainApp() if (!command.empty()) { + if(!m_finishDir.empty()) + { + args.push_back("--dir"); + args.push_back(m_finishDir); + } LOG(Info,"Starting main application " + command); if(!m_dryRun) { diff --git a/mmc_updater/src/UpdateInstaller.h b/mmc_updater/src/UpdateInstaller.h index 5cbac561..5920deec 100644 --- a/mmc_updater/src/UpdateInstaller.h +++ b/mmc_updater/src/UpdateInstaller.h @@ -34,6 +34,7 @@ class UpdateInstaller void setAutoClose(bool autoClose); void setDryRun(bool dryRun); void setFinishCmd(const std::string& cmd); + void setFinishDir(const std::string& dir); void setObserver(UpdateObserver* observer); @@ -62,6 +63,7 @@ class UpdateInstaller std::string m_packageDir; std::string m_backupDir; std::string m_finishCmd; + std::string m_finishDir; PLATFORM_PID m_waitPid = 0; UpdateScript* m_script = nullptr; UpdateObserver* m_observer = nullptr; diff --git a/mmc_updater/src/UpdaterOptions.cpp b/mmc_updater/src/UpdaterOptions.cpp index 5f9e97d8..abc7c6d7 100644 --- a/mmc_updater/src/UpdaterOptions.cpp +++ b/mmc_updater/src/UpdaterOptions.cpp @@ -40,6 +40,7 @@ void UpdaterOptions::parse(int argc, char** argv) parser.setOption("install-dir"); parser.setOption("package-dir"); parser.setOption("finish-cmd"); + parser.setOption("finish-dir"); parser.setOption("script"); parser.setOption("wait"); parser.setOption("mode"); @@ -74,6 +75,10 @@ void UpdaterOptions::parse(int argc, char** argv) { finishCmd = parser.getValue("finish-cmd"); } + if (parser.getValue("finish-dir")) + { + finishDir = parser.getValue("finish-dir"); + } showVersion = parser.getFlag("version"); forceElevated = parser.getFlag("force-elevated"); diff --git a/mmc_updater/src/UpdaterOptions.h b/mmc_updater/src/UpdaterOptions.h index d9104804..d4345490 100644 --- a/mmc_updater/src/UpdaterOptions.h +++ b/mmc_updater/src/UpdaterOptions.h @@ -15,6 +15,7 @@ class UpdaterOptions std::string packageDir; std::string scriptPath; std::string finishCmd; + std::string finishDir; PLATFORM_PID waitPid; std::string logFile; bool showVersion; diff --git a/mmc_updater/src/main.cpp b/mmc_updater/src/main.cpp index f6b31a32..602c30a6 100644 --- a/mmc_updater/src/main.cpp +++ b/mmc_updater/src/main.cpp @@ -138,7 +138,8 @@ int main(int argc, char** argv) + ", wait-pid: " + intToStr(options.waitPid) + ", script-path: " + options.scriptPath + ", mode: " + intToStr(options.mode) - + ", finish-cmd: " + options.finishCmd); + + ", finish-cmd: " + options.finishCmd + + ", finish-dir: " + options.finishDir); installer.setMode(options.mode); installer.setInstallDir(options.installDir); @@ -148,6 +149,7 @@ int main(int argc, char** argv) installer.setForceElevated(options.forceElevated); installer.setAutoClose(options.autoClose); installer.setFinishCmd(options.finishCmd); + installer.setFinishDir(options.finishDir); installer.setDryRun(options.dryRun); if (options.mode == UpdateInstaller::Main) diff --git a/mmc_updater/src/tests/CMakeLists.txt b/mmc_updater/src/tests/CMakeLists.txt index 79402245..08501a98 100644 --- a/mmc_updater/src/tests/CMakeLists.txt +++ b/mmc_updater/src/tests/CMakeLists.txt @@ -44,5 +44,4 @@ macro(ADD_UPDATER_TEST CLASS) endmacro() add_updater_test(TestParseScript) -add_updater_test(TestUpdaterOptions) add_updater_test(TestFileUtils) diff --git a/mmc_updater/src/tests/TestUpdaterOptions.cpp b/mmc_updater/src/tests/TestUpdaterOptions.cpp deleted file mode 100644 index a4cb7d33..00000000 --- a/mmc_updater/src/tests/TestUpdaterOptions.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "TestUpdaterOptions.h" - -#include "FileUtils.h" -#include "Platform.h" -#include "TestUtils.h" -#include "UpdaterOptions.h" - -#include <string.h> -#include <stdlib.h> - -void TestUpdaterOptions::testOldFormatArgs() -{ - const int argc = 6; - char* argv[argc]; - argv[0] = strdup("updater"); - - std::string currentDir("CurrentDir="); - const char* appDir = 0; - - // CurrentDir is the path to the directory containing the main - // Mendeley Desktop binary, on Linux and Mac this differs from - // the root of the install directory -#ifdef PLATFORM_LINUX - appDir = "/tmp/path-to-app/lib/mendeleydesktop/libexec/"; - FileUtils::mkpath(appDir); -#elif defined(PLATFORM_MAC) - appDir = "/tmp/path-to-app/Contents/MacOS/"; - FileUtils::mkpath(appDir); -#elif defined(PLATFORM_WINDOWS) - appDir = "C:/path/to/app/"; -#endif - currentDir += appDir; - - argv[1] = strdup(currentDir.c_str()); - argv[2] = strdup("TempDir=/tmp/updater"); - argv[3] = strdup("UpdateScriptFileName=/tmp/updater/file_list.xml"); - argv[4] = strdup("AppFileName=/path/to/app/theapp"); - argv[5] = strdup("PID=123456"); - - UpdaterOptions options; - options.parse(argc,argv); - - TEST_COMPARE(options.mode,UpdateInstaller::Setup); -#ifdef PLATFORM_LINUX - TEST_COMPARE(options.installDir,"/tmp/path-to-app"); -#elif defined(PLATFORM_MAC) - // /tmp is a symlink to /private/tmp on Mac - TEST_COMPARE(options.installDir,"/private/tmp/path-to-app"); -#else - TEST_COMPARE(options.installDir,"C:/path/to/app/"); -#endif - TEST_COMPARE(options.packageDir,"/tmp/updater"); - TEST_COMPARE(options.scriptPath,"/tmp/updater/file_list.xml"); - TEST_COMPARE(options.waitPid,123456); - - for (int i=0; i < argc; i++) - { - free(argv[i]); - } -} - -int main(int,char**) -{ - TestList<TestUpdaterOptions> tests; - tests.addTest(&TestUpdaterOptions::testOldFormatArgs); - return TestUtils::runTest(tests); -} - diff --git a/mmc_updater/src/tests/TestUpdaterOptions.h b/mmc_updater/src/tests/TestUpdaterOptions.h deleted file mode 100644 index 5ed102c1..00000000 --- a/mmc_updater/src/tests/TestUpdaterOptions.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -class TestUpdaterOptions -{ - public: - void testOldFormatArgs(); -}; - |