| 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, temp_dir): |
| 75 if options.zip_file_location: |
| 76 ExtractZipFile(options.zip_file_location, temp_dir) |
| 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: | |
| 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 | |
| 323 version = GetMicrosoftProductVersion(options.version) | 345 version = GetMicrosoftProductVersion(options.version) |
| 324 with utils.TempDir('installer') as temp_dir: | 346 with utils.TempDir('installer') as temp_dir: |
| 325 ExtractZipFile(options.zip_file_location, temp_dir) | 347 input_location = GetInputDirectory(options, temp_dir) |
| 326 print "Generating wix XML" | 348 print "Generating wix XML" |
| 327 XmlHeader() | 349 XmlHeader() |
| 328 with WixAndProduct(version): | 350 with WixAndProduct(version): |
| 329 AppendBlankLine() | 351 AppendBlankLine() |
| 330 Package() | 352 Package() |
| 331 MediaTemplate() | 353 MediaTemplate() |
| 332 AppendComment('We always do a major upgrade, at least for now') | 354 AppendComment('We always do a major upgrade, at least for now') |
| 333 MajorUpgrade() | 355 MajorUpgrade() |
| 334 | 356 |
| 335 AppendComment('Directory structure') | 357 AppendComment('Directory structure') |
| 336 with Directory('TARGETDIR', 'SourceDir'): | 358 with Directory('TARGETDIR', 'SourceDir'): |
| 337 with Directory('ProgramFilesFolder'): | 359 with Directory('ProgramFilesFolder'): |
| 338 with Directory('RootInstallDir', 'Dart Editor'): | 360 with Directory('RootInstallDir', 'Dart Editor'): |
| 339 AppendComment("Add all files and directories") | 361 AppendComment("Add all files and directories") |
| 340 print 'Installing files and directories in xml' | 362 print 'Installing files and directories in xml' |
| 341 ListFiles(os.path.join(temp_dir, 'dart')) | 363 ListFiles(input_location) |
| 342 AppendBlankLine() | 364 AppendBlankLine() |
| 343 AppendComment("Create shortcuts") | 365 AppendComment("Create shortcuts") |
| 344 with Directory('ProgramMenuFolder'): | 366 with Directory('ProgramMenuFolder'): |
| 345 with Directory('ShortcutFolder', 'Dart Editor'): | 367 with Directory('ShortcutFolder', 'Dart Editor'): |
| 346 with Component('shortcut'): | 368 with Component('shortcut'): |
| 347 # When generating a shortcut we need an entry with | 369 # When generating a shortcut we need an entry with |
| 348 # a KeyPath (RegistryEntry) below - to be able to remove | 370 # a KeyPath (RegistryEntry) below - to be able to remove |
| 349 # the shortcut again. The RemoveFolder tag is needed | 371 # the shortcut again. The RemoveFolder tag is needed |
| 350 # to clean up everything | 372 # to clean up everything |
| 351 Shortcut('editor_shortcut', 'Dart Editor', | 373 Shortcut('editor_shortcut', 'Dart Editor', |
| 352 '[RootInstallDir]DartEditor.exe') | 374 '[RootInstallDir]DartEditor.exe') |
| 353 RemoveFolder('RemoveShortcuts') | 375 RemoveFolder('RemoveShortcuts') |
| 354 RegistryEntry('DartEditor') | 376 RegistryEntry('DartEditor') |
| 355 with Feature(): | 377 with Feature(): |
| 356 # We have only one feature and that consist of all the | 378 # We have only one feature and that consist of all the |
| 357 # files=components we have listed above" | 379 # files=components we have listed above" |
| 358 ComponentRefs() | 380 ComponentRefs() |
| 359 xml = GetContent() | 381 xml = GetContent() |
| 360 if options.print_wxs: | 382 if options.print_wxs: |
| 361 print xml | 383 print xml |
| 362 GenerateInstaller(xml, options, temp_dir) | 384 GenerateInstaller(xml, options, temp_dir) |
| 363 | 385 |
| 364 if __name__ == '__main__': | 386 if __name__ == '__main__': |
| 365 sys.exit(Main(sys.argv)) | 387 sys.exit(Main(sys.argv)) |
| OLD | NEW |