Chromium Code Reviews| 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 insert_before, ''.join(manifest_lines))) | 341 insert_before, ''.join(manifest_lines))) |
| 342 old = manifest_lines[insert_line] | 342 old = manifest_lines[insert_line] |
| 343 manifest_lines[insert_line] = (old[:insert_pos] + inserted_string + | 343 manifest_lines[insert_line] = (old[:insert_pos] + inserted_string + |
| 344 old[insert_pos:]) | 344 old[insert_pos:]) |
| 345 | 345 |
| 346 modified_manifest_file = open( | 346 modified_manifest_file = open( |
| 347 os.path.join(output_dir, manifest_name), 'w') | 347 os.path.join(output_dir, manifest_name), 'w') |
| 348 modified_manifest_file.write(''.join(manifest_lines)) | 348 modified_manifest_file.write(''.join(manifest_lines)) |
| 349 modified_manifest_file.close() | 349 modified_manifest_file.close() |
| 350 | 350 |
| 351 def AddVersionAssemblyManifest(staging_dir, current_version): | |
| 352 """Creates a manifest file, {current_version}.manifest, and places it in the | |
| 353 VersionDir, so that chrome.exe can find the chrome_elf dll. | |
| 354 """ | |
| 355 # Get the required directories for the upcoming operations. | |
| 356 chrome_dir = os.path.join(staging_dir, CHROME_DIR) | |
| 357 version_dir = os.path.join(chrome_dir, current_version) | |
| 358 | |
| 359 version_manifest = ( | |
| 360 "<assembly\n" | |
| 361 " xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>\n" | |
| 362 " <assemblyIdentity name='{version}' version='{version}'\n" | |
| 363 " type='win32'/>\n" | |
| 364 " <file name='chrome_elf.dll'/>\n" | |
| 365 "</assembly>".format(version=current_version)) | |
| 366 | |
| 367 manifest_name = "%s.manifest" % current_version | |
| 368 | |
| 369 with open(os.path.join(version_dir, manifest_name), 'w') as f: | |
|
gab
2013/11/05 16:43:20
I'm guessing this automatically closes |f| when it
grt (UTC plus 2)
2013/11/05 20:56:06
at the end of the scope opened by the "with", yes.
| |
| 370 f.write(version_manifest) | |
| 371 | |
| 351 | 372 |
| 352 def CopyIfChanged(src, target_dir): | 373 def CopyIfChanged(src, target_dir): |
| 353 """Copy specified |src| file to |target_dir|, but only write to target if | 374 """Copy specified |src| file to |target_dir|, but only write to target if |
| 354 the file has changed. This avoids a problem during packaging where parts of | 375 the file has changed. This avoids a problem during packaging where parts of |
| 355 the build have not completed and have the runtime DLL locked when we try to | 376 the build have not completed and have the runtime DLL locked when we try to |
| 356 copy over it. See http://crbug.com/305877 for details.""" | 377 copy over it. See http://crbug.com/305877 for details.""" |
| 357 assert os.path.isdir(target_dir) | 378 assert os.path.isdir(target_dir) |
| 358 dest = os.path.join(target_dir, os.path.basename(src)) | 379 dest = os.path.join(target_dir, os.path.basename(src)) |
| 359 if os.path.exists(dest): | 380 if os.path.exists(dest): |
| 360 # We assume the files are OK to buffer fully into memory since we know | 381 # We assume the files are OK to buffer fully into memory since we know |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 | 571 |
| 551 # Now copy the remainder of the files from the build dir. | 572 # Now copy the remainder of the files from the build dir. |
| 552 CopyAllFilesToStagingDir(config, options.distribution, | 573 CopyAllFilesToStagingDir(config, options.distribution, |
| 553 staging_dir, options.build_dir, | 574 staging_dir, options.build_dir, |
| 554 options.enable_hidpi, options.enable_touch_ui) | 575 options.enable_hidpi, options.enable_touch_ui) |
| 555 | 576 |
| 556 if options.component_build == '1': | 577 if options.component_build == '1': |
| 557 DoComponentBuildTasks(staging_dir, options.build_dir, | 578 DoComponentBuildTasks(staging_dir, options.build_dir, |
| 558 options.target_arch, current_version) | 579 options.target_arch, current_version) |
| 559 | 580 |
| 581 AddVersionAssemblyManifest(staging_dir, current_version) | |
| 582 | |
| 560 version_numbers = current_version.split('.') | 583 version_numbers = current_version.split('.') |
| 561 current_build_number = version_numbers[2] + '.' + version_numbers[3] | 584 current_build_number = version_numbers[2] + '.' + version_numbers[3] |
| 562 prev_build_number = '' | 585 prev_build_number = '' |
| 563 if prev_version: | 586 if prev_version: |
| 564 version_numbers = prev_version.split('.') | 587 version_numbers = prev_version.split('.') |
| 565 prev_build_number = version_numbers[2] + '.' + version_numbers[3] | 588 prev_build_number = version_numbers[2] + '.' + version_numbers[3] |
| 566 | 589 |
| 567 # Name of the archive file built (for example - chrome.7z or | 590 # Name of the archive file built (for example - chrome.7z or |
| 568 # patch-<old_version>-<new_version>.7z or patch-<new_version>.7z | 591 # patch-<old_version>-<new_version>.7z or patch-<new_version>.7z |
| 569 archive_file = CreateArchiveFile(options, staging_dir, | 592 archive_file = CreateArchiveFile(options, staging_dir, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 639 if not options.resource_file_path: | 662 if not options.resource_file_path: |
| 640 options.resource_file_path = os.path.join(options.build_dir, | 663 options.resource_file_path = os.path.join(options.build_dir, |
| 641 MINI_INSTALLER_INPUT_FILE) | 664 MINI_INSTALLER_INPUT_FILE) |
| 642 | 665 |
| 643 return options | 666 return options |
| 644 | 667 |
| 645 | 668 |
| 646 if '__main__' == __name__: | 669 if '__main__' == __name__: |
| 647 print sys.argv | 670 print sys.argv |
| 648 sys.exit(main(_ParseOptions())) | 671 sys.exit(main(_ParseOptions())) |
| OLD | NEW |