OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/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 Buildbot steps for src tarball generation and debian package generation | 8 Buildbot steps for src tarball generation and debian package generation |
9 | 9 |
10 Package up the src of the dart repo and create a debian package. | 10 Package up the src of the dart repo and create a debian package. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 for entry in os.listdir(builddir): | 48 for entry in os.listdir(builddir): |
49 full_path = os.path.join(builddir, entry) | 49 full_path = os.path.join(builddir, entry) |
50 # We expect a flat structure, not subdirectories | 50 # We expect a flat structure, not subdirectories |
51 assert(os.path.isfile(full_path)) | 51 assert(os.path.isfile(full_path)) |
52 if full_path != tarfile: | 52 if full_path != tarfile: |
53 package_dir = namer.linux_packages_directory(revision, linux_system) | 53 package_dir = namer.linux_packages_directory(revision, linux_system) |
54 remote_file = '/'.join([package_dir, | 54 remote_file = '/'.join([package_dir, |
55 os.path.basename(entry)]) | 55 os.path.basename(entry)]) |
56 gsutil.upload(full_path, remote_file, public=True) | 56 gsutil.upload(full_path, remote_file, public=True) |
57 | 57 |
58 def InstallFromDep(builddir): | |
59 for entry in os.listdir(builddir): | |
60 if entry.endswith("_amd64.deb"): | |
Søren Gjesse
2014/05/08 13:32:56
Only 2 space indent.
ricow1
2014/05/08 17:00:04
Done.
| |
61 path = os.path.join(builddir, entry) | |
62 Run(['sudo', 'dpkg', '-i', path]) | |
63 | |
64 def UninstallDart(): | |
65 Run(['sudo', 'dpkg', '-r', 'dart']) | |
66 | |
67 def CreateDartTestFile(tempdir): | |
Søren Gjesse
2014/05/08 13:32:56
Only 2 space indent.
ricow1
2014/05/08 17:00:04
Done.
| |
68 filename = os.path.join(tempdir, 'test.dart') | |
69 with open(filename, 'w') as f: | |
70 f.write('import "dart:html";\n\n') | |
71 f.write('void main() {\n') | |
72 f.write(' print("Hello world");\n') | |
73 f.write('}') | |
74 return filename | |
75 | |
76 def Run(args): | |
77 print "Running: %s" % ' '.join(args) | |
78 bot.RunProcess(args) | |
79 | |
80 def TestInstallation(assume_installed=True): | |
81 paths = ['/usr/bin/dart'] | |
82 for tool in ['dart2js', 'pub', 'dart', 'dartanalyzer']: | |
83 paths.append(os.path.join('/usr/lib/dart/bin', tool)) | |
84 for path in paths: | |
85 if os.path.exists(path): | |
86 if not assume_installed: | |
87 print 'Assumed not installed, found %s' % path | |
88 sys.exit(1) | |
89 else: | |
90 if assume_installed: | |
91 print 'Assumed installed, but could not find %s' % path | |
92 sys.exit(1) | |
93 | |
58 def SrcSteps(build_info): | 94 def SrcSteps(build_info): |
59 # We always clobber the bot, to not leave old tarballs and packages | 95 # We always clobber the bot, to not leave old tarballs and packages |
60 # floating around the out dir. | 96 # floating around the out dir. |
61 bot.Clobber(force=True) | 97 bot.Clobber(force=True) |
98 | |
62 version = utils.GetVersion() | 99 version = utils.GetVersion() |
63 builddir = os.path.join(bot_utils.DART_DIR, | 100 builddir = os.path.join(bot_utils.DART_DIR, |
64 utils.GetBuildDir(HOST_OS, HOST_OS), | 101 utils.GetBuildDir(HOST_OS, HOST_OS), |
65 'src_and_installation') | 102 'src_and_installation') |
103 | |
66 if not os.path.exists(builddir): | 104 if not os.path.exists(builddir): |
67 os.makedirs(builddir) | 105 os.makedirs(builddir) |
68 tarfilename = 'dart-%s.tar.gz' % version | 106 tarfilename = 'dart-%s.tar.gz' % version |
69 tarfile = os.path.join(builddir, tarfilename) | 107 tarfile = os.path.join(builddir, tarfilename) |
70 | 108 |
71 with bot.BuildStep('Validating linux system'): | 109 with bot.BuildStep('Validating linux system'): |
72 print 'Validating that we are on %s' % build_info.builder_tag | 110 print 'Validating that we are on %s' % build_info.builder_tag |
73 args = ['cat', '/etc/os-release'] | 111 args = ['cat', '/etc/os-release'] |
74 (stdout, stderr, exitcode) = bot_utils.run(args) | 112 (stdout, stderr, exitcode) = bot_utils.run(args) |
75 if exitcode != 0: | 113 if exitcode != 0: |
76 print "Could not find linux system, exiting" | 114 print "Could not find linux system, exiting" |
77 sys.exit(1) | 115 sys.exit(1) |
78 | 116 |
79 if build_info.builder_tag == "debian_wheezy": | 117 if build_info.builder_tag == "debian_wheezy": |
80 if not "wheezy" in stdout: | 118 if not "wheezy" in stdout: |
81 print "Trying to build debian bits on a non debian system" | 119 print "Trying to build debian bits on a non debian system" |
82 sys.exit(1) | 120 sys.exit(1) |
83 if build_info.builder_tag == "ubuntu_precise": | 121 if build_info.builder_tag == "ubuntu_precise": |
84 if not "precise" in stdout: | 122 if not "precise" in stdout: |
85 print "Trying to build ubuntu bits on a non ubuntu system" | 123 print "Trying to build ubuntu bits on a non ubuntu system" |
86 sys.exit(1) | 124 sys.exit(1) |
87 | 125 |
88 with bot.BuildStep('Create src tarball'): | 126 with bot.BuildStep('Create src tarball'): |
89 args = [sys.executable, './tools/create_tarball.py', '--tar_filename', | |
90 tarfile] | |
91 print 'Building src tarball' | 127 print 'Building src tarball' |
92 bot.RunProcess(args) | 128 Run([sys.executable, './tools/create_tarball.py', |
129 '--tar_filename', tarfile]) | |
130 | |
93 print 'Building Debian packages' | 131 print 'Building Debian packages' |
94 args = [sys.executable, './tools/create_debian_packages.py', | 132 Run([sys.executable, './tools/create_debian_packages.py', |
95 '--tar_filename', tarfile, | 133 '--tar_filename', tarfile, |
96 '--out_dir', builddir] | 134 '--out_dir', builddir]) |
97 bot.RunProcess(args) | 135 |
98 | 136 with bot.BuildStep('Sanity check installation'): |
137 if os.path.exists('/usr/bin/dart'): | |
138 print "Dart already installled, removing" | |
139 UninstallDart() | |
140 TestInstallation(assume_installed=False) | |
141 | |
142 InstallFromDep(builddir) | |
143 TestInstallation(assume_installed=True) | |
144 | |
145 # We build the runtime target to get everything we need to test the | |
146 # standalone target. | |
147 Run([sys.executable, './tools/build.py', '-mrelease', '-ax64', 'runtime']) | |
148 # Copy in the installed binary to avoid poluting /usr/bin (and having to | |
149 # run as root) | |
150 Run(['cp', '/usr/bin/dart', 'out/ReleaseX64/dart']) | |
151 | |
152 Run([sys.executable, './tools/test.py', '-ax64', | |
153 '--mode=release', 'standalone']) | |
154 | |
155 # Sanity check dart2js and the analyzer against a hello world program | |
156 with utils.TempDir() as temp_dir: | |
157 test_file = CreateDartTestFile(temp_dir) | |
158 Run(['/usr/lib/dart/bin/dart2js', test_file]) | |
159 Run(['/usr/lib/dart/bin/dartanalyzer', test_file]) | |
160 | |
161 # Sanity check that pub can start up and print the version | |
162 Run(['/usr/lib/dart/bin/pub', '--version']) | |
163 | |
164 UninstallDart() | |
165 TestInstallation(assume_installed=False) | |
166 | |
99 with bot.BuildStep('Upload artifacts'): | 167 with bot.BuildStep('Upload artifacts'): |
100 bot_name, _ = bot.GetBotName() | 168 bot_name, _ = bot.GetBotName() |
101 channel = bot_utils.GetChannelFromName(bot_name) | 169 channel = bot_utils.GetChannelFromName(bot_name) |
102 if channel != bot_utils.Channel.BLEEDING_EDGE: | 170 if channel != bot_utils.Channel.BLEEDING_EDGE: |
103 ArchiveArtifacts(tarfile, builddir, channel, build_info.builder_tag) | 171 ArchiveArtifacts(tarfile, builddir, channel, build_info.builder_tag) |
104 else: | 172 else: |
105 print 'Not uploading artifacts on bleeding edge' | 173 print 'Not uploading artifacts on bleeding edge' |
106 | 174 |
107 if __name__ == '__main__': | 175 if __name__ == '__main__': |
108 # We pass in None for build_step to avoid building the sdk. | 176 # We pass in None for build_step to avoid building the sdk. |
109 bot.RunBot(SrcConfig, SrcSteps, build_step=None) | 177 bot.RunBot(SrcConfig, SrcSteps, build_step=None) |
OLD | NEW |