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