diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-08-28 00:32:28 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-05-19 03:43:19 +0200 |
commit | 132c9f88f55e2ce2ee9e66b9c6bbd9cd6037b36a (patch) | |
tree | 70c4e45d5aabf01265a01c06f822c9fdf2c371e6 | |
parent | 569269078576fa832143ec4f0bf03283ff358f48 (diff) |
apply the mar file after downloading
Change-Id: Id793ecc7954e1bb8f6859a7fbb3f4aad6e84fb37
-rw-r--r-- | desktop/source/app/app.cxx | 6 | ||||
-rw-r--r-- | desktop/source/app/updater.cxx | 24 | ||||
-rw-r--r-- | desktop/source/app/updater.hxx | 4 |
3 files changed, 19 insertions, 15 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index e25b849df6ed..49eb27b4050d 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1472,17 +1472,15 @@ int Desktop::Main() if (aPatchInfo.is()) { - OUString aInstallationDir( "$BRAND_BASE_DIR/" LIBO_LIBEXEC_FOLDER ); + OUString aInstallationDir( "$BRAND_BASE_DIR/"); rtl::Bootstrap::expandMacros(aInstallationDir); - CreateValidUpdateDir(aInstallationDir); osl::DirectoryItem aDirectoryItem; osl::DirectoryItem::get(aInstallationDir + "/updated", aDirectoryItem); bool bValidUpdateDirExists = aDirectoryItem.is(); if (bValidUpdateDirExists) { - rtl::Bootstrap::expandMacros(aInstallationDir); - Update(aInstallationDir); + Update(); } } diff --git a/desktop/source/app/updater.cxx b/desktop/source/app/updater.cxx index 1856d0c3e4dd..70879f2b3b30 100644 --- a/desktop/source/app/updater.cxx +++ b/desktop/source/app/updater.cxx @@ -84,7 +84,7 @@ void createStr(const OUString& rStr, char** pArgs, size_t i) pArgs[i] = pStr; } -char** createCommandLine(const OUString& rInstallDir) +char** createCommandLine(const OUString& rInstallDir, bool bReplace) { size_t nArgs = 6; char** pArgs = new char*[nArgs]; @@ -105,7 +105,7 @@ char** createCommandLine(const OUString& rInstallDir) createStr(aWorkingDir, pArgs, 3); } { - const char* pPID = "/replace"; + const char* pPID = bReplace ? "/replace" : "-1"; createStr(pPID, pArgs, 4); } pArgs[nArgs - 1] = nullptr; @@ -115,16 +115,19 @@ char** createCommandLine(const OUString& rInstallDir) } -void Update(const OUString& rInstallDirURL) +void Update() { + OUString aLibExecDirURL( "$BRAND_BASE_DIR/" LIBO_LIBEXEC_FOLDER ); + rtl::Bootstrap::expandMacros(aLibExecDirURL); + utl::TempFile aTempDir(nullptr, true); OUString aTempDirURL = aTempDir.GetURL(); - CopyUpdaterToTempDir(rInstallDirURL, aTempDirURL); + CopyUpdaterToTempDir(aLibExecDirURL, aTempDirURL); OUString aTempDirPath = getPathFromURL(aTempDirURL); OString aPath = OUStringToOString(aTempDirPath + "/" + OUString::fromUtf8(pUpdaterName), RTL_TEXTENCODING_UTF8); - char** pArgs = createCommandLine(rInstallDirURL); + char** pArgs = createCommandLine(aLibExecDirURL, true); if (execv(aPath.getStr(), pArgs)) { @@ -137,16 +140,18 @@ void Update(const OUString& rInstallDirURL) delete[] pArgs; } -void CreateValidUpdateDir(const OUString& rInstallDir) +void CreateValidUpdateDir() { - OUString aInstallPath = getPathFromURL(rInstallDir); - OUString aWorkdirPath = getPathFromURL(rInstallDir + "/updated"); + OUString aInstallDir("$BRAND_BASE_DIR"); + rtl::Bootstrap::expandMacros(aInstallDir); + OUString aInstallPath = getPathFromURL(aInstallDir); + OUString aWorkdirPath = getPathFromURL(aInstallDir + "/updated"); OUString aPatchDirPath("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/patch/"); rtl::Bootstrap::expandMacros(aPatchDirPath); OUString aPatchDir = getPathFromURL(aPatchDirPath); - OUString aUpdaterPath = getPathFromURL(rInstallDir + "/program/" + OUString::fromUtf8(pUpdaterName)); + OUString aUpdaterPath = getPathFromURL(aInstallDir + "/program/" + OUString::fromUtf8(pUpdaterName)); OUString aCommand = aUpdaterPath + " " + aPatchDir + " " + aInstallPath + " " + aWorkdirPath + " -1"; @@ -488,6 +493,7 @@ void update_checker() { update_info aUpdateInfo = parse_response(response_body); download_file(aUpdateInfo.aUpdateFile.aURL, aUpdateInfo.aUpdateFile.nSize, aUpdateInfo.aUpdateFile.aHash, "update.mar"); + CreateValidUpdateDir(); } } catch (const invalid_update_info&) diff --git a/desktop/source/app/updater.hxx b/desktop/source/app/updater.hxx index c73e302eea50..410cc21b4de8 100644 --- a/desktop/source/app/updater.hxx +++ b/desktop/source/app/updater.hxx @@ -12,8 +12,8 @@ #include <rtl/ustring.hxx> -void CreateValidUpdateDir(const OUString& rInstallDir); -void Update(const OUString& rInstallDir); +void CreateValidUpdateDir(); +void Update(); void update_checker(); |