Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2009-2011 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009-2011 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 """Package builder for the dev server.""" | 7 """Package builder for the dev server.""" |
| 8 import os | 8 import os |
| 9 import subprocess | 9 import subprocess |
| 10 import sys | 10 import sys |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 return pkg in _OutputOf([ | 44 return pkg in _OutputOf([ |
| 45 'cros_workon', '--board=' + board, 'list', '--all']) | 45 'cros_workon', '--board=' + board, 'list', '--all']) |
| 46 | 46 |
| 47 def SetError(self, text): | 47 def SetError(self, text): |
| 48 cherrypy.response.status = 500 | 48 cherrypy.response.status = 500 |
| 49 cherrypy.log(text, 'BUILD') | 49 cherrypy.log(text, 'BUILD') |
| 50 return text | 50 return text |
| 51 | 51 |
| 52 def Build(self, board, pkg, additional_args): | 52 def Build(self, board, pkg, additional_args): |
| 53 """Handles a build request from the cherrypy server.""" | 53 """Handles a build request from the cherrypy server.""" |
| 54 cherrypy.log('Additional build request arguments: '+ str(additional_args), | 54 cherrypy.log('Additional build request arguments: ' + str(additional_args), |
| 55 'BUILD') | 55 'BUILD') |
| 56 | 56 |
| 57 original_use = os.environ.get('USE', '') | 57 original_use = os.environ.get('USE', '') |
| 58 if 'use' in additional_args: | 58 if 'use' in additional_args: |
| 59 os.environ['USE'] = original_use + ' ' + additional_args['use'] | 59 os.environ['USE'] = original_use + ' ' + additional_args['use'] |
| 60 cherrypy.log('USE flags modified to ' + os.environ['USE'], 'BUILD') | 60 cherrypy.log('USE flags modified to ' + os.environ['USE'], 'BUILD') |
| 61 | 61 |
| 62 if 'features' in additional_args: | |
| 63 os.environ['FEATURES'] = original_use + ' ' + additional_args['features'] | |
|
rochberg
2011/04/09 19:59:34
= original_features + ...
Probably best to switch
| |
| 64 cherrypy.log('FEATURES flags modified to ' + os.environ['FEATURES'], | |
| 65 'BUILD') | |
| 66 | |
| 62 try: | 67 try: |
| 63 if (self._ShouldBeWorkedOn(board, pkg) and | 68 if (self._ShouldBeWorkedOn(board, pkg) and |
| 64 not additional_args.get('accept_stable')): | 69 not additional_args.get('accept_stable')): |
| 65 return self.SetError( | 70 return self.SetError( |
| 66 'Package is not cros_workon\'d on the devserver machine.\n' | 71 'Package is not cros_workon\'d on the devserver machine.\n' |
| 67 'Either start working on the package or pass --accept_stable ' | 72 'Either start working on the package or pass --accept_stable ' |
| 68 'to gmerge') | 73 'to gmerge') |
| 69 | 74 |
| 70 rc = subprocess.call(['emerge-%s' % board, pkg]) | 75 rc = subprocess.call(['emerge-%s' % board, pkg]) |
| 71 if rc != 0: | 76 if rc != 0: |
| 72 return self.SetError('Could not emerge ' + pkg) | 77 return self.SetError('Could not emerge ' + pkg) |
| 73 | 78 |
| 74 cherrypy.log('ecleaning %s' % pkg, 'BUILD') | 79 cherrypy.log('ecleaning %s' % pkg, 'BUILD') |
| 75 rc = subprocess.call(['eclean-' + board, '-d', 'packages']) | 80 rc = subprocess.call(['eclean-' + board, '-d', 'packages']) |
| 76 if rc != 0: | 81 if rc != 0: |
| 77 return self.SetError('eclean failed') | 82 return self.SetError('eclean failed') |
| 78 | 83 |
| 79 cherrypy.log('eclean complete %s' % pkg, 'BUILD') | 84 cherrypy.log('eclean complete %s' % pkg, 'BUILD') |
| 80 return 'Success\n' | 85 return 'Success\n' |
| 81 except OSError, e: | 86 except OSError, e: |
| 82 return self.SetError('Could not execute build command: ' + str(e)) | 87 return self.SetError('Could not execute build command: ' + str(e)) |
| 83 finally: | 88 finally: |
| 84 os.environ['USE'] = original_use | 89 os.environ['USE'] = original_use |
|
rochberg
2011/04/09 19:59:34
Should also restore FEATURES, or, better yet, be m
| |
| OLD | NEW |