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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 'archive_file': archive_file, | 305 'archive_file': archive_file, |
306 'archive_file_path': | 306 'archive_file_path': |
307 os.path.join(output_dir, archive_file).replace("\\","/"), | 307 os.path.join(output_dir, archive_file).replace("\\","/"), |
308 } | 308 } |
309 resource_file = _RESOURCE_FILE_TEMPLATE % args | 309 resource_file = _RESOURCE_FILE_TEMPLATE % args |
310 | 310 |
311 with open(resource_file_path, 'w') as f: | 311 with open(resource_file_path, 'w') as f: |
312 f.write(resource_file) | 312 f.write(resource_file) |
313 | 313 |
314 | 314 |
315 def DoComponentBuildTasks(staging_dir, build_dir, current_version): | |
316 # Copy all the DLLs in |build_dir| to the version directory. | |
317 chrome_dir = os.path.join(staging_dir, CHROME_DIR) | |
318 version_dir = os.path.join(chrome_dir, current_version) | |
319 dlls = glob.glob(os.path.join(build_dir, '*.dll')) | |
320 for dll in dlls: | |
321 shutil.copy(dll, version_dir) | |
322 | |
323 # Write chrome.exe.config to point to the version directory. | |
324 chrome_exe_config = ( | |
325 "<configuration>\n" | |
326 " <windows>\n" | |
327 " <assemblyBinding xmlns='urn:schemas-microsoft-com:asm.v1'>\n" | |
328 " <probing privatePath='{version}' />\n" | |
329 " </assemblyBinding>\n" | |
330 " </windows>\n" | |
331 "</configuration>".format(version = current_version)) | |
332 | |
333 chrome_exe_config_file = open( | |
334 os.path.join(chrome_dir, 'chrome.exe.config'), 'w') | |
335 chrome_exe_config_file.write(chrome_exe_config) | |
336 chrome_exe_config_file.close() | |
337 | |
338 # Build a list containing the name of each DLL found in |build_dir| | |
339 dll_names = [] | |
340 for dll in dlls: | |
341 dll_names.append(os.path.splitext(os.path.basename(dll))[0]) | |
342 | |
343 # Write chrome.exe.manifest in which we list all the DLLs as side by side | |
344 # assembly dependencies. | |
345 chrome_exe_manifest_parts = [ | |
346 "<assembly\n" | |
347 " xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>\n" | |
348 " <assemblyIdentity \n" | |
grt (UTC plus 2)
2012/05/09 15:49:40
nit: remove the space before the newline
gab
2012/05/09 21:13:24
Done.
| |
349 " name='chrome.chromeexe' version='0.0.0.0' type='win32' />\n"] | |
grt (UTC plus 2)
2012/05/09 15:49:40
i hate with the heat of a thousand suns this trend
gab
2012/05/09 21:13:24
Me make Greg happy :)
| |
350 | |
351 for name in dll_names: | |
352 chrome_exe_manifest_parts.append( | |
353 " <dependency>\n" | |
354 " <dependentAssembly>\n" | |
355 " <assemblyIdentity type='win32' name='chrome.{dll_basename}'\n" | |
356 " version='0.0.0.0' processorArchitecture='x86'\n" | |
357 " language='*' />\n" | |
grt (UTC plus 2)
2012/05/09 15:49:40
(cue the sound of greg running through the halls s
gab
2012/05/09 21:13:24
Can I get a recording of this to soothe my soul if
| |
358 " </dependentAssembly>\n" | |
359 " </dependency>\n".format(dll_basename = name)) | |
360 | |
361 chrome_exe_manifest_parts.append("</assembly>") | |
362 | |
363 chrome_exe_manifest_file = open( | |
364 os.path.join(chrome_dir, 'chrome.exe.manifest'), 'w') | |
365 chrome_exe_manifest_file.write(''.join(chrome_exe_manifest_parts)) | |
366 chrome_exe_manifest_file.close() | |
367 | |
368 # Write chrome.{dllname}.manifest in the version directory for each DLL list | |
369 # as a dependency in the previous step. | |
370 for name in dll_names: | |
371 dll_manifest = ( | |
372 "<assembly\n" | |
373 " xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>\n" | |
374 " <assemblyIdentity name='chrome.{dll_basename}' version='0.0.0.0'\n" | |
375 " type='win32' processorArchitecture='x86' />\n" | |
grt (UTC plus 2)
2012/05/09 15:49:40
(oh, god, no)
gab
2012/05/09 21:13:24
Asked like that, I cannot refuse and shall fulfill
| |
376 " <file name='{dll_basename}.dll' />\n" | |
377 "</assembly>".format(dll_basename = name)) | |
378 | |
379 dll_manifest_file = open(os.path.join( | |
380 version_dir, | |
381 "chrome.{dll_basename}.manifest".format(dll_basename = name)), 'w') | |
382 dll_manifest_file.write(dll_manifest) | |
383 dll_manifest_file.close() | |
384 | |
385 | |
315 def main(options): | 386 def main(options): |
316 """Main method that reads input file, creates archive file and write | 387 """Main method that reads input file, creates archive file and write |
317 resource input file. | 388 resource input file. |
318 """ | 389 """ |
319 current_version = BuildVersion(options.build_dir) | 390 current_version = BuildVersion(options.build_dir) |
320 | 391 |
321 config = Readconfig(options.build_dir, options.input_file, current_version) | 392 config = Readconfig(options.build_dir, options.input_file, current_version) |
322 | 393 |
323 (staging_dir, temp_dir) = MakeStagingDirectories(options.staging_dir) | 394 (staging_dir, temp_dir) = MakeStagingDirectories(options.staging_dir) |
324 | 395 |
325 prev_version = GetPrevVersion(options.build_dir, temp_dir, | 396 prev_version = GetPrevVersion(options.build_dir, temp_dir, |
326 options.last_chrome_installer) | 397 options.last_chrome_installer) |
327 | 398 |
328 # Preferentially copy the files we can find from the output_dir, as | 399 # Preferentially copy the files we can find from the output_dir, as |
329 # this is where we'll find the Syzygy-optimized executables when | 400 # this is where we'll find the Syzygy-optimized executables when |
330 # building the optimized mini_installer. | 401 # building the optimized mini_installer. |
331 if options.build_dir != options.output_dir: | 402 if options.build_dir != options.output_dir: |
332 CopyAllFilesToStagingDir(config, options.distribution, | 403 CopyAllFilesToStagingDir(config, options.distribution, |
333 staging_dir, options.output_dir, | 404 staging_dir, options.output_dir, |
334 options.enable_hidpi, options.enable_metro) | 405 options.enable_hidpi, options.enable_metro) |
335 | 406 |
336 # Now copy the remainder of the files from the build dir. | 407 # Now copy the remainder of the files from the build dir. |
337 CopyAllFilesToStagingDir(config, options.distribution, | 408 CopyAllFilesToStagingDir(config, options.distribution, |
338 staging_dir, options.build_dir, | 409 staging_dir, options.build_dir, |
339 options.enable_hidpi, options.enable_metro) | 410 options.enable_hidpi, options.enable_metro) |
340 | 411 |
412 if options.component_build == '1': | |
413 DoComponentBuildTasks(staging_dir, options.build_dir, current_version) | |
414 | |
341 version_numbers = current_version.split('.') | 415 version_numbers = current_version.split('.') |
342 current_build_number = version_numbers[2] + '.' + version_numbers[3] | 416 current_build_number = version_numbers[2] + '.' + version_numbers[3] |
343 prev_build_number = '' | 417 prev_build_number = '' |
344 if prev_version: | 418 if prev_version: |
345 version_numbers = prev_version.split('.') | 419 version_numbers = prev_version.split('.') |
346 prev_build_number = version_numbers[2] + '.' + version_numbers[3] | 420 prev_build_number = version_numbers[2] + '.' + version_numbers[3] |
347 | 421 |
348 # Name of the archive file built (for example - chrome.7z or | 422 # Name of the archive file built (for example - chrome.7z or |
349 # patch-<old_version>-<new_version>.7z or patch-<new_version>.7z | 423 # patch-<old_version>-<new_version>.7z or patch-<new_version>.7z |
350 archive_file = CreateArchiveFile(options, staging_dir, | 424 archive_file = CreateArchiveFile(options, staging_dir, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 parser.add_option('-a', '--diff_algorithm', default='BSDIFF', | 460 parser.add_option('-a', '--diff_algorithm', default='BSDIFF', |
387 help='Diff algorithm to use when generating differential patches ' | 461 help='Diff algorithm to use when generating differential patches ' |
388 '{BSDIFF|COURGETTE}.') | 462 '{BSDIFF|COURGETTE}.') |
389 parser.add_option('-n', '--output_name', default='chrome', | 463 parser.add_option('-n', '--output_name', default='chrome', |
390 help='Name used to prefix names of generated archives.') | 464 help='Name used to prefix names of generated archives.') |
391 parser.add_option('--enable_hidpi', default='0', | 465 parser.add_option('--enable_hidpi', default='0', |
392 help='Whether to include HiDPI resource files.') | 466 help='Whether to include HiDPI resource files.') |
393 parser.add_option('--enable_metro', default='0', | 467 parser.add_option('--enable_metro', default='0', |
394 help='Whether to include resource files from the "METRO" section of the ' | 468 help='Whether to include resource files from the "METRO" section of the ' |
395 'input file.') | 469 'input file.') |
470 parser.add_option('--component_build', default='0', | |
471 help='Whether this archive is packaging a component build.') | |
396 | 472 |
397 options, args = parser.parse_args() | 473 options, args = parser.parse_args() |
398 if not options.build_dir: | 474 if not options.build_dir: |
399 parser.error('You must provide a build dir.') | 475 parser.error('You must provide a build dir.') |
400 | 476 |
401 if not options.staging_dir: | 477 if not options.staging_dir: |
402 parser.error('You must provide a staging dir.') | 478 parser.error('You must provide a staging dir.') |
403 | 479 |
480 if not options.input_file: | |
gab
2012/05/09 21:13:24
FYI.
This is required and it is a mistake that it
| |
481 parser.error('You must provide an input file') | |
482 | |
404 if not options.output_dir: | 483 if not options.output_dir: |
405 options.output_dir = options.build_dir | 484 options.output_dir = options.build_dir |
406 | 485 |
407 if not options.resource_file_path: | 486 if not options.resource_file_path: |
408 options.options.resource_file_path = os.path.join(options.build_dir, | 487 options.resource_file_path = os.path.join(options.build_dir, |
gab
2012/05/09 21:13:24
FYI.
This was a typo and would crash if this path
| |
409 MINI_INSTALLER_INPUT_FILE) | 488 MINI_INSTALLER_INPUT_FILE) |
410 | 489 |
411 return options | 490 return options |
412 | 491 |
413 | 492 |
414 if '__main__' == __name__: | 493 if '__main__' == __name__: |
415 print sys.argv | 494 print sys.argv |
416 sys.exit(main(_ParseOptions())) | 495 sys.exit(main(_ParseOptions())) |
OLD | NEW |