Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: chrome/tools/build/win/create_installer_archive.py

Issue 9701050: Make setup.exe compatible with the component build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make it work Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 # Adds component build DLLs and required config files and manifests in order
grt (UTC plus 2) 2012/05/11 15:10:50 ?? Adds -> Generates ??
gab 2012/05/11 15:56:51 Yes, but "copies" for the DLLs, let me know if the
grt (UTC plus 2) 2012/05/11 17:01:22 Right on.
316 # for chrome.exe and setup.exe to be able to find those DLLs at run-time.
317 # This is meant for developer builds only and should never be used to package
318 # an official build.
319 def DoComponentBuildTasks(staging_dir, build_dir, current_version):
320 # Get the required directories for the upcoming operations.
321 chrome_dir = os.path.join(staging_dir, CHROME_DIR)
322 version_dir = os.path.join(chrome_dir, current_version)
323 installer_dir = os.path.join(version_dir, 'Installer')
324 # |installer_dir| is technically only created post-install, but we need it
325 # now to add setup.exe's config and manifest to the archive.
326 if not os.path.exists(installer_dir):
327 os.mkdir(installer_dir)
328
329 # Copy all the DLLs in |build_dir| to the version directory.
330 dlls = glob.glob(os.path.join(build_dir, '*.dll'))
331 for dll in dlls:
332 shutil.copy(dll, version_dir)
333
334 exe_config = (
335 "<configuration>\n"
336 " <windows>\n"
337 " <assemblyBinding xmlns='urn:schemas-microsoft-com:asm.v1'>\n"
338 " <probing privatePath='{rel_path}'/>\n"
339 " </assemblyBinding>\n"
340 " </windows>\n"
341 "</configuration>")
342
343 # Write chrome.exe.config to point to the version directory.
344 chrome_exe_config_file = open(
345 os.path.join(chrome_dir, 'chrome.exe.config'), 'w')
346 chrome_exe_config_file.write(exe_config.format(rel_path=current_version))
347 chrome_exe_config_file.close()
348
349 # Write setup.exe.config to point to the version directory (which is under it
350 # post-install).
351 setup_exe_config_file = open(
352 os.path.join(installer_dir, 'setup.exe.config'), 'w')
353 setup_exe_config_file.write(exe_config.format(rel_path='..'))
354 setup_exe_config_file.close()
355
356 # Build a list containing the name of each DLL found in |build_dir|.
357 dll_names = []
358 for dll in dlls:
359 dll_names.append(os.path.splitext(os.path.basename(dll))[0])
360
361 # Build the manifests for chrome.exe and setup.exe in which we list all the
362 # DLLs as side by side assembly dependencies.
363 # TODO (gab): These extra properties should be merged with the existing
364 # chrome/app/chrome.exe.manifest and
365 # chrome/installer/setup/setup.exe.manifest.
366 exe_manifest_parts = [
367 "<assembly\n"
368 " xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>\n"
369 " <trustInfo xmlns='urn:schemas-microsoft-com:asm.v3'>\n"
370 " <security>\n"
371 " <requestedPrivileges>\n"
372 " <requestedExecutionLevel level='asInvoker' uiAccess='false'/>\n"
373 " </requestedPrivileges>\n"
374 " </security>\n"
375 " </trustInfo>\n"]
376
377 for name in dll_names:
378 exe_manifest_parts.append(
379 " <dependency>\n"
380 " <dependentAssembly>\n"
381 " <assemblyIdentity type='win32' name='chrome.{dll_basename}'\n"
382 " version='0.0.0.0' processorArchitecture='x86'\n"
383 " language='*'/>\n"
384 " </dependentAssembly>\n"
385 " </dependency>\n".format(dll_basename=name))
386
387 exe_manifest_parts.append("</assembly>")
388 exe_manifest = ''.join(exe_manifest_parts)
389
390 # Write chrome.exe.manifest beside chrome.exe.
391 chrome_exe_manifest_file = open(
392 os.path.join(chrome_dir, 'chrome.exe.manifest'), 'w')
393 chrome_exe_manifest_file.write(exe_manifest)
394 chrome_exe_manifest_file.close()
395
396 # Write setup.exe.manifest beside setup.exe in |version_dir|/Installer.
397 setup_exe_manifest_file = open(
398 os.path.join(installer_dir, 'setup.exe.manifest'), 'w')
399 setup_exe_manifest_file.write(exe_manifest)
400 setup_exe_manifest_file.close()
401
402 # Write chrome.{dllname}.manifest in the version directory for each DLL list
403 # as a dependency in the previous step.
404 # TODO (gab): The properties should probably be merged with the existing
405 # chrome/app/chrome.dll.manifest which could be duplicated for every extra
406 # DLL in the component build.
407 for name in dll_names:
408 dll_manifest = (
409 "<assembly\n"
410 " xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>\n"
411 " <assemblyIdentity name='chrome.{dll_basename}' version='0.0.0.0'\n"
412 " type='win32' processorArchitecture='x86'/>\n"
413 " <file name='{dll_basename}.dll'/>\n"
414 "</assembly>".format(dll_basename=name))
415
416 dll_manifest_file = open(os.path.join(
417 version_dir,
418 "chrome.{dll_basename}.manifest".format(dll_basename=name)), 'w')
419 dll_manifest_file.write(dll_manifest)
420 dll_manifest_file.close()
421
422
315 def main(options): 423 def main(options):
316 """Main method that reads input file, creates archive file and write 424 """Main method that reads input file, creates archive file and write
317 resource input file. 425 resource input file.
318 """ 426 """
319 current_version = BuildVersion(options.build_dir) 427 current_version = BuildVersion(options.build_dir)
320 428
321 config = Readconfig(options.build_dir, options.input_file, current_version) 429 config = Readconfig(options.build_dir, options.input_file, current_version)
322 430
323 (staging_dir, temp_dir) = MakeStagingDirectories(options.staging_dir) 431 (staging_dir, temp_dir) = MakeStagingDirectories(options.staging_dir)
324 432
325 prev_version = GetPrevVersion(options.build_dir, temp_dir, 433 prev_version = GetPrevVersion(options.build_dir, temp_dir,
326 options.last_chrome_installer) 434 options.last_chrome_installer)
327 435
328 # Preferentially copy the files we can find from the output_dir, as 436 # Preferentially copy the files we can find from the output_dir, as
329 # this is where we'll find the Syzygy-optimized executables when 437 # this is where we'll find the Syzygy-optimized executables when
330 # building the optimized mini_installer. 438 # building the optimized mini_installer.
331 if options.build_dir != options.output_dir: 439 if options.build_dir != options.output_dir:
332 CopyAllFilesToStagingDir(config, options.distribution, 440 CopyAllFilesToStagingDir(config, options.distribution,
333 staging_dir, options.output_dir, 441 staging_dir, options.output_dir,
334 options.enable_hidpi, options.enable_metro) 442 options.enable_hidpi, options.enable_metro)
335 443
336 # Now copy the remainder of the files from the build dir. 444 # Now copy the remainder of the files from the build dir.
337 CopyAllFilesToStagingDir(config, options.distribution, 445 CopyAllFilesToStagingDir(config, options.distribution,
338 staging_dir, options.build_dir, 446 staging_dir, options.build_dir,
339 options.enable_hidpi, options.enable_metro) 447 options.enable_hidpi, options.enable_metro)
340 448
449 if options.component_build == '1':
450 DoComponentBuildTasks(staging_dir, options.build_dir, current_version)
451
341 version_numbers = current_version.split('.') 452 version_numbers = current_version.split('.')
342 current_build_number = version_numbers[2] + '.' + version_numbers[3] 453 current_build_number = version_numbers[2] + '.' + version_numbers[3]
343 prev_build_number = '' 454 prev_build_number = ''
344 if prev_version: 455 if prev_version:
345 version_numbers = prev_version.split('.') 456 version_numbers = prev_version.split('.')
346 prev_build_number = version_numbers[2] + '.' + version_numbers[3] 457 prev_build_number = version_numbers[2] + '.' + version_numbers[3]
347 458
348 # Name of the archive file built (for example - chrome.7z or 459 # Name of the archive file built (for example - chrome.7z or
349 # patch-<old_version>-<new_version>.7z or patch-<new_version>.7z 460 # patch-<old_version>-<new_version>.7z or patch-<new_version>.7z
350 archive_file = CreateArchiveFile(options, staging_dir, 461 archive_file = CreateArchiveFile(options, staging_dir,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 parser.add_option('-a', '--diff_algorithm', default='BSDIFF', 497 parser.add_option('-a', '--diff_algorithm', default='BSDIFF',
387 help='Diff algorithm to use when generating differential patches ' 498 help='Diff algorithm to use when generating differential patches '
388 '{BSDIFF|COURGETTE}.') 499 '{BSDIFF|COURGETTE}.')
389 parser.add_option('-n', '--output_name', default='chrome', 500 parser.add_option('-n', '--output_name', default='chrome',
390 help='Name used to prefix names of generated archives.') 501 help='Name used to prefix names of generated archives.')
391 parser.add_option('--enable_hidpi', default='0', 502 parser.add_option('--enable_hidpi', default='0',
392 help='Whether to include HiDPI resource files.') 503 help='Whether to include HiDPI resource files.')
393 parser.add_option('--enable_metro', default='0', 504 parser.add_option('--enable_metro', default='0',
394 help='Whether to include resource files from the "METRO" section of the ' 505 help='Whether to include resource files from the "METRO" section of the '
395 'input file.') 506 'input file.')
507 parser.add_option('--component_build', default='0',
508 help='Whether this archive is packaging a component build.')
396 509
397 options, args = parser.parse_args() 510 options, args = parser.parse_args()
398 if not options.build_dir: 511 if not options.build_dir:
399 parser.error('You must provide a build dir.') 512 parser.error('You must provide a build dir.')
400 513
401 if not options.staging_dir: 514 if not options.staging_dir:
402 parser.error('You must provide a staging dir.') 515 parser.error('You must provide a staging dir.')
403 516
517 if not options.input_file:
518 parser.error('You must provide an input file')
519
404 if not options.output_dir: 520 if not options.output_dir:
405 options.output_dir = options.build_dir 521 options.output_dir = options.build_dir
406 522
407 if not options.resource_file_path: 523 if not options.resource_file_path:
408 options.options.resource_file_path = os.path.join(options.build_dir, 524 options.resource_file_path = os.path.join(options.build_dir,
409 MINI_INSTALLER_INPUT_FILE) 525 MINI_INSTALLER_INPUT_FILE)
410 526
411 return options 527 return options
412 528
413 529
414 if '__main__' == __name__: 530 if '__main__' == __name__:
415 print sys.argv 531 print sys.argv
416 sys.exit(main(_ParseOptions())) 532 sys.exit(main(_ParseOptions()))
OLDNEW
« chrome/installer/setup/install_worker.cc ('K') | « chrome/installer/setup/install_worker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698