David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 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 |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | import datetime |
| 7 | import multiprocessing |
| 8 | import optparse |
| 9 | import os |
| 10 | import re |
| 11 | import sys |
| 12 | import tempfile |
| 13 | import time |
| 14 | |
Chris Sosa | 471532a | 2011-02-01 15:10:06 -0800 | [diff] [blame] | 15 | if __name__ == '__main__': |
| 16 | import constants |
| 17 | sys.path.append(constants.SOURCE_ROOT) |
| 18 | |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 19 | from chromite.lib import cros_build_lib |
| 20 | from chromite.lib.binpkg import (GrabLocalPackageIndex, GrabRemotePackageIndex, |
| 21 | PackageIndex) |
| 22 | """ |
| 23 | This script is used to upload host prebuilts as well as board BINHOSTS. |
| 24 | |
| 25 | If the URL starts with 'gs://', we upload using gsutil to Google Storage. |
| 26 | Otherwise, rsync is used. |
| 27 | |
| 28 | After a build is successfully uploaded a file is updated with the proper |
| 29 | BINHOST version as well as the target board. This file is defined in GIT_FILE |
| 30 | |
| 31 | |
| 32 | To read more about prebuilts/binhost binary packages please refer to: |
| 33 | http://sites/chromeos/for-team-members/engineering/releng/prebuilt-binaries-for-streamlining-the-build-process |
| 34 | |
| 35 | |
| 36 | Example of uploading prebuilt amd64 host files to Google Storage: |
| 37 | ./prebuilt.py -p /b/cbuild/build -s -u gs://chromeos-prebuilt |
| 38 | |
| 39 | Example of uploading x86-dogfood binhosts to Google Storage: |
| 40 | ./prebuilt.py -b x86-dogfood -p /b/cbuild/build/ -u gs://chromeos-prebuilt -g |
| 41 | |
| 42 | Example of uploading prebuilt amd64 host files using rsync: |
| 43 | ./prebuilt.py -p /b/cbuild/build -s -u codf30.jail:/tmp |
| 44 | """ |
| 45 | |
| 46 | # as per http://crosbug.com/5855 always filter the below packages |
| 47 | _FILTER_PACKAGES = set() |
| 48 | _RETRIES = 3 |
| 49 | _GSUTIL_BIN = '/b/build/third_party/gsutil/gsutil' |
| 50 | _HOST_PACKAGES_PATH = 'chroot/var/lib/portage/pkgs' |
David James | 05bcb2b | 2011-02-09 09:25:47 -0800 | [diff] [blame] | 51 | _CATEGORIES_PATH = 'chroot/etc/portage/categories' |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 52 | _HOST_TARGET = 'amd64' |
| 53 | _BOARD_PATH = 'chroot/build/%(board)s' |
David James | 8fa34ea | 2011-04-15 13:00:20 -0700 | [diff] [blame] | 54 | # board/board-target/version/' |
| 55 | _REL_BOARD_PATH = 'board/%(board)s/%(version)s' |
| 56 | # host/host-target/version/' |
| 57 | _REL_HOST_PATH = 'host/%(target)s/%(version)s' |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 58 | # Private overlays to look at for builds to filter |
| 59 | # relative to build path |
| 60 | _PRIVATE_OVERLAY_DIR = 'src/private-overlays' |
Scott Zawalski | ab1bed3 | 2011-03-16 15:24:24 -0700 | [diff] [blame] | 61 | _GOOGLESTORAGE_ACL_FILE = 'googlestorage_acl.xml' |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 62 | _BINHOST_BASE_URL = 'http://commondatastorage.googleapis.com/chromeos-prebuilt' |
| 63 | _PREBUILT_BASE_DIR = 'src/third_party/chromiumos-overlay/chromeos/config/' |
| 64 | # Created in the event of new host targets becoming available |
| 65 | _PREBUILT_MAKE_CONF = {'amd64': os.path.join(_PREBUILT_BASE_DIR, |
| 66 | 'make.conf.amd64-host')} |
| 67 | _BINHOST_CONF_DIR = 'src/third_party/chromiumos-overlay/chromeos/binhost' |
| 68 | |
| 69 | |
| 70 | class FiltersEmpty(Exception): |
| 71 | """Raised when filters are used but none are found.""" |
| 72 | pass |
| 73 | |
| 74 | |
| 75 | class UploadFailed(Exception): |
| 76 | """Raised when one of the files uploaded failed.""" |
| 77 | pass |
| 78 | |
| 79 | class UnknownBoardFormat(Exception): |
| 80 | """Raised when a function finds an unknown board format.""" |
| 81 | pass |
| 82 | |
| 83 | class GitPushFailed(Exception): |
| 84 | """Raised when a git push failed after retry.""" |
| 85 | pass |
| 86 | |
| 87 | |
| 88 | def UpdateLocalFile(filename, value, key='PORTAGE_BINHOST'): |
| 89 | """Update the key in file with the value passed. |
| 90 | File format: |
| 91 | key="value" |
| 92 | Note quotes are added automatically |
| 93 | |
| 94 | Args: |
| 95 | filename: Name of file to modify. |
| 96 | value: Value to write with the key. |
| 97 | key: The variable key to update. (Default: PORTAGE_BINHOST) |
| 98 | """ |
| 99 | if os.path.exists(filename): |
| 100 | file_fh = open(filename) |
| 101 | else: |
| 102 | file_fh = open(filename, 'w+') |
| 103 | file_lines = [] |
| 104 | found = False |
| 105 | keyval_str = '%(key)s=%(value)s' |
| 106 | for line in file_fh: |
| 107 | # Strip newlines from end of line. We already add newlines below. |
| 108 | line = line.rstrip("\n") |
| 109 | |
| 110 | if len(line.split('=')) != 2: |
| 111 | # Skip any line that doesn't fit key=val. |
| 112 | file_lines.append(line) |
| 113 | continue |
| 114 | |
| 115 | file_var, file_val = line.split('=') |
| 116 | if file_var == key: |
| 117 | found = True |
| 118 | print 'Updating %s=%s to %s="%s"' % (file_var, file_val, key, value) |
| 119 | value = '"%s"' % value |
| 120 | file_lines.append(keyval_str % {'key': key, 'value': value}) |
| 121 | else: |
| 122 | file_lines.append(keyval_str % {'key': file_var, 'value': file_val}) |
| 123 | |
| 124 | if not found: |
| 125 | file_lines.append(keyval_str % {'key': key, 'value': value}) |
| 126 | |
| 127 | file_fh.close() |
| 128 | # write out new file |
| 129 | new_file_fh = open(filename, 'w') |
| 130 | new_file_fh.write('\n'.join(file_lines) + '\n') |
| 131 | new_file_fh.close() |
| 132 | |
| 133 | |
| 134 | def RevGitPushWithRetry(retries=5): |
| 135 | """Repo sync and then push git changes in flight. |
| 136 | |
| 137 | Args: |
| 138 | retries: The number of times to retry before giving up, default: 5 |
| 139 | |
| 140 | Raises: |
| 141 | GitPushFailed if push was unsuccessful after retries |
| 142 | """ |
Chris Sosa | 471532a | 2011-02-01 15:10:06 -0800 | [diff] [blame] | 143 | for retry in range(1, retries + 1): |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 144 | try: |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 145 | cros_build_lib.RunCommand(['repo', 'sync', '.']) |
| 146 | cros_build_lib.RunCommand(['git', 'push']) |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 147 | break |
| 148 | except cros_build_lib.RunCommandError: |
| 149 | if retry < retries: |
| 150 | print 'Error pushing changes trying again (%s/%s)' % (retry, retries) |
Chris Sosa | 471532a | 2011-02-01 15:10:06 -0800 | [diff] [blame] | 151 | time.sleep(5 * retry) |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 152 | else: |
| 153 | raise GitPushFailed('Failed to push change after %s retries' % retries) |
| 154 | |
| 155 | |
| 156 | def RevGitFile(filename, value, retries=5, key='PORTAGE_BINHOST'): |
| 157 | """Update and push the git file. |
| 158 | |
| 159 | Args: |
| 160 | filename: file to modify that is in a git repo already |
| 161 | value: string representing the version of the prebuilt that has been |
| 162 | uploaded. |
| 163 | retries: The number of times to retry before giving up, default: 5 |
| 164 | key: The variable key to update in the git file. |
| 165 | (Default: PORTAGE_BINHOST) |
| 166 | """ |
| 167 | prebuilt_branch = 'prebuilt_branch' |
| 168 | old_cwd = os.getcwd() |
| 169 | os.chdir(os.path.dirname(filename)) |
| 170 | |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 171 | commit = cros_build_lib.RunCommand(['git', 'rev-parse', 'HEAD'], |
Peter Mayo | fe0e687 | 2011-04-20 00:52:08 -0400 | [diff] [blame] | 172 | redirect_stdout=True).output.rstrip() |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 173 | cros_build_lib.RunCommand(['git', 'remote', 'update']) |
| 174 | cros_build_lib.RunCommand(['repo', 'start', prebuilt_branch, '.']) |
| 175 | git_ssh_config_cmd = [ |
| 176 | 'git', |
| 177 | 'config', |
| 178 | 'url.ssh://git@gitrw.chromium.org:9222.pushinsteadof', |
| 179 | 'http://git.chromium.org/git' ] |
| 180 | cros_build_lib.RunCommand(git_ssh_config_cmd) |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 181 | description = 'Update %s="%s" in %s' % (key, value, filename) |
| 182 | print description |
| 183 | try: |
| 184 | UpdateLocalFile(filename, value, key) |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 185 | cros_build_lib.RunCommand(['git', 'config', 'push.default', 'tracking']) |
| 186 | cros_build_lib.RunCommand(['git', 'commit', '-am', description]) |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 187 | RevGitPushWithRetry(retries) |
| 188 | finally: |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 189 | cros_build_lib.RunCommand(['repo', 'abandon', 'prebuilt_branch', '.']) |
| 190 | cros_build_lib.RunCommand(['git', 'checkout', commit]) |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 191 | os.chdir(old_cwd) |
| 192 | |
| 193 | |
| 194 | def GetVersion(): |
| 195 | """Get the version to put in LATEST and update the git version with.""" |
| 196 | return datetime.datetime.now().strftime('%d.%m.%y.%H%M%S') |
| 197 | |
| 198 | |
| 199 | def LoadPrivateFilters(build_path): |
| 200 | """Load private filters based on ebuilds found under _PRIVATE_OVERLAY_DIR. |
| 201 | |
| 202 | This function adds filters to the global set _FILTER_PACKAGES. |
| 203 | Args: |
| 204 | build_path: Path that _PRIVATE_OVERLAY_DIR is in. |
| 205 | """ |
| 206 | # TODO(scottz): eventually use manifest.xml to find the proper |
| 207 | # private overlay path. |
| 208 | filter_path = os.path.join(build_path, _PRIVATE_OVERLAY_DIR) |
| 209 | files = cros_build_lib.ListFiles(filter_path) |
| 210 | filters = [] |
| 211 | for file in files: |
| 212 | if file.endswith('.ebuild'): |
| 213 | basename = os.path.basename(file) |
| 214 | match = re.match('(.*?)-\d.*.ebuild', basename) |
| 215 | if match: |
| 216 | filters.append(match.group(1)) |
| 217 | |
| 218 | if not filters: |
| 219 | raise FiltersEmpty('No filters were returned') |
| 220 | |
| 221 | _FILTER_PACKAGES.update(filters) |
| 222 | |
| 223 | |
| 224 | def ShouldFilterPackage(file_path): |
| 225 | """Skip a particular file if it matches a pattern. |
| 226 | |
| 227 | Skip any files that machine the list of packages to filter in |
| 228 | _FILTER_PACKAGES. |
| 229 | |
| 230 | Args: |
| 231 | file_path: string of a file path to inspect against _FILTER_PACKAGES |
| 232 | |
| 233 | Returns: |
| 234 | True if we should filter the package, |
| 235 | False otherwise. |
| 236 | """ |
| 237 | for name in _FILTER_PACKAGES: |
| 238 | if name in file_path: |
| 239 | print 'FILTERING %s' % file_path |
| 240 | return True |
| 241 | |
| 242 | return False |
| 243 | |
| 244 | |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 245 | def _RetryRun(cmd, print_cmd=True, cwd=None): |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 246 | """Run the specified command, retrying if necessary. |
| 247 | |
| 248 | Args: |
| 249 | cmd: The command to run. |
| 250 | print_cmd: Whether to print out the cmd. |
| 251 | shell: Whether to treat the command as a shell. |
| 252 | cwd: Working directory to run command in. |
| 253 | |
| 254 | Returns: |
| 255 | True if the command succeeded. Otherwise, returns False. |
| 256 | """ |
| 257 | |
| 258 | # TODO(scottz): port to use _Run or similar when it is available in |
| 259 | # cros_build_lib. |
| 260 | for attempt in range(_RETRIES): |
| 261 | try: |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 262 | output = cros_build_lib.RunCommand(cmd, print_cmd=print_cmd, |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 263 | cwd=cwd) |
| 264 | return True |
| 265 | except cros_build_lib.RunCommandError: |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 266 | print 'Failed to run %r' % cmd |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 267 | else: |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 268 | print 'Retry failed run %r, giving up' % cmd |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 269 | return False |
| 270 | |
| 271 | |
| 272 | def _GsUpload(args): |
| 273 | """Upload to GS bucket. |
| 274 | |
| 275 | Args: |
David James | fd0b085 | 2011-02-23 11:15:36 -0800 | [diff] [blame] | 276 | args: a tuple of three arguments that contains local_file, remote_file, and |
| 277 | the acl used for uploading the file. |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 278 | |
| 279 | Returns: |
| 280 | Return the arg tuple of two if the upload failed |
| 281 | """ |
David James | fd0b085 | 2011-02-23 11:15:36 -0800 | [diff] [blame] | 282 | (local_file, remote_file, acl) = args |
Scott Zawalski | ab1bed3 | 2011-03-16 15:24:24 -0700 | [diff] [blame] | 283 | CANNED_ACLS = ['public-read', 'private', 'bucket-owner-read', |
| 284 | 'authenticated-read', 'bucket-owner-full-control', |
| 285 | 'public-read-write'] |
| 286 | acl_cmd = None |
| 287 | if acl in CANNED_ACLS: |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 288 | cmd = [_GSUTIL_BIN, 'cp', '-a', acl, local_file, remote_file] |
Scott Zawalski | ab1bed3 | 2011-03-16 15:24:24 -0700 | [diff] [blame] | 289 | else: |
| 290 | # For private uploads we assume that the overlay board is set up properly |
| 291 | # and a googlestore_acl.xml is present, if not this script errors |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 292 | cmd = [_GSUTIL_BIN, 'cp', '-a', 'private', local_file, remote_file] |
Scott Zawalski | ab1bed3 | 2011-03-16 15:24:24 -0700 | [diff] [blame] | 293 | if not os.path.exists(acl): |
| 294 | print >> sys.stderr, ('You are specifying either a file that does not ' |
| 295 | 'exist or an unknown canned acl: %s. Aborting ' |
| 296 | 'upload') % acl |
| 297 | # emulate the failing of an upload since we are not uploading the file |
| 298 | return (local_file, remote_file) |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 299 | |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 300 | acl_cmd = [_GSUTIL_BIN, 'setacl', acl, remote_file] |
Scott Zawalski | ab1bed3 | 2011-03-16 15:24:24 -0700 | [diff] [blame] | 301 | |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 302 | if not _RetryRun(cmd, print_cmd=False): |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 303 | return (local_file, remote_file) |
| 304 | |
Scott Zawalski | ab1bed3 | 2011-03-16 15:24:24 -0700 | [diff] [blame] | 305 | if acl_cmd: |
| 306 | # Apply the passed in ACL xml file to the uploaded object. |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 307 | _RetryRun(acl_cmd, print_cmd=False) |
Scott Zawalski | ab1bed3 | 2011-03-16 15:24:24 -0700 | [diff] [blame] | 308 | |
| 309 | |
David James | fd0b085 | 2011-02-23 11:15:36 -0800 | [diff] [blame] | 310 | def RemoteUpload(acl, files, pool=10): |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 311 | """Upload to google storage. |
| 312 | |
| 313 | Create a pool of process and call _GsUpload with the proper arguments. |
| 314 | |
| 315 | Args: |
David James | fd0b085 | 2011-02-23 11:15:36 -0800 | [diff] [blame] | 316 | acl: The canned acl used for uploading. acl can be one of: "public-read", |
| 317 | "public-read-write", "authenticated-read", "bucket-owner-read", |
| 318 | "bucket-owner-full-control", or "private". |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 319 | files: dictionary with keys to local files and values to remote path. |
| 320 | pool: integer of maximum proesses to have at the same time. |
| 321 | |
| 322 | Returns: |
| 323 | Return a set of tuple arguments of the failed uploads |
| 324 | """ |
| 325 | # TODO(scottz) port this to use _RunManyParallel when it is available in |
| 326 | # cros_build_lib |
| 327 | pool = multiprocessing.Pool(processes=pool) |
| 328 | workers = [] |
| 329 | for local_file, remote_path in files.iteritems(): |
David James | fd0b085 | 2011-02-23 11:15:36 -0800 | [diff] [blame] | 330 | workers.append((local_file, remote_path, acl)) |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 331 | |
| 332 | result = pool.map_async(_GsUpload, workers, chunksize=1) |
| 333 | while True: |
| 334 | try: |
Chris Sosa | 471532a | 2011-02-01 15:10:06 -0800 | [diff] [blame] | 335 | return set(result.get(60 * 60)) |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 336 | except multiprocessing.TimeoutError: |
| 337 | pass |
| 338 | |
| 339 | |
| 340 | def GenerateUploadDict(base_local_path, base_remote_path, pkgs): |
| 341 | """Build a dictionary of local remote file key pairs to upload. |
| 342 | |
| 343 | Args: |
| 344 | base_local_path: The base path to the files on the local hard drive. |
| 345 | remote_path: The base path to the remote paths. |
| 346 | pkgs: The packages to upload. |
| 347 | |
| 348 | Returns: |
| 349 | Returns a dictionary of local_path/remote_path pairs |
| 350 | """ |
| 351 | upload_files = {} |
| 352 | for pkg in pkgs: |
| 353 | suffix = pkg['CPV'] + '.tbz2' |
| 354 | local_path = os.path.join(base_local_path, suffix) |
| 355 | assert os.path.exists(local_path) |
| 356 | remote_path = '%s/%s' % (base_remote_path.rstrip('/'), suffix) |
| 357 | upload_files[local_path] = remote_path |
| 358 | |
| 359 | return upload_files |
| 360 | |
| 361 | def GetBoardPathFromCrosOverlayList(build_path, target): |
| 362 | """Use the cros_overlay_list to determine the path to the board overlay |
| 363 | Args: |
| 364 | build_path: The path to the root of the build directory |
| 365 | target: The target that we are looking for, could consist of board and |
| 366 | board_variant, we handle that properly |
| 367 | Returns: |
| 368 | The last line from cros_overlay_list as a string |
| 369 | """ |
Chris Sosa | 471532a | 2011-02-01 15:10:06 -0800 | [diff] [blame] | 370 | script_dir = os.path.join(build_path, 'src/platform/dev/host') |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 371 | cmd = ['./cros_overlay_list'] |
| 372 | if re.match('.*?_.*', target): |
| 373 | (board, variant) = target.split('_') |
| 374 | cmd += ['--board', board, '--variant', variant] |
| 375 | elif re.match('.*?-\w+', target): |
| 376 | cmd += ['--board', target] |
| 377 | else: |
| 378 | raise UnknownBoardFormat('Unknown format: %s' % target) |
| 379 | |
| 380 | cmd_output = cros_build_lib.RunCommand(cmd, redirect_stdout=True, |
| 381 | cwd=script_dir) |
| 382 | # We only care about the last entry |
| 383 | return cmd_output.output.splitlines().pop() |
| 384 | |
| 385 | |
| 386 | def DeterminePrebuiltConfFile(build_path, target): |
| 387 | """Determine the prebuilt.conf file that needs to be updated for prebuilts. |
| 388 | |
| 389 | Args: |
| 390 | build_path: The path to the root of the build directory |
| 391 | target: String representation of the board. This includes host and board |
| 392 | targets |
| 393 | |
| 394 | Returns |
| 395 | A string path to a prebuilt.conf file to be updated. |
| 396 | """ |
| 397 | if _HOST_TARGET == target: |
| 398 | # We are host. |
| 399 | # Without more examples of hosts this is a kludge for now. |
| 400 | # TODO(Scottz): as new host targets come online expand this to |
| 401 | # work more like boards. |
Chris Sosa | 471532a | 2011-02-01 15:10:06 -0800 | [diff] [blame] | 402 | make_path = _PREBUILT_MAKE_CONF[target] |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 403 | else: |
| 404 | # We are a board |
| 405 | board = GetBoardPathFromCrosOverlayList(build_path, target) |
| 406 | make_path = os.path.join(board, 'prebuilt.conf') |
| 407 | |
| 408 | return make_path |
| 409 | |
| 410 | |
| 411 | def UpdateBinhostConfFile(path, key, value): |
| 412 | """Update binhost config file file with key=value. |
| 413 | |
| 414 | Args: |
| 415 | path: Filename to update. |
| 416 | key: Key to update. |
| 417 | value: New value for key. |
| 418 | """ |
| 419 | cwd = os.path.dirname(os.path.abspath(path)) |
| 420 | filename = os.path.basename(path) |
| 421 | if not os.path.isdir(cwd): |
| 422 | os.makedirs(cwd) |
| 423 | if not os.path.isfile(path): |
| 424 | config_file = file(path, 'w') |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 425 | config_file.close() |
| 426 | UpdateLocalFile(path, value, key) |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 427 | cros_build_lib.RunCommand(['git', 'add', filename], cwd=cwd) |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 428 | description = 'Update %s=%s in %s' % (key, value, filename) |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 429 | cros_build_lib.RunCommand(['git', 'commit', '-m', description], cwd=cwd) |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 430 | |
| 431 | |
David James | ce093af | 2011-02-23 15:21:58 -0800 | [diff] [blame] | 432 | def _GrabAllRemotePackageIndexes(binhost_urls): |
David James | 05bcb2b | 2011-02-09 09:25:47 -0800 | [diff] [blame] | 433 | """Grab all of the packages files associated with a list of binhost_urls. |
| 434 | |
David James | 05bcb2b | 2011-02-09 09:25:47 -0800 | [diff] [blame] | 435 | Args: |
| 436 | binhost_urls: The URLs for the directories containing the Packages files we |
| 437 | want to grab. |
David James | 05bcb2b | 2011-02-09 09:25:47 -0800 | [diff] [blame] | 438 | |
| 439 | Returns: |
| 440 | A list of PackageIndex objects. |
| 441 | """ |
| 442 | pkg_indexes = [] |
| 443 | for url in binhost_urls: |
| 444 | pkg_index = GrabRemotePackageIndex(url) |
| 445 | if pkg_index: |
| 446 | pkg_indexes.append(pkg_index) |
David James | 05bcb2b | 2011-02-09 09:25:47 -0800 | [diff] [blame] | 447 | return pkg_indexes |
| 448 | |
| 449 | |
David James | 05bcb2b | 2011-02-09 09:25:47 -0800 | [diff] [blame] | 450 | |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 451 | class PrebuiltUploader(object): |
| 452 | """Synchronize host and board prebuilts.""" |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 453 | |
David James | fd0b085 | 2011-02-23 11:15:36 -0800 | [diff] [blame] | 454 | def __init__(self, upload_location, acl, binhost_base_url, pkg_indexes): |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 455 | """Constructor for prebuilt uploader object. |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 456 | |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 457 | This object can upload host or prebuilt files to Google Storage. |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 458 | |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 459 | Args: |
| 460 | upload_location: The upload location. |
David James | fd0b085 | 2011-02-23 11:15:36 -0800 | [diff] [blame] | 461 | acl: The canned acl used for uploading to Google Storage. acl can be one |
| 462 | of: "public-read", "public-read-write", "authenticated-read", |
| 463 | "bucket-owner-read", "bucket-owner-full-control", or "private". If |
| 464 | we are not uploading to Google Storage, this parameter is unused. |
| 465 | binhost_base_url: The URL used for downloading the prebuilts. |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 466 | pkg_indexes: Old uploaded prebuilts to compare against. Instead of |
| 467 | uploading duplicate files, we just link to the old files. |
| 468 | """ |
| 469 | self._upload_location = upload_location |
David James | fd0b085 | 2011-02-23 11:15:36 -0800 | [diff] [blame] | 470 | self._acl = acl |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 471 | self._binhost_base_url = binhost_base_url |
| 472 | self._pkg_indexes = pkg_indexes |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 473 | |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 474 | def _UploadPrebuilt(self, package_path, url_suffix): |
| 475 | """Upload host or board prebuilt files to Google Storage space. |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 476 | |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 477 | Args: |
| 478 | package_path: The path to the packages dir. |
David James | ce093af | 2011-02-23 15:21:58 -0800 | [diff] [blame] | 479 | url_suffix: The remote subdirectory where we should upload the packages. |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 480 | """ |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 481 | |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 482 | # Process Packages file, removing duplicates and filtered packages. |
| 483 | pkg_index = GrabLocalPackageIndex(package_path) |
| 484 | pkg_index.SetUploadLocation(self._binhost_base_url, url_suffix) |
| 485 | pkg_index.RemoveFilteredPackages(ShouldFilterPackage) |
| 486 | uploads = pkg_index.ResolveDuplicateUploads(self._pkg_indexes) |
David James | 05bcb2b | 2011-02-09 09:25:47 -0800 | [diff] [blame] | 487 | |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 488 | # Write Packages file. |
| 489 | tmp_packages_file = pkg_index.WriteToNamedTemporaryFile() |
David James | 05bcb2b | 2011-02-09 09:25:47 -0800 | [diff] [blame] | 490 | |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 491 | remote_location = '%s/%s' % (self._upload_location.rstrip('/'), url_suffix) |
| 492 | if remote_location.startswith('gs://'): |
| 493 | # Build list of files to upload. |
| 494 | upload_files = GenerateUploadDict(package_path, remote_location, uploads) |
| 495 | remote_file = '%s/Packages' % remote_location.rstrip('/') |
| 496 | upload_files[tmp_packages_file.name] = remote_file |
David James | 05bcb2b | 2011-02-09 09:25:47 -0800 | [diff] [blame] | 497 | |
David James | fd0b085 | 2011-02-23 11:15:36 -0800 | [diff] [blame] | 498 | failed_uploads = RemoteUpload(self._acl, upload_files) |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 499 | if len(failed_uploads) > 1 or (None not in failed_uploads): |
David James | f4db112 | 2011-03-17 16:18:05 -0700 | [diff] [blame] | 500 | error_msg = ['%s -> %s\n' % args for args in failed_uploads if args] |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 501 | raise UploadFailed('Error uploading:\n%s' % error_msg) |
| 502 | else: |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 503 | pkgs = [p['CPV'] + '.tbz2' for p in uploads] |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 504 | ssh_server, remote_path = remote_location.split(':', 1) |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 505 | remote_path = remote_path.rstrip('/') |
| 506 | pkg_index = tmp_packages_file.name |
| 507 | remote_location = remote_location.rstrip('/') |
| 508 | remote_packages = '%s/Packages' % remote_location |
| 509 | cmds = [['ssh', ssh_server, 'mkdir', '-p', remote_path], |
| 510 | ['rsync', '-av', '--chmod=a+r', pkg_index, remote_packages]] |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 511 | if pkgs: |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 512 | cmds.append(['rsync', '-Rav'] + pkgs + [remote_location + '/']) |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 513 | for cmd in cmds: |
Peter Mayo | 193f68f | 2011-04-19 19:08:21 -0400 | [diff] [blame] | 514 | if not _RetryRun(cmd, cwd=package_path): |
| 515 | raise UploadFailed('Could not run %r' % cmd) |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 516 | |
David James | 8fa34ea | 2011-04-15 13:00:20 -0700 | [diff] [blame] | 517 | def _UploadBoardTarball(self, board_path, url_suffix): |
| 518 | """Upload a tarball of the board at the specified path to Google Storage. |
| 519 | |
| 520 | Args: |
| 521 | board_path: The path to the board dir. |
| 522 | url_suffix: The remote subdirectory where we should upload the packages. |
| 523 | """ |
| 524 | remote_location = '%s/%s' % (self._upload_location.rstrip('/'), url_suffix) |
| 525 | assert remote_location.startswith('gs://') |
| 526 | cwd, boardname = os.path.split(board_path.rstrip(os.path.sep)) |
| 527 | tmpdir = tempfile.mkdtemp() |
| 528 | try: |
| 529 | tarfile = os.path.join(tmpdir, '%s.tbz2' % boardname) |
| 530 | cmd = ['sudo', 'tar', '-I', 'pbzip2', '-cf', tarfile] |
| 531 | excluded_paths = ('usr/lib/debug', 'usr/local/autotest', 'packages', |
| 532 | 'tmp') |
| 533 | for path in excluded_paths: |
| 534 | cmd.append('--exclude=%s/%s/*' % (boardname, path)) |
| 535 | cmd.append(boardname) |
| 536 | cros_build_lib.RunCommand(cmd, cwd=cwd) |
| 537 | remote_tarfile = '%s/%s.tbz2' % (remote_location.rstrip('/'), boardname) |
| 538 | if _GsUpload((tarfile, remote_tarfile, self._acl)): |
| 539 | sys.exit(1) |
| 540 | finally: |
| 541 | cros_build_lib.RunCommand(['sudo', 'rm', '-rf', tmpdir], cwd=cwd) |
| 542 | |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 543 | def _SyncHostPrebuilts(self, build_path, version, key, git_sync, |
| 544 | sync_binhost_conf): |
| 545 | """Synchronize host prebuilt files. |
David James | 05bcb2b | 2011-02-09 09:25:47 -0800 | [diff] [blame] | 546 | |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 547 | This function will sync both the standard host packages, plus the host |
| 548 | packages associated with all targets that have been "setup" with the |
| 549 | current host's chroot. For instance, if this host has been used to build |
| 550 | x86-generic, it will sync the host packages associated with |
| 551 | 'i686-pc-linux-gnu'. If this host has also been used to build arm-generic, |
| 552 | it will also sync the host packages associated with |
| 553 | 'armv7a-cros-linux-gnueabi'. |
David James | 05bcb2b | 2011-02-09 09:25:47 -0800 | [diff] [blame] | 554 | |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 555 | Args: |
| 556 | build_path: The path to the directory containing the chroot. |
| 557 | version: A unique string, intended to be included in the upload path, |
| 558 | which identifies the version number of the uploaded prebuilts. |
| 559 | key: The variable key to update in the git file. |
| 560 | git_sync: If set, update make.conf of target to reference the latest |
| 561 | prebuilt packages generated here. |
| 562 | sync_binhost_conf: If set, update binhost config file in |
| 563 | chromiumos-overlay for the host. |
| 564 | """ |
| 565 | # Upload prebuilts. |
| 566 | package_path = os.path.join(build_path, _HOST_PACKAGES_PATH) |
| 567 | url_suffix = _REL_HOST_PATH % {'version': version, 'target': _HOST_TARGET} |
David James | 8fa34ea | 2011-04-15 13:00:20 -0700 | [diff] [blame] | 568 | packages_url_suffix = '%s/packages' % url_suffix.rstrip('/') |
| 569 | self._UploadPrebuilt(package_path, packages_url_suffix) |
David James | 05bcb2b | 2011-02-09 09:25:47 -0800 | [diff] [blame] | 570 | |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 571 | # Record URL where prebuilts were uploaded. |
| 572 | url_value = '%s/%s/' % (self._binhost_base_url.rstrip('/'), |
David James | f0e6fd7 | 2011-04-15 15:58:07 -0700 | [diff] [blame] | 573 | packages_url_suffix.rstrip('/')) |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 574 | if git_sync: |
| 575 | git_file = os.path.join(build_path, _PREBUILT_MAKE_CONF[_HOST_TARGET]) |
| 576 | RevGitFile(git_file, url_value, key=key) |
| 577 | if sync_binhost_conf: |
| 578 | binhost_conf = os.path.join(build_path, _BINHOST_CONF_DIR, 'host', |
| 579 | '%s-%s.conf' % (_HOST_TARGET, key)) |
| 580 | UpdateBinhostConfFile(binhost_conf, key, url_value) |
| 581 | |
| 582 | def _SyncBoardPrebuilts(self, board, build_path, version, key, git_sync, |
David James | 8fa34ea | 2011-04-15 13:00:20 -0700 | [diff] [blame] | 583 | sync_binhost_conf, upload_board_tarball): |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 584 | """Synchronize board prebuilt files. |
| 585 | |
| 586 | Args: |
| 587 | board: The board to upload to Google Storage. |
| 588 | build_path: The path to the directory containing the chroot. |
| 589 | version: A unique string, intended to be included in the upload path, |
| 590 | which identifies the version number of the uploaded prebuilts. |
| 591 | key: The variable key to update in the git file. |
| 592 | git_sync: If set, update make.conf of target to reference the latest |
| 593 | prebuilt packages generated here. |
| 594 | sync_binhost_conf: If set, update binhost config file in |
| 595 | chromiumos-overlay for the current board. |
David James | 8fa34ea | 2011-04-15 13:00:20 -0700 | [diff] [blame] | 596 | upload_board_tarball: Include a tarball of the board in our upload. |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 597 | """ |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 598 | board_path = os.path.join(build_path, _BOARD_PATH % {'board': board}) |
| 599 | package_path = os.path.join(board_path, 'packages') |
| 600 | url_suffix = _REL_BOARD_PATH % {'board': board, 'version': version} |
David James | 8fa34ea | 2011-04-15 13:00:20 -0700 | [diff] [blame] | 601 | packages_url_suffix = '%s/packages' % url_suffix.rstrip('/') |
| 602 | |
| 603 | # Upload board tarballs in the background. |
| 604 | if upload_board_tarball: |
| 605 | tar_process = multiprocessing.Process(target=self._UploadBoardTarball, |
| 606 | args=(board_path, url_suffix)) |
| 607 | tar_process.start() |
| 608 | |
| 609 | # Upload prebuilts. |
| 610 | self._UploadPrebuilt(package_path, packages_url_suffix) |
| 611 | |
| 612 | # Make sure we finished uploading the board tarballs. |
| 613 | if upload_board_tarball: |
| 614 | tar_process.join() |
| 615 | assert tar_process.exitcode == 0 |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 616 | |
| 617 | # Record URL where prebuilts were uploaded. |
| 618 | url_value = '%s/%s/' % (self._binhost_base_url.rstrip('/'), |
David James | f0e6fd7 | 2011-04-15 15:58:07 -0700 | [diff] [blame] | 619 | packages_url_suffix.rstrip('/')) |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 620 | if git_sync: |
| 621 | git_file = DeterminePrebuiltConfFile(build_path, board) |
| 622 | RevGitFile(git_file, url_value, key=key) |
| 623 | if sync_binhost_conf: |
| 624 | binhost_conf = os.path.join(build_path, _BINHOST_CONF_DIR, 'target', |
| 625 | '%s-%s.conf' % (board, key)) |
| 626 | UpdateBinhostConfFile(binhost_conf, key, url_value) |
David James | 05bcb2b | 2011-02-09 09:25:47 -0800 | [diff] [blame] | 627 | |
| 628 | |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 629 | def usage(parser, msg): |
| 630 | """Display usage message and parser help then exit with 1.""" |
| 631 | print >> sys.stderr, msg |
| 632 | parser.print_help() |
| 633 | sys.exit(1) |
| 634 | |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 635 | def ParseOptions(): |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 636 | parser = optparse.OptionParser() |
| 637 | parser.add_option('-H', '--binhost-base-url', dest='binhost_base_url', |
| 638 | default=_BINHOST_BASE_URL, |
| 639 | help='Base URL to use for binhost in make.conf updates') |
| 640 | parser.add_option('', '--previous-binhost-url', action='append', |
| 641 | default=[], dest='previous_binhost_url', |
| 642 | help='Previous binhost URL') |
| 643 | parser.add_option('-b', '--board', dest='board', default=None, |
| 644 | help='Board type that was built on this machine') |
| 645 | parser.add_option('-p', '--build-path', dest='build_path', |
David James | 05bcb2b | 2011-02-09 09:25:47 -0800 | [diff] [blame] | 646 | help='Path to the directory containing the chroot') |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 647 | parser.add_option('-s', '--sync-host', dest='sync_host', |
| 648 | default=False, action='store_true', |
| 649 | help='Sync host prebuilts') |
| 650 | parser.add_option('-g', '--git-sync', dest='git_sync', |
| 651 | default=False, action='store_true', |
| 652 | help='Enable git version sync (This commits to a repo)') |
| 653 | parser.add_option('-u', '--upload', dest='upload', |
| 654 | default=None, |
| 655 | help='Upload location') |
| 656 | parser.add_option('-V', '--prepend-version', dest='prepend_version', |
| 657 | default=None, |
| 658 | help='Add an identifier to the front of the version') |
| 659 | parser.add_option('-f', '--filters', dest='filters', action='store_true', |
| 660 | default=False, |
| 661 | help='Turn on filtering of private ebuild packages') |
| 662 | parser.add_option('-k', '--key', dest='key', |
| 663 | default='PORTAGE_BINHOST', |
| 664 | help='Key to update in make.conf / binhost.conf') |
| 665 | parser.add_option('', '--sync-binhost-conf', dest='sync_binhost_conf', |
| 666 | default=False, action='store_true', |
| 667 | help='Update binhost.conf') |
David James | fd0b085 | 2011-02-23 11:15:36 -0800 | [diff] [blame] | 668 | parser.add_option('-P', '--private', dest='private', action='store_true', |
| 669 | default=False, help='Mark gs:// uploads as private.') |
David James | 8fa34ea | 2011-04-15 13:00:20 -0700 | [diff] [blame] | 670 | parser.add_option('', '--upload-board-tarball', dest='upload_board_tarball', |
| 671 | action='store_true', default=False, |
| 672 | help='Upload board tarball to Google Storage.') |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 673 | |
| 674 | options, args = parser.parse_args() |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 675 | if not options.build_path: |
| 676 | usage(parser, 'Error: you need provide a chroot path') |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 677 | if not options.upload: |
| 678 | usage(parser, 'Error: you need to provide an upload location using -u') |
Scott Zawalski | ab1bed3 | 2011-03-16 15:24:24 -0700 | [diff] [blame] | 679 | |
David James | 8fa34ea | 2011-04-15 13:00:20 -0700 | [diff] [blame] | 680 | |
| 681 | if options.upload_board_tarball and not options.upload.startswith('gs://'): |
| 682 | usage(parser, 'Error: --upload-board-tarball only works with gs:// URLs.\n' |
| 683 | '--upload must be a gs:// URL.') |
| 684 | |
Scott Zawalski | ab1bed3 | 2011-03-16 15:24:24 -0700 | [diff] [blame] | 685 | if options.private: |
| 686 | if options.sync_host: |
| 687 | usage(parser, 'Error: --private and --sync-host/-s cannot be specified ' |
| 688 | 'together, we do not support private host prebuilts') |
| 689 | |
| 690 | if not options.upload.startswith('gs://'): |
| 691 | usage(parser, 'Error: --private is only valid for gs:// URLs.\n' |
| 692 | '--upload must be a gs:// URL.') |
| 693 | |
| 694 | if options.binhost_base_url != _BINHOST_BASE_URL: |
| 695 | usage(parser, 'Error: when using --private the --binhost-base-url ' |
| 696 | 'is automatically derived.') |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 697 | return options |
| 698 | |
| 699 | def main(): |
| 700 | options = ParseOptions() |
| 701 | |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 702 | if options.filters: |
| 703 | LoadPrivateFilters(options.build_path) |
| 704 | |
David James | fd0b085 | 2011-02-23 11:15:36 -0800 | [diff] [blame] | 705 | |
David James | 05bcb2b | 2011-02-09 09:25:47 -0800 | [diff] [blame] | 706 | # Calculate a list of Packages index files to compare against. Whenever we |
| 707 | # upload a package, we check to make sure it's not already stored in one of |
| 708 | # the packages files we uploaded. This list of packages files might contain |
| 709 | # both board and host packages. |
David James | ce093af | 2011-02-23 15:21:58 -0800 | [diff] [blame] | 710 | pkg_indexes = _GrabAllRemotePackageIndexes(options.previous_binhost_url) |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 711 | |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 712 | version = GetVersion() |
| 713 | if options.prepend_version: |
| 714 | version = '%s-%s' % (options.prepend_version, version) |
| 715 | |
Scott Zawalski | ab1bed3 | 2011-03-16 15:24:24 -0700 | [diff] [blame] | 716 | acl = 'public-read' |
| 717 | binhost_base_url = options.binhost_base_url |
| 718 | |
| 719 | if options.private: |
| 720 | binhost_base_url = options.upload |
| 721 | board_path = GetBoardPathFromCrosOverlayList(options.build_path, |
| 722 | options.board) |
| 723 | acl = os.path.join(board_path, _GOOGLESTORAGE_ACL_FILE) |
| 724 | |
| 725 | uploader = PrebuiltUploader(options.upload, acl, binhost_base_url, |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 726 | pkg_indexes) |
| 727 | |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 728 | if options.sync_host: |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 729 | uploader._SyncHostPrebuilts(options.build_path, version, options.key, |
| 730 | options.git_sync, options.sync_binhost_conf) |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 731 | |
| 732 | if options.board: |
David James | c0f158a | 2011-02-22 16:07:29 -0800 | [diff] [blame] | 733 | uploader._SyncBoardPrebuilts(options.board, options.build_path, version, |
| 734 | options.key, options.git_sync, |
David James | 8fa34ea | 2011-04-15 13:00:20 -0700 | [diff] [blame] | 735 | options.sync_binhost_conf, |
| 736 | options.upload_board_tarball) |
David James | 8c84649 | 2011-01-25 17:07:29 -0800 | [diff] [blame] | 737 | |
| 738 | if __name__ == '__main__': |
| 739 | main() |