desktop/source/app/updater.cxx | 17 + onlineupdate/qa/lang_packs/Makefile | 21 ++ onlineupdate/qa/lang_packs/update_en_signed.mar |binary onlineupdate/qa/lang_packs/update_signed.mar |binary onlineupdate/qa/lang_packs/updater_lang.zip |binary onlineupdate/qa/replace_request/README | 2 onlineupdate/source/update/updater/updater.cxx | 209 ++++++++++++++---------- 7 files changed, 161 insertions(+), 88 deletions(-)
New commits: commit f680b3c0944894a18875ae8046026d48e850b37c Author: Markus Mohrhard <[email protected]> Date: Fri Jun 16 17:30:34 2017 +0200 updater: add manual test for new language updates Change-Id: I6d77039f0cafe0f436cc687bb424588a59c3d464 diff --git a/onlineupdate/qa/lang_packs/Makefile b/onlineupdate/qa/lang_packs/Makefile new file mode 100644 index 000000000000..d328472f53bf --- /dev/null +++ b/onlineupdate/qa/lang_packs/Makefile @@ -0,0 +1,21 @@ +gb_Side := host +include ../../../config_host.mk + +UPDATER_DIR := $(WORKDIR)/updater/lang_pack + +all : call + +unpack: + @echo "Unpacking the updater test project" + @rm -r $(UPDATER_DIR) || true + @mkdir -p $(WORKDIR)/updater/ + @unzip updater_lang.zip -d $(WORKDIR)/updater > /dev/null + @cp update_signed.mar $(UPDATER_DIR)/user/patch/update.mar + @cp update_en_signed.mar $(UPDATER_DIR)/user/patch/update_en_signed.mar + +call: unpack + @echo "Update the test project" + @$(INSTDIR)/program/updater $(UPDATER_DIR)/user/patch $(UPDATER_DIR) $(UPDATER_DIR)/user/update -1 + +call-gdb: unpack + gdb --args $(INSTDIR)/program/updater $(UPDATER_DIR)/user/patch $(UPDATER_DIR) $(UPDATER_DIR)/user/update -1 diff --git a/onlineupdate/qa/lang_packs/update_en_signed.mar b/onlineupdate/qa/lang_packs/update_en_signed.mar new file mode 100644 index 000000000000..89ce8731f433 Binary files /dev/null and b/onlineupdate/qa/lang_packs/update_en_signed.mar differ diff --git a/onlineupdate/qa/lang_packs/update_signed.mar b/onlineupdate/qa/lang_packs/update_signed.mar new file mode 100644 index 000000000000..70ddd1ef0cbd Binary files /dev/null and b/onlineupdate/qa/lang_packs/update_signed.mar differ diff --git a/onlineupdate/qa/lang_packs/updater_lang.zip b/onlineupdate/qa/lang_packs/updater_lang.zip new file mode 100644 index 000000000000..05b206bc8905 Binary files /dev/null and b/onlineupdate/qa/lang_packs/updater_lang.zip differ commit 38a91e27f28cc14499f78f0c8bde105b06323916 Author: Markus Mohrhard <[email protected]> Date: Fri Jun 16 17:29:36 2017 +0200 updater: fix update file lookup for language pack files Change-Id: I221c81ff2f0bee7a8643304201722dbbbc114bec diff --git a/onlineupdate/source/update/updater/updater.cxx b/onlineupdate/source/update/updater/updater.cxx index 26f0b5df943d..8b3f7bceee8d 100644 --- a/onlineupdate/source/update/updater/updater.cxx +++ b/onlineupdate/source/update/updater/updater.cxx @@ -2553,7 +2553,7 @@ ReadMARChannelIDs(const NS_tchar *path, MARChannelStringTable *results) #endif static int -GetUpdateFileNames(std::vector<tstring> fileNames) +GetUpdateFileNames(std::vector<tstring>& fileNames) { NS_tchar fileName[MAXPATHLEN]; NS_tsnprintf(fileName, MAXPATHLEN, @@ -2572,7 +2572,8 @@ GetUpdateFileNames(std::vector<tstring> fileNames) while ((entry = NS_treaddir(dir)) != nullptr) { if (NS_tstrcmp(entry->d_name, NS_T(".")) && - NS_tstrcmp(entry->d_name, NS_T(".."))) + NS_tstrcmp(entry->d_name, NS_T("..")) && + NS_tstrcmp(entry->d_name, NS_T("update.mar"))) { if (NS_tstrncmp(entry->d_name, NS_T("update"), 6) == 0) { commit a87e03035f8a6d000785f719e2d327e2f6e6d124 Author: Markus Mohrhard <[email protected]> Date: Fri Jun 16 13:57:52 2017 +0200 updater: rename test directory to reflect the tested code Change-Id: I672bbb2ac30c5e27b729fe34e206642e436c076b diff --git a/onlineupdate/qa/updater/Makefile b/onlineupdate/qa/replace_request/Makefile similarity index 100% rename from onlineupdate/qa/updater/Makefile rename to onlineupdate/qa/replace_request/Makefile diff --git a/onlineupdate/qa/updater/README b/onlineupdate/qa/replace_request/README similarity index 100% rename from onlineupdate/qa/updater/README rename to onlineupdate/qa/replace_request/README diff --git a/onlineupdate/qa/updater/updater.zip b/onlineupdate/qa/replace_request/updater.zip similarity index 100% rename from onlineupdate/qa/updater/updater.zip rename to onlineupdate/qa/replace_request/updater.zip commit a5adc48d5f9066088af076ff2066a3b773405208 Author: Markus Mohrhard <[email protected]> Date: Fri Jun 16 13:55:59 2017 +0200 updater: add short explanation about the test Change-Id: Ic0cfa565048793181ece17b33337e011028a2aad diff --git a/onlineupdate/qa/updater/README b/onlineupdate/qa/updater/README index dab8d8a753db..f50c692fd692 100644 --- a/onlineupdate/qa/updater/README +++ b/onlineupdate/qa/updater/README @@ -1 +1,3 @@ +Tests the replacement request done by the automatic updater + After calling 'make call' the content in workdir/updater/program/datei.txt should say "new". commit 5244a49b92fa5acfa7445292775edf61bde6b232 Author: Markus Mohrhard <[email protected]> Date: Fri Jun 16 13:53:57 2017 +0200 updater: find all the language update files Change-Id: I5261d8d96f83b8b81b0dc2576cbd9241705ae9b7 diff --git a/onlineupdate/source/update/updater/updater.cxx b/onlineupdate/source/update/updater/updater.cxx index b3de68a80f6f..26f0b5df943d 100644 --- a/onlineupdate/source/update/updater/updater.cxx +++ b/onlineupdate/source/update/updater/updater.cxx @@ -2556,13 +2556,39 @@ static int GetUpdateFileNames(std::vector<tstring> fileNames) { NS_tchar fileName[MAXPATHLEN]; - // TODO: moggi: needs adaption for LibreOffice - // We would like to store the name inside of an ini file NS_tsnprintf(fileName, MAXPATHLEN, NS_T("%s/update.mar"), gPatchDirPath); fileNames.push_back(fileName); // add the language packs + NS_tDIR* dir = NS_topendir(gPatchDirPath); + if (!dir) + { + LOG(("Could not open directory " LOG_S, gPatchDirPath)); + return READ_ERROR; + } + + NS_tdirent* entry; + while ((entry = NS_treaddir(dir)) != nullptr) + { + if (NS_tstrcmp(entry->d_name, NS_T(".")) && + NS_tstrcmp(entry->d_name, NS_T(".."))) + { + if (NS_tstrncmp(entry->d_name, NS_T("update"), 6) == 0) + { + char *dot = strrchr(entry->d_name, '.'); + if (dot && !strcmp(dot, ".mar")) + { + NS_tchar updatePath[MAXPATHLEN]; + NS_tsnprintf(updatePath, sizeof(updatePath)/sizeof(updatePath[0]), + NS_T("%s/%s"), gPatchDirPath, entry->d_name); + + LOG (("Found language update file: " LOG_S, updatePath)); + fileNames.push_back(updatePath); + } + } + } + } return OK; } commit ebeb76f00e094abe4ca023e29471a3711a022451 Author: Markus Mohrhard <[email protected]> Date: Fri Jun 16 13:21:48 2017 +0200 updater: work on supporting language pack updates Change-Id: I563aa8ee285d4c2ecdb45835b5cee38074295106 diff --git a/onlineupdate/source/update/updater/updater.cxx b/onlineupdate/source/update/updater/updater.cxx index 629e19e33c0c..b3de68a80f6f 100644 --- a/onlineupdate/source/update/updater/updater.cxx +++ b/onlineupdate/source/update/updater/updater.cxx @@ -2553,133 +2553,143 @@ ReadMARChannelIDs(const NS_tchar *path, MARChannelStringTable *results) #endif static int -GetUpdateFileName(NS_tchar *fileName, int maxChars) +GetUpdateFileNames(std::vector<tstring> fileNames) { + NS_tchar fileName[MAXPATHLEN]; // TODO: moggi: needs adaption for LibreOffice // We would like to store the name inside of an ini file - NS_tsnprintf(fileName, maxChars, + NS_tsnprintf(fileName, MAXPATHLEN, NS_T("%s/update.mar"), gPatchDirPath); + fileNames.push_back(fileName); + + // add the language packs return OK; } -static void -UpdateThreadFunc(void * /*param*/) +static int +CheckSignature(tstring& fileName) { - // open ZIP archive and process... - int rv; - if (sReplaceRequest) - { - rv = ProcessReplaceRequest(); - } - else - { - NS_tchar dataFile[MAXPATHLEN]; - rv = GetUpdateFileName(dataFile, sizeof(dataFile)/sizeof(dataFile[0])); - if (rv == OK) - { - rv = gArchiveReader.Open(dataFile); - } + int rv = gArchiveReader.Open(fileName.c_str()); #ifdef VERIFY_MAR_SIGNATURE - if (rv == OK) - { + if (rv == OK) + { #ifdef _WIN32 - HKEY baseKey = nullptr; - wchar_t valueName[] = L"Image Path"; - wchar_t rasenh[] = L"rsaenh.dll"; - bool reset = false; - if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, - L"SOFTWARE\\Microsoft\\Cryptography\\Defaults\\Provider\\Microsoft Enhanced Cryptographic Provider v1.0", - 0, KEY_READ | KEY_WRITE, - &baseKey) == ERROR_SUCCESS) + HKEY baseKey = nullptr; + wchar_t valueName[] = L"Image Path"; + wchar_t rasenh[] = L"rsaenh.dll"; + bool reset = false; + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SOFTWARE\\Microsoft\\Cryptography\\Defaults\\Provider\\Microsoft Enhanced Cryptographic Provider v1.0", + 0, KEY_READ | KEY_WRITE, + &baseKey) == ERROR_SUCCESS) + { + wchar_t path[MAX_PATH + 1]; + DWORD size = sizeof(path); + DWORD type; + if (RegQueryValueExW(baseKey, valueName, 0, &type, + (LPBYTE)path, &size) == ERROR_SUCCESS) { - wchar_t path[MAX_PATH + 1]; - DWORD size = sizeof(path); - DWORD type; - if (RegQueryValueExW(baseKey, valueName, 0, &type, - (LPBYTE)path, &size) == ERROR_SUCCESS) + if (type == REG_SZ && wcscmp(path, rasenh) == 0) { - if (type == REG_SZ && wcscmp(path, rasenh) == 0) + wchar_t rasenhFullPath[] = L"%SystemRoot%\\System32\\rsaenh.dll"; + if (RegSetValueExW(baseKey, valueName, 0, REG_SZ, + (const BYTE*)rasenhFullPath, + sizeof(rasenhFullPath)) == ERROR_SUCCESS) { - wchar_t rasenhFullPath[] = L"%SystemRoot%\\System32\\rsaenh.dll"; - if (RegSetValueExW(baseKey, valueName, 0, REG_SZ, - (const BYTE*)rasenhFullPath, - sizeof(rasenhFullPath)) == ERROR_SUCCESS) - { - reset = true; - } + reset = true; } } } + } #endif - rv = gArchiveReader.VerifySignature(); + rv = gArchiveReader.VerifySignature(); #ifdef _WIN32 - if (baseKey) + if (baseKey) + { + if (reset) { - if (reset) - { - RegSetValueExW(baseKey, valueName, 0, REG_SZ, - (const BYTE*)rasenh, - sizeof(rasenh)); - } - RegCloseKey(baseKey); + RegSetValueExW(baseKey, valueName, 0, REG_SZ, + (const BYTE*)rasenh, + sizeof(rasenh)); } -#endif + RegCloseKey(baseKey); } +#endif + } + if (rv == OK) + { if (rv == OK) { - if (rv == OK) - { - NS_tchar updateSettingsPath[MAX_TEXT_LEN]; + NS_tchar updateSettingsPath[MAX_TEXT_LEN]; - // TODO: moggi: needs adaption for LibreOffice - // These paths need to be adapted for us. - NS_tsnprintf(updateSettingsPath, - sizeof(updateSettingsPath) / sizeof(updateSettingsPath[0]), + // TODO: moggi: needs adaption for LibreOffice + // These paths need to be adapted for us. + NS_tsnprintf(updateSettingsPath, + sizeof(updateSettingsPath) / sizeof(updateSettingsPath[0]), #ifdef MACOSX - NS_T("%s/Contents/Resources/update-settings.ini"), + NS_T("%s/Contents/Resources/update-settings.ini"), #else - NS_T("%s/update-settings.ini"), + NS_T("%s/update-settings.ini"), #endif - gWorkingDirPath); - MARChannelStringTable MARStrings; - if (ReadMARChannelIDs(updateSettingsPath, &MARStrings) != OK) - { - // If we can't read from update-settings.ini then we shouldn't impose - // a MAR restriction. Some installations won't even include this file. - MARStrings.MARChannelID[0] = '\0'; - } - - rv = gArchiveReader.VerifyProductInformation(MARStrings.MARChannelID, - LIBO_VERSION_DOTTED); + gWorkingDirPath); + MARChannelStringTable MARStrings; + if (ReadMARChannelIDs(updateSettingsPath, &MARStrings) != OK) + { + // If we can't read from update-settings.ini then we shouldn't impose + // a MAR restriction. Some installations won't even include this file. + MARStrings.MARChannelID[0] = '\0'; } + + rv = gArchiveReader.VerifyProductInformation(MARStrings.MARChannelID, + LIBO_VERSION_DOTTED); } + } #endif - if (rv == OK && sStagedUpdate) + gArchiveReader.Close(); + + return rv; +} + +static void +UpdateThreadFunc(void * /*param*/) +{ + // open ZIP archive and process... + int rv; + if (sReplaceRequest) + { + rv = ProcessReplaceRequest(); + } + else + { + std::vector<tstring> fileNames; + GetUpdateFileNames(fileNames); + + for (auto& fileName: fileNames) { -#ifdef TEST_UPDATER - // The MOZ_TEST_SKIP_UPDATE_STAGE environment variable prevents copying - // the files in dist/bin in the test updater when staging an update since - // this can cause tests to timeout. - if (EnvHasValue("MOZ_TEST_SKIP_UPDATE_STAGE")) + rv = CheckSignature(fileName); + if (rv != OK) { - rv = OK; - } - else - { - rv = CopyInstallDirToDestDir(); + LOG(("Could not verify the signature of " LOG_S, fileName.c_str())); + break; } -#else + } + + if (rv == OK && sStagedUpdate) + { rv = CopyInstallDirToDestDir(); -#endif } if (rv == OK) { - rv = DoUpdate(); - gArchiveReader.Close(); + for (auto& fileName: fileNames) + { + gArchiveReader.Open(fileName.c_str()); + rv = DoUpdate(); + gArchiveReader.Close(); + } NS_tchar updatingDir[MAXPATHLEN]; NS_tsnprintf(updatingDir, sizeof(updatingDir)/sizeof(updatingDir[0]), NS_T("%s/updating"), gWorkingDirPath); commit fc26bbc05e8a3afdffb660d5ea8562afd53918ff Author: Markus Mohrhard <[email protected]> Date: Wed Jun 14 18:04:09 2017 +0200 updater: only download language packs for installed languages Change-Id: I8c605e2c64fee4d369732f783cc9dd76f7dc858c diff --git a/desktop/source/app/updater.cxx b/desktop/source/app/updater.cxx index fbb48d137811..949ec186d1fe 100644 --- a/desktop/source/app/updater.cxx +++ b/desktop/source/app/updater.cxx @@ -33,6 +33,12 @@ #include <orcus/pstring.hpp> #include <comphelper/hash.hxx> +#include <com/sun/star/container/XNameAccess.hpp> + +#include <officecfg/Setup.hxx> + +#include <set> + namespace { class error_updater : public std::exception @@ -626,6 +632,7 @@ void update_checker() std::string response_body = download_content(aURL, false, aHash); if (!response_body.empty()) { + update_info aUpdateInfo = parse_response(response_body); if (aUpdateInfo.aUpdateFile.aURL.isEmpty()) { @@ -636,11 +643,17 @@ void update_checker() } else { + css::uno::Sequence<OUString> aInstalledLanguages(officecfg::Setup::Office::InstalledLocales::get()->getElementNames()); + std::set<OUString> aInstalledLanguageSet(std::begin(aInstalledLanguages), std::end(aInstalledLanguages)); download_file(aUpdateInfo.aUpdateFile.aURL, aUpdateInfo.aUpdateFile.nSize, aUpdateInfo.aUpdateFile.aHash, "update.mar"); for (auto& lang_update : aUpdateInfo.aLanguageFiles) { - OUString aFileName = "update_" + lang_update.aLangCode + ".mar"; - download_file(lang_update.aUpdateFile.aURL, lang_update.aUpdateFile.nSize, lang_update.aUpdateFile.aHash, aFileName); + // only download the language packs for installed languages + if (aInstalledLanguageSet.find(lang_update.aLangCode) != aInstalledLanguageSet.end()) + { + OUString aFileName = "update_" + lang_update.aLangCode + ".mar"; + download_file(lang_update.aUpdateFile.aURL, lang_update.aUpdateFile.nSize, lang_update.aUpdateFile.aHash, aFileName); + } } CreateValidUpdateDir(aUpdateInfo); } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
