Ejemplo n.º 1
0
def download_and_unpack_rust_deps(platform):
    if not should_download():
        return 0

    url = get_url(platform)

    try:
        deps.DownloadAndUnpack(url, RUSTUP_PATH)
    except URLError:
        print('Failed to download Rust deps: %s' % url)
        print('Exiting.')
        sys.exit(1)
Ejemplo n.º 2
0
def DownloadAndUnpackRustDeps(platform):
    if AlreadyUpToDate():
        return 0

    url = GetUrl(platform)

    try:
        deps.DownloadAndUnpack(url, RUSTUP_DIR)
    except urllib2.URLError:
        print 'Failed to download Rust deps %s' % url
        print 'Exiting.'
        sys.exit(1)
Ejemplo n.º 3
0
def InstallXcodeBinaries():
    """Installs the Xcode binaries and accepts the license."""

    # only download for Brave goma users
    goma_server_host = os.environ.get('npm_config_goma_server_host')
    if goma_server_host is None or not goma_server_host.endswith('.brave.com'):
        print("Goma server host is not configured for Brave")
        return 0

    binaries_root = os.path.join(TOOLCHAIN_ROOT, 'xcode_binaries')
    if (XCODE_VERSION == GetHermeticXcodeVersion(binaries_root)
            and not os.path.islink(binaries_root)):
        print(f"Hermetic Xcode {XCODE_VERSION} already installed")
        return 0

    url = HERMETIC_XCODE_BINARY
    print(f"Downloading hermetic Xcode: {url}")
    try:
        deps.DownloadAndUnpack(url, binaries_root)
    except URLError:
        print(f"Failed to download hermetic Xcode: {url}")
        print("Exiting.")
        return 1

    # Accept the license for this version of Xcode if it's newer than the
    # currently accepted version.
    hermetic_xcode_version = GetHermeticXcodeVersion(binaries_root)

    hermetic_xcode_license_path = os.path.join(
        binaries_root, 'Contents/Resources/LicenseInfo.plist')
    hermetic_xcode_license_plist = LoadPList(hermetic_xcode_license_path)
    hermetic_xcode_license_version = hermetic_xcode_license_plist['licenseID']

    should_overwrite_license = True
    current_license_path = '/Library/Preferences/com.apple.dt.Xcode.plist'
    if os.path.exists(current_license_path):
        current_license_plist = LoadPList(current_license_path)
        xcode_version = current_license_plist.get(
            'IDEXcodeVersionForAgreedToGMLicense')
        if (xcode_version is not None
                and pkg_resources.parse_version(xcode_version) >=
                pkg_resources.parse_version(hermetic_xcode_version)):
            should_overwrite_license = False

    if not should_overwrite_license:
        return 0

    # Use puppet's sudoers script to accept the license if its available.
    license_accept_script = '/usr/local/bin/xcode_accept_license.py'
    if os.path.exists(license_accept_script):
        args = [
            'sudo', license_accept_script, '--xcode-version',
            hermetic_xcode_version, '--license-version',
            hermetic_xcode_license_version
        ]
        subprocess.check_call(args)
        return 0

    # Otherwise manually accept the license. This will prompt for sudo.
    print('Accepting new Xcode license. Requires sudo.')
    sys.stdout.flush()
    args = [
        'sudo', 'defaults', 'write', current_license_path,
        'IDEXcodeVersionForAgreedToGMLicense', hermetic_xcode_version
    ]
    subprocess.check_call(args)
    args = [
        'sudo', 'defaults', 'write', current_license_path,
        'IDELastGMLicenseAgreedTo', hermetic_xcode_license_version
    ]
    subprocess.check_call(args)
    args = ['sudo', 'plutil', '-convert', 'xml1', current_license_path]
    subprocess.check_call(args)

    return 0