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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 raise ValueError('could not find {0} in the manifest:\n{1}'.format( | 328 raise ValueError('could not find {0} in the manifest:\n{1}'.format( |
329 insert_before, ''.join(manifest_lines))) | 329 insert_before, ''.join(manifest_lines))) |
330 manifest_lines.insert(insert_index, inserted_string) | 330 manifest_lines.insert(insert_index, inserted_string) |
331 | 331 |
332 modified_manifest_file = open( | 332 modified_manifest_file = open( |
333 os.path.join(output_dir, manifest_name), 'w') | 333 os.path.join(output_dir, manifest_name), 'w') |
334 modified_manifest_file.write(''.join(manifest_lines)) | 334 modified_manifest_file.write(''.join(manifest_lines)) |
335 modified_manifest_file.close() | 335 modified_manifest_file.close() |
336 | 336 |
337 | 337 |
| 338 # Copy the relevant CRT DLLs to |build_dir|. We copy DLLs from all versions |
| 339 # of VS installed to make sure we have the correct CRT version, unused DLLs |
| 340 # should not conflict with the others anyways. |
| 341 def CopyVisualStudioRuntimeDLLs(build_dir): |
| 342 is_debug = os.path.basename(build_dir) == 'Debug' |
| 343 if not is_debug and os.path.basename(build_dir) != 'Release': |
| 344 print ("Warning: could not determine build configuration from " |
| 345 "output directory, assuming Release build.") |
| 346 |
| 347 crt_dlls = [] |
| 348 if is_debug: |
| 349 crt_dlls = glob.glob( |
| 350 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" |
| 351 "Debug_NonRedist/x86/Microsoft.*.DebugCRT/*.dll") |
| 352 else: |
| 353 crt_dlls = glob.glob( |
| 354 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/x86/" |
| 355 "Microsoft.*.CRT/*.dll") |
| 356 |
| 357 # Also handle the case where someone is building using only winsdk and |
| 358 # doesn't have Visual Studio installed. |
| 359 if not crt_dlls: |
| 360 # On a 64-bit system, 32-bit dlls are in SysWOW64 (don't ask). |
| 361 if os.access("C:/Windows/SysWOW64", os.F_OK): |
| 362 sys_dll_dir = "C:/Windows/SysWOW64" |
| 363 else: |
| 364 sys_dll_dir = "C:/Windows/System32" |
| 365 |
| 366 if is_debug: |
| 367 crt_dlls = glob.glob(os.path.join(sys_dll_dir, "msvc*0d.dll")) |
| 368 else: |
| 369 crt_dlls = glob.glob(os.path.join(sys_dll_dir, "msvc*0.dll")) |
| 370 |
| 371 if not crt_dlls: |
| 372 print ("Warning: could not find CRT DLLs to copy to build dir - target " |
| 373 "may not run on a system that doesn't have those DLLs.") |
| 374 |
| 375 for dll in crt_dlls: |
| 376 shutil.copy(dll, build_dir) |
| 377 |
| 378 |
338 # Copies component build DLLs and generates required config files and manifests | 379 # Copies component build DLLs and generates required config files and manifests |
339 # in order for chrome.exe and setup.exe to be able to find those DLLs at | 380 # in order for chrome.exe and setup.exe to be able to find those DLLs at |
340 # run-time. | 381 # run-time. |
341 # This is meant for developer builds only and should never be used to package | 382 # This is meant for developer builds only and should never be used to package |
342 # an official build. | 383 # an official build. |
343 def DoComponentBuildTasks(staging_dir, build_dir, current_version): | 384 def DoComponentBuildTasks(staging_dir, build_dir, current_version): |
344 # Get the required directories for the upcoming operations. | 385 # Get the required directories for the upcoming operations. |
345 chrome_dir = os.path.join(staging_dir, CHROME_DIR) | 386 chrome_dir = os.path.join(staging_dir, CHROME_DIR) |
346 version_dir = os.path.join(chrome_dir, current_version) | 387 version_dir = os.path.join(chrome_dir, current_version) |
347 installer_dir = os.path.join(version_dir, 'Installer') | 388 installer_dir = os.path.join(version_dir, 'Installer') |
348 # |installer_dir| is technically only created post-install, but we need it | 389 # |installer_dir| is technically only created post-install, but we need it |
349 # now to add setup.exe's config and manifest to the archive. | 390 # now to add setup.exe's config and manifest to the archive. |
350 if not os.path.exists(installer_dir): | 391 if not os.path.exists(installer_dir): |
351 os.mkdir(installer_dir) | 392 os.mkdir(installer_dir) |
352 | 393 |
353 # Copy the relevant CRT DLLs to |build_dir|. We copy DLLs from all versions | 394 # Copy the VS CRT DLLs to |build_dir|. This must be done before the general |
354 # of VS installed to make sure we have the correct CRT version, unused DLLs | 395 # copy step below to ensure the CRT DLLs are added to the archive and marked |
355 # should not conflict with the others anyways. | 396 # as a dependency in the exe manifests generated below. |
356 crt_dlls = [] | 397 CopyVisualStudioRuntimeDLLs(build_dir) |
357 if build_dir.endswith('Debug/'): | |
358 crt_dlls = glob.glob( | |
359 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" | |
360 "Debug_NonRedist/x86/Microsoft.*.DebugCRT/*.dll") | |
361 elif build_dir.endswith('Release/'): | |
362 crt_dlls = glob.glob( | |
363 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/x86/" | |
364 "Microsoft.*.CRT/*.dll") | |
365 else: | |
366 print ("Warning: CRT DLLs not copied, could not determine build " | |
367 "configuration from output directory.") | |
368 | |
369 for dll in crt_dlls: | |
370 shutil.copy(dll, build_dir) | |
371 | 398 |
372 # Copy all the DLLs in |build_dir| to the version directory. Simultaneously | 399 # Copy all the DLLs in |build_dir| to the version directory. Simultaneously |
373 # build a list of their names to mark them as dependencies of chrome.exe and | 400 # build a list of their names to mark them as dependencies of chrome.exe and |
374 # setup.exe later. | 401 # setup.exe later. |
375 dlls = glob.glob(os.path.join(build_dir, '*.dll')) | 402 dlls = glob.glob(os.path.join(build_dir, '*.dll')) |
376 dll_names = [] | 403 dll_names = [] |
377 for dll in dlls: | 404 for dll in dlls: |
378 shutil.copy(dll, version_dir) | 405 shutil.copy(dll, version_dir) |
379 dll_names.append(os.path.splitext(os.path.basename(dll))[0]) | 406 dll_names.append(os.path.splitext(os.path.basename(dll))[0]) |
380 | 407 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 help='Whether to include HiDPI resource files.') | 556 help='Whether to include HiDPI resource files.') |
530 parser.add_option('--enable_metro', default='0', | 557 parser.add_option('--enable_metro', default='0', |
531 help='Whether to include resource files from the "METRO" section of the ' | 558 help='Whether to include resource files from the "METRO" section of the ' |
532 'input file.') | 559 'input file.') |
533 parser.add_option('--component_build', default='0', | 560 parser.add_option('--component_build', default='0', |
534 help='Whether this archive is packaging a component build.') | 561 help='Whether this archive is packaging a component build.') |
535 | 562 |
536 options, args = parser.parse_args() | 563 options, args = parser.parse_args() |
537 if not options.build_dir: | 564 if not options.build_dir: |
538 parser.error('You must provide a build dir.') | 565 parser.error('You must provide a build dir.') |
539 elif not options.build_dir.endswith('/'): | 566 |
540 options.build_dir += '/' | 567 options.build_dir = os.path.normpath(options.build_dir) |
541 | 568 |
542 if not options.staging_dir: | 569 if not options.staging_dir: |
543 parser.error('You must provide a staging dir.') | 570 parser.error('You must provide a staging dir.') |
544 | 571 |
545 if not options.input_file: | 572 if not options.input_file: |
546 parser.error('You must provide an input file') | 573 parser.error('You must provide an input file') |
547 | 574 |
548 if not options.output_dir: | 575 if not options.output_dir: |
549 options.output_dir = options.build_dir | 576 options.output_dir = options.build_dir |
550 | 577 |
551 if not options.resource_file_path: | 578 if not options.resource_file_path: |
552 options.resource_file_path = os.path.join(options.build_dir, | 579 options.resource_file_path = os.path.join(options.build_dir, |
553 MINI_INSTALLER_INPUT_FILE) | 580 MINI_INSTALLER_INPUT_FILE) |
554 | 581 |
555 return options | 582 return options |
556 | 583 |
557 | 584 |
558 if '__main__' == __name__: | 585 if '__main__' == __name__: |
559 print sys.argv | 586 print sys.argv |
560 sys.exit(main(_ParseOptions())) | 587 sys.exit(main(_ParseOptions())) |
OLD | NEW |