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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 | 351 |
| 352 # Copy the relevant CRT DLLs to |build_dir|. We copy DLLs from all versions | 352 # Copy the relevant CRT DLLs to |build_dir|. We copy DLLs from all versions |
| 353 # of VS installed to make sure we have the correct CRT version, unused DLLs | 353 # of VS installed to make sure we have the correct CRT version, unused DLLs |
| 354 # should not conflict with the others anyways. | 354 # should not conflict with the others anyways. |
| 355 def CopyVisualStudioRuntimeDLLs(build_dir): | 355 def CopyVisualStudioRuntimeDLLs(build_dir, target_arch): |
| 356 is_debug = os.path.basename(build_dir) == 'Debug' | 356 is_debug = os.path.basename(build_dir).startswith('Debug') |
| 357 if not is_debug and os.path.basename(build_dir) != 'Release': | 357 if not is_debug and not os.path.basename(build_dir).startswith('Release'): |
| 358 print ("Warning: could not determine build configuration from " | 358 print ("Warning: could not determine build configuration from " |
| 359 "output directory, assuming Release build.") | 359 "output directory, assuming Release build.") |
| 360 | 360 |
| 361 crt_dlls = [] | 361 crt_dlls = [] |
| 362 if is_debug: | 362 if is_debug: |
| 363 crt_dlls = glob.glob( | 363 crt_dlls = glob.glob( |
| 364 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" | 364 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" |
| 365 "Debug_NonRedist/x86/Microsoft.*.DebugCRT/*.dll") | 365 "Debug_NonRedist/" + target_arch + "/Microsoft.*.DebugCRT/*.dll") |
| 366 else: | 366 else: |
| 367 crt_dlls = glob.glob( | 367 crt_dlls = glob.glob( |
| 368 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/x86/" | 368 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" + |
| 369 "Microsoft.*.CRT/*.dll") | 369 target_arch + "/Microsoft.*.CRT/*.dll") |
| 370 | 370 |
| 371 # Also handle the case where someone is building using only winsdk and | 371 # Also handle the case where someone is building using only winsdk and |
| 372 # doesn't have Visual Studio installed. | 372 # doesn't have Visual Studio installed. |
| 373 if not crt_dlls: | 373 if not crt_dlls: |
| 374 # On a 64-bit system, 32-bit dlls are in SysWOW64 (don't ask). | 374 if target_arch == 'x64': |
| 375 if os.access("C:/Windows/SysWOW64", os.F_OK): | 375 # check we are are on a 64bit system by existence of WOW64 dir |
| 376 sys_dll_dir = "C:/Windows/SysWOW64" | 376 if os.access("C:/Windows/SysWOW64", os.F_OK): |
| 377 sys_dll_dir = "C:/Windows/System32" | |
| 378 else: | |
| 379 # only support packaging of 64bit installer on 64bit system | |
| 380 # but this just as bad as not finding DLLs at all so we | |
| 381 # don't abort here to mirror behavior below | |
| 382 print ("Warning: could not find x64 CRT DLLs on x86 system.") | |
|
robertshield
2013/02/27 01:23:09
come to think of it, won't this raise a symbol not
Will Harris
2013/02/27 01:39:00
Done.
| |
| 377 else: | 383 else: |
| 378 sys_dll_dir = "C:/Windows/System32" | 384 # On a 64-bit system, 32-bit dlls are in SysWOW64 (don't ask). |
| 385 if os.access("C:/Windows/SysWOW64", os.F_OK): | |
| 386 sys_dll_dir = "C:/Windows/SysWOW64" | |
| 387 else: | |
| 388 sys_dll_dir = "C:/Windows/System32" | |
| 379 | 389 |
| 380 if is_debug: | 390 if is_debug: |
| 381 crt_dlls = glob.glob(os.path.join(sys_dll_dir, "msvc*0d.dll")) | 391 crt_dlls = glob.glob(os.path.join(sys_dll_dir, "msvc*0d.dll")) |
| 382 else: | 392 else: |
| 383 crt_dlls = glob.glob(os.path.join(sys_dll_dir, "msvc*0.dll")) | 393 crt_dlls = glob.glob(os.path.join(sys_dll_dir, "msvc*0.dll")) |
| 384 | 394 |
| 385 if not crt_dlls: | 395 if not crt_dlls: |
| 386 print ("Warning: could not find CRT DLLs to copy to build dir - target " | 396 print ("Warning: could not find CRT DLLs to copy to build dir - target " |
| 387 "may not run on a system that doesn't have those DLLs.") | 397 "may not run on a system that doesn't have those DLLs.") |
| 388 | 398 |
| 389 for dll in crt_dlls: | 399 for dll in crt_dlls: |
| 390 shutil.copy(dll, build_dir) | 400 shutil.copy(dll, build_dir) |
| 391 | 401 |
| 392 | 402 |
| 393 # Copies component build DLLs and generates required config files and manifests | 403 # Copies component build DLLs and generates required config files and manifests |
| 394 # in order for chrome.exe and setup.exe to be able to find those DLLs at | 404 # in order for chrome.exe and setup.exe to be able to find those DLLs at |
| 395 # run-time. | 405 # run-time. |
| 396 # This is meant for developer builds only and should never be used to package | 406 # This is meant for developer builds only and should never be used to package |
| 397 # an official build. | 407 # an official build. |
| 398 def DoComponentBuildTasks(staging_dir, build_dir, current_version): | 408 def DoComponentBuildTasks(staging_dir, build_dir, target_arch, current_version): |
| 399 # Get the required directories for the upcoming operations. | 409 # Get the required directories for the upcoming operations. |
| 400 chrome_dir = os.path.join(staging_dir, CHROME_DIR) | 410 chrome_dir = os.path.join(staging_dir, CHROME_DIR) |
| 401 version_dir = os.path.join(chrome_dir, current_version) | 411 version_dir = os.path.join(chrome_dir, current_version) |
| 402 installer_dir = os.path.join(version_dir, 'Installer') | 412 installer_dir = os.path.join(version_dir, 'Installer') |
| 403 # |installer_dir| is technically only created post-install, but we need it | 413 # |installer_dir| is technically only created post-install, but we need it |
| 404 # now to add setup.exe's config and manifest to the archive. | 414 # now to add setup.exe's config and manifest to the archive. |
| 405 if not os.path.exists(installer_dir): | 415 if not os.path.exists(installer_dir): |
| 406 os.mkdir(installer_dir) | 416 os.mkdir(installer_dir) |
| 407 | 417 |
| 408 # Copy the VS CRT DLLs to |build_dir|. This must be done before the general | 418 # Copy the VS CRT DLLs to |build_dir|. This must be done before the general |
| 409 # copy step below to ensure the CRT DLLs are added to the archive and marked | 419 # copy step below to ensure the CRT DLLs are added to the archive and marked |
| 410 # as a dependency in the exe manifests generated below. | 420 # as a dependency in the exe manifests generated below. |
| 411 CopyVisualStudioRuntimeDLLs(build_dir) | 421 CopyVisualStudioRuntimeDLLs(build_dir, target_arch) |
| 412 | 422 |
| 413 # Copy all the DLLs in |build_dir| to the version directory. Simultaneously | 423 # Copy all the DLLs in |build_dir| to the version directory. Simultaneously |
| 414 # build a list of their names to mark them as dependencies of chrome.exe and | 424 # build a list of their names to mark them as dependencies of chrome.exe and |
| 415 # setup.exe later. | 425 # setup.exe later. |
| 416 dlls = glob.glob(os.path.join(build_dir, '*.dll')) | 426 dlls = glob.glob(os.path.join(build_dir, '*.dll')) |
| 417 dll_names = [] | 427 dll_names = [] |
| 418 for dll in dlls: | 428 for dll in dlls: |
| 419 shutil.copy(dll, version_dir) | 429 shutil.copy(dll, version_dir) |
| 420 dll_names.append(os.path.splitext(os.path.basename(dll))[0]) | 430 dll_names.append(os.path.splitext(os.path.basename(dll))[0]) |
| 421 | 431 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 507 CopyAllFilesToStagingDir(config, options.distribution, | 517 CopyAllFilesToStagingDir(config, options.distribution, |
| 508 staging_dir, options.output_dir, | 518 staging_dir, options.output_dir, |
| 509 options.enable_hidpi, options.enable_touch_ui) | 519 options.enable_hidpi, options.enable_touch_ui) |
| 510 | 520 |
| 511 # Now copy the remainder of the files from the build dir. | 521 # Now copy the remainder of the files from the build dir. |
| 512 CopyAllFilesToStagingDir(config, options.distribution, | 522 CopyAllFilesToStagingDir(config, options.distribution, |
| 513 staging_dir, options.build_dir, | 523 staging_dir, options.build_dir, |
| 514 options.enable_hidpi, options.enable_touch_ui) | 524 options.enable_hidpi, options.enable_touch_ui) |
| 515 | 525 |
| 516 if options.component_build == '1': | 526 if options.component_build == '1': |
| 517 DoComponentBuildTasks(staging_dir, options.build_dir, current_version) | 527 DoComponentBuildTasks(staging_dir, options.build_dir, |
| 528 options.target_arch, current_version) | |
| 518 | 529 |
| 519 version_numbers = current_version.split('.') | 530 version_numbers = current_version.split('.') |
| 520 current_build_number = version_numbers[2] + '.' + version_numbers[3] | 531 current_build_number = version_numbers[2] + '.' + version_numbers[3] |
| 521 prev_build_number = '' | 532 prev_build_number = '' |
| 522 if prev_version: | 533 if prev_version: |
| 523 version_numbers = prev_version.split('.') | 534 version_numbers = prev_version.split('.') |
| 524 prev_build_number = version_numbers[2] + '.' + version_numbers[3] | 535 prev_build_number = version_numbers[2] + '.' + version_numbers[3] |
| 525 | 536 |
| 526 # Name of the archive file built (for example - chrome.7z or | 537 # Name of the archive file built (for example - chrome.7z or |
| 527 # patch-<old_version>-<new_version>.7z or patch-<new_version>.7z | 538 # patch-<old_version>-<new_version>.7z or patch-<new_version>.7z |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 568 help='Name used to prefix names of generated archives.') | 579 help='Name used to prefix names of generated archives.') |
| 569 parser.add_option('--enable_hidpi', default='0', | 580 parser.add_option('--enable_hidpi', default='0', |
| 570 help='Whether to include HiDPI resource files.') | 581 help='Whether to include HiDPI resource files.') |
| 571 parser.add_option('--enable_touch_ui', default='0', | 582 parser.add_option('--enable_touch_ui', default='0', |
| 572 help='Whether to include resource files from the "TOUCH" section of the ' | 583 help='Whether to include resource files from the "TOUCH" section of the ' |
| 573 'input file.') | 584 'input file.') |
| 574 parser.add_option('--component_build', default='0', | 585 parser.add_option('--component_build', default='0', |
| 575 help='Whether this archive is packaging a component build. This will ' | 586 help='Whether this archive is packaging a component build. This will ' |
| 576 'also turn off compression of chrome.7z into chrome.packed.7z and ' | 587 'also turn off compression of chrome.7z into chrome.packed.7z and ' |
| 577 'helpfully delete any old chrome.packed.7z in |output_dir|.') | 588 'helpfully delete any old chrome.packed.7z in |output_dir|.') |
| 589 parser.add_option('--target_arch', default='x86', | |
| 590 help='Specify the target architecture for installer - this is used ' | |
| 591 'to determine which CRT runtime files to pull and package ' | |
| 592 'with the installer archive {x86|x64}.') | |
| 578 | 593 |
| 579 options, _ = parser.parse_args() | 594 options, _ = parser.parse_args() |
| 580 if not options.build_dir: | 595 if not options.build_dir: |
| 581 parser.error('You must provide a build dir.') | 596 parser.error('You must provide a build dir.') |
| 582 | 597 |
| 583 options.build_dir = os.path.normpath(options.build_dir) | 598 options.build_dir = os.path.normpath(options.build_dir) |
| 584 | 599 |
| 585 if not options.staging_dir: | 600 if not options.staging_dir: |
| 586 parser.error('You must provide a staging dir.') | 601 parser.error('You must provide a staging dir.') |
| 587 | 602 |
| 588 if not options.input_file: | 603 if not options.input_file: |
| 589 parser.error('You must provide an input file') | 604 parser.error('You must provide an input file') |
| 590 | 605 |
| 591 if not options.output_dir: | 606 if not options.output_dir: |
| 592 options.output_dir = options.build_dir | 607 options.output_dir = options.build_dir |
| 593 | 608 |
| 594 if not options.resource_file_path: | 609 if not options.resource_file_path: |
| 595 options.resource_file_path = os.path.join(options.build_dir, | 610 options.resource_file_path = os.path.join(options.build_dir, |
| 596 MINI_INSTALLER_INPUT_FILE) | 611 MINI_INSTALLER_INPUT_FILE) |
| 597 | 612 |
| 598 return options | 613 return options |
| 599 | 614 |
| 600 | 615 |
| 601 if '__main__' == __name__: | 616 if '__main__' == __name__: |
| 602 print sys.argv | 617 print sys.argv |
| 603 sys.exit(main(_ParseOptions())) | 618 sys.exit(main(_ParseOptions())) |
| OLD | NEW |