| #!/usr/bin/python2.4 |
| # Copyright 2009 Google Inc. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| # ======================================================================== |
| |
| # Copies files from an official build directory (i.e on filer) to the checked |
| # in build directory. |
| # |
| # We use Hammer instead of a batch script, because we want to copy the same set |
| # of files used by the metainstaller, including all languages defined in |
| # main.scons and the same version of the OneClick DLL. |
| # |
| # To run this script, execute the following from the omaha\ directory: |
| # hammer --bin --official_build_path=<build_path> |
| # where <build_path> is the location of the official build output. For example: |
| # //filer/shares/googleclient/save/builds/Omaha/1.2.133.15 |
| |
| |
| Import('env') |
| |
| import os |
| |
| from installers import get_payload_files |
| from installers import update_version |
| |
| rel_dir = ('opt', 'dbg')[env.Bit('debug')] |
| |
| # Set the value of version_major, etc. in this file to the checked-in version. |
| execfile(env.File(os.path.join('$MAIN_DIR/bin', rel_dir, 'VERSION')).abspath) |
| |
| |
| def CopyFilesFromOfficialBuild(official_build_path): |
| update_version.UpdateSettingsExceptForCheckedInVersion(env, |
| oneclick_plugin_version) |
| |
| # Build the meta-installer for each version. |
| first = True |
| for _ in env['product_version']: |
| if first: |
| first = False |
| prefix = '' |
| else: |
| prefix = 'TEST_' |
| |
| mi_stub = '%smi_exe_stub.exe' % (prefix) |
| |
| files_to_copy = get_payload_files.GetListOfPayloadFiles( |
| prefix, |
| env['ACTIVEX_FILENAME'], |
| env['BHO_FILENAME'], |
| env['languages'], |
| env['product_version'][0]) |
| |
| files_to_copy += [ |
| mi_stub, |
| 'VERSION', |
| ] |
| |
| # Get absolute path to files to be replaced |
| bin_dir_abs = env.Dir('$MAIN_DIR/bin/' + rel_dir).abspath |
| |
| # Check if the files to be replaced are writable, and fail if they are not. |
| unwritable_files = [file for file in files_to_copy if not |
| os.access(os.path.join(bin_dir_abs, file), os.W_OK)] |
| |
| if len(unwritable_files) > 0: |
| UNWRITEABLE_ERROR = ( |
| '\nThe following files are not writable. Make sure you \'g4 edit\'\n' |
| 'all files in the <%s> dir:\n\t%s\n') % (bin_dir_abs, |
| '\n\t'.join(unwritable_files)) |
| raise Exception(UNWRITEABLE_ERROR) |
| |
| existing_files = os.listdir(bin_dir_abs) |
| |
| files_to_copy.sort() |
| existing_files.sort() |
| |
| has_different_files = False |
| if files_to_copy != existing_files: |
| has_different_files = True |
| print 'The set of files to copy is different from the existing files.' |
| |
| input_files = [os.path.join(official_build_path, rel_dir, file) |
| for file in files_to_copy] |
| |
| # Tell Hammer that, yes, we really do actually want to do what we're |
| # telling it do... by adding the target directory to the list of default |
| # targets. Otherwise, it will happily ignore the Replicate() command below. |
| Default(bin_dir_abs) |
| |
| # Do the actual copy |
| replicate_results = env.Replicate(bin_dir_abs, input_files) |
| |
| lines_to_echo = [ |
| '.', |
| ' Copied %s files.' % len(files_to_copy), |
| '.', |
| ' *************************************************************', |
| ' * ACTION REQUIRED * ACTION REQUIRED * ACTION REQUIRED *', |
| ' *', |
| ' * Assuming you checked out all files in "#/bin/", verify that', |
| ' * no files are reverted (because they are unchanged) when you', |
| ' * g4 mail or g4 submit the CL. This would probably indicate', |
| ' * that something is wrong, because all files should be', |
| ' * submitted together (or else g4 delete\'d). The only exception', |
| ' * is the shell (GoogleUpdate.exe), because it may not change', |
| ' * between builds.', |
| ' *', |
| ' * ACTION REQUIRED * ACTION REQUIRED * ACTION REQUIRED *', |
| ' *************************************************************', |
| '.', |
| ] |
| |
| if has_different_files: |
| lines_to_echo += [ |
| '.', |
| ' *************************************************************', |
| ' * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING *', |
| ' *', |
| ' * The filenames copied are different than the existing files.', |
| ' * You may need to g4 add or g4 delete files.', |
| ' *', |
| ' * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING *', |
| ' *************************************************************', |
| '.', |
| ] |
| |
| if not env.Bit('all'): |
| lines_to_echo += [ |
| '.', |
| ' WARNING: Did you remember to copy for all build modes (use "-a")?', |
| '.', |
| ] |
| |
| # Print out the messages, *only* after the files have |
| # been successfully copied. |
| env.Command( |
| # Need to have a dummy target here, and it has to be under |
| # $OBJ_ROOT, or Hammer will not execute the command. |
| target='$OBJ_ROOT/output', |
| # Need to pretend to be taking the result of the Replicate() command |
| # as a source, so Hammer knows what order to run the actions in. |
| source=replicate_results, |
| action='@echo%s' % '\n@echo'.join(lines_to_echo) |
| ) |
| |
| |
| OFFICIAL_ERROR_MESSAGE = """ |
| |
| **** ERROR ****** ERROR **** ERROR **** ERROR **** |
| Path to official build must be defined! |
| Specify "--official_build_path=..." in the Hammer args. |
| ************************************************** |
| |
| """ |
| |
| if env.Bit('bin'): |
| if GetOption('official_build_path') is None: |
| raise Exception(OFFICIAL_ERROR_MESSAGE) |
| else: |
| CopyFilesFromOfficialBuild(GetOption('official_build_path')) |