Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: bin/cbuildbot.py

Issue 5854001: Add package.keywords logic to build version of chrome we specify. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Fix todo Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """CBuildbot is wrapper around the build process used by the pre-flight queue""" 7 """CBuildbot is wrapper around the build process used by the pre-flight queue"""
8 8
9 import errno 9 import errno
10 import heapq 10 import heapq
11 import re 11 import re
12 import optparse 12 import optparse
13 import os 13 import os
14 import shutil 14 import shutil
15 import sys 15 import sys
16 16
17 import cbuildbot_comm 17 import cbuildbot_comm
18 from cbuildbot_config import config 18 from cbuildbot_config import config
19 19
20 sys.path.append(os.path.join(os.path.dirname(__file__), '../lib')) 20 sys.path.append(os.path.join(os.path.dirname(__file__), '../lib'))
21 from cros_build_lib import (Die, Info, ReinterpretPathForChroot, RunCommand, 21 from cros_build_lib import (Die, Info, ReinterpretPathForChroot, RunCommand,
22 Warning) 22 Warning)
23 23
24 _DEFAULT_RETRIES = 3 24 _DEFAULT_RETRIES = 3
25 _PACKAGE_FILE = '%(buildroot)s/src/scripts/cbuildbot_package.list' 25 _PACKAGE_FILE = '%(buildroot)s/src/scripts/cbuildbot_package.list'
26 ARCHIVE_BASE = '/var/www/archive' 26 ARCHIVE_BASE = '/var/www/archive'
27 ARCHIVE_COUNT = 10 27 ARCHIVE_COUNT = 10
28 PUBLIC_OVERLAY = '%(buildroot)s/src/third_party/chromiumos-overlay' 28 PUBLIC_OVERLAY = '%(buildroot)s/src/third_party/chromiumos-overlay'
29 PRIVATE_OVERLAY = '%(buildroot)s/src/private-overlays/chromeos-overlay' 29 PRIVATE_OVERLAY = '%(buildroot)s/src/private-overlays/chromeos-overlay'
30 CHROME_KEYWORDS_FILE = ('/build/%(board)s/etc/portage/package.keywords/chrome')
30 31
31 # Currently, both the full buildbot and the preflight buildbot store their 32 # Currently, both the full buildbot and the preflight buildbot store their
32 # data in a variable named PORTAGE_BINHOST, but they're in different files. 33 # data in a variable named PORTAGE_BINHOST, but they're in different files.
33 # We're planning on joining the two files soon and renaming the full binhost 34 # We're planning on joining the two files soon and renaming the full binhost
34 # to FULL_BINHOST. 35 # to FULL_BINHOST.
35 _FULL_BINHOST = 'PORTAGE_BINHOST' 36 _FULL_BINHOST = 'PORTAGE_BINHOST'
36 _PREFLIGHT_BINHOST = 'PORTAGE_BINHOST' 37 _PREFLIGHT_BINHOST = 'PORTAGE_BINHOST'
37 38
38 # ======================== Utility functions ================================ 39 # ======================== Utility functions ================================
39 40
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 '--board=%s' % board, 211 '--board=%s' % board,
211 '--tracking_branch=%s' % tracking_branch, 212 '--tracking_branch=%s' % tracking_branch,
212 '--overlays=%s' % ':'.join(chroot_overlays), 213 '--overlays=%s' % ':'.join(chroot_overlays),
213 '--packages=%s' % ':'.join(packages), 214 '--packages=%s' % ':'.join(packages),
214 '--drop_file=%s' % ReinterpretPathForChroot(_PACKAGE_FILE % 215 '--drop_file=%s' % ReinterpretPathForChroot(_PACKAGE_FILE %
215 {'buildroot': buildroot}), 216 {'buildroot': buildroot}),
216 'commit'], 217 'commit'],
217 cwd=cwd, enter_chroot=True) 218 cwd=cwd, enter_chroot=True)
218 219
219 220
220 def _MarkChromeAsStable(buildroot, tracking_branch, chrome_rev): 221 def _MarkChromeAsStable(buildroot, tracking_branch, chrome_rev, board):
221 """Returns the portage atom for the revved chrome ebuild - see man emerge.""" 222 """Returns the portage atom for the revved chrome ebuild - see man emerge."""
222 cwd = os.path.join(buildroot, 'src', 'scripts') 223 cwd = os.path.join(buildroot, 'src', 'scripts')
223 portage_atom_string = RunCommand(['bin/cros_mark_chrome_as_stable', 224 portage_atom_string = RunCommand(['bin/cros_mark_chrome_as_stable',
224 '--tracking_branch=%s' % tracking_branch, 225 '--tracking_branch=%s' % tracking_branch,
225 chrome_rev], cwd=cwd, redirect_stdout=True, 226 chrome_rev], cwd=cwd, redirect_stdout=True,
226 enter_chroot=True).rstrip() 227 enter_chroot=True).rstrip()
227 if not portage_atom_string: 228 if not portage_atom_string:
228 Info('Found nothing to rev.') 229 Info('Found nothing to rev.')
229 return None 230 return None
230 else: 231 else:
231 return portage_atom_string.split('=')[1] 232 chrome_atom = portage_atom_string.split('=')[1]
233 # TODO(sosa): Workaround to build unstable chrome ebuild we uprevved.
234 RunCommand(['sudo', 'tee', CHROME_KEYWORDS_FILE % {'board': board}],
235 input='=%s\n' % chrome_atom, enter_chroot=True,
236 cwd=cwd)
237 return chrome_atom
232 238
233 239
234 def _UprevAllPackages(buildroot, tracking_branch, board, overlays): 240 def _UprevAllPackages(buildroot, tracking_branch, board, overlays):
235 """Uprevs all packages that have been updated since last uprev.""" 241 """Uprevs all packages that have been updated since last uprev."""
236 cwd = os.path.join(buildroot, 'src', 'scripts') 242 cwd = os.path.join(buildroot, 'src', 'scripts')
237 chroot_overlays = [ReinterpretPathForChroot(path) for path in overlays] 243 chroot_overlays = [ReinterpretPathForChroot(path) for path in overlays]
238 RunCommand(['./cros_mark_as_stable', '--all', 244 RunCommand(['./cros_mark_as_stable', '--all',
239 '--board=%s' % board, 245 '--board=%s' % board,
240 '--overlays=%s' % ':'.join(chroot_overlays), 246 '--overlays=%s' % ':'.join(chroot_overlays),
241 '--tracking_branch=%s' % tracking_branch, 247 '--tracking_branch=%s' % tracking_branch,
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 cmd = ['./build_packages'] 415 cmd = ['./build_packages']
410 if emptytree: 416 if emptytree:
411 cmd.insert(0, 'EXTRA_BOARD_FLAGS=--emptytree') 417 cmd.insert(0, 'EXTRA_BOARD_FLAGS=--emptytree')
412 418
413 RunCommand(cmd, cwd=cwd, enter_chroot=True) 419 RunCommand(cmd, cwd=cwd, enter_chroot=True)
414 420
415 421
416 def _BuildChrome(buildroot, board, chrome_atom_to_build): 422 def _BuildChrome(buildroot, board, chrome_atom_to_build):
417 """Wrapper for emerge call to build Chrome.""" 423 """Wrapper for emerge call to build Chrome."""
418 cwd = os.path.join(buildroot, 'src', 'scripts') 424 cwd = os.path.join(buildroot, 'src', 'scripts')
419 RunCommand(['ACCEPT_KEYWORDS="* ~*"', 'emerge-%s' % board, 425 RunCommand(['emerge-%s' % board,
420 '=%s' % chrome_atom_to_build], 426 '=%s' % chrome_atom_to_build],
421 cwd=cwd, enter_chroot=True) 427 cwd=cwd, enter_chroot=True)
422 428
423 429
424 def _EnableLocalAccount(buildroot): 430 def _EnableLocalAccount(buildroot):
425 cwd = os.path.join(buildroot, 'src', 'scripts') 431 cwd = os.path.join(buildroot, 'src', 'scripts')
426 # Set local account for test images. 432 # Set local account for test images.
427 RunCommand(['./enable_localaccount.sh', 433 RunCommand(['./enable_localaccount.sh',
428 'chronos'], 434 'chronos'],
429 print_cmd=False, cwd=cwd) 435 print_cmd=False, cwd=cwd)
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 733
728 if not os.path.isdir(chroot_path): 734 if not os.path.isdir(chroot_path):
729 _MakeChroot(buildroot) 735 _MakeChroot(buildroot)
730 736
731 if not os.path.isdir(boardpath): 737 if not os.path.isdir(boardpath):
732 _SetupBoard(buildroot, board=buildconfig['board']) 738 _SetupBoard(buildroot, board=buildconfig['board'])
733 739
734 # Perform uprev. If chrome_uprev is set, rev Chrome ebuilds. 740 # Perform uprev. If chrome_uprev is set, rev Chrome ebuilds.
735 if options.chrome_rev: 741 if options.chrome_rev:
736 chrome_atom_to_build = _MarkChromeAsStable(buildroot, tracking_branch, 742 chrome_atom_to_build = _MarkChromeAsStable(buildroot, tracking_branch,
737 options.chrome_rev) 743 options.chrome_rev, board)
738 # If we found nothing to rev, we're done here. 744 # If we found nothing to rev, we're done here.
739 if not chrome_atom_to_build: 745 if not chrome_atom_to_build:
740 return 746 return
741 747
742 elif buildconfig['uprev']: 748 elif buildconfig['uprev']:
743 _UprevPackages(buildroot, tracking_branch, revisionfile, 749 _UprevPackages(buildroot, tracking_branch, revisionfile,
744 buildconfig['board'], rev_overlays) 750 buildconfig['board'], rev_overlays)
745 751
746 _EnableLocalAccount(buildroot) 752 _EnableLocalAccount(buildroot)
747 # Doesn't rebuild without acquiring more source. 753 # Doesn't rebuild without acquiring more source.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 except: 798 except:
793 # Send failure to master bot. 799 # Send failure to master bot.
794 if not buildconfig['master'] and buildconfig['important']: 800 if not buildconfig['master'] and buildconfig['important']:
795 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) 801 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED)
796 802
797 raise 803 raise
798 804
799 805
800 if __name__ == '__main__': 806 if __name__ == '__main__':
801 main() 807 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698