[Libreoffice-commits] core.git: Branch 'feature/mar-updater' - 5 commits - onlineupdate/source

Markus Mohrhard markus.mohrhard at googlemail.com
Fri Dec 30 19:14:15 UTC 2016


 onlineupdate/source/service/workmonitor.cxx    |    8 +--
 onlineupdate/source/update/updater/updater.cxx |   56 ++++++++++++-------------
 2 files changed, 33 insertions(+), 31 deletions(-)

New commits:
commit 6560991fc089a836c61934856c3f2127757473e9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Dec 30 20:12:50 2016 +0100

    add TODO comments for the places that need further inspection
    
    This is just from a quick scroll through the code.
    
    Change-Id: I72132ba9244d7aa559befe63412f7a5ef2005ad1

diff --git a/onlineupdate/source/update/updater/updater.cxx b/onlineupdate/source/update/updater/updater.cxx
index b3a36f9..7b337e2 100644
--- a/onlineupdate/source/update/updater/updater.cxx
+++ b/onlineupdate/source/update/updater/updater.cxx
@@ -1843,6 +1843,9 @@ LaunchWinPostProcess(const WCHAR *installationDir,
     WCHAR workingDirectory[MAX_PATH + 1] = { L'\0' };
     wcsncpy(workingDirectory, installationDir, MAX_PATH);
 
+    // TODO: moggi: needs adaption for LibreOffice
+    // Most likely we don't have the helper method yet. Check if we really need it.
+
     // Launch helper.exe to perform post processing (e.g. registry and log file
     // modifications) for the update.
     WCHAR inifile[MAX_PATH + 1] = { L'\0' };
@@ -2312,6 +2315,8 @@ WaitForServiceFinishThread(void* /*param*/)
 static int
 ReadMARChannelIDs(const NS_tchar *path, MARChannelStringTable *results)
 {
+    // TODO: moggi: needs adaption for LibreOffice
+    // Check where this function gets its parameters from
     const unsigned int kNumStrings = 1;
     const char *kUpdaterKeys = "ACCEPTED_MAR_CHANNEL_IDS\0";
     char updater_strings[kNumStrings][MAX_TEXT_LEN];
@@ -2329,6 +2334,8 @@ ReadMARChannelIDs(const NS_tchar *path, MARChannelStringTable *results)
 static int
 GetUpdateFileName(NS_tchar *fileName, int maxChars)
 {
+    // TODO: moggi: needs adaption for LibreOffice
+    // We would like to store the name inside of an ini file
     NS_tsnprintf(fileName, maxChars,
             NS_T("%s/update.mar"), gPatchDirPath);
     return OK;
@@ -2391,6 +2398,9 @@ UpdateThreadFunc(void * /*param*/)
         if (rv == OK) {
             if (rv == OK) {
                 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]),
 #ifdef MACOSX
@@ -2563,6 +2573,7 @@ int NS_main(int argc, NS_tchar **argv)
     const int callbackIndex = 6;
 
 #ifdef MACOSX
+    // TODO: moggi: needs adaption for LibreOffice
     bool isElevated =
         strstr(argv[0], "/Library/PrivilegedHelperTools/org.mozilla.updater") != 0;
     if (isElevated) {
@@ -2651,6 +2662,7 @@ int NS_main(int argc, NS_tchar **argv)
 
     // Remove everything except close window from the context menu
     {
+        // TODO: moggi: needs adaption for LibreOffice
         HKEY hkApp = nullptr;
         RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\Classes\\Applications",
                 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, nullptr,
@@ -2937,6 +2949,8 @@ int NS_main(int argc, NS_tchar **argv)
             // are available.  If not don't use the service.
             if (useService) {
                 WCHAR maintenanceServiceKey[MAX_PATH + 1];
+                // TODO: moggi: needs adaption for LibreOffice
+                // Most likely the registry part is not correct yet
                 if (CalculateRegistryPathFromFilePath(gInstallDirPath,
                             maintenanceServiceKey)) {
                     HKEY baseKey = nullptr;
@@ -3957,6 +3971,8 @@ int DoUpdate()
     ensure_parent_dir(manifest);
 
     // extract the manifest
+    // TODO: moggi: needs adaption for LibreOffice
+    // Why would we need the manifest? Even if we need it why would we need 2?
     int rv = gArchiveReader.ExtractFile("updatev3.manifest", manifest);
     if (rv) {
         rv = gArchiveReader.ExtractFile("updatev2.manifest", manifest);
commit 635745f555287cfc6f7b767158e85f4375030359
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Dec 30 19:00:54 2016 +0100

    hide the function behind the correct define checks
    
    Change-Id: Ifef59d40975b6061a40b58d80817b6c15b856713

diff --git a/onlineupdate/source/update/updater/updater.cxx b/onlineupdate/source/update/updater/updater.cxx
index 7c060f1..b3a36f9 100644
--- a/onlineupdate/source/update/updater/updater.cxx
+++ b/onlineupdate/source/update/updater/updater.cxx
@@ -277,12 +277,14 @@ mstrtok(const NS_tchar *delims, NS_tchar **str)
     return ret;
 }
 
+#if defined(_WIN32) && defined(MAINTENANCE_SERVICE)
 static bool
 EnvHasValue(const char *name)
 {
     const char *val = getenv(name);
     return (val && *val);
 }
+#endif
 
 /**
  * Coverts a relative update path to a full path.
commit 11640418c1526ba2dc073a99f50bee7a698def0f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Dec 30 18:57:18 2016 +0100

    remove the MOZ_ prefix from a few env variables and defines
    
    Change-Id: Icbb5f0751cd5f85fc2c4af8d2adbc8d64911a94b

diff --git a/onlineupdate/source/service/workmonitor.cxx b/onlineupdate/source/service/workmonitor.cxx
index f27a914..76bbe1c 100644
--- a/onlineupdate/source/service/workmonitor.cxx
+++ b/onlineupdate/source/service/workmonitor.cxx
@@ -223,10 +223,10 @@ StartUpdateProcess(int argc,
                                        MOVEFILE_REPLACE_EXISTING);
   }
 
-  // Add an env var for MOZ_USING_SERVICE so the updater.exe can
+  // Add an env var for USING_SERVICE so the updater.exe can
   // do anything special that it needs to do for service updates.
-  // Search in updater.cpp for more info on MOZ_USING_SERVICE.
-  putenv(const_cast<char*>("MOZ_USING_SERVICE=1"));
+  // Search in updater.cpp for more info on USING_SERVICE.
+  putenv(const_cast<char*>("USING_SERVICE=1"));
   LOG(("Starting service with cmdline: %ls", cmdLine));
   processStarted = CreateProcessW(argv[0], cmdLine,
                                   nullptr, nullptr, FALSE,
@@ -234,7 +234,7 @@ StartUpdateProcess(int argc,
                                   nullptr,
                                   nullptr, &si, &pi);
   // Empty value on putenv is how you remove an env variable in Windows
-  putenv(const_cast<char*>("MOZ_USING_SERVICE="));
+  putenv(const_cast<char*>("USING_SERVICE="));
 
   BOOL updateWasSuccessful = FALSE;
   if (processStarted) {
diff --git a/onlineupdate/source/update/updater/updater.cxx b/onlineupdate/source/update/updater/updater.cxx
index 8f107bc..7c060f1 100644
--- a/onlineupdate/source/update/updater/updater.cxx
+++ b/onlineupdate/source/update/updater/updater.cxx
@@ -120,7 +120,7 @@ struct UpdateServerThreadArgs
 #endif
 
 #ifdef _WIN32
-#ifdef MOZ_MAINTENANCE_SERVICE
+#ifdef MAINTENANCE_SERVICE
 #include "registrycertificates.h"
 #endif
 BOOL PathAppendSafe(LPWSTR base, LPCWSTR extra);
@@ -1881,7 +1881,7 @@ LaunchWinPostProcess(const WCHAR *installationDir,
         return false;
     }
 
-#if !defined(TEST_UPDATER) && defined(MOZ_MAINTENANCE_SERVICE)
+#if !defined(TEST_UPDATER) && defined(MAINTENANCE_SERVICE)
     if (sUsingService &&
             !DoesBinaryMatchAllowedCertificates(installationDir, exefullpath)) {
         return false;
@@ -2043,7 +2043,7 @@ WriteStatusFile(int status)
     WriteStatusFile(text);
 }
 
-#ifdef MOZ_MAINTENANCE_SERVICE
+#ifdef MAINTENANCE_SERVICE
 /*
  * Read the update.status file and sets isPendingService to true if
  * the status is set to pending-service.
@@ -2529,7 +2529,7 @@ int LaunchCallbackAndPostProcessApps(int argc, NS_tchar** argv,
             // because it's possible we are updating with updater.exe without the
             // service if the service failed to apply the update. We want to update
             // the service to a newer version in that case. If we are not running
-            // through the service, then MOZ_USING_SERVICE will not exist.
+            // through the service, then USING_SERVICE will not exist.
             if (!sUsingService) {
                 StartServiceUpdate(gInstallDirPath);
             }
@@ -2639,7 +2639,7 @@ int NS_main(int argc, NS_tchar **argv)
 
     // We never want the service to be used unless we build with
     // the maintenance service.
-#ifdef MOZ_MAINTENANCE_SERVICE
+#ifdef MAINTENANCE_SERVICE
     useService = IsUpdateStatusPendingService();
     // Our tests run with a different apply directory for each test.
     // We use this registry key on our test slaves to store the
@@ -2796,9 +2796,9 @@ int NS_main(int argc, NS_tchar **argv)
 #endif
 
 #if defined(_WIN32)
-#ifdef MOZ_MAINTENANCE_SERVICE
-    sUsingService = EnvHasValue("MOZ_USING_SERVICE");
-    putenv(const_cast<char*>("MOZ_USING_SERVICE="));
+#ifdef MAINTENANCE_SERVICE
+    sUsingService = EnvHasValue("USING_SERVICE");
+    putenv(const_cast<char*>("USING_SERVICE="));
 #endif
     // lastFallbackError keeps track of the last error for the service not being
     // used, in case of an error when fallback is not enabled we write the
commit fb6130da223776151235e3814cc1b96508c66bdc
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Dec 30 18:50:11 2016 +0100

    use std::min instead of own code
    
    Change-Id: I4bb62a120c1d791d41cdaaa88faf0fed27cc4787

diff --git a/onlineupdate/source/update/updater/updater.cxx b/onlineupdate/source/update/updater/updater.cxx
index 772b790..8f107bc 100644
--- a/onlineupdate/source/update/updater/updater.cxx
+++ b/onlineupdate/source/update/updater/updater.cxx
@@ -236,12 +236,6 @@ static const NS_tchar kWhitespace[] = NS_T(" \t");
 static const NS_tchar kNL[] = NS_T("\r\n");
 static const NS_tchar kQuote[] = NS_T("\"");
 
-static inline size_t
-mmin(size_t a, size_t b)
-{
-    return (a > b) ? b : a;
-}
-
 static NS_tchar*
 mstrtok(const NS_tchar *delims, NS_tchar **str)
 {
@@ -1417,7 +1411,7 @@ PatchFile::LoadSourceFile(FILE* ofile)
     size_t r = header.slen;
     unsigned char *rb = buf;
     while (r) {
-        const size_t count = mmin(SSIZE_MAX, r);
+        const size_t count = std::min<size_t>(SSIZE_MAX, r);
         size_t c = fread(rb, 1, count, ofile);
         if (c != count) {
             LOG(("LoadSourceFile: error reading destination file: " LOG_S,
@@ -3857,7 +3851,7 @@ GetManifestContents(const NS_tchar *manifest)
     size_t r = ms.st_size;
     char *rb = mbuf;
     while (r) {
-        const size_t count = mmin(SSIZE_MAX, r);
+        const size_t count = std::min<size_t>(SSIZE_MAX, r);
         size_t c = fread(rb, 1, count, mfile);
         if (c != count) {
             LOG(("GetManifestContents: error reading manifest file: " LOG_S, manifest));
commit 4402c33a4dc4d45bf4d5b0f413b7c814f5529c08
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Dec 30 18:49:49 2016 +0100

    remove unnecessary case from updater code
    
    Change-Id: I9001b661a929a66723cf8e83ed3d8f664f180b14

diff --git a/onlineupdate/source/update/updater/updater.cxx b/onlineupdate/source/update/updater/updater.cxx
index 828b855..772b790 100644
--- a/onlineupdate/source/update/updater/updater.cxx
+++ b/onlineupdate/source/update/updater/updater.cxx
@@ -223,7 +223,6 @@ static bool gSucceeded = false;
 static bool sStagedUpdate = false;
 static bool sReplaceRequest = false;
 static bool sUsingService = false;
-static bool sIsOSUpdate = false;
 
 #ifdef _WIN32
 // The current working directory specified in the command line.
@@ -2417,7 +2416,7 @@ UpdateThreadFunc(void * /*param*/)
         }
 #endif
 
-        if (rv == OK && sStagedUpdate && !sIsOSUpdate) {
+        if (rv == OK && sStagedUpdate) {
 #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
@@ -2728,11 +2727,6 @@ int NS_main(int argc, NS_tchar **argv)
     }
 #endif
 
-    if (EnvHasValue("MOZ_OS_UPDATE")) {
-        sIsOSUpdate = true;
-        putenv(const_cast<char*>("MOZ_OS_UPDATE="));
-    }
-
     LogInit(gPatchDirPath, NS_T("update.log"));
 
     if (!WriteStatusFile("applying")) {
@@ -3901,10 +3895,6 @@ GetManifestContents(const NS_tchar *manifest)
 
 int AddPreCompleteActions(ActionList *list)
 {
-    if (sIsOSUpdate) {
-        return OK;
-    }
-
 #ifdef MACOSX
     std::unique_ptr<NS_tchar> manifestPath(get_full_path(
                 NS_T("Contents/Resources/precomplete")));


More information about the Libreoffice-commits mailing list