| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 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 | |
| 5 # BSD-style license that can be found in the LICENSE file. | |
| 6 # | |
| 7 # Script to push the barback package to pub. Barback is treated specially | |
| 8 # because it is tightly coupled to the SDK. Pub includes its own copy of | |
| 9 # barback but also includes code that is run against the user's copy of barback. | |
| 10 # To ensure that those are in sync, each version of the SDK has a single | |
| 11 # version of barback that it works with. | |
| 12 # | |
| 13 # We enforce this by placing a narrow SDK constraint in each version of barback. | |
| 14 # This ensures the only barback that will be selected is the one that works | |
| 15 # with the user's SDK. Once barback is more stable, we can loosen this. | |
| 16 # | |
| 17 # Usage: publish_barback.py | |
| 18 # | |
| 19 # "pub" must be in PATH. | |
| 20 | |
| 21 import os | |
| 22 import os.path | |
| 23 import shutil | |
| 24 import sys | |
| 25 import subprocess | |
| 26 import tempfile | |
| 27 | |
| 28 import utils | |
| 29 | |
| 30 def Main(argv): | |
| 31 HOME = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) | |
| 32 BARBACK = os.path.join(HOME, 'pkg', 'barback') | |
| 33 | |
| 34 (channel, major, minor, service, qualifier) = utils.ReadVersionFile() | |
| 35 major = int(major) | |
| 36 minor = int(minor) | |
| 37 service = int(service) | |
| 38 | |
| 39 # The bleeding_edge branch has a fixed version number of 0.1.x.y. Don't allow | |
| 40 # users to publish packages from there. | |
| 41 if (major == 0 and minor <= 1) or channel == 'be': | |
| 42 print 'Error: Do not run this script from a bleeding_edge checkout.' | |
| 43 #return -1 | |
| 44 | |
| 45 # Convert the version to semver syntax. | |
| 46 version = '%d.%d.%d+%s' % (major, minor, service, qualifier) | |
| 47 | |
| 48 # Copy the package to a temp directory so we can fill in its pubspec. | |
| 49 tmpDir = tempfile.mkdtemp() | |
| 50 shutil.copytree(os.path.join(HOME, BARBACK), os.path.join(tmpDir, 'barback')) | |
| 51 | |
| 52 pubspecPath = os.path.join(tmpDir, 'barback', 'pubspec.yaml') | |
| 53 with open(pubspecPath) as pubspecFile: | |
| 54 pubspec = pubspecFile.read() | |
| 55 | |
| 56 # Fill in the SDK version constraint. It pins barback to the current version | |
| 57 # of the SDK with a small amount of wiggle room for hotfixes. | |
| 58 constraint = '>=%d.%d.%d <%d.%d.0' % (major, minor, service, major, minor + 1) | |
| 59 | |
| 60 # Fill in the SDK version constraint. | |
| 61 pubspec = pubspec.replace('$SDK_CONSTRAINT$', constraint) | |
| 62 | |
| 63 # Give barback a new version that roughly mirrors the SDK, like so: | |
| 64 # SDK 1.2.3+4 --> barback 0.12.3+4. | |
| 65 barback_version = 'version: 0.%d.%d+%s # Set by publish_barback.py.' % ( | |
| 66 10 + minor, service, qualifier) | |
| 67 pubspec = pubspec.replace( | |
| 68 'version: 0.9.0 # Replaced by publish_barback.py. Do not edit.', | |
| 69 barback_version) | |
| 70 | |
| 71 return | |
| 72 | |
| 73 with open(pubspecPath, 'w') as pubspecFile: | |
| 74 pubspecFile.write(pubspec) | |
| 75 | |
| 76 print ('Publishing barback %s with SDK constraint "%s".' % | |
| 77 (version, constraint)) | |
| 78 subprocess.call(['pub', 'lish'], cwd=os.path.join(tmpDir, 'barback')) | |
| 79 shutil.rmtree(tmpDir) | |
| 80 | |
| 81 if __name__ == '__main__': | |
| 82 sys.exit(Main(sys.argv)) | |
| OLD | NEW |