OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2014, 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 | 7 |
8 # Script to build a tarball of the Dart source. | 8 # Script to build a tarball of the Dart source. |
9 # | 9 # |
10 # The tarball includes all the source needed to build Dart. This | 10 # The tarball includes all the source needed to build Dart. This |
11 # includes source in third_party. As part of creating the tarball the | 11 # includes source in third_party. As part of creating the tarball the |
12 # files used to build Debian packages are copied to a top-level debian | 12 # files used to build Debian packages are copied to a top-level debian |
13 # directory. This makes it easy to build Debian packages from the | 13 # directory. This makes it easy to build Debian packages from the |
14 # tarball. | 14 # tarball. |
15 # | 15 # |
16 # For building a Debian package one need to the tarball to follow the | 16 # For building a Debian package one need to the tarball to follow the |
17 # Debian naming rules upstream tar files. | 17 # Debian naming rules upstream tar files. |
18 # | 18 # |
19 # $ mv dart-XXX.tar.gz dart_XXX.orig.tar.gz | 19 # $ mv dart-XXX.tar.gz dart_XXX.orig.tar.gz |
20 # $ tar xf dart_XXX.orig.tar.gz | 20 # $ tar xf dart_XXX.orig.tar.gz |
21 # $ cd dart_XXX | 21 # $ cd dart_XXX |
22 # $ debuild -us -uc | 22 # $ debuild -us -uc |
23 | 23 |
24 import datetime | 24 import datetime |
25 import optparse | 25 import optparse |
26 import sys | 26 import sys |
27 import tarfile | 27 import tarfile |
| 28 from os import listdir |
| 29 from os.path import join, split, abspath |
| 30 |
28 import utils | 31 import utils |
29 | 32 |
30 from os import listdir, makedirs | |
31 from os.path import join, exists, split, dirname, abspath | |
32 | 33 |
33 HOST_OS = utils.GuessOS() | 34 HOST_OS = utils.GuessOS() |
34 DART_DIR = abspath(join(__file__, '..', '..')) | 35 DART_DIR = abspath(join(__file__, '..', '..')) |
35 # Flags. | 36 # Flags. |
36 verbose = False | 37 verbose = False |
37 | 38 |
38 # Name of the dart directory when unpacking the tarball. | 39 # Name of the dart directory when unpacking the tarball. |
39 versiondir = '' | 40 versiondir = '' |
40 | 41 |
41 # Ignore Git/SVN files, checked-in binaries, backup files, etc.. | 42 # Ignore Git/SVN files, checked-in binaries, backup files, etc.. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 109 |
109 def CreateTarball(tarfilename): | 110 def CreateTarball(tarfilename): |
110 global ignoredPaths # Used for adding the output directory. | 111 global ignoredPaths # Used for adding the output directory. |
111 # Generate the name of the tarfile | 112 # Generate the name of the tarfile |
112 version = utils.GetVersion() | 113 version = utils.GetVersion() |
113 global versiondir | 114 global versiondir |
114 versiondir = 'dart-%s' % version | 115 versiondir = 'dart-%s' % version |
115 debian_dir = 'tools/linux_dist_support/debian' | 116 debian_dir = 'tools/linux_dist_support/debian' |
116 # Don't include the build directory in the tarball (ignored paths | 117 # Don't include the build directory in the tarball (ignored paths |
117 # are relative to DART_DIR). | 118 # are relative to DART_DIR). |
118 builddir = utils.GetBuildDir(HOST_OS, HOST_OS) | 119 builddir = utils.GetBuildDir(HOST_OS) |
119 ignoredPaths.append(builddir) | 120 ignoredPaths.append(builddir) |
120 | 121 |
121 print 'Creating tarball: %s' % tarfilename | 122 print 'Creating tarball: %s' % tarfilename |
122 with tarfile.open(tarfilename, mode='w:gz') as tar: | 123 with tarfile.open(tarfilename, mode='w:gz') as tar: |
123 for f in listdir(DART_DIR): | 124 for f in listdir(DART_DIR): |
124 tar.add(join(DART_DIR, f), filter=Filter) | 125 tar.add(join(DART_DIR, f), filter=Filter) |
125 for f in listdir(join(DART_DIR, debian_dir)): | 126 for f in listdir(join(DART_DIR, debian_dir)): |
126 tar.add(join(DART_DIR, debian_dir, f), | 127 tar.add(join(DART_DIR, debian_dir, f), |
127 arcname='%s/debian/%s' % (versiondir, f)) | 128 arcname='%s/debian/%s' % (versiondir, f)) |
128 | 129 |
129 with utils.TempDir() as temp_dir: | 130 with utils.TempDir() as temp_dir: |
130 # Generate and add debian/copyright | 131 # Generate and add debian/copyright |
131 copyright = join(temp_dir, 'copyright') | 132 copyright_file = join(temp_dir, 'copyright') |
132 GenerateCopyright(copyright) | 133 GenerateCopyright(copyright_file) |
133 tar.add(copyright, arcname='%s/debian/copyright' % versiondir) | 134 tar.add(copyright_file, arcname='%s/debian/copyright' % versiondir) |
134 | 135 |
135 # Generate and add debian/changelog | 136 # Generate and add debian/changelog |
136 change_log = join(temp_dir, 'changelog') | 137 change_log = join(temp_dir, 'changelog') |
137 GenerateChangeLog(change_log, version) | 138 GenerateChangeLog(change_log, version) |
138 tar.add(change_log, arcname='%s/debian/changelog' % versiondir) | 139 tar.add(change_log, arcname='%s/debian/changelog' % versiondir) |
139 | 140 |
140 # For bleeding_edge add the SVN_REVISION file. | 141 # For bleeding_edge add the SVN_REVISION file. |
141 if utils.GetChannel() == 'be': | 142 if utils.GetChannel() == 'be': |
142 svn_revision = join(temp_dir, 'SVN_REVISION') | 143 svn_revision = join(temp_dir, 'SVN_REVISION') |
143 GenerateSvnRevision(svn_revision, utils.GetSVNRevision()) | 144 GenerateSvnRevision(svn_revision, utils.GetSVNRevision()) |
144 tar.add(svn_revision, arcname='%s/dart/tools/SVN_REVISION' % versiondir) | 145 tar.add(svn_revision, arcname='%s/dart/tools/SVN_REVISION' % versiondir) |
145 | 146 |
146 def Main(): | 147 def Main(): |
147 if HOST_OS != 'linux': | 148 if HOST_OS != 'linux': |
148 print 'Tarball can only be created on linux' | 149 print 'Tarball can only be created on linux' |
149 return -1 | 150 return -1 |
150 | 151 |
151 # Parse the options. | 152 # Parse the options. |
152 parser = BuildOptions() | 153 parser = BuildOptions() |
153 (options, args) = parser.parse_args() | 154 (options, args) = parser.parse_args() |
154 if options.verbose: | 155 if options.verbose: |
155 global verbose | 156 global verbose |
156 verbose = True | 157 verbose = True |
157 | 158 |
158 tar_filename = options.tar_filename | 159 tar_filename = options.tar_filename |
159 if not tar_filename: | 160 if not tar_filename: |
160 tar_filename = join(DART_DIR, | 161 tar_filename = join(DART_DIR, |
161 utils.GetBuildDir(HOST_OS, HOST_OS), | 162 utils.GetBuildDir(HOST_OS), |
162 'dart-%s.tar.gz' % utils.GetVersion()) | 163 'dart-%s.tar.gz' % utils.GetVersion()) |
163 | 164 |
164 CreateTarball(tar_filename) | 165 CreateTarball(tar_filename) |
165 | 166 |
166 if __name__ == '__main__': | 167 if __name__ == '__main__': |
167 sys.exit(Main()) | 168 sys.exit(Main()) |
OLD | NEW |