| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/python2.4 | |
| 2 # | |
| 3 # Copyright 2009 Google Inc. | |
| 4 # | |
| 5 # Licensed under the Apache License, Version 2.0 (the "License"); | |
| 6 # you may not use this file except in compliance with the License. | |
| 7 # You may obtain a copy of the License at | |
| 8 # | |
| 9 # http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 # | |
| 11 # Unless required by applicable law or agreed to in writing, software | |
| 12 # distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 # See the License for the specific language governing permissions and | |
| 15 # limitations under the License. | |
| 16 # ======================================================================== | |
| 17 | |
| 18 | |
| 19 Import('env') | |
| 20 | |
| 21 import codecs | |
| 22 import os | |
| 23 import re | |
| 24 import string | |
| 25 | |
| 26 from installers import build_metainstaller | |
| 27 | |
| 28 _RECOVERY_MARKUP_DLL_BASE_NAME = 'recovery_markup' | |
| 29 _RECOVERY_MARKUP_DLL = _RECOVERY_MARKUP_DLL_BASE_NAME + '.dll' | |
| 30 | |
| 31 _CLICKONCE_DEPLOY_DIR = '$TARGET_ROOT/clickonce_deployment' | |
| 32 | |
| 33 # This will be of the form 'GoogleInstaller_en.application'. | |
| 34 def _GetClickOnceDeploymentName(language): | |
| 35 return 'GoogleInstaller_%s.application' % (language) | |
| 36 | |
| 37 # Generate a ClickOnce deployment manifest personalized with the localized | |
| 38 # display name of 'Google Installer'. | |
| 39 def _GenerateDeploymentForOneLanguage(omaha_version_info, language): | |
| 40 clickonce_deployment_name = _GetClickOnceDeploymentName(language) | |
| 41 | |
| 42 clickonce_manifest_name = 'clickonce_bootstrap.exe.manifest' | |
| 43 clickonce_manifest = '%s/%s' % (_CLICKONCE_DEPLOY_DIR, | |
| 44 clickonce_manifest_name) | |
| 45 | |
| 46 # Generate the deployment manifest with a dummy name of 'xxxXXXxxx'. The | |
| 47 # Python commands module does not work with Unicode strings, so we will | |
| 48 # substitute the name in the add_trusturlparams_and_name_command below. | |
| 49 generate_deploy_manifest_command = ( | |
| 50 '@mage -New Deployment -Install false -ToFile $TARGET -Name xxxXXXxxx' | |
| 51 ' -Version %s -Processor x86 -AppManifest $SOURCE -AppCodeBase %s' % | |
| 52 (omaha_version_info.GetVersionString(), clickonce_manifest_name)) | |
| 53 | |
| 54 # Have to set up a clear chain of source->target1->target2->target3->etc so | |
| 55 # that declarative Hammer will know the order in which to run each command. | |
| 56 clickonce_target_1 = env.Command( | |
| 57 target=clickonce_deployment_name + '.base', | |
| 58 source=clickonce_manifest, | |
| 59 action=generate_deploy_manifest_command, | |
| 60 ) | |
| 61 | |
| 62 # Get the localized 'Google Installer' string. | |
| 63 mi_generated_resource = ( | |
| 64 '$MAIN_DIR/mi_exe_stub/mi_generated_resources_%s.rc' % language) | |
| 65 f_in = codecs.open(env.File(mi_generated_resource).abspath, 'r', 'utf16') | |
| 66 mi_resource_contents = f_in.read() | |
| 67 f_in.close() | |
| 68 | |
| 69 # Get and format strings necessary to generate the display name. | |
| 70 # index() will throw and abort the build if there is no match. | |
| 71 | |
| 72 # First, get the company name. | |
| 73 company_name_start = (mi_resource_contents.index('IDS_FRIENDLY_COMPANY_NAME')) | |
| 74 company_name_start = mi_resource_contents.index('"', company_name_start) | |
| 75 company_name_end = mi_resource_contents.index('"', company_name_start + 1) | |
| 76 # Since it is inserted into the display name, the quotes must be dropped. | |
| 77 company_name = mi_resource_contents[company_name_start + 1:company_name_end] | |
| 78 if -1 != company_name.find('"'): | |
| 79 raise Exception('Slice indexes are incorrect!') | |
| 80 | |
| 81 # Now get the installer display name and replace the placeholder with the | |
| 82 # company name. | |
| 83 display_name_start = ( | |
| 84 mi_resource_contents.index('IDS_INSTALLER_DISPLAY_NAME')) | |
| 85 display_name_start = mi_resource_contents.index('"', display_name_start) | |
| 86 display_name_end = mi_resource_contents.index('"', display_name_start + 1) | |
| 87 display_name = mi_resource_contents[display_name_start:display_name_end + 1] | |
| 88 display_name = display_name.replace('%1!s!', company_name) | |
| 89 | |
| 90 # display_name is utf8 encoded to allow the commands and the default codec to | |
| 91 # pass it through. | |
| 92 display_name = display_name.encode('utf8') | |
| 93 | |
| 94 # mage.exe does not provide a way to add the trustURLParameters attribute to | |
| 95 # an application manifest. This script fills that gap. It also adds in the | |
| 96 # localized display name, to get around issues with the Python commands | |
| 97 # module. | |
| 98 add_trusturlparams_and_name_command = ( | |
| 99 '@python %s --manifest_file=$SOURCE --output_file=$TARGET --display_name=' | |
| 100 '%s' % (env.File('$MAIN_DIR/clickonce/add_trusturlparams.py').abspath, | |
| 101 display_name)) | |
| 102 | |
| 103 # This is the next step in the target chain | |
| 104 clickonce_target_2 = env.Command( | |
| 105 target=clickonce_deployment_name + '.unsigned', | |
| 106 source=clickonce_target_1, | |
| 107 action=add_trusturlparams_and_name_command, | |
| 108 ) | |
| 109 | |
| 110 # Sign the deployment manifest. | |
| 111 # This will be of the form | |
| 112 # 'scons-out\dbg-win\clickonce_deployment\GoogleInstaller_en.application'. | |
| 113 manifest_target = '%s/%s' % (_CLICKONCE_DEPLOY_DIR, clickonce_deployment_name) | |
| 114 env.SignDotNetManifest(manifest_target, clickonce_target_2) | |
| 115 | |
| 116 | |
| 117 | |
| 118 def _BuildSetup(omaha_versions_info, is_repair = False): | |
| 119 # Build the meta-installer for each version. | |
| 120 _PRODUCT_NAME = 'GoogleUpdate' | |
| 121 | |
| 122 for omaha_version_info in omaha_versions_info: | |
| 123 prefix = omaha_version_info.filename_prefix | |
| 124 | |
| 125 source_binary = '$OBJ_ROOT/mi_exe_stub/%smi_exe_stub.exe' % prefix | |
| 126 | |
| 127 if is_repair: | |
| 128 _BuildSetupRepairVersion(omaha_version_info, | |
| 129 source_binary, | |
| 130 _PRODUCT_NAME, | |
| 131 prefix) | |
| 132 else: | |
| 133 _BuildSetupVersion(omaha_version_info, | |
| 134 source_binary, | |
| 135 _PRODUCT_NAME, | |
| 136 prefix) | |
| 137 | |
| 138 | |
| 139 | |
| 140 def _BuildSetupRepairVersion(omaha_version_info, | |
| 141 source_binary, | |
| 142 product_name, | |
| 143 prefix = ''): | |
| 144 # Build the target setup executable by merging the empty metafile | |
| 145 # with the resource dll built earlier | |
| 146 merged_output = env.Command( | |
| 147 target='%smi_exe_stub_repair.exe' % (prefix), | |
| 148 source=[source_binary, '$OBJ_ROOT/installers/' + _RECOVERY_MARKUP_DLL], | |
| 149 action='@$MAIN_DIR/tools/resmerge --copyappend $SOURCES $TARGET', | |
| 150 ) | |
| 151 | |
| 152 build_metainstaller.BuildMetaInstaller( | |
| 153 env=env, | |
| 154 target_name='%s%sSetup_repair.exe' % (prefix, product_name), | |
| 155 omaha_version_info=omaha_version_info, | |
| 156 empty_metainstaller_path=merged_output, | |
| 157 omaha_files_path='$STAGING_DIR', | |
| 158 prefix = prefix, | |
| 159 suffix = '_repair', | |
| 160 additional_payload_contents = [ | |
| 161 '$STAGING_DIR/GoogleUpdateHelperPatch.msp', | |
| 162 ], | |
| 163 ) | |
| 164 | |
| 165 | |
| 166 | |
| 167 def _BuildSetupVersion(omaha_version_info, | |
| 168 source_binary, | |
| 169 product_name, | |
| 170 prefix = ''): | |
| 171 target_name = '%s%sSetup.exe' % (prefix, product_name) | |
| 172 | |
| 173 build_metainstaller.BuildMetaInstaller( | |
| 174 env=env, | |
| 175 omaha_version_info=omaha_version_info, | |
| 176 target_name=target_name, | |
| 177 empty_metainstaller_path=source_binary, | |
| 178 omaha_files_path='$STAGING_DIR', | |
| 179 prefix=prefix | |
| 180 ) | |
| 181 | |
| 182 # Generate the i18n ClickOnce deployment manifest for languages that we | |
| 183 # support. | |
| 184 if env.Bit('all') or 'OMAHA_BUILD_CLICKONCE' in os.environ.keys(): | |
| 185 for language in omaha_version_info.GetSupportedLanguages(): | |
| 186 _GenerateDeploymentForOneLanguage(omaha_version_info, language) | |
| 187 | |
| 188 # zh-HK needs a deployment file, but it is not in | |
| 189 # omaha_version_info.GetSupportedLanguages() and there is no | |
| 190 # mi_generated_resources_zh-HK.rc file. The few translations are inherited | |
| 191 # from zh-TW, and there are no language code-specific values in the | |
| 192 # deployment file, so just copy the zh-TW file to zh-HK. | |
| 193 env.Command( | |
| 194 target='%s/%s' % (_CLICKONCE_DEPLOY_DIR, | |
| 195 _GetClickOnceDeploymentName('zh-HK')), | |
| 196 source='%s/%s' % (_CLICKONCE_DEPLOY_DIR, | |
| 197 _GetClickOnceDeploymentName('zh-TW')), | |
| 198 action='@copy /y $SOURCES $TARGET' | |
| 199 ) | |
| 200 | |
| 201 if not env.Bit('official_installers'): | |
| 202 omaha_versions_info = env['omaha_versions_info'] | |
| 203 | |
| 204 # Build the normal tagged installers. | |
| 205 _BuildSetup(omaha_versions_info) | |
| 206 | |
| 207 env.Replicate( | |
| 208 target=[ | |
| 209 '$TARGET_ROOT/clickonce_deployment/bin/', | |
| 210 '$STAGING_DIR', | |
| 211 ], | |
| 212 source='$OBJ_ROOT/installers/GoogleUpdateSetup.exe', | |
| 213 ) | |
| 214 | |
| 215 # Build the repair installer. | |
| 216 _BuildSetup(omaha_versions_info, is_repair = True) | |
| 217 | |
| 218 # Build a resource DLL containing the recovery markup resource. | |
| 219 dll_env = env.Clone(COMPONENT_STATIC=False) | |
| 220 dll_env['LINKFLAGS'] += ['/noentry'] | |
| 221 | |
| 222 dll_inputs = [ | |
| 223 '../installers/resource_only_dll.def', | |
| 224 dll_env.RES('recovery_markup.res', | |
| 225 '$MAIN_DIR/recovery/recovery_markup.rc') | |
| 226 ] | |
| 227 | |
| 228 dll_env.ComponentLibrary(_RECOVERY_MARKUP_DLL_BASE_NAME, dll_inputs) | |
| 229 | |
| 230 | |
| OLD | NEW |