| 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. |
| 11 Archive tarball and debian package to google cloud storage. | 11 Archive tarball and debian package to google cloud storage. |
| 12 """ | 12 """ |
| 13 | 13 |
| 14 import os | 14 import os |
| 15 import re | 15 import re |
| 16 import sys | 16 import sys |
| 17 | 17 |
| 18 import bot | 18 import bot |
| 19 import bot_utils | 19 import bot_utils |
| 20 | 20 |
| 21 utils = bot_utils.GetUtils() | 21 utils = bot_utils.GetUtils() |
| 22 | 22 |
| 23 HOST_OS = utils.GuessOS() | 23 HOST_OS = utils.GuessOS() |
| 24 SRC_BUILDER = r'src-tarball-linux' | 24 SRC_BUILDER = r'src-tarball-linux-(debian_wheezy|ubuntu_precise)' |
| 25 | 25 |
| 26 def SrcConfig(name, is_buildbot): | 26 def SrcConfig(name, is_buildbot): |
| 27 """Returns info for the current buildbot based on the name of the builder. | 27 """Returns info for the current buildbot based on the name of the builder. |
| 28 | 28 |
| 29 Currently, since we only run this on linux, this is just: | 29 Currently, since we only run this on linux, this is just: |
| 30 - mode: always "release" | 30 - mode: always "release" |
| 31 - system: always "linux" | 31 - system: always "linux" |
| 32 """ | 32 """ |
| 33 src_pattern = re.match(SRC_BUILDER, name) | 33 src_pattern = re.match(SRC_BUILDER, name) |
| 34 if not src_pattern: | 34 if not src_pattern: |
| 35 return None | 35 return None |
| 36 return bot.BuildInfo('none', 'none', 'release', 'linux', |
| 37 builder_tag=src_pattern.group(1)) |
| 36 | 38 |
| 37 return bot.BuildInfo('none', 'none', 'release', 'linux') | 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) |
| 38 | 57 |
| 39 def SrcSteps(build_info): | 58 def SrcSteps(build_info): |
| 40 # We always clobber the bot, to not leave old tarballs and packages | 59 # We always clobber the bot, to not leave old tarballs and packages |
| 41 # floating around the out dir. | 60 # floating around the out dir. |
| 42 bot.Clobber(force=True) | 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 |
| 43 with bot.BuildStep('Create src tarball'): | 71 with bot.BuildStep('Create src tarball'): |
| 44 version = utils.GetVersion() | |
| 45 builddir = os.path.join(bot_utils.DART_DIR, | |
| 46 utils.GetBuildDir(HOST_OS, HOST_OS), | |
| 47 'src_and_installation') | |
| 48 if not os.path.exists(builddir): | |
| 49 os.makedirs(builddir) | |
| 50 tarfilename = 'dart-%s.tar.gz' % version | |
| 51 tarfile = os.path.join(builddir, tarfilename) | |
| 52 args = [sys.executable, './tools/create_tarball.py', '--tar_filename', | 72 args = [sys.executable, './tools/create_tarball.py', '--tar_filename', |
| 53 tarfile] | 73 tarfile] |
| 54 print 'Building src tarball' | 74 print 'Building src tarball' |
| 55 bot.RunProcess(args) | 75 bot.RunProcess(args) |
| 56 print 'Building Debian packages' | 76 print 'Building Debian packages' |
| 57 args = [sys.executable, './tools/create_debian_packages.py', | 77 args = [sys.executable, './tools/create_debian_packages.py', |
| 58 '--tar_filename', tarfile, | 78 '--tar_filename', tarfile, |
| 59 '--out_dir', builddir] | 79 '--out_dir', builddir] |
| 60 bot.RunProcess(args) | 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' |
| 61 | 89 |
| 62 if __name__ == '__main__': | 90 if __name__ == '__main__': |
| 63 # We pass in None for build_step to avoid building the sdk. | 91 # We pass in None for build_step to avoid building the sdk. |
| 64 bot.RunBot(SrcConfig, SrcSteps, build_step=None) | 92 bot.RunBot(SrcConfig, SrcSteps, build_step=None) |
| OLD | NEW |