| 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 setup_file = SETUP_PATCH_FILE_PREFIX + '_' + current_version + \ | 318 setup_file = SETUP_PATCH_FILE_PREFIX + '_' + current_version + \ |
| 319 '_from_' + prev_version + COMPRESSED_FILE_EXT | 319 '_from_' + prev_version + COMPRESSED_FILE_EXT |
| 320 setup_file_path = os.path.join(options.build_dir, setup_file) | 320 setup_file_path = os.path.join(options.build_dir, setup_file) |
| 321 CompressUsingLZMA(options.build_dir, setup_file_path, patch_file, | 321 CompressUsingLZMA(options.build_dir, setup_file_path, patch_file, |
| 322 options.verbose) | 322 options.verbose) |
| 323 else: | 323 else: |
| 324 cmd = ['makecab.exe', | 324 cmd = ['makecab.exe', |
| 325 '/D', 'CompressionType=LZX', | 325 '/D', 'CompressionType=LZX', |
| 326 '/V1', | 326 '/V1', |
| 327 '/L', options.output_dir, | 327 '/L', options.output_dir, |
| 328 os.path.join(options.build_dir, SETUP_EXEC),] | 328 os.path.join(options.output_dir, SETUP_EXEC),] |
| 329 RunSystemCommand(cmd, options.verbose) | 329 RunSystemCommand(cmd, options.verbose) |
| 330 setup_file = SETUP_EXEC[:-1] + "_" | 330 setup_file = SETUP_EXEC[:-1] + "_" |
| 331 return setup_file | 331 return setup_file |
| 332 | 332 |
| 333 | 333 |
| 334 _RESOURCE_FILE_HEADER = """\ | 334 _RESOURCE_FILE_HEADER = """\ |
| 335 // This file is automatically generated by create_installer_archive.py. | 335 // This file is automatically generated by create_installer_archive.py. |
| 336 // It contains the resource entries that are going to be linked inside | 336 // It contains the resource entries that are going to be linked inside |
| 337 // mini_installer.exe. For each file to be linked there should be two | 337 // mini_installer.exe. For each file to be linked there should be two |
| 338 // lines: | 338 // lines: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 359 setup_resource_type = "B7" | 359 setup_resource_type = "B7" |
| 360 | 360 |
| 361 # An array of (file, type, path) tuples of the files to be included. | 361 # An array of (file, type, path) tuples of the files to be included. |
| 362 resources = [] | 362 resources = [] |
| 363 resources.append((setup_file, setup_resource_type, | 363 resources.append((setup_file, setup_resource_type, |
| 364 os.path.join(output_dir, setup_file))) | 364 os.path.join(output_dir, setup_file))) |
| 365 resources.append((archive_file, 'B7', | 365 resources.append((archive_file, 'B7', |
| 366 os.path.join(output_dir, archive_file))) | 366 os.path.join(output_dir, archive_file))) |
| 367 # Include all files needed to run setup.exe (these are copied into the | 367 # Include all files needed to run setup.exe (these are copied into the |
| 368 # 'Installer' dir by DoComponentBuildTasks). | 368 # 'Installer' dir by DoComponentBuildTasks). |
| 369 if component_build: | 369 installer_dir = os.path.join(staging_dir, CHROME_DIR, current_version, |
| 370 installer_dir = os.path.join(staging_dir, CHROME_DIR, current_version, | 370 'Installer') |
| 371 'Installer') | 371 for file in os.listdir(installer_dir): |
| 372 for file in os.listdir(installer_dir): | 372 resources.append((file, 'BN', os.path.join(installer_dir, file))) |
| 373 resources.append((file, 'BN', os.path.join(installer_dir, file))) | |
| 374 | 373 |
| 375 with open(resource_file_path, 'w') as f: | 374 with open(resource_file_path, 'w') as f: |
| 376 f.write(_RESOURCE_FILE_HEADER) | 375 f.write(_RESOURCE_FILE_HEADER) |
| 377 for (file, type, path) in resources: | 376 for (file, type, path) in resources: |
| 378 f.write('\n%s %s\n "%s"\n' % (file, type, path.replace("\\","/"))) | 377 f.write('\n%s %s\n "%s"\n' % (file, type, path.replace("\\","/"))) |
| 379 | 378 |
| 380 | 379 |
| 381 # Reads |manifest_name| from |build_dir| and writes |manifest_name| to | 380 # Reads |manifest_name| from |build_dir| and writes |manifest_name| to |
| 382 # |output_dir| with the same content plus |inserted_string| added just before | 381 # |output_dir| with the same content plus |inserted_string| added just before |
| 383 # |insert_before|. | 382 # |insert_before|. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 def ParseDLLsFromDeps(build_dir, runtime_deps_file): | 460 def ParseDLLsFromDeps(build_dir, runtime_deps_file): |
| 462 """Parses the runtime_deps file and returns the set of DLLs in it, relative | 461 """Parses the runtime_deps file and returns the set of DLLs in it, relative |
| 463 to build_dir.""" | 462 to build_dir.""" |
| 464 build_dlls = set() | 463 build_dlls = set() |
| 465 args = open(runtime_deps_file).read() | 464 args = open(runtime_deps_file).read() |
| 466 for l in args.splitlines(): | 465 for l in args.splitlines(): |
| 467 if os.path.splitext(l)[1] == ".dll": | 466 if os.path.splitext(l)[1] == ".dll": |
| 468 build_dlls.add(os.path.join(build_dir, l)) | 467 build_dlls.add(os.path.join(build_dir, l)) |
| 469 return build_dlls | 468 return build_dlls |
| 470 | 469 |
| 470 |
| 471 def CopySetupRuntimeDeps(build_dir, setup_runtime_deps, version_dir): |
| 472 """Copy the setup.exe runtime dependencies to the installer's directory.""" |
| 473 installer_dir = os.path.join(version_dir, 'Installer') |
| 474 # |installer_dir| is technically only created post-install, but we need it |
| 475 # now to add setup.exe's config and manifest to the archive. |
| 476 if not os.path.exists(installer_dir): |
| 477 os.mkdir(installer_dir) |
| 478 |
| 479 setup_component_dlls = ParseDLLsFromDeps(build_dir, setup_runtime_deps) |
| 480 for setup_component_dll in setup_component_dlls: |
| 481 g_archive_inputs.append(setup_component_dll) |
| 482 shutil.copy(setup_component_dll, installer_dir) |
| 483 |
| 484 |
| 471 # Copies component build DLLs and generates required config files and manifests | 485 # Copies component build DLLs and generates required config files and manifests |
| 472 # in order for chrome.exe and setup.exe to be able to find those DLLs at | 486 # in order for chrome.exe and setup.exe to be able to find those DLLs at |
| 473 # run-time. | 487 # run-time. |
| 474 # This is meant for developer builds only and should never be used to package | 488 # This is meant for developer builds only and should never be used to package |
| 475 # an official build. | 489 # an official build. |
| 476 def DoComponentBuildTasks(staging_dir, build_dir, target_arch, | 490 def DoComponentBuildTasks(staging_dir, build_dir, target_arch, |
| 477 setup_runtime_deps, chrome_runtime_deps, | 491 setup_runtime_deps, chrome_runtime_deps, |
| 478 current_version): | 492 current_version): |
| 479 # Get the required directories for the upcoming operations. | 493 # Get the required directories for the upcoming operations. |
| 480 chrome_dir = os.path.join(staging_dir, CHROME_DIR) | 494 chrome_dir = os.path.join(staging_dir, CHROME_DIR) |
| 481 version_dir = os.path.join(chrome_dir, current_version) | 495 version_dir = os.path.join(chrome_dir, current_version) |
| 482 installer_dir = os.path.join(version_dir, 'Installer') | |
| 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. | |
| 485 if not os.path.exists(installer_dir): | |
| 486 os.mkdir(installer_dir) | |
| 487 | 496 |
| 488 setup_component_dlls = ParseDLLsFromDeps(build_dir, setup_runtime_deps) | 497 CopySetupRuntimeDeps(build_dir, setup_runtime_deps, version_dir) |
| 489 | |
| 490 for setup_component_dll in setup_component_dlls: | |
| 491 g_archive_inputs.append(setup_component_dll) | |
| 492 shutil.copy(setup_component_dll, installer_dir) | |
| 493 | 498 |
| 494 # Stage all the component DLLs to the |version_dir| (for | 499 # Stage all the component DLLs to the |version_dir| (for |
| 495 # the version assembly to be able to refer to them below and make sure | 500 # the version assembly to be able to refer to them below and make sure |
| 496 # chrome.exe can find them at runtime), except the ones that are already | 501 # chrome.exe can find them at runtime), except the ones that are already |
| 497 # staged (i.e. non-component DLLs). | 502 # staged (i.e. non-component DLLs). |
| 498 build_dlls = ParseDLLsFromDeps(build_dir, chrome_runtime_deps) | 503 build_dlls = ParseDLLsFromDeps(build_dir, chrome_runtime_deps) |
| 499 staged_dll_basenames = [os.path.basename(staged_dll) for staged_dll in \ | 504 staged_dll_basenames = [os.path.basename(staged_dll) for staged_dll in \ |
| 500 glob.glob(os.path.join(version_dir, '*.dll'))] | 505 glob.glob(os.path.join(version_dir, '*.dll'))] |
| 501 component_dll_filenames = [] | 506 component_dll_filenames = [] |
| 502 for component_dll in [dll for dll in build_dlls if \ | 507 for component_dll in [dll for dll in build_dlls if \ |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 | 547 |
| 543 # Now copy the remainder of the files from the build dir. | 548 # Now copy the remainder of the files from the build dir. |
| 544 CopyAllFilesToStagingDir(config, options.distribution, | 549 CopyAllFilesToStagingDir(config, options.distribution, |
| 545 staging_dir, options.build_dir, | 550 staging_dir, options.build_dir, |
| 546 options.enable_hidpi) | 551 options.enable_hidpi) |
| 547 | 552 |
| 548 if options.component_build == '1': | 553 if options.component_build == '1': |
| 549 DoComponentBuildTasks(staging_dir, options.build_dir, | 554 DoComponentBuildTasks(staging_dir, options.build_dir, |
| 550 options.target_arch, options.setup_runtime_deps, | 555 options.target_arch, options.setup_runtime_deps, |
| 551 options.chrome_runtime_deps, current_version) | 556 options.chrome_runtime_deps, current_version) |
| 557 elif options.setup_runtime_deps: |
| 558 CopySetupRuntimeDeps(options.build_dir, options.setup_runtime_deps, |
| 559 os.path.join(staging_dir, CHROME_DIR, current_version)) |
| 552 | 560 |
| 553 version_numbers = current_version.split('.') | 561 version_numbers = current_version.split('.') |
| 554 current_build_number = version_numbers[2] + '.' + version_numbers[3] | 562 current_build_number = version_numbers[2] + '.' + version_numbers[3] |
| 555 prev_build_number = '' | 563 prev_build_number = '' |
| 556 if prev_version: | 564 if prev_version: |
| 557 version_numbers = prev_version.split('.') | 565 version_numbers = prev_version.split('.') |
| 558 prev_build_number = version_numbers[2] + '.' + version_numbers[3] | 566 prev_build_number = version_numbers[2] + '.' + version_numbers[3] |
| 559 | 567 |
| 560 # Name of the archive file built (for example - chrome.7z or | 568 # Name of the archive file built (for example - chrome.7z or |
| 561 # patch-<old_version>-<new_version>.7z or patch-<new_version>.7z | 569 # patch-<old_version>-<new_version>.7z or patch-<new_version>.7z |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 MINI_INSTALLER_INPUT_FILE) | 658 MINI_INSTALLER_INPUT_FILE) |
| 651 | 659 |
| 652 return options | 660 return options |
| 653 | 661 |
| 654 | 662 |
| 655 if '__main__' == __name__: | 663 if '__main__' == __name__: |
| 656 options = _ParseOptions() | 664 options = _ParseOptions() |
| 657 if options.verbose: | 665 if options.verbose: |
| 658 print sys.argv | 666 print sys.argv |
| 659 sys.exit(main(options)) | 667 sys.exit(main(options)) |
| OLD | NEW |