| 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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 current_version): | 478 current_version): |
| 479 # Get the required directories for the upcoming operations. | 479 # Get the required directories for the upcoming operations. |
| 480 chrome_dir = os.path.join(staging_dir, CHROME_DIR) | 480 chrome_dir = os.path.join(staging_dir, CHROME_DIR) |
| 481 version_dir = os.path.join(chrome_dir, current_version) | 481 version_dir = os.path.join(chrome_dir, current_version) |
| 482 installer_dir = os.path.join(version_dir, 'Installer') | 482 installer_dir = os.path.join(version_dir, 'Installer') |
| 483 # |installer_dir| is technically only created post-install, but we need it | 483 # |installer_dir| is technically only created post-install, but we need it |
| 484 # now to add setup.exe's config and manifest to the archive. | 484 # now to add setup.exe's config and manifest to the archive. |
| 485 if not os.path.exists(installer_dir): | 485 if not os.path.exists(installer_dir): |
| 486 os.mkdir(installer_dir) | 486 os.mkdir(installer_dir) |
| 487 | 487 |
| 488 if setup_runtime_deps: | 488 setup_component_dlls = ParseDLLsFromDeps(build_dir, setup_runtime_deps) |
| 489 setup_component_dlls = ParseDLLsFromDeps(build_dir, setup_runtime_deps) | 489 |
| 490 else: | |
| 491 # Explicitly list the component DLLs setup.exe depends on (this list may | |
| 492 # contain wildcards). These will be copied to |installer_dir| in the | |
| 493 # archive. | |
| 494 # TODO(jbauman): Remove when GYP is deprecated on Windows. | |
| 495 setup_component_dll_globs = [ 'api-ms-win-*.dll', | |
| 496 'base.dll', | |
| 497 'boringssl.dll', | |
| 498 'crcrypto.dll', | |
| 499 'icui18n.dll', | |
| 500 'icuuc.dll', | |
| 501 'msvc*.dll', | |
| 502 'ucrtbase*.dll', | |
| 503 'vcruntime*.dll', ] | |
| 504 setup_component_dlls = set() | |
| 505 for setup_component_dll_glob in setup_component_dll_globs: | |
| 506 setup_component_partial_dlls = glob.glob( | |
| 507 os.path.join(build_dir, setup_component_dll_glob)) | |
| 508 if len(setup_component_partial_dlls) == 0: | |
| 509 raise Exception('Error: missing expected DLL for component build ' | |
| 510 'mini_installer: "%s"' % setup_component_dll_glob) | |
| 511 setup_component_dlls.update(setup_component_partial_dlls) | |
| 512 for setup_component_dll in setup_component_dlls: | 490 for setup_component_dll in setup_component_dlls: |
| 513 g_archive_inputs.append(setup_component_dll) | 491 g_archive_inputs.append(setup_component_dll) |
| 514 shutil.copy(setup_component_dll, installer_dir) | 492 shutil.copy(setup_component_dll, installer_dir) |
| 515 | 493 |
| 516 # Stage all the component DLLs to the |version_dir| (for | 494 # Stage all the component DLLs to the |version_dir| (for |
| 517 # the version assembly to be able to refer to them below and make sure | 495 # the version assembly to be able to refer to them below and make sure |
| 518 # chrome.exe can find them at runtime), except the ones that are already | 496 # chrome.exe can find them at runtime), except the ones that are already |
| 519 # staged (i.e. non-component DLLs). | 497 # staged (i.e. non-component DLLs). |
| 520 if chrome_runtime_deps: | 498 build_dlls = ParseDLLsFromDeps(build_dir, chrome_runtime_deps) |
| 521 build_dlls = ParseDLLsFromDeps(build_dir, chrome_runtime_deps) | |
| 522 else: | |
| 523 # If no chrome_runtime_deps was specified, every DLL in build_dir is | |
| 524 # considered to be a component DLL. | |
| 525 # TODO(jbauman): Remove when GYP is deprecated on Windows. | |
| 526 build_dlls = glob.glob(os.path.join(build_dir, '*.dll')) | |
| 527 staged_dll_basenames = [os.path.basename(staged_dll) for staged_dll in \ | 499 staged_dll_basenames = [os.path.basename(staged_dll) for staged_dll in \ |
| 528 glob.glob(os.path.join(version_dir, '*.dll'))] | 500 glob.glob(os.path.join(version_dir, '*.dll'))] |
| 529 component_dll_filenames = [] | 501 component_dll_filenames = [] |
| 530 for component_dll in [dll for dll in build_dlls if \ | 502 for component_dll in [dll for dll in build_dlls if \ |
| 531 os.path.basename(dll) not in staged_dll_basenames]: | 503 os.path.basename(dll) not in staged_dll_basenames]: |
| 532 component_dll_name = os.path.basename(component_dll) | 504 component_dll_name = os.path.basename(component_dll) |
| 533 # These remoting_*.dll's don't belong in the archive (it doesn't depend | |
| 534 # on them in gyp). Trying to copy them causes a build race when creating the | |
| 535 # installer archive in component mode. See: crbug.com/180996 and | |
| 536 # crbug.com/586967 | |
| 537 if (component_dll_name.startswith('remoting_')): | |
| 538 continue | |
| 539 | |
| 540 component_dll_filenames.append(component_dll_name) | 505 component_dll_filenames.append(component_dll_name) |
| 541 g_archive_inputs.append(component_dll) | 506 g_archive_inputs.append(component_dll) |
| 542 shutil.copy(component_dll, version_dir) | 507 shutil.copy(component_dll, version_dir) |
| 543 | 508 |
| 544 # Augment {version}.manifest to include all component DLLs as part of the | 509 # Augment {version}.manifest to include all component DLLs as part of the |
| 545 # assembly it constitutes, which will allow dependents of this assembly to | 510 # assembly it constitutes, which will allow dependents of this assembly to |
| 546 # find these DLLs. | 511 # find these DLLs. |
| 547 version_assembly_dll_additions = [] | 512 version_assembly_dll_additions = [] |
| 548 for dll_filename in component_dll_filenames: | 513 for dll_filename in component_dll_filenames: |
| 549 version_assembly_dll_additions.append(" <file name='%s'/>" % dll_filename) | 514 version_assembly_dll_additions.append(" <file name='%s'/>" % dll_filename) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 help='Name used to prefix names of generated archives.') | 604 help='Name used to prefix names of generated archives.') |
| 640 parser.add_option('--enable_hidpi', default='0', | 605 parser.add_option('--enable_hidpi', default='0', |
| 641 help='Whether to include HiDPI resource files.') | 606 help='Whether to include HiDPI resource files.') |
| 642 parser.add_option('--component_build', default='0', | 607 parser.add_option('--component_build', default='0', |
| 643 help='Whether this archive is packaging a component build. This will ' | 608 help='Whether this archive is packaging a component build. This will ' |
| 644 'also turn off compression of chrome.7z into chrome.packed.7z and ' | 609 'also turn off compression of chrome.7z into chrome.packed.7z and ' |
| 645 'helpfully delete any old chrome.packed.7z in |output_dir|.') | 610 'helpfully delete any old chrome.packed.7z in |output_dir|.') |
| 646 parser.add_option('--depfile', | 611 parser.add_option('--depfile', |
| 647 help='Generate a depfile with the given name listing the implicit inputs ' | 612 help='Generate a depfile with the given name listing the implicit inputs ' |
| 648 'to the archive process that can be used with a build system.') | 613 'to the archive process that can be used with a build system.') |
| 649 | |
| 650 # TODO(jbauman): Make --chrome_runtime_deps and --setup_runtime_deps | |
| 651 # mandatory when GYP is deprecated on Windows. | |
| 652 parser.add_option('--chrome_runtime_deps', | 614 parser.add_option('--chrome_runtime_deps', |
| 653 help='A file listing runtime dependencies. This will be used to get a ' | 615 help='A file listing runtime dependencies. This will be used to get a ' |
| 654 'list of DLLs to archive in a component build.') | 616 'list of DLLs to archive in a component build.') |
| 655 parser.add_option('--setup_runtime_deps', | 617 parser.add_option('--setup_runtime_deps', |
| 656 help='A file listing runtime dependencies for setup.exe. This will be ' | 618 help='A file listing runtime dependencies for setup.exe. This will be ' |
| 657 'used to get a list of DLLs to archive in a component build.') | 619 'used to get a list of DLLs to archive in a component build.') |
| 658 parser.add_option('--target_arch', default='x86', | 620 parser.add_option('--target_arch', default='x86', |
| 659 help='Specify the target architecture for installer - this is used ' | 621 help='Specify the target architecture for installer - this is used ' |
| 660 'to determine which CRT runtime files to pull and package ' | 622 'to determine which CRT runtime files to pull and package ' |
| 661 'with the installer archive {x86|x64}.') | 623 'with the installer archive {x86|x64}.') |
| 662 parser.add_option('-v', '--verbose', action='store_true', dest='verbose', | 624 parser.add_option('-v', '--verbose', action='store_true', dest='verbose', |
| 663 default=False) | 625 default=False) |
| 664 | 626 |
| 665 options, _ = parser.parse_args() | 627 options, _ = parser.parse_args() |
| 666 if not options.build_dir: | 628 if not options.build_dir: |
| 667 parser.error('You must provide a build dir.') | 629 parser.error('You must provide a build dir.') |
| 668 | 630 |
| 669 options.build_dir = os.path.normpath(options.build_dir) | 631 options.build_dir = os.path.normpath(options.build_dir) |
| 670 | 632 |
| 671 if not options.staging_dir: | 633 if not options.staging_dir: |
| 672 parser.error('You must provide a staging dir.') | 634 parser.error('You must provide a staging dir.') |
| 673 | 635 |
| 674 if not options.input_file: | 636 if not options.input_file: |
| 675 parser.error('You must provide an input file') | 637 parser.error('You must provide an input file') |
| 676 | 638 |
| 639 is_component_build = options.component_build == '1' |
| 640 if is_component_build and not options.chrome_runtime_deps: |
| 641 parser.error("chrome_runtime_deps must be specified for a component build") |
| 642 if is_component_build and not options.setup_runtime_deps: |
| 643 parser.error("setup_runtime_deps must be specified for a component build") |
| 644 |
| 677 if not options.output_dir: | 645 if not options.output_dir: |
| 678 options.output_dir = options.build_dir | 646 options.output_dir = options.build_dir |
| 679 | 647 |
| 680 if not options.resource_file_path: | 648 if not options.resource_file_path: |
| 681 options.resource_file_path = os.path.join(options.build_dir, | 649 options.resource_file_path = os.path.join(options.build_dir, |
| 682 MINI_INSTALLER_INPUT_FILE) | 650 MINI_INSTALLER_INPUT_FILE) |
| 683 | 651 |
| 684 return options | 652 return options |
| 685 | 653 |
| 686 | 654 |
| 687 if '__main__' == __name__: | 655 if '__main__' == __name__: |
| 688 options = _ParseOptions() | 656 options = _ParseOptions() |
| 689 if options.verbose: | 657 if options.verbose: |
| 690 print sys.argv | 658 print sys.argv |
| 691 sys.exit(main(options)) | 659 sys.exit(main(options)) |
| OLD | NEW |