Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import datetime | 6 import datetime |
| 7 import multiprocessing | 7 import multiprocessing |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 _HOST_TARGET = 'amd64' | 47 _HOST_TARGET = 'amd64' |
| 48 _BOARD_PATH = 'chroot/build/%(board)s' | 48 _BOARD_PATH = 'chroot/build/%(board)s' |
| 49 _BOTO_CONFIG = '/home/chrome-bot/external-boto' | 49 _BOTO_CONFIG = '/home/chrome-bot/external-boto' |
| 50 # board/board-target/version/packages/' | 50 # board/board-target/version/packages/' |
| 51 _REL_BOARD_PATH = 'board/%(board)s/%(version)s/packages' | 51 _REL_BOARD_PATH = 'board/%(board)s/%(version)s/packages' |
| 52 # host/host-target/version/packages/' | 52 # host/host-target/version/packages/' |
| 53 _REL_HOST_PATH = 'host/%(target)s/%(version)s/packages' | 53 _REL_HOST_PATH = 'host/%(target)s/%(version)s/packages' |
| 54 # Private overlays to look at for builds to filter | 54 # Private overlays to look at for builds to filter |
| 55 # relative to build path | 55 # relative to build path |
| 56 _PRIVATE_OVERLAY_DIR = 'src/private-overlays' | 56 _PRIVATE_OVERLAY_DIR = 'src/private-overlays' |
| 57 _BINHOST_BASE_DIR = 'src/overlays' | |
| 58 _BINHOST_BASE_URL = 'http://commondatastorage.googleapis.com/chromeos-prebuilt' | 57 _BINHOST_BASE_URL = 'http://commondatastorage.googleapis.com/chromeos-prebuilt' |
| 59 _PREBUILT_BASE_DIR = 'src/third_party/chromiumos-overlay/chromeos/config/' | 58 _PREBUILT_BASE_DIR = 'src/third_party/chromiumos-overlay/chromeos/config/' |
| 60 # Created in the event of new host targets becoming available | 59 # Created in the event of new host targets becoming available |
| 61 _PREBUILT_MAKE_CONF = {'amd64': os.path.join(_PREBUILT_BASE_DIR, | 60 _PREBUILT_MAKE_CONF = {'amd64': os.path.join(_PREBUILT_BASE_DIR, |
| 62 'make.conf.amd64-host')} | 61 'make.conf.amd64-host')} |
| 63 _BINHOST_CONF_DIR = 'src/third_party/chromiumos-overlay/chromeos/binhost' | 62 _BINHOST_CONF_DIR = 'src/third_party/chromiumos-overlay/chromeos/binhost' |
| 64 | 63 |
| 65 | 64 |
| 66 class FiltersEmpty(Exception): | 65 class FiltersEmpty(Exception): |
| 67 """Raised when filters are used but none are found.""" | 66 """Raised when filters are used but none are found.""" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 upload_files = {} | 316 upload_files = {} |
| 318 for pkg in pkgs: | 317 for pkg in pkgs: |
| 319 suffix = pkg['CPV'] + '.tbz2' | 318 suffix = pkg['CPV'] + '.tbz2' |
| 320 local_path = os.path.join(base_local_path, suffix) | 319 local_path = os.path.join(base_local_path, suffix) |
| 321 assert os.path.exists(local_path) | 320 assert os.path.exists(local_path) |
| 322 remote_path = '%s/%s' % (base_remote_path.rstrip('/'), suffix) | 321 remote_path = '%s/%s' % (base_remote_path.rstrip('/'), suffix) |
| 323 upload_files[local_path] = remote_path | 322 upload_files[local_path] = remote_path |
| 324 | 323 |
| 325 return upload_files | 324 return upload_files |
| 326 | 325 |
| 326 def GetBoardPathFromCrosOverlayList(build_path, target): | |
| 327 """Use the cros_overlay_list to determine the path to the board overlay | |
| 328 Args: | |
| 329 build_path: The path to the root of the build directory | |
| 330 target: The target that we are looking for, could consist of board and | |
| 331 board_variant, we handle that properly | |
| 332 Returns: | |
| 333 The last line from cros_overlay_list as a string | |
| 334 """ | |
| 335 script_dir = os.path.join(build_path, 'src/scripts/bin') | |
| 336 cmd = ['./cros_overlay_list'] | |
| 337 if re.match('.*?_.*', target): | |
|
sosa
2011/01/19 21:51:15
is this true? It looks like variants are board (w
scottz
2011/01/19 22:11:06
Not in this script, in cbuild and archive_build we
| |
| 338 (board, variant) = target.split('_') | |
|
sosa
2011/01/19 21:51:15
partition might be better here ... (board, _, vari
scottz
2011/01/19 22:11:06
Can you explain a bit more what you mean here?
On
| |
| 339 cmd += ['--board', board, '--variant', variant] | |
| 340 elif re.match('.*?-\w+', target): | |
| 341 cmd += ['--board', target] | |
| 342 else: | |
| 343 raise UnknownBoardFormat('Unknown format: %s' % target) | |
| 327 | 344 |
| 328 def DeterminePrebuiltConfFile(target): | 345 cmd_output = cros_build_lib.RunCommand(cmd, redirect_stdout=True, |
| 346 cwd=script_dir) | |
| 347 # We only care about the last entry | |
| 348 return cmd_output.output.splitlines().pop() | |
| 349 | |
| 350 | |
| 351 def DeterminePrebuiltConfFile(build_path, target): | |
| 329 """Determine the prebuilt.conf file that needs to be updated for prebuilts. | 352 """Determine the prebuilt.conf file that needs to be updated for prebuilts. |
| 330 | 353 |
| 331 Args: | 354 Args: |
| 355 build_path: The path to the root of the build directory | |
| 332 target: String representation of the board. This includes host and board | 356 target: String representation of the board. This includes host and board |
| 333 targets | 357 targets |
| 334 | 358 |
| 335 Returns | 359 Returns |
| 336 A string path to a prebuilt.conf file to be updated. | 360 A string path to a prebuilt.conf file to be updated. |
| 337 """ | 361 """ |
| 338 overlay_base_dir = _BINHOST_BASE_DIR | |
| 339 # If this is a private checkout default to updating | |
| 340 # private overlays over public. | |
| 341 if os.path.exists(_PRIVATE_OVERLAY_DIR): | |
| 342 overlay_base_dir = _PRIVATE_OVERLAY_DIR | |
| 343 | |
| 344 if _HOST_TARGET == target: | 362 if _HOST_TARGET == target: |
| 345 # We are host. | 363 # We are host. |
| 346 # Without more examples of hosts this is a kludge for now. | 364 # Without more examples of hosts this is a kludge for now. |
| 347 # TODO(Scottz): as new host targets come online expand this to | 365 # TODO(Scottz): as new host targets come online expand this to |
| 348 # work more like boards. | 366 # work more like boards. |
| 349 make_path = _PREBUILT_MAKE_CONF[target] | 367 make_path = _PREBUILT_MAKE_CONF[target] |
| 350 elif re.match('.*?_.*', target): | |
| 351 # We are a board variant | |
| 352 overlay_str = 'overlay-variant-%s' % target.replace('_', '-') | |
| 353 make_path = os.path.join(overlay_base_dir, overlay_str, 'prebuilt.conf') | |
| 354 elif re.match('.*?-\w+', target): | |
| 355 overlay_str = 'overlay-%s' % target | |
| 356 make_path = os.path.join(overlay_base_dir, overlay_str, 'prebuilt.conf') | |
| 357 else: | 368 else: |
| 358 raise UnknownBoardFormat('Unknown format: %s' % target) | 369 # We are a board |
| 370 board = GetBoardPathFromCrosOverlayList(build_path, target) | |
| 371 make_path = os.path.join(board, 'prebuilt.conf') | |
| 359 | 372 |
| 360 return os.path.join(make_path) | 373 return make_path |
| 361 | 374 |
| 362 | 375 |
| 363 def UpdateBinhostConfFile(path, key, value): | 376 def UpdateBinhostConfFile(path, key, value): |
| 364 """Update binhost config file file with key=value. | 377 """Update binhost config file file with key=value. |
| 365 | 378 |
| 366 Args: | 379 Args: |
| 367 path: Filename to update. | 380 path: Filename to update. |
| 368 key: Key to update. | 381 key: Key to update. |
| 369 value: New value for key. | 382 value: New value for key. |
| 370 """ | 383 """ |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 url_suffix = _REL_HOST_PATH % {'version': version, 'target': _HOST_TARGET} | 426 url_suffix = _REL_HOST_PATH % {'version': version, 'target': _HOST_TARGET} |
| 414 package_string = _HOST_TARGET | 427 package_string = _HOST_TARGET |
| 415 git_file = os.path.join(build_path, _PREBUILT_MAKE_CONF[_HOST_TARGET]) | 428 git_file = os.path.join(build_path, _PREBUILT_MAKE_CONF[_HOST_TARGET]) |
| 416 binhost_conf = os.path.join(build_path, _BINHOST_CONF_DIR, 'host', | 429 binhost_conf = os.path.join(build_path, _BINHOST_CONF_DIR, 'host', |
| 417 '%s.conf' % _HOST_TARGET) | 430 '%s.conf' % _HOST_TARGET) |
| 418 else: | 431 else: |
| 419 board_path = os.path.join(build_path, _BOARD_PATH % {'board': board}) | 432 board_path = os.path.join(build_path, _BOARD_PATH % {'board': board}) |
| 420 package_path = os.path.join(board_path, 'packages') | 433 package_path = os.path.join(board_path, 'packages') |
| 421 package_string = board | 434 package_string = board |
| 422 url_suffix = _REL_BOARD_PATH % {'board': board, 'version': version} | 435 url_suffix = _REL_BOARD_PATH % {'board': board, 'version': version} |
| 423 git_file = os.path.join(build_path, DeterminePrebuiltConfFile(board)) | 436 git_file = DeterminePrebuiltConfFile(build_path, board) |
|
sosa
2011/01/19 21:51:15
why?
scottz
2011/01/19 22:11:06
Why did I remove os.path.join? We are now doing th
| |
| 424 binhost_conf = os.path.join(build_path, _BINHOST_CONF_DIR, 'target', | 437 binhost_conf = os.path.join(build_path, _BINHOST_CONF_DIR, 'target', |
| 425 '%s.conf' % board) | 438 '%s.conf' % board) |
| 426 remote_location = '%s/%s' % (upload_location.rstrip('/'), url_suffix) | 439 remote_location = '%s/%s' % (upload_location.rstrip('/'), url_suffix) |
| 427 | 440 |
| 428 # Process Packages file, removing duplicates and filtered packages. | 441 # Process Packages file, removing duplicates and filtered packages. |
| 429 pkg_index = GrabLocalPackageIndex(package_path) | 442 pkg_index = GrabLocalPackageIndex(package_path) |
| 430 pkg_index.SetUploadLocation(binhost_base_url, url_suffix) | 443 pkg_index.SetUploadLocation(binhost_base_url, url_suffix) |
| 431 pkg_index.RemoveFilteredPackages(lambda pkg: ShouldFilterPackage(pkg)) | 444 pkg_index.RemoveFilteredPackages(lambda pkg: ShouldFilterPackage(pkg)) |
| 432 uploads = pkg_index.ResolveDuplicateUploads(pkg_indexes) | 445 uploads = pkg_index.ResolveDuplicateUploads(pkg_indexes) |
| 433 | 446 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 if options.board: | 555 if options.board: |
| 543 UploadPrebuilt(options.build_path, options.upload, version, | 556 UploadPrebuilt(options.build_path, options.upload, version, |
| 544 options.binhost_base_url, board=options.board, | 557 options.binhost_base_url, board=options.board, |
| 545 git_sync=options.git_sync, key=options.key, | 558 git_sync=options.git_sync, key=options.key, |
| 546 pkg_indexes=pkg_indexes, | 559 pkg_indexes=pkg_indexes, |
| 547 sync_binhost_conf=options.sync_binhost_conf) | 560 sync_binhost_conf=options.sync_binhost_conf) |
| 548 | 561 |
| 549 | 562 |
| 550 if __name__ == '__main__': | 563 if __name__ == '__main__': |
| 551 main() | 564 main() |
| OLD | NEW |