OLD | NEW |
| (Empty) |
1 #!/usr/bin/python | |
2 | |
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 | |
5 # BSD-style license that can be found in the LICENSE file. | |
6 | |
7 """ | |
8 Buildbot steps for src tarball generation and debian package generation | |
9 | |
10 Package up the src of the dart repo and create a debian package. | |
11 Archive tarball and debian package to google cloud storage. | |
12 """ | |
13 | |
14 import os | |
15 import re | |
16 import sys | |
17 | |
18 import bot | |
19 import bot_utils | |
20 | |
21 utils = bot_utils.GetUtils() | |
22 | |
23 HOST_OS = utils.GuessOS() | |
24 SRC_BUILDER = r'src-tarball-linux-(debian_wheezy|ubuntu_precise)' | |
25 | |
26 def SrcConfig(name, is_buildbot): | |
27 """Returns info for the current buildbot based on the name of the builder. | |
28 | |
29 Currently, since we only run this on linux, this is just: | |
30 - mode: always "release" | |
31 - system: always "linux" | |
32 """ | |
33 src_pattern = re.match(SRC_BUILDER, name) | |
34 if not src_pattern: | |
35 return None | |
36 return bot.BuildInfo('none', 'none', 'release', 'linux', | |
37 builder_tag=src_pattern.group(1)) | |
38 | |
39 def ArchiveArtifacts(tarfile, builddir, channel, linux_system): | |
40 namer = bot_utils.GCSNamer(channel=channel) | |
41 gsutil = bot_utils.GSUtil() | |
42 revision = utils.GetSVNRevision() | |
43 # Archive the src tar to the src dir | |
44 remote_tarfile = '/'.join([namer.src_directory(revision), | |
45 os.path.basename(tarfile)]) | |
46 gsutil.upload(tarfile, remote_tarfile, public=True) | |
47 # Archive all files except the tar file to the linux packages dir | |
48 for entry in os.listdir(builddir): | |
49 full_path = os.path.join(builddir, entry) | |
50 # We expect a flat structure, not subdirectories | |
51 assert(os.path.isfile(full_path)) | |
52 if full_path != tarfile: | |
53 package_dir = namer.linux_packages_directory(revision, linux_system) | |
54 remote_file = '/'.join([package_dir, | |
55 os.path.basename(entry)]) | |
56 gsutil.upload(full_path, remote_file, public=True) | |
57 | |
58 def SrcSteps(build_info): | |
59 # We always clobber the bot, to not leave old tarballs and packages | |
60 # floating around the out dir. | |
61 bot.Clobber(force=True) | |
62 version = utils.GetVersion() | |
63 builddir = os.path.join(bot_utils.DART_DIR, | |
64 utils.GetBuildDir(HOST_OS, HOST_OS), | |
65 'src_and_installation') | |
66 if not os.path.exists(builddir): | |
67 os.makedirs(builddir) | |
68 tarfilename = 'dart-%s.tar.gz' % version | |
69 tarfile = os.path.join(builddir, tarfilename) | |
70 | |
71 with bot.BuildStep('Create src tarball'): | |
72 args = [sys.executable, './tools/create_tarball.py', '--tar_filename', | |
73 tarfile] | |
74 print 'Building src tarball' | |
75 bot.RunProcess(args) | |
76 print 'Building Debian packages' | |
77 args = [sys.executable, './tools/create_debian_packages.py', | |
78 '--tar_filename', tarfile, | |
79 '--out_dir', builddir] | |
80 bot.RunProcess(args) | |
81 | |
82 with bot.BuildStep('Upload artifacts'): | |
83 bot_name, _ = bot.GetBotName() | |
84 channel = bot_utils.GetChannelFromName(bot_name) | |
85 if channel != bot_utils.Channel.BLEEDING_EDGE: | |
86 ArchiveArtifacts(tarfile, builddir, channel, build_info.builder_tag) | |
87 else: | |
88 print 'Not uploading artifacts on bleeding edge' | |
89 | |
90 if __name__ == '__main__': | |
91 # We pass in None for build_step to avoid building the sdk. | |
92 bot.RunBot(SrcConfig, SrcSteps, build_step=None) | |
OLD | NEW |