OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Script to create Chrome Installer archive. | 6 """Script to create Chrome Installer archive. |
7 | 7 |
8 This script is used to create an archive of all the files required for a | 8 This script is used to create an archive of all the files required for a |
9 Chrome install in appropriate directory structure. It reads chrome.release | 9 Chrome install in appropriate directory structure. It reads chrome.release |
10 file as input, creates chrome.7z archive, compresses setup.exe and | 10 file as input, creates chrome.7z archive, compresses setup.exe and |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 else: | 242 else: |
243 raise Exception('Did not find an archive input file for "%s"' % | 243 raise Exception('Did not find an archive input file for "%s"' % |
244 staging_file) | 244 staging_file) |
245 | 245 |
246 # Finally, write the depfile referencing the inputs. | 246 # Finally, write the depfile referencing the inputs. |
247 with open(options.depfile, 'wb') as f: | 247 with open(options.depfile, 'wb') as f: |
248 f.write(path_fixup(os.path.relpath(archive_file, options.build_dir)) + | 248 f.write(path_fixup(os.path.relpath(archive_file, options.build_dir)) + |
249 ': \\\n') | 249 ': \\\n') |
250 f.write(' ' + ' \\\n '.join(path_fixup(x) for x in g_archive_inputs)) | 250 f.write(' ' + ' \\\n '.join(path_fixup(x) for x in g_archive_inputs)) |
251 | 251 |
| 252 # It is important to use abspath to create the path to the directory because |
| 253 # if you use a relative path without any .. sequences then 7za.exe uses the |
| 254 # entire relative path as part of the file paths in the archive. If you have |
| 255 # a .. sequence or an absolute path then only the last directory is stored as |
| 256 # part of the file paths in the archive, which is what we want. |
252 cmd = [lzma_exec, | 257 cmd = [lzma_exec, |
253 'a', | 258 'a', |
254 '-t7z', | 259 '-t7z', |
255 archive_file, | 260 archive_file, |
256 os.path.join(staging_dir, CHROME_DIR), | 261 os.path.abspath(os.path.join(staging_dir, CHROME_DIR)), |
257 '-mx0',] | 262 '-mx0',] |
258 # There doesnt seem to be any way in 7za.exe to override existing file so | 263 # There doesnt seem to be any way in 7za.exe to override existing file so |
259 # we always delete before creating a new one. | 264 # we always delete before creating a new one. |
260 if not os.path.exists(archive_file): | 265 if not os.path.exists(archive_file): |
261 RunSystemCommand(cmd, options.verbose) | 266 RunSystemCommand(cmd, options.verbose) |
262 elif options.skip_rebuild_archive != "true": | 267 elif options.skip_rebuild_archive != "true": |
263 os.remove(archive_file) | 268 os.remove(archive_file) |
264 RunSystemCommand(cmd, options.verbose) | 269 RunSystemCommand(cmd, options.verbose) |
265 | 270 |
266 # Do not compress the archive in developer (component) builds. | 271 # Do not compress the archive in developer (component) builds. |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 version_assembly_dll_additions = [] | 600 version_assembly_dll_additions = [] |
596 for dll_filename in component_dll_filenames: | 601 for dll_filename in component_dll_filenames: |
597 version_assembly_dll_additions.append(" <file name='%s'/>" % dll_filename) | 602 version_assembly_dll_additions.append(" <file name='%s'/>" % dll_filename) |
598 CopyAndAugmentManifest(build_dir, version_dir, | 603 CopyAndAugmentManifest(build_dir, version_dir, |
599 '%s.manifest' % current_version, | 604 '%s.manifest' % current_version, |
600 '\n'.join(version_assembly_dll_additions), | 605 '\n'.join(version_assembly_dll_additions), |
601 '</assembly>') | 606 '</assembly>') |
602 | 607 |
603 | 608 |
604 def main(options): | 609 def main(options): |
605 """Main method that reads input file, creates archive file and write | 610 """Main method that reads input file, creates archive file and writes |
606 resource input file. | 611 resource input file. |
607 """ | 612 """ |
608 current_version = BuildVersion(options.build_dir) | 613 current_version = BuildVersion(options.build_dir) |
609 | 614 |
610 config = Readconfig(options.input_file, current_version) | 615 config = Readconfig(options.input_file, current_version) |
611 | 616 |
612 (staging_dir, temp_dir) = MakeStagingDirectories(options.staging_dir) | 617 (staging_dir, temp_dir) = MakeStagingDirectories(options.staging_dir) |
613 | 618 |
614 prev_version = GetPrevVersion(options.build_dir, temp_dir, | 619 prev_version = GetPrevVersion(options.build_dir, temp_dir, |
615 options.last_chrome_installer, | 620 options.last_chrome_installer, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 MINI_INSTALLER_INPUT_FILE) | 725 MINI_INSTALLER_INPUT_FILE) |
721 | 726 |
722 return options | 727 return options |
723 | 728 |
724 | 729 |
725 if '__main__' == __name__: | 730 if '__main__' == __name__: |
726 options = _ParseOptions() | 731 options = _ParseOptions() |
727 if options.verbose: | 732 if options.verbose: |
728 print sys.argv | 733 print sys.argv |
729 sys.exit(main(options)) | 734 sys.exit(main(options)) |
OLD | NEW |