| 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 # Hammer file to create the stub .msi and .msp files | |
| 20 # | |
| 21 | |
| 22 import os | |
| 23 import stat | |
| 24 | |
| 25 Import('env') | |
| 26 | |
| 27 _repair_exe_obj_dir = '$OBJ_ROOT/recovery/repair_exe/' | |
| 28 | |
| 29 _custom_actions_path = ( | |
| 30 _repair_exe_obj_dir + 'custom_action/executecustomaction.dll') | |
| 31 _cert_file = env.File(GetOption('patching_certificate')).abspath | |
| 32 _required_file = '$MAIN_DIR/recovery/repair_exe/msp/requiredfile.txt' | |
| 33 | |
| 34 # TODO(omaha): Update the build machine command lines to use | |
| 35 # patching_certificate instead of authenticode_file and remove this. | |
| 36 # The following is for backwards compatibility. Historically, the build server, | |
| 37 # as specified the patching_certificate with --authenticode_file. | |
| 38 if (env.Bit('build_server') and | |
| 39 GetOption('patching_certificate') == '$MAIN_DIR/data/OmahaTestCert.cer'): | |
| 40 _cert_file = env.File(GetOption('authenticode_file')).abspath | |
| 41 | |
| 42 | |
| 43 omaha_version_info = env['omaha_versions_info'][0] | |
| 44 omaha_version_string = omaha_version_info.GetVersionString() | |
| 45 | |
| 46 old_unsigned_env = env.Clone() | |
| 47 old_unsigned_env.Append( | |
| 48 WIXCANDLEFLAGS = [ | |
| 49 '-dFinalMsi=0', | |
| 50 '-dCertificateFile=' + _cert_file, | |
| 51 '-dRequiredFile=' + env.File(_required_file).abspath, | |
| 52 '-dGoogleUpdateVersion=' + omaha_version_string, | |
| 53 ], | |
| 54 WIXLIGHTFLAGS = [ | |
| 55 '-dRequiredFile=' + env.File(_required_file).abspath, | |
| 56 ], | |
| 57 ) | |
| 58 | |
| 59 old_unsigned_output = old_unsigned_env.WiX('GoogleUpdateHelper_unsigned.msi', | |
| 60 'patchableinstaller.wxs') | |
| 61 | |
| 62 env.Depends(old_unsigned_output, [_custom_actions_path, _required_file]) | |
| 63 | |
| 64 | |
| 65 new_unsigned_env = env.Clone() | |
| 66 new_unsigned_env.Append( | |
| 67 WIXCANDLEFLAGS = [ | |
| 68 '-dFinalMsi=1', | |
| 69 '-dExecuteCustomActionDLL=' + env.File(_custom_actions_path).abspath, | |
| 70 '-dCertificateFile=' + _cert_file, | |
| 71 '-dRequiredFile=' + env.File(_required_file).abspath, | |
| 72 '-dGoogleUpdateVersion=' + omaha_version_string, | |
| 73 ], | |
| 74 WIXLIGHTFLAGS = [ | |
| 75 '-dRequiredFile=' + env.File(_required_file).abspath, | |
| 76 ], | |
| 77 ) | |
| 78 | |
| 79 # Output to a subdirectory to avoid build breaks caused by two different actions | |
| 80 # referencing files with the same name and path. | |
| 81 new_unsigned_env['WIXOBJPREFIX'] = new_unsigned_env['WIXOBJPREFIX'] + 'new/' | |
| 82 | |
| 83 new_unsigned_output = new_unsigned_env.WiX( | |
| 84 target='new/GoogleUpdateHelper_unsigned.msi', | |
| 85 source='patchableinstaller.wxs' | |
| 86 ) | |
| 87 | |
| 88 env.Depends(new_unsigned_output, [_custom_actions_path, _required_file]) | |
| 89 | |
| 90 | |
| 91 # | |
| 92 # Create the MSP file | |
| 93 # | |
| 94 msp_env = env.Clone() | |
| 95 | |
| 96 patch_output = msp_env.Command( | |
| 97 target='patch.wixobj', | |
| 98 source='patch.wxs', | |
| 99 action=('@candle.exe -nologo -out $TARGET $SOURCE -dAfterImage=%s' | |
| 100 ' -dBeforeImage=%s' % (env.File(new_unsigned_output[0]).abspath, | |
| 101 env.File(old_unsigned_output[0]).abspath)) | |
| 102 ) | |
| 103 | |
| 104 # Required because the before and after images are not in the source. | |
| 105 Depends(patch_output, [new_unsigned_output, old_unsigned_output]) | |
| 106 | |
| 107 pcp_output = msp_env.Command( | |
| 108 target='patch.pcp', | |
| 109 source=patch_output, | |
| 110 action='@light.exe -nologo -out $TARGET $SOURCE' | |
| 111 ) | |
| 112 | |
| 113 # The PCP, and thus the MSP, fail to rebuild when the MSI files change without | |
| 114 # this explicit dependency, probably because the .wixobj hash does not change. | |
| 115 Depends(pcp_output, [patch_output, old_unsigned_output, new_unsigned_output]) | |
| 116 | |
| 117 # Delete temp dir that vista sdk version of msimsp.exe cannot remove for itself. | |
| 118 _temp_dir = os.path.join(env['ENV']['TMP'], '~pcw_tmp.tmp') | |
| 119 if os.path.exists(_temp_dir): | |
| 120 # Recursively delete subdirectories | |
| 121 def rm_rf(dir): | |
| 122 for file in os.listdir(dir): | |
| 123 path = os.path.join(dir, file) | |
| 124 if os.path.isdir(path): | |
| 125 rm_rf(path) | |
| 126 else: | |
| 127 os.chmod(path, stat.S_IWRITE) # Make sure file is writeable. | |
| 128 os.remove(path) | |
| 129 os.rmdir(dir) | |
| 130 | |
| 131 # Remove the temp dir. | |
| 132 rm_rf(_temp_dir) | |
| 133 | |
| 134 unsigned_msp_name = 'GoogleUpdateHelperPatch_unsigned.msp' | |
| 135 unsigned_msp_path = _repair_exe_obj_dir + 'msp/' + unsigned_msp_name | |
| 136 | |
| 137 msp_output = msp_env.Command( | |
| 138 target=unsigned_msp_name, | |
| 139 source=pcp_output, | |
| 140 action='@msimsp.exe -s $SOURCE -p $TARGET -l %s' % ( | |
| 141 env.File(unsigned_msp_path + '.log').abspath), | |
| 142 ) | |
| 143 | |
| 144 # For unknown reasons, the PCP fails to rebuild and cause the MSP to rebuild | |
| 145 # when the MSI files change without this explicit dependency. | |
| 146 Depends(msp_output, pcp_output) | |
| 147 | |
| 148 | |
| 149 # | |
| 150 # Sign the old MSI and MSP | |
| 151 # | |
| 152 signed_msi = env.SignedBinary( | |
| 153 target='GoogleUpdateHelper.msi', | |
| 154 source=old_unsigned_output, | |
| 155 ) | |
| 156 | |
| 157 signed_msp = env.SignedBinary( | |
| 158 target='GoogleUpdateHelperPatch.msp', | |
| 159 source=msp_output, | |
| 160 ) | |
| 161 | |
| 162 env.Replicate('$STAGING_DIR', [signed_msi, signed_msp]) | |
| OLD | NEW |