Remove no-longer-needed scripts (#37881)
This commit is contained in:
@@ -1 +0,0 @@
|
||||
7b727f0d4c853c9848847839a317300cb83f4ece
|
||||
@@ -1 +0,0 @@
|
||||
7690a8ffe9ad4e7e65382c721bc1d8ba0e3829ef
|
||||
@@ -1 +0,0 @@
|
||||
e21479f1ae8d2fac385c3965672c912d08dff280
|
||||
@@ -1 +0,0 @@
|
||||
c09a7d34318f0574972a4bc9cd4b4ffa0eb267af
|
||||
@@ -1 +0,0 @@
|
||||
6a0a0b852dc974b8aed40dad44f0feb4e128e737
|
||||
@@ -1,123 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# Copyright 2015 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.
|
||||
|
||||
"""
|
||||
Downloads trimmed-down Android Tools from Google Cloud Storage and extracts
|
||||
them to INSTALL_DIR, updating INSTALL_DIR/VERSION_* stamp files with current
|
||||
version. Does nothing if INSTALL_DIR/VERSION_* are already up to date.
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import optparse
|
||||
|
||||
# Path constants. (All of these should be absolute paths.)
|
||||
THIS_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
INSTALL_DIR = os.path.join(THIS_DIR, 'android_tools')
|
||||
|
||||
import find_depot_tools
|
||||
|
||||
DEPOT_PATH = find_depot_tools.add_depot_tools_to_path()
|
||||
GSUTIL_PATH = os.path.join(DEPOT_PATH, 'gsutil.py')
|
||||
|
||||
def RunCommand(command):
|
||||
"""Run command and return success (True) or failure."""
|
||||
|
||||
print 'Running %s' % (str(command))
|
||||
if subprocess.call(command, shell=False) == 0:
|
||||
return True
|
||||
print 'Failed.'
|
||||
return False
|
||||
|
||||
def GetInstalledVersion(version_stamp):
|
||||
version_file = os.path.join(INSTALL_DIR, version_stamp)
|
||||
if not os.path.exists(version_file):
|
||||
return None
|
||||
with open(version_file) as f:
|
||||
return f.read().strip()
|
||||
|
||||
def VersionStampName(tools_name):
|
||||
if sys.platform.startswith('linux'):
|
||||
return 'VERSION_LINUX_' + tools_name.upper()
|
||||
elif sys.platform == 'darwin':
|
||||
return 'VERSION_MACOSX_' + tools_name.upper()
|
||||
elif sys.platform.startswith(('cygwin', 'win')):
|
||||
return 'VERSION_WIN_' + tools_name.upper()
|
||||
else:
|
||||
raise Exception('Unsupported platform: ' + sys.platform)
|
||||
|
||||
def UpdateTools(tools_name):
|
||||
"""Downloads zipped tools from Google Cloud Storage and extracts them,
|
||||
stamping current version."""
|
||||
|
||||
# Read latest version.
|
||||
version_stamp = VersionStampName(tools_name)
|
||||
version = ''
|
||||
with open(os.path.join(THIS_DIR, version_stamp)) as f:
|
||||
version = f.read().strip()
|
||||
# Return if installed binaries are up to date.
|
||||
if version == GetInstalledVersion(version_stamp):
|
||||
return True
|
||||
|
||||
# Remove the old install directory checked out from git.
|
||||
if os.path.exists(os.path.join(INSTALL_DIR, '.git')):
|
||||
shutil.rmtree(INSTALL_DIR)
|
||||
# Make sure that the install directory exists.
|
||||
if not os.path.exists(INSTALL_DIR):
|
||||
os.mkdir(INSTALL_DIR)
|
||||
# Remove current installation.
|
||||
tools_root = os.path.join(INSTALL_DIR, tools_name)
|
||||
if os.path.exists(tools_root):
|
||||
shutil.rmtree(tools_root)
|
||||
|
||||
# Download tools from GCS.
|
||||
archive_path = os.path.join(INSTALL_DIR, tools_name + '.tar.gz')
|
||||
download_cmd = ['python', GSUTIL_PATH, 'cp',
|
||||
'gs://mojo/android/tool/%s.tar.gz' % version,
|
||||
archive_path]
|
||||
if not RunCommand(download_cmd):
|
||||
print ('WARNING: Failed to download Android tools.')
|
||||
return False
|
||||
|
||||
print "Extracting Android tools (" + tools_name + ")"
|
||||
with tarfile.open(archive_path) as arch:
|
||||
arch.extractall(INSTALL_DIR)
|
||||
os.remove(archive_path)
|
||||
# Write version as the last step.
|
||||
with open(os.path.join(INSTALL_DIR, version_stamp), 'w+') as f:
|
||||
f.write('%s\n' % version)
|
||||
return True
|
||||
|
||||
def main(argv):
|
||||
option_parser = optparse.OptionParser()
|
||||
option_parser.add_option('-t',
|
||||
'--type',
|
||||
help='type of the tools: sdk, ndk, or both',
|
||||
type='string',
|
||||
default='both')
|
||||
(options, args) = option_parser.parse_args(argv)
|
||||
|
||||
if len(args) > 1:
|
||||
print 'Unknown argument: ', args[1:]
|
||||
option_parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
if not options.type in ('sdk', 'ndk', 'both'):
|
||||
option_parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
if options.type in ('sdk', 'both') and not UpdateTools('sdk'):
|
||||
print ('ERROR: Failed to download sdk.')
|
||||
sys.exit(1)
|
||||
|
||||
if options.type in ('ndk', 'both') and not UpdateTools('ndk'):
|
||||
print ('ERROR: Failed to download ndk.')
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
||||
@@ -1,45 +0,0 @@
|
||||
# Copyright (c) 2011 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.
|
||||
"""Small utility function to find depot_tools and add it to the python path.
|
||||
|
||||
Will throw an ImportError exception if depot_tools can't be found since it
|
||||
imports breakpad.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def IsRealDepotTools(path):
|
||||
return os.path.isfile(os.path.join(path, 'gclient.py'))
|
||||
|
||||
|
||||
def add_depot_tools_to_path():
|
||||
"""Search for depot_tools and add it to sys.path."""
|
||||
# First look if depot_tools is already in PYTHONPATH.
|
||||
for i in sys.path:
|
||||
if i.rstrip(os.sep).endswith('depot_tools') and IsRealDepotTools(i):
|
||||
return i
|
||||
# Then look if depot_tools is in PATH, common case.
|
||||
for i in os.environ['PATH'].split(os.pathsep):
|
||||
if IsRealDepotTools(i):
|
||||
sys.path.append(i.rstrip(os.sep))
|
||||
return i
|
||||
# Rare case, it's not even in PATH, look upward up to root.
|
||||
root_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
previous_dir = os.path.abspath(__file__)
|
||||
while root_dir and root_dir != previous_dir:
|
||||
i = os.path.join(root_dir, 'depot_tools')
|
||||
if IsRealDepotTools(i):
|
||||
sys.path.append(i)
|
||||
return i
|
||||
previous_dir = root_dir
|
||||
root_dir = os.path.dirname(root_dir)
|
||||
print >> sys.stderr, 'Failed to find depot_tools'
|
||||
return None
|
||||
|
||||
add_depot_tools_to_path()
|
||||
|
||||
# pylint: disable=W0611
|
||||
import breakpad
|
||||
@@ -1,131 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# Copyright 2015 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.
|
||||
|
||||
"""
|
||||
This script takes an Android Tools tree, creates a tar.gz archive and
|
||||
uploads it to Google Cloud Storage at gs://mojo/android/tool. It also produces
|
||||
the VERSION stamp files with the sha1 code of the uploaded archive.
|
||||
|
||||
This script operates in the INSTALL_DIR directory, so it automatically updates
|
||||
your current installation of the android tools binaries on success. On failure
|
||||
it invalidates your current installation; to fix it, run
|
||||
run download_android_tools.py.
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import optparse
|
||||
|
||||
# Path constants. (All of these should be absolute paths.)
|
||||
THIS_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
INSTALL_DIR = os.path.join(THIS_DIR, 'android_tools')
|
||||
|
||||
import find_depot_tools
|
||||
|
||||
DEPOT_PATH = find_depot_tools.add_depot_tools_to_path()
|
||||
GSUTIL_PATH = os.path.join(DEPOT_PATH, 'gsutil.py')
|
||||
|
||||
def RunCommand(command, env=None):
|
||||
"""Run command and return success (True) or failure."""
|
||||
|
||||
print 'Running %s' % (str(command))
|
||||
if subprocess.call(command, shell=False, env=env) == 0:
|
||||
return True
|
||||
print 'Failed.'
|
||||
return False
|
||||
|
||||
def VersionStampName(tools_name):
|
||||
if sys.platform.startswith('linux'):
|
||||
return 'VERSION_LINUX_' + tools_name.upper()
|
||||
elif sys.platform == 'darwin':
|
||||
return 'VERSION_MACOSX_' + tools_name.upper()
|
||||
elif sys.platform.startswith(('cygwin', 'win')):
|
||||
return 'VERSION_WIN_' + tools_name.upper()
|
||||
else:
|
||||
raise Exception('Unsupported platform: ' + sys.platform)
|
||||
|
||||
def CheckInstallDir(tools_name):
|
||||
"""Check if the tools directory exists."""
|
||||
|
||||
tools_dir = os.path.join(INSTALL_DIR, tools_name)
|
||||
if not os.path.exists(tools_dir):
|
||||
print tools_dir + ' does not exists'
|
||||
sys.exit(1)
|
||||
# Remove the existing version stamp.
|
||||
version_stamp = VersionStampName(tools_name)
|
||||
stamp_file = os.path.join(INSTALL_DIR, version_stamp)
|
||||
if os.path.exists(stamp_file):
|
||||
os.remove(stamp_file)
|
||||
|
||||
def Compress(tools_name):
|
||||
"""Compresses the tools into tar.gz and generates sha1 code, renames the
|
||||
archive to sha1.tar.gz and returns the sha1 code."""
|
||||
|
||||
print "Compressing tools, this may take several minutes."
|
||||
os.chdir(INSTALL_DIR)
|
||||
archive_name = tools_name + '.tar.gz'
|
||||
with tarfile.open(os.path.join(archive_name), 'w|gz') as tools:
|
||||
tools.add(tools_name)
|
||||
|
||||
sha1 = ''
|
||||
with open(os.path.join(INSTALL_DIR, archive_name)) as f:
|
||||
sha1 = hashlib.sha1(f.read()).hexdigest()
|
||||
os.rename(os.path.join(INSTALL_DIR, archive_name),
|
||||
os.path.join(INSTALL_DIR, '%s.tar.gz' % sha1))
|
||||
return sha1
|
||||
|
||||
def Upload(tools_name, sha1):
|
||||
"""Uploads INSTALL_DIR/sha1.tar.gz to Google Cloud Storage under
|
||||
gs://mojo/android/tool and writes sha1 to THIS_DIR/VERSION_*."""
|
||||
|
||||
file_name = '%s.tar.gz' % sha1
|
||||
upload_cmd = ['python', GSUTIL_PATH, 'cp',
|
||||
'-n', # Do not upload if the file already exists.
|
||||
os.path.join(INSTALL_DIR, file_name),
|
||||
'gs://mojo/android/tool/%s' % file_name]
|
||||
|
||||
print "Uploading ' + tools_name + ' tools to GCS."
|
||||
if not RunCommand(upload_cmd):
|
||||
print "Failed to upload android tool to GCS."
|
||||
sys.exit(1)
|
||||
os.remove(os.path.join(INSTALL_DIR, file_name))
|
||||
# Write versions as the last step.
|
||||
version_stamp = VersionStampName(tools_name)
|
||||
stamp_file = os.path.join(THIS_DIR, version_stamp)
|
||||
with open(stamp_file, 'w+') as stamp:
|
||||
stamp.write('%s\n' % sha1)
|
||||
|
||||
stamp_file = os.path.join(INSTALL_DIR, version_stamp)
|
||||
with open(stamp_file, 'w+') as stamp:
|
||||
stamp.write('%s\n' % sha1)
|
||||
|
||||
def main(argv):
|
||||
option_parser = optparse.OptionParser()
|
||||
option_parser.add_option('-t',
|
||||
'--type',
|
||||
help='type of the tools: sdk or ndk',
|
||||
type='string')
|
||||
(options, args) = option_parser.parse_args(argv)
|
||||
|
||||
if len(args) > 1:
|
||||
print 'Unknown argument: ', args[1:]
|
||||
option_parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
if not options.type in {'sdk', 'ndk'}:
|
||||
option_parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
CheckInstallDir(options.type)
|
||||
sha1 = Compress(options.type)
|
||||
Upload(options.type, sha1)
|
||||
print "Done."
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
||||
Reference in New Issue
Block a user