| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import base64 | 5 import base64 |
| 6 import hashlib | 6 import hashlib |
| 7 import os | 7 import os |
| 8 import string | 8 import string |
| 9 import win32api | 9 import win32api |
| 10 import win32com.client | 10 import win32com.client |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 | 55 |
| 56 class VariableExpander: | 56 class VariableExpander: |
| 57 """Expands variables in strings.""" | 57 """Expands variables in strings.""" |
| 58 | 58 |
| 59 def __init__(self, mini_installer_path, next_version_mini_installer_path): | 59 def __init__(self, mini_installer_path, next_version_mini_installer_path): |
| 60 """Constructor. | 60 """Constructor. |
| 61 | 61 |
| 62 The constructor initializes a variable dictionary that maps variables to | 62 The constructor initializes a variable dictionary that maps variables to |
| 63 their values. These are the only acceptable variables: | 63 their values. These are the only acceptable variables: |
| 64 * $BRAND: the browser brand (e.g., "Google Chrome" or "Chromium"). |
| 64 * $CHROME_DIR: the directory of Chrome (or Chromium) from the base | 65 * $CHROME_DIR: the directory of Chrome (or Chromium) from the base |
| 65 installation directory. | 66 installation directory. |
| 66 * $CHROME_HTML_PROG_ID: 'ChromeHTML' (or 'ChromiumHTM'). | 67 * $CHROME_HTML_PROG_ID: 'ChromeHTML' (or 'ChromiumHTM'). |
| 67 * $CHROME_LONG_NAME: 'Google Chrome' (or 'Chromium'). | 68 * $CHROME_LONG_NAME: 'Google Chrome' (or 'Chromium'). |
| 68 * $CHROME_LONG_NAME_SXS: 'Google Chrome SxS' if $SUPPORTS_SXS. | 69 * $CHROME_LONG_NAME_BETA: 'Google Chrome Beta' if $BRAND is 'Google |
| 70 * Chrome'. |
| 71 * $CHROME_LONG_NAME_DEV: 'Google Chrome Dev' if $BRAND is 'Google |
| 72 * Chrome'. |
| 73 * $CHROME_LONG_NAME_SXS: 'Google Chrome SxS' if $BRAND is 'Google |
| 74 * Chrome'. |
| 69 * $CHROME_SHORT_NAME: 'Chrome' (or 'Chromium'). | 75 * $CHROME_SHORT_NAME: 'Chrome' (or 'Chromium'). |
| 70 * $CHROME_SHORT_NAME_SXS: 'ChromeCanary' if $SUPPORTS_SXS. | 76 * $CHROME_SHORT_NAME_BETA: 'ChromeBeta' if $BRAND is 'Google Chrome'. |
| 77 * $CHROME_SHORT_NAME_DEV: 'ChromeDev' if $BRAND is 'Google Chrome'. |
| 78 * $CHROME_SHORT_NAME_SXS: 'ChromeCanary' if $BRAND is 'Google Chrome'. |
| 71 * $CHROME_UPDATE_REGISTRY_SUBKEY: the registry key, excluding the root | 79 * $CHROME_UPDATE_REGISTRY_SUBKEY: the registry key, excluding the root |
| 72 key, of Chrome for Google Update. | 80 key, of Chrome for Google Update. |
| 81 * $CHROME_UPDATE_REGISTRY_SUBKEY_DEV: the registry key, excluding the |
| 82 root key, of Chrome Dev for Google Update. |
| 83 * $CHROME_UPDATE_REGISTRY_SUBKEY_BETA: the registry key, excluding the |
| 84 root key, of Chrome Beta for Google Update. |
| 73 * $CHROME_UPDATE_REGISTRY_SUBKEY_SXS: the registry key, excluding the | 85 * $CHROME_UPDATE_REGISTRY_SUBKEY_SXS: the registry key, excluding the |
| 74 root key, of Chrome SxS for Google Update. | 86 root key, of Chrome SxS for Google Update. |
| 75 * $LAUNCHER_UPDATE_REGISTRY_SUBKEY: the registry key, excluding the root | 87 * $LAUNCHER_UPDATE_REGISTRY_SUBKEY: the registry key, excluding the root |
| 76 key, of the app launcher for Google Update if $SUPPORTS_SXS. | 88 key, of the app launcher for Google Update if $BRAND is 'Google |
| 89 * Chrome'. |
| 77 * $LOCAL_APPDATA: the unquoted path to the Local Application Data | 90 * $LOCAL_APPDATA: the unquoted path to the Local Application Data |
| 78 folder. | 91 folder. |
| 79 * $MINI_INSTALLER: the unquoted path to the mini_installer. | 92 * $MINI_INSTALLER: the unquoted path to the mini_installer. |
| 80 * $MINI_INSTALLER_FILE_VERSION: the file version of $MINI_INSTALLER. | 93 * $MINI_INSTALLER_FILE_VERSION: the file version of $MINI_INSTALLER. |
| 81 * $NEXT_VERSION_MINI_INSTALLER: the unquoted path to a mini_installer | 94 * $NEXT_VERSION_MINI_INSTALLER: the unquoted path to a mini_installer |
| 82 whose version is higher than $MINI_INSTALLER. | 95 whose version is higher than $MINI_INSTALLER. |
| 83 * $NEXT_VERSION_MINI_INSTALLER_FILE_VERSION: the file version of | 96 * $NEXT_VERSION_MINI_INSTALLER_FILE_VERSION: the file version of |
| 84 $NEXT_VERSION_MINI_INSTALLER. | 97 $NEXT_VERSION_MINI_INSTALLER. |
| 85 * $PROGRAM_FILES: the unquoted path to the Program Files folder. | 98 * $PROGRAM_FILES: the unquoted path to the Program Files folder. |
| 86 * $SUPPORTS_SXS: a boolean indicating whether or not SxS installs | |
| 87 are supported by the mini_installer under test. | |
| 88 * $USER_SPECIFIC_REGISTRY_SUFFIX: the output from the function | 99 * $USER_SPECIFIC_REGISTRY_SUFFIX: the output from the function |
| 89 _GetUserSpecificRegistrySuffix(). | 100 _GetUserSpecificRegistrySuffix(). |
| 90 * $VERSION_[XP/SERVER_2003/VISTA/WIN7/WIN8/WIN8_1/WIN10]: a 2-tuple | 101 * $VERSION_[XP/SERVER_2003/VISTA/WIN7/WIN8/WIN8_1/WIN10]: a 2-tuple |
| 91 representing the version of the corresponding OS. | 102 representing the version of the corresponding OS. |
| 92 * $WINDOWS_VERSION: a 2-tuple representing the current Windows version. | 103 * $WINDOWS_VERSION: a 2-tuple representing the current Windows version. |
| 93 | 104 |
| 94 Args: | 105 Args: |
| 95 mini_installer_path: The path to a mini_installer. | 106 mini_installer_path: The path to a mini_installer. |
| 96 next_version_mini_installer_path: The path to a mini_installer whose | 107 next_version_mini_installer_path: The path to a mini_installer whose |
| 97 version is higher than |mini_installer_path|. | 108 version is higher than |mini_installer_path|. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 117 'VERSION_WIN7': '(6, 1)', | 128 'VERSION_WIN7': '(6, 1)', |
| 118 'VERSION_WIN8': '(6, 2)', | 129 'VERSION_WIN8': '(6, 2)', |
| 119 'VERSION_WIN8_1': '(6, 3)', | 130 'VERSION_WIN8_1': '(6, 3)', |
| 120 'VERSION_XP': '(5, 1)', | 131 'VERSION_XP': '(5, 1)', |
| 121 'WINDOWS_VERSION': '(%s, %s)' % (windows_major_ver, windows_minor_ver) | 132 'WINDOWS_VERSION': '(%s, %s)' % (windows_major_ver, windows_minor_ver) |
| 122 } | 133 } |
| 123 | 134 |
| 124 mini_installer_product_name = _GetProductName(mini_installer_abspath) | 135 mini_installer_product_name = _GetProductName(mini_installer_abspath) |
| 125 if mini_installer_product_name == 'Google Chrome Installer': | 136 if mini_installer_product_name == 'Google Chrome Installer': |
| 126 self._variable_mapping.update({ | 137 self._variable_mapping.update({ |
| 138 'BRAND': 'Google Chrome', |
| 127 'BINARIES_UPDATE_REGISTRY_SUBKEY': ( | 139 'BINARIES_UPDATE_REGISTRY_SUBKEY': ( |
| 128 'Software\\Google\\Update\\Clients\\' | 140 'Software\\Google\\Update\\Clients\\' |
| 129 '{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}'), | 141 '{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}'), |
| 130 'CHROME_DIR': 'Google\\Chrome', | 142 'CHROME_DIR': 'Google\\Chrome', |
| 131 'CHROME_HTML_PROG_ID': 'ChromeHTML', | 143 'CHROME_HTML_PROG_ID': 'ChromeHTML', |
| 132 'CHROME_LONG_NAME': 'Google Chrome', | 144 'CHROME_LONG_NAME': 'Google Chrome', |
| 133 'CHROME_SHORT_NAME': 'Chrome', | 145 'CHROME_SHORT_NAME': 'Chrome', |
| 134 'CHROME_UPDATE_REGISTRY_SUBKEY': ( | 146 'CHROME_UPDATE_REGISTRY_SUBKEY': ( |
| 135 'Software\\Google\\Update\\Clients\\' | 147 'Software\\Google\\Update\\Clients\\' |
| 136 '{8A69D345-D564-463c-AFF1-A69D9E530F96}'), | 148 '{8A69D345-D564-463c-AFF1-A69D9E530F96}'), |
| 137 'CHROME_CLIENT_STATE_KEY': ( | 149 'CHROME_CLIENT_STATE_KEY': ( |
| 138 'Software\\Google\\Update\\ClientState\\' | 150 'Software\\Google\\Update\\ClientState\\' |
| 139 '{8A69D345-D564-463c-AFF1-A69D9E530F96}'), | 151 '{8A69D345-D564-463c-AFF1-A69D9E530F96}'), |
| 140 'SUPPORTS_SXS': True, | 152 'CHROME_DIR_BETA': 'Google\\Chrome Beta', |
| 153 'CHROME_DIR_DEV': 'Google\\Chrome Dev', |
| 141 'CHROME_DIR_SXS': 'Google\\Chrome SxS', | 154 'CHROME_DIR_SXS': 'Google\\Chrome SxS', |
| 155 'CHROME_LONG_NAME_BETA': 'Google Chrome Beta', |
| 156 'CHROME_LONG_NAME_DEV': 'Google Chrome Dev', |
| 142 'CHROME_LONG_NAME_SXS': 'Google Chrome SxS', | 157 'CHROME_LONG_NAME_SXS': 'Google Chrome SxS', |
| 158 'CHROME_SHORT_NAME_BETA': 'ChromeBeta', |
| 159 'CHROME_SHORT_NAME_DEV': 'ChromeDev', |
| 143 'CHROME_SHORT_NAME_SXS': 'ChromeCanary', | 160 'CHROME_SHORT_NAME_SXS': 'ChromeCanary', |
| 161 'CHROME_UPDATE_REGISTRY_SUBKEY_BETA': ( |
| 162 'Software\\Google\\Update\\Clients\\' |
| 163 '{8237E44A-0054-442C-B6B6-EA0509993955}'), |
| 164 'CHROME_UPDATE_REGISTRY_SUBKEY_DEV': ( |
| 165 'Software\\Google\\Update\\Clients\\' |
| 166 '{401C381F-E0DE-4B85-8BD8-3F3F14FBDA57}'), |
| 144 'CHROME_UPDATE_REGISTRY_SUBKEY_SXS': ( | 167 'CHROME_UPDATE_REGISTRY_SUBKEY_SXS': ( |
| 145 'Software\\Google\\Update\\Clients\\' | 168 'Software\\Google\\Update\\Clients\\' |
| 146 '{4ea16ac7-fd5a-47c3-875b-dbf4a2008c20}'), | 169 '{4ea16ac7-fd5a-47c3-875b-dbf4a2008c20}'), |
| 147 'LAUNCHER_UPDATE_REGISTRY_SUBKEY': ( | 170 'LAUNCHER_UPDATE_REGISTRY_SUBKEY': ( |
| 148 'Software\\Google\\Update\\Clients\\' | 171 'Software\\Google\\Update\\Clients\\' |
| 149 '{FDA71E6F-AC4C-4a00-8B70-9958A68906BF}') | 172 '{FDA71E6F-AC4C-4a00-8B70-9958A68906BF}') |
| 150 }) | 173 }) |
| 151 elif mini_installer_product_name == 'Chromium Installer': | 174 elif mini_installer_product_name == 'Chromium Installer': |
| 152 self._variable_mapping.update({ | 175 self._variable_mapping.update({ |
| 176 'BRAND': 'Chromium', |
| 153 'BINARIES_UPDATE_REGISTRY_SUBKEY': 'Software\\Chromium Binaries', | 177 'BINARIES_UPDATE_REGISTRY_SUBKEY': 'Software\\Chromium Binaries', |
| 154 'CHROME_DIR': 'Chromium', | 178 'CHROME_DIR': 'Chromium', |
| 155 'CHROME_HTML_PROG_ID': 'ChromiumHTM', | 179 'CHROME_HTML_PROG_ID': 'ChromiumHTM', |
| 156 'CHROME_LONG_NAME': 'Chromium', | 180 'CHROME_LONG_NAME': 'Chromium', |
| 157 'CHROME_SHORT_NAME': 'Chromium', | 181 'CHROME_SHORT_NAME': 'Chromium', |
| 158 'CHROME_UPDATE_REGISTRY_SUBKEY': 'Software\\Chromium', | 182 'CHROME_UPDATE_REGISTRY_SUBKEY': 'Software\\Chromium', |
| 159 'CHROME_CLIENT_STATE_KEY': 'Software\\Chromium', | 183 'CHROME_CLIENT_STATE_KEY': 'Software\\Chromium', |
| 160 'SUPPORTS_SXS': False | |
| 161 }) | 184 }) |
| 162 else: | 185 else: |
| 163 raise KeyError("Unknown mini_installer product name '%s'" % | 186 raise KeyError("Unknown mini_installer product name '%s'" % |
| 164 mini_installer_product_name) | 187 mini_installer_product_name) |
| 165 | 188 |
| 166 | 189 |
| 167 def Expand(self, str): | 190 def Expand(self, str): |
| 168 """Expands variables in the given string. | 191 """Expands variables in the given string. |
| 169 | 192 |
| 170 This method resolves only variables defined in the constructor. It does not | 193 This method resolves only variables defined in the constructor. It does not |
| 171 resolve environment variables. Any dollar signs that are not part of | 194 resolve environment variables. Any dollar signs that are not part of |
| 172 variables must be escaped with $$, otherwise a KeyError or a ValueError will | 195 variables must be escaped with $$, otherwise a KeyError or a ValueError will |
| 173 be raised. | 196 be raised. |
| 174 | 197 |
| 175 Args: | 198 Args: |
| 176 str: A string. | 199 str: A string. |
| 177 | 200 |
| 178 Returns: | 201 Returns: |
| 179 A new string created by replacing variables with their values. | 202 A new string created by replacing variables with their values. |
| 180 """ | 203 """ |
| 181 return string.Template(str).substitute(self._variable_mapping) | 204 return string.Template(str).substitute(self._variable_mapping) |
| OLD | NEW |