| OLD | NEW |
| 1 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import autoupdate | 5 import autoupdate |
| 6 import buildutil | 6 import buildutil |
| 7 import optparse | 7 import optparse |
| 8 import os | 8 import os |
| 9 import SimpleHTTPServer | 9 import SimpleHTTPServer |
| 10 import sys |
| 10 import web | 11 import web |
| 11 import sys | |
| 12 | 12 |
| 13 global updater | 13 global updater |
| 14 updater = None | 14 updater = None |
| 15 | 15 |
| 16 global buildbot | 16 global buildbot |
| 17 buildbot = None | 17 buildbot = None |
| 18 | 18 |
| 19 class index: | 19 class index: |
| 20 def GET(self): | 20 def GET(self): |
| 21 pkgs = buildbot.GetPackages() | 21 pkgs = buildbot.GetPackages() |
| (...skipping 18 matching lines...) Expand all Loading... |
| 40 emerge_command = 'emerge-%s %s' % (input.board, input.pkg) | 40 emerge_command = 'emerge-%s %s' % (input.board, input.pkg) |
| 41 err = os.system(emerge_command) | 41 err = os.system(emerge_command) |
| 42 if err != 0: | 42 if err != 0: |
| 43 raise Exception('failed to execute %s' % emerge_command) | 43 raise Exception('failed to execute %s' % emerge_command) |
| 44 | 44 |
| 45 if __name__ == '__main__': | 45 if __name__ == '__main__': |
| 46 usage = 'usage: %prog [options]' | 46 usage = 'usage: %prog [options]' |
| 47 parser = optparse.OptionParser(usage) | 47 parser = optparse.OptionParser(usage) |
| 48 parser.add_option('-a', '--archive_dir', dest='archive_dir', | 48 parser.add_option('-a', '--archive_dir', dest='archive_dir', |
| 49 help='serve archived builds only.') | 49 help='serve archived builds only.') |
| 50 parser.add_option('--factory_config', dest='factory_config', |
| 51 help='Config file for serving images from factory floor.') |
| 50 parser.add_option('-t', action='store_true', dest='test_image') | 52 parser.add_option('-t', action='store_true', dest='test_image') |
| 51 parser.add_option('-u', '--urlbase', dest='urlbase', | 53 parser.add_option('-u', '--urlbase', dest='urlbase', |
| 52 help='base URL, other than devserver, for update images.') | 54 help='base URL, other than devserver, for update images.') |
| 55 parser.add_option('--validate_factory_config', action="store_true", |
| 56 dest='validate_factory_config', |
| 57 help='Validate factory config file, then exit.') |
| 53 options, args = parser.parse_args() | 58 options, args = parser.parse_args() |
| 54 # clean up the args, due to httpserver's hardcoded use of sys.argv | 59 # clean up the args, due to httpserver's hardcoded use of sys.argv |
| 55 if options.archive_dir: | 60 if options.archive_dir: |
| 56 sys.argv.remove('-a') | 61 sys.argv.remove('-a') |
| 62 sys.argv.remove('--archive_dir') |
| 57 sys.argv.remove(options.archive_dir) | 63 sys.argv.remove(options.archive_dir) |
| 64 if options.factory_config: |
| 65 sys.argv.remove('--factory_config') |
| 66 sys.argv.remove(options.factory_config) |
| 58 if options.test_image: | 67 if options.test_image: |
| 59 sys.argv.remove('-t') | 68 sys.argv.remove('-t') |
| 60 if options.urlbase: | 69 if options.urlbase: |
| 61 sys.argv.remove('-u') | 70 sys.argv.remove('-u') |
| 62 sys.argv.remove(options.urlbase) | 71 sys.argv.remove(options.urlbase) |
| 72 if options.validate_factory_config: |
| 73 sys.argv.remove('--validate_factory_config') |
| 63 | 74 |
| 64 root_dir = os.path.realpath('%s/../..' % | 75 root_dir = os.path.realpath('%s/../..' % |
| 65 os.path.dirname(os.path.abspath(sys.argv[0]))) | 76 os.path.dirname(os.path.abspath(sys.argv[0]))) |
| 66 if options.archive_dir: | 77 if options.archive_dir: |
| 67 static_dir = os.path.realpath(options.archive_dir) | 78 static_dir = os.path.realpath(options.archive_dir) |
| 68 assert os.path.exists(static_dir), '%s must exist.' % options.archive_dir | 79 assert os.path.exists(static_dir), '%s must exist.' % options.archive_dir |
| 69 web.debug('using archive dir: %s' % static_dir) | 80 web.debug('using archive dir: %s' % static_dir) |
| 70 else: | 81 else: |
| 71 static_dir = os.path.realpath('%s/static' % | 82 static_dir = os.path.realpath('%s/static' % |
| 72 os.path.dirname(os.path.abspath(sys.argv[0]))) | 83 os.path.dirname(os.path.abspath(sys.argv[0]))) |
| 73 web.debug('dev root is %s' % root_dir) | 84 web.debug('dev root is %s' % root_dir) |
| 74 os.system('mkdir -p %s' % static_dir) | 85 os.system('mkdir -p %s' % static_dir) |
| 75 web.debug('Serving images from %s' % static_dir) | 86 web.debug('Serving images from %s' % static_dir) |
| 76 | 87 |
| 77 updater = autoupdate.Autoupdate(root_dir=root_dir, | 88 updater = autoupdate.Autoupdate( |
| 78 static_dir=static_dir, | 89 root_dir=root_dir, |
| 79 serve_only=options.archive_dir, | 90 static_dir=static_dir, |
| 80 urlbase=options.urlbase, | 91 serve_only=options.archive_dir, |
| 81 test_image=options.test_image) | 92 urlbase=options.urlbase, |
| 93 test_image=options.test_image, |
| 94 factory_config_path=options.factory_config, |
| 95 validate_factory_config=options.validate_factory_config) |
| 96 if options.validate_factory_config: |
| 97 sys.exit(0) |
| 82 urls = ('/', 'index', | 98 urls = ('/', 'index', |
| 83 '/update', 'update', | 99 '/update', 'update', |
| 84 '/update/(.+)', 'update', | 100 '/update/(.+)', 'update', |
| 85 '/webbuild', 'webbuild', | 101 '/webbuild', 'webbuild', |
| 86 '/build', 'build') | 102 '/build', 'build') |
| 87 | 103 |
| 88 app = web.application(urls, globals(), autoreload=True) | 104 app = web.application(urls, globals(), autoreload=True) |
| 89 render = web.template.render('templates/') | 105 render = web.template.render('templates/') |
| 90 app.run() | 106 app.run() |
| OLD | NEW |