blob: 555567e6d7111c29251d7351fb9f424d8a5877a5 [file] [log] [blame]
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Syncs the nacl sdk at a pinned version given in NACLSDK.json."""
import argparse
import logging
import os
import shutil
import sys
import urllib
from import build_common
from import logging_util
from import download_package_util
from import download_package_util_flags
_DEPS_FILE_PATH = 'src/build/DEPS.naclsdk'
_LATEST_MANIFEST_URL = _NACL_MIRROR + '/nacl/nacl_sdk/naclsdk_manifest2.json'
_NACL_SDK_ZIP_URL = _NACL_MIRROR + '/nacl/nacl_sdk/'
_SRC_FILES = ['canned/host/nacl_sdk/',
_DST_FILE_PATH = 'third_party/nacl_sdk/sdk_tools/'
def roll_pinned_manifest_forward():
"""Roll forward the pinned manifest to the latest version."""'Rolling forward the pinned NaCl manifest.')
urllib.urlretrieve(_LATEST_MANIFEST_URL, _DEPS_FILE_PATH)'Done.')
class NaClSDKFiles(download_package_util.BasicCachedPackage):
"""Handles syncing the NaCl SDK."""
def post_update_work(self):
# Update based on pinned manifest. This part can be as slow as 1-2 minutes
# regardless of whether it is a fresh install or an update.
# Awful hack to avoid the certificates file used by NaCl SDK tools, as the
# current one causes an InvalidCertificateException. This will prevent
# NaCl SDK Tools from self-updating, as well as prevent the NaCl SDK Tools
# from using a now-invalid certificate file.
dst = os.path.join(build_common.get_arc_root(), _DST_FILE_PATH)
for f in _SRC_FILES:
src = os.path.join(build_common.get_arc_root(), f)'%s: copying %s to %s',, src, dst)
shutil.copy(src, dst)'%s: Updating naclsdk using manifest.',
'./naclsdk', 'update', '-U',
'file://' + os.path.join(build_common.get_arc_root(),
'--force', 'pepper_canary'], cwd=self.unpacked_linked_cache_path)
def check_and_perform_updates(cache_base_path, cache_history_size):
def main(args):
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--verbose', action='store_true', help='Emit '
'verbose output.')
parser.add_argument('-r', '--roll-forward', dest='roll', action='store_true',
help='Update pinned NaCl SDK manifest version to the '
args = parser.parse_args(args)
logging_util.setup(level=logging.DEBUG if args.verbose else logging.WARNING)
if args.roll:
check_and_perform_updates(args.download_cache_path, args.download_cache_size)
if __name__ == '__main__':