Bug 721758 - Ability to configure updater to accept multiple MAR IDs. r=rstrong
authorBrian R. Bondy <netzen@gmail.com>
Fri, 24 Feb 2012 16:29:42 -0500
changeset 87638 d74612c5824585fb14631b5a8eb36d4394acb74c
parent 87637 52bd72d77fda6827b8b5470149abd1f80801e731
child 87639 0bde78f1b76a08170e201e9172e6701c40eddd51
push id22138
push userbbondy@mozilla.com
push dateFri, 24 Feb 2012 21:30:05 +0000
treeherdermozilla-central@2b1a53905350 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs721758
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 721758 - Ability to configure updater to accept multiple MAR IDs. r=rstrong
browser/confvars.sh
build/Makefile.in
build/update-settings.ini.in
config/autoconf.mk.in
configure.in
toolkit/mozapps/update/common/updatehelper.cpp
toolkit/mozapps/update/updater/archivereader.cpp
toolkit/mozapps/update/updater/updater.cpp
--- a/browser/confvars.sh
+++ b/browser/confvars.sh
@@ -54,12 +54,17 @@ MOZ_SERVICES_SYNC=1
 MOZ_APP_VERSION=$FIREFOX_VERSION
 MOZ_EXTENSIONS_DEFAULT=" gnomevfs"
 # MOZ_APP_DISPLAYNAME will be set by branding/configure.sh
 # Changing either of these values requires a clobber to ensure correct results,
 # because branding dependencies are broken.
 MOZ_BRANDING_DIRECTORY=browser/branding/nightly
 MOZ_OFFICIAL_BRANDING_DIRECTORY=browser/branding/official
 MOZ_APP_ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
+# This should usually be the same as the value MAR_CHANNEL_ID.
+# If more than one ID is needed, then you should use a comma separated list
+# of values.
+ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-central
+# The MAR_CHANNEL_ID must not contain the following 3 characters: ",\t "
 MAR_CHANNEL_ID=firefox-mozilla-central
 MOZ_PROFILE_MIGRATOR=1
 MOZ_EXTENSION_MANAGER=1
 MOZ_APP_STATIC_INI=1
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -99,16 +99,17 @@ ifdef SOURCE_REPO
 DEFINES += -DMOZ_SOURCE_REPO="$(SOURCE_REPO)"
 endif
 
 DEFINES += \
   -DMOZ_APP_BASENAME="$(MOZ_APP_BASENAME)" \
   -DMOZ_APP_VENDOR="$(MOZ_APP_VENDOR)" \
   -DMOZ_APP_ID="$(MOZ_APP_ID)" \
   -DMAR_CHANNEL_ID="$(MAR_CHANNEL_ID)" \
+  -DACCEPTED_MAR_CHANNEL_IDS="$(ACCEPTED_MAR_CHANNEL_IDS)" \
   $(NULL)
 
 ifdef MOZ_APP_PROFILE
 DEFINES += -DMOZ_APP_PROFILE="$(MOZ_APP_PROFILE)"
 endif
 
 ifdef MOZILLA_OFFICIAL
 DEFINES += -DMOZILLA_OFFICIAL
--- a/build/update-settings.ini.in
+++ b/build/update-settings.ini.in
@@ -36,9 +36,9 @@
 ;
 ; ***** END LICENSE BLOCK *****
 #endif
 ; If you modify this file updates may fail.
 ; Do not modify this file.
 
 #filter substitution
 [Settings]
-MAR_CHANNEL_ID=@MAR_CHANNEL_ID@
+ACCEPTED_MAR_CHANNEL_IDS=@ACCEPTED_MAR_CHANNEL_IDS@
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -49,16 +49,17 @@ FIREFOX_VERSION	= @FIREFOX_VERSION@
 MOZ_BUILD_APP = @MOZ_BUILD_APP@
 MOZ_APP_NAME	= @MOZ_APP_NAME@
 MOZ_APP_DISPLAYNAME = @MOZ_APP_DISPLAYNAME@
 MOZ_APP_BASENAME = @MOZ_APP_BASENAME@
 MOZ_APP_VENDOR = @MOZ_APP_VENDOR@
 MOZ_APP_PROFILE = @MOZ_APP_PROFILE@
 MOZ_APP_ID = @MOZ_APP_ID@
 MAR_CHANNEL_ID = @MAR_CHANNEL_ID@
+ACCEPTED_MAR_CHANNEL_IDS = @ACCEPTED_MAR_CHANNEL_IDS@
 MOZ_PROFILE_MIGRATOR = @MOZ_PROFILE_MIGRATOR@
 MOZ_EXTENSION_MANAGER = @MOZ_EXTENSION_MANAGER@
 MOZ_APP_UA_NAME = @MOZ_APP_UA_NAME@
 MOZ_APP_VERSION = @MOZ_APP_VERSION@
 MOZ_UA_BUILDID = @MOZ_UA_BUILDID@
 MOZ_MACBUNDLE_NAME = @MOZ_MACBUNDLE_NAME@
 MOZ_APP_STATIC_INI = @MOZ_APP_STATIC_INI@
 
--- a/configure.in
+++ b/configure.in
@@ -8690,16 +8690,17 @@ fi
 
 AC_SUBST(MOZ_APP_NAME)
 AC_SUBST(MOZ_APP_DISPLAYNAME)
 AC_SUBST(MOZ_APP_BASENAME)
 AC_SUBST(MOZ_APP_VENDOR)
 AC_SUBST(MOZ_APP_PROFILE)
 AC_SUBST(MOZ_APP_ID)
 AC_SUBST(MAR_CHANNEL_ID)
+AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
 AC_SUBST(MOZ_PROFILE_MIGRATOR)
 AC_SUBST(MOZ_EXTENSION_MANAGER)
 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
 AC_SUBST(MOZ_APP_UA_NAME)
 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
 AC_SUBST(MOZ_APP_VERSION)
 AC_DEFINE_UNQUOTED(MOZ_UA_FIREFOX_VERSION, "$FIREFOX_VERSION")
 AC_DEFINE_UNQUOTED(FIREFOX_VERSION,$FIREFOX_VERSION)
--- a/toolkit/mozapps/update/common/updatehelper.cpp
+++ b/toolkit/mozapps/update/common/updatehelper.cpp
@@ -569,18 +569,18 @@ WaitForServiceStop(LPCWSTR serviceName, 
 }
 
 /**
  * Determines if there is at least one process running for the specified
  * application. A match will be found across any session for any user.
  *
  * @param process The process to check for existance
  * @return ERROR_NOT_FOUND if the process was not found
- * @       ERROR_SUCCESS if the process was found and there were no errors
- * @       Other Win32 system error code for other errors
+ *         ERROR_SUCCESS if the process was found and there were no errors
+ *         Other Win32 system error code for other errors
 **/
 DWORD
 IsProcessRunning(LPCWSTR filename)
 {
   // Take a snapshot of all processes in the system.
   HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
   if (INVALID_HANDLE_VALUE == snapshot) {
     return GetLastError();
--- a/toolkit/mozapps/update/updater/archivereader.cpp
+++ b/toolkit/mozapps/update/updater/archivereader.cpp
@@ -163,16 +163,18 @@ ArchiveReader::VerifySignature()
 
 /**
  * Verifies that the MAR file matches the current product, channel, and version
  * 
  * @param MARChannelID   The MAR channel name to use, only updates from MARs
  *                       with a matching MAR channel name will succeed.
  *                       If an empty string is passed, no check will be done
  *                       for the channel name in the product information block.
+ *                       If a comma separated list of values is passed then
+ *                       one value must match.
  * @param appVersion     The application version to use, only MARs with an
  *                       application version >= to appVersion will be applied.
  * @return OK on success
  *         COULD_NOT_READ_PRODUCT_INFO_BLOCK if the product info block 
  *                                           could not be read.
  *         MARCHANNEL_MISMATCH_ERROR         if update-settings.ini's MAR 
  *                                           channel ID doesn't match the MAR
  *                                           file's MAR channel ID. 
@@ -193,18 +195,30 @@ ArchiveReader::VerifyProductInformation(
                                        &productInfoBlock);
   if (rv != OK) {
     return COULD_NOT_READ_PRODUCT_INFO_BLOCK_ERROR;
   }
 
   // Only check the MAR channel name if specified, it should be passed in from
   // the update-settings.ini file.
   if (MARChannelID && strlen(MARChannelID)) {
-    if (rv == OK && strcmp(MARChannelID, productInfoBlock.MARChannelID)) {
-      rv = MAR_CHANNEL_MISMATCH_ERROR;
+    // Check for at least one match in the comma separated list of values.
+    const char *delimiter = " ,\t";
+    // Make a copy of the string in case a read only memory buffer 
+    // was specified.  strtok modifies the input buffer.
+    char channelCopy[512] = { 0 };
+    strncpy(channelCopy, MARChannelID, sizeof(channelCopy) - 1);
+    char *channel = strtok(channelCopy, delimiter);
+    rv = MAR_CHANNEL_MISMATCH_ERROR;
+    while(channel) {
+      if (!strcmp(channel, productInfoBlock.MARChannelID)) {
+        rv = OK;
+        break;
+      }
+      channel = strtok(NULL, delimiter);
     }
   }
 
   if (rv == OK) {
     /* Compare both versions to ensure we don't have a downgrade
         1 if appVersion is older than productInfoBlock.productVersion
         -1 if appVersion is newer than productInfoBlock.productVersion 
         0 if appVersion is the same as productInfoBlock.productVersion 
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -1536,27 +1536,27 @@ WaitForServiceFinishThread(void *param)
   // before deciding to show this UI.
   WaitForServiceStop(SVC_NAME, 595);
   LOG(("calling QuitProgressUI\n"));
   QuitProgressUI();
 }
 #endif
 
 /**
- * This function reads in the MAR_CHANNEL_ID from update-settings.ini
+ * This function reads in the ACCEPTED_MAR_CHANNEL_IDS from update-settings.ini
  *
  * @param path    The path to the ini file that is to be read
  * @param results A pointer to the location to store the read strings
  * @return OK on success
  */
 static int
 ReadMARChannelIDs(const NS_tchar *path, MARChannelStringTable *results)
 {
   const unsigned int kNumStrings = 1;
-  const char *kUpdaterKeys = "MAR_CHANNEL_ID\0";
+  const char *kUpdaterKeys = "ACCEPTED_MAR_CHANNEL_IDS\0";
   char updater_strings[kNumStrings][MAX_TEXT_LEN];
 
   int result = ReadStrings(path, kUpdaterKeys, kNumStrings,
                            updater_strings, "Settings");
 
   strncpy(results->MARChannelID, updater_strings[0], MAX_TEXT_LEN - 1);
   results->MARChannelID[MAX_TEXT_LEN - 1] = 0;