Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 | 6 |
| 7 # A script to generate a windows installer for the editor bundle. | 7 # A script to generate a windows installer for the editor bundle. |
| 8 # As input the script takes a zip file, a version and the location | 8 # As input the script takes a zip file, a version and the location |
| 9 # to store the resulting msi file in. | 9 # to store the resulting msi file in. |
| 10 # | 10 # |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 # The components we want to add to our feature. | 33 # The components we want to add to our feature. |
| 34 feature_components = [] | 34 feature_components = [] |
| 35 | 35 |
| 36 # Indentation level, each level is indented 2 spaces | 36 # Indentation level, each level is indented 2 spaces |
| 37 current_indentation = 0 | 37 current_indentation = 0 |
| 38 | 38 |
| 39 def GetOptions(): | 39 def GetOptions(): |
| 40 options = optparse.OptionParser(usage='usage: %prog [options]') | 40 options = optparse.OptionParser(usage='usage: %prog [options]') |
| 41 options.add_option("--zip_file_location", | 41 options.add_option("--zip_file_location", |
| 42 help='Where the zip file including the editor is located.') | 42 help='Where the zip file including the editor is located.') |
| 43 options.add_option("--input_directory", | |
| 44 help='Directory where all the files needed is located.') | |
| 43 options.add_option("--msi_location", | 45 options.add_option("--msi_location", |
| 44 help='Where to store the resulting msi.') | 46 help='Where to store the resulting msi.') |
| 45 options.add_option("--version", | 47 options.add_option("--version", |
| 46 help='The version specified as Major.Minor.Build.Patch.') | 48 help='The version specified as Major.Minor.Build.Patch.') |
| 47 options.add_option("--wix_bin", | 49 options.add_option("--wix_bin", |
| 48 help='The location of the wix binary files.') | 50 help='The location of the wix binary files.') |
| 49 options.add_option("--print_wxs", action="store_true", dest="print_wxs", | 51 options.add_option("--print_wxs", action="store_true", dest="print_wxs", |
| 50 default=False, | 52 default=False, |
| 51 help="Prints the generated wxs to stdout.") | 53 help="Prints the generated wxs to stdout.") |
| 52 return options.parse_args() | 54 (options, args) = options.parse_args() |
| 55 if len(args) > 0: | |
| 56 raise Exception("This script takes no arguments, only options") | |
| 57 ValidateOptions(options) | |
| 58 return options | |
| 59 | |
| 60 def ValidateOptions(options): | |
| 61 if not options.version: | |
| 62 raise Exception('You must supply a version') | |
| 63 if options.zip_file_location and options.input_directory: | |
| 64 raise Exception('Please pass either zip_file_location or input_directory') | |
| 65 if not options.zip_file_location and not options.input_directory: | |
| 66 raise Exception('Please pass either zip_file_location or input_directory') | |
| 67 if (options.zip_file_location and | |
| 68 not os.path.isfile(options.zip_file_location)): | |
| 69 raise Exception('Passed in zip file not found') | |
| 70 if (options.input_directory and | |
| 71 not os.path.isdir(options.input_directory)): | |
| 72 raise Exception('Passed in directory not found') | |
| 73 | |
| 74 def GetInputDirectory(options): | |
| 75 if options.zip_file_location: | |
| 76 ExtractZipFile(options.zip_file_location, temp_dir) | |
|
kustermann
2013/10/29 08:44:47
Where is "temp_dir" defined?
ricow1
2013/10/29 08:59:05
Fixed
| |
| 77 return os.path.join(temp_dir, 'dart') | |
| 78 return options.input_directory | |
| 53 | 79 |
| 54 # We combine the build and patch into a single entry since | 80 # We combine the build and patch into a single entry since |
| 55 # the windows installer does _not_ consider a change in Patch | 81 # the windows installer does _not_ consider a change in Patch |
| 56 # to require a new install. | 82 # to require a new install. |
| 57 # In addition to that, the limits on the size are: | 83 # In addition to that, the limits on the size are: |
| 58 # Major: 256 | 84 # Major: 256 |
| 59 # Minor: 256 | 85 # Minor: 256 |
| 60 # Build: 65536 | 86 # Build: 65536 |
| 61 # To circumvent this we create the version like this: | 87 # To circumvent this we create the version like this: |
| 62 # Major.Minor.X | 88 # Major.Minor.X |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 candle_bin = os.path.join(options.wix_bin, 'candle.exe') | 330 candle_bin = os.path.join(options.wix_bin, 'candle.exe') |
| 305 light_bin = os.path.join(options.wix_bin, 'light.exe') | 331 light_bin = os.path.join(options.wix_bin, 'light.exe') |
| 306 print 'Calling candle on %s' % wxs_file | 332 print 'Calling candle on %s' % wxs_file |
| 307 subprocess.check_call('%s %s -o %s' % (candle_bin, wxs_file, | 333 subprocess.check_call('%s %s -o %s' % (candle_bin, wxs_file, |
| 308 wixobj_file)) | 334 wixobj_file)) |
| 309 print 'Calling light on %s' % wixobj_file | 335 print 'Calling light on %s' % wixobj_file |
| 310 subprocess.check_call('%s %s -o %s' % (light_bin, wixobj_file, | 336 subprocess.check_call('%s %s -o %s' % (light_bin, wixobj_file, |
| 311 options.msi_location)) | 337 options.msi_location)) |
| 312 print 'Created msi file to %s' % options.msi_location | 338 print 'Created msi file to %s' % options.msi_location |
| 313 | 339 |
| 340 | |
| 314 def Main(argv): | 341 def Main(argv): |
| 315 if sys.platform != 'win32': | 342 if sys.platform != 'win32': |
| 316 raise Exception("This script can only be run on windows") | 343 raise Exception("This script can only be run on windows") |
| 317 (options, args) = GetOptions() | 344 options = GetOptions() |
| 318 if not options.version: | 345 input_location = GetInputDirectory(options) |
|
kustermann
2013/10/29 08:44:47
Remove this and add the following line inside "wit
ricow1
2013/10/29 08:59:05
Done.
| |
| 319 raise Exception('You must supply a version') | |
| 320 if not os.path.isfile(options.zip_file_location): | |
| 321 raise Exception('You must pass in a valid zip file') | |
| 322 | 346 |
| 323 version = GetMicrosoftProductVersion(options.version) | 347 version = GetMicrosoftProductVersion(options.version) |
| 324 with utils.TempDir('installer') as temp_dir: | 348 with utils.TempDir('installer') as temp_dir: |
| 325 ExtractZipFile(options.zip_file_location, temp_dir) | |
| 326 print "Generating wix XML" | 349 print "Generating wix XML" |
| 327 XmlHeader() | 350 XmlHeader() |
| 328 with WixAndProduct(version): | 351 with WixAndProduct(version): |
| 329 AppendBlankLine() | 352 AppendBlankLine() |
| 330 Package() | 353 Package() |
| 331 MediaTemplate() | 354 MediaTemplate() |
| 332 AppendComment('We always do a major upgrade, at least for now') | 355 AppendComment('We always do a major upgrade, at least for now') |
| 333 MajorUpgrade() | 356 MajorUpgrade() |
| 334 | 357 |
| 335 AppendComment('Directory structure') | 358 AppendComment('Directory structure') |
| 336 with Directory('TARGETDIR', 'SourceDir'): | 359 with Directory('TARGETDIR', 'SourceDir'): |
| 337 with Directory('ProgramFilesFolder'): | 360 with Directory('ProgramFilesFolder'): |
| 338 with Directory('RootInstallDir', 'Dart Editor'): | 361 with Directory('RootInstallDir', 'Dart Editor'): |
| 339 AppendComment("Add all files and directories") | 362 AppendComment("Add all files and directories") |
| 340 print 'Installing files and directories in xml' | 363 print 'Installing files and directories in xml' |
| 341 ListFiles(os.path.join(temp_dir, 'dart')) | 364 ListFiles(input_location) |
| 342 AppendBlankLine() | 365 AppendBlankLine() |
| 343 AppendComment("Create shortcuts") | 366 AppendComment("Create shortcuts") |
| 344 with Directory('ProgramMenuFolder'): | 367 with Directory('ProgramMenuFolder'): |
| 345 with Directory('ShortcutFolder', 'Dart Editor'): | 368 with Directory('ShortcutFolder', 'Dart Editor'): |
| 346 with Component('shortcut'): | 369 with Component('shortcut'): |
| 347 # When generating a shortcut we need an entry with | 370 # When generating a shortcut we need an entry with |
| 348 # a KeyPath (RegistryEntry) below - to be able to remove | 371 # a KeyPath (RegistryEntry) below - to be able to remove |
| 349 # the shortcut again. The RemoveFolder tag is needed | 372 # the shortcut again. The RemoveFolder tag is needed |
| 350 # to clean up everything | 373 # to clean up everything |
| 351 Shortcut('editor_shortcut', 'Dart Editor', | 374 Shortcut('editor_shortcut', 'Dart Editor', |
| 352 '[RootInstallDir]DartEditor.exe') | 375 '[RootInstallDir]DartEditor.exe') |
| 353 RemoveFolder('RemoveShortcuts') | 376 RemoveFolder('RemoveShortcuts') |
| 354 RegistryEntry('DartEditor') | 377 RegistryEntry('DartEditor') |
| 355 with Feature(): | 378 with Feature(): |
| 356 # We have only one feature and that consist of all the | 379 # We have only one feature and that consist of all the |
| 357 # files=components we have listed above" | 380 # files=components we have listed above" |
| 358 ComponentRefs() | 381 ComponentRefs() |
| 359 xml = GetContent() | 382 xml = GetContent() |
| 360 if options.print_wxs: | 383 if options.print_wxs: |
| 361 print xml | 384 print xml |
| 362 GenerateInstaller(xml, options, temp_dir) | 385 GenerateInstaller(xml, options, temp_dir) |
| 363 | 386 |
| 364 if __name__ == '__main__': | 387 if __name__ == '__main__': |
| 365 sys.exit(Main(sys.argv)) | 388 sys.exit(Main(sys.argv)) |
| OLD | NEW |