aboutsummaryrefslogtreecommitdiff
path: root/setup_chromeos.py
diff options
context:
space:
mode:
authorLuis Lozano <llozano@chromium.org>2015-12-15 13:49:30 -0800
committerLuis Lozano <llozano@chromium.org>2015-12-16 17:36:06 +0000
commitf2a3ef46f75d2196a93d3ed27f4d1fcf22b54fbe (patch)
tree185d243c7eed7c7a0db6f0e640746cadc1479ea9 /setup_chromeos.py
parent2a66f70fef907c1cb15229cb58e5129cb620ac98 (diff)
downloadtoolchain-utils-f2a3ef46f75d2196a93d3ed27f4d1fcf22b54fbe.tar.gz
Run pyformat on all the toolchain-utils files.
This gets rid of a lot of lint issues. Ran by doing this: for f in *.py; do echo -n "$f " ; if [ -x $f ]; then pyformat -i --remove_trailing_comma --yapf --force_quote_type=double $f ; else pyformat -i --remove_shebang --remove_trailing_comma --yapf --force_quote_type=double $f ; fi ; done BUG=chromium:567921 TEST=Ran simple crosperf run. Change-Id: I59778835fdaa5f706d2e1765924389f9e97433d1 Reviewed-on: https://chrome-internal-review.googlesource.com/242031 Reviewed-by: Luis Lozano <llozano@chromium.org> Commit-Queue: Luis Lozano <llozano@chromium.org> Tested-by: Luis Lozano <llozano@chromium.org> Reviewed-by: Yunlian Jiang <yunlian@google.com>
Diffstat (limited to 'setup_chromeos.py')
-rwxr-xr-xsetup_chromeos.py169
1 files changed, 91 insertions, 78 deletions
diff --git a/setup_chromeos.py b/setup_chromeos.py
index 8a66c800..b90e2ae4 100755
--- a/setup_chromeos.py
+++ b/setup_chromeos.py
@@ -3,14 +3,13 @@
# Copyright 2010 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-
"""Script to checkout the ChromeOS source.
This script sets up the ChromeOS source in the given directory, matching a
particular release of ChromeOS.
"""
-__author__ = "raymes@google.com (Raymes Khoury)"
+__author__ = 'raymes@google.com (Raymes Khoury)'
from datetime import datetime
import getpass
@@ -41,64 +40,70 @@ GCLIENT_FILE = """solutions = [
# List of stable versions used for common team image
# Sheriff must update this list when a new common version becomes available
-COMMON_VERSIONS = "/home/mobiletc-prebuild/common_images/common_list.txt"
+COMMON_VERSIONS = '/home/mobiletc-prebuild/common_images/common_list.txt'
+
def Usage(parser):
parser.print_help()
sys.exit(0)
+
# Get version spec file, either from "paladin" or "buildspec" directory.
def GetVersionSpecFile(version, versions_git):
temp = tempfile.mkdtemp()
- commands = ["cd {0}".format(temp), \
- "git clone {0} versions".format(versions_git)]
+ commands = ['cd {0}'.format(temp), \
+ 'git clone {0} versions'.format(versions_git)]
cmd_executer = command_executer.GetCommandExecuter()
ret = cmd_executer.RunCommands(commands)
err_msg = None
if ret:
- err_msg = "Failed to checkout versions_git - {0}".format(versions_git)
+ err_msg = 'Failed to checkout versions_git - {0}'.format(versions_git)
ret = None
else:
- v, m = version.split(".", 1)
- paladin_spec = "paladin/buildspecs/{0}/{1}.xml".format(v, m)
- generic_spec = "buildspecs/{0}/{1}.xml".format(v, m)
- paladin_path = "{0}/versions/{1}".format(temp, paladin_spec)
- generic_path = "{0}/versions/{1}".format(temp, generic_spec)
+ v, m = version.split('.', 1)
+ paladin_spec = 'paladin/buildspecs/{0}/{1}.xml'.format(v, m)
+ generic_spec = 'buildspecs/{0}/{1}.xml'.format(v, m)
+ paladin_path = '{0}/versions/{1}'.format(temp, paladin_spec)
+ generic_path = '{0}/versions/{1}'.format(temp, generic_spec)
if os.path.exists(paladin_path):
ret = paladin_spec
elif os.path.exists(generic_path):
ret = generic_spec
else:
- err_msg = "No spec found for version {0}".format(version)
+ err_msg = 'No spec found for version {0}'.format(version)
ret = None
# Fall through to clean up.
- commands = ["rm -rf {0}".format(temp)]
+ commands = ['rm -rf {0}'.format(temp)]
cmd_executer.RunCommands(commands)
if err_msg:
logger.GetLogger().LogFatal(err_msg)
return ret
+
def TimeToCommonVersion(timestamp):
"""Convert timestamp to common image version."""
tdt = datetime.fromtimestamp(float(timestamp))
- with open(COMMON_VERSIONS, "r") as f:
+ with open(COMMON_VERSIONS, 'r') as f:
common_list = pickle.load(f)
for sv in common_list:
- sdt = datetime.strptime(sv["date"], "%Y-%m-%d %H:%M:%S.%f")
+ sdt = datetime.strptime(sv['date'], '%Y-%m-%d %H:%M:%S.%f')
if tdt >= sdt:
- return "%s.%s" % (sv["chrome_major_version"], sv["chromeos_version"])
+ return '%s.%s' % (sv['chrome_major_version'], sv['chromeos_version'])
# should never reach here
- logger.GetLogger().LogFatal("No common version for timestamp")
+ logger.GetLogger().LogFatal('No common version for timestamp')
return None
def Main(argv):
"""Checkout the ChromeOS source."""
parser = optparse.OptionParser()
- parser.add_option("--dir", dest="directory",
- help="Target directory for ChromeOS installation.")
- parser.add_option("--version", dest="version", default="latest_lkgm",
+ parser.add_option('--dir',
+ dest='directory',
+ help='Target directory for ChromeOS installation.')
+ parser.add_option('--version',
+ dest='version',
+ default='latest_lkgm',
help="""ChromeOS version. Can be:
(1) A release version in the format: 'X.X.X.X'
(2) 'top' for top of trunk
@@ -107,128 +112,136 @@ def Main(argv):
(5) 'latest_common' for the latest team common stable version
(6) 'common' for the team common stable version before timestamp
Default is 'latest_lkgm'.""")
- parser.add_option("--timestamp", dest="timestamp", default=None,
+ parser.add_option('--timestamp',
+ dest='timestamp',
+ default=None,
help="""Timestamps in epoch format. It will check out the
latest LKGM or the latest COMMON version of ChromeOS before the timestamp.
Use in combination with --version=latest or --version=common. Use
'date -d <date string> +%s' to find epoch time""")
- parser.add_option("--minilayout", dest="minilayout", default=False,
- action="store_true",
+ parser.add_option('--minilayout',
+ dest='minilayout',
+ default=False,
+ action='store_true',
help="""Whether to checkout the minilayout
(smaller checkout).'""")
- parser.add_option("--jobs", "-j", dest="jobs",
- help="Number of repo sync threads to use.")
- parser.add_option("--public", "-p", dest="public", default=False,
- action="store_true",
- help="Use the public checkout instead of the private one.")
+ parser.add_option('--jobs',
+ '-j',
+ dest='jobs',
+ help='Number of repo sync threads to use.')
+ parser.add_option('--public',
+ '-p',
+ dest='public',
+ default=False,
+ action='store_true',
+ help='Use the public checkout instead of the private one.')
options = parser.parse_args(argv)[0]
if not options.version:
parser.print_help()
- logger.GetLogger().LogFatal("No version specified.")
+ logger.GetLogger().LogFatal('No version specified.')
else:
version = options.version.strip()
if not options.timestamp:
- timestamp = ""
+ timestamp = ''
else:
timestamp = options.timestamp.strip()
- if version not in ("lkgm", "common"):
+ if version not in ('lkgm', 'common'):
parser.print_help()
- logger.GetLogger().LogFatal("timestamp option only applies for "
+ logger.GetLogger().LogFatal('timestamp option only applies for '
"versions \"lkgm\" or \"common\"")
if not options.directory:
parser.print_help()
- logger.GetLogger().LogFatal("No directory specified.")
+ logger.GetLogger().LogFatal('No directory specified.')
directory = options.directory.strip()
if options.public:
- manifest_repo = "https://chromium.googlesource.com/chromiumos/manifest.git"
- versions_repo = ("https://chromium.googlesource.com/"
- "chromiumos/manifest-versions.git")
+ manifest_repo = 'https://chromium.googlesource.com/chromiumos/manifest.git'
+ versions_repo = ('https://chromium.googlesource.com/'
+ 'chromiumos/manifest-versions.git')
else:
manifest_repo = (
- "https://chrome-internal.googlesource.com/chromeos/manifest-internal.git")
+ 'https://chrome-internal.googlesource.com/chromeos/manifest-internal.git'
+ )
versions_repo = (
- "https://chrome-internal.googlesource.com/chromeos/manifest-versions.git")
+ 'https://chrome-internal.googlesource.com/chromeos/manifest-versions.git'
+ )
- if version == "top":
- init = "repo init -u %s" % manifest_repo
- elif version == "latest_lkgm":
+ if version == 'top':
+ init = 'repo init -u %s' % manifest_repo
+ elif version == 'latest_lkgm':
manifests = manifest_versions.ManifestVersions()
version = manifests.TimeToVersion(time.mktime(time.gmtime()))
- version, manifest = version.split(".", 1)
- logger.GetLogger().LogOutput("found version %s.%s for latest LKGM" % (
- version, manifest))
- init = ("repo init -u %s -m paladin/buildspecs/%s/%s.xml" % (
- versions_repo, version, manifest))
+ version, manifest = version.split('.', 1)
+ logger.GetLogger().LogOutput('found version %s.%s for latest LKGM' %
+ (version, manifest))
+ init = ('repo init -u %s -m paladin/buildspecs/%s/%s.xml' %
+ (versions_repo, version, manifest))
del manifests
- elif version == "lkgm":
+ elif version == 'lkgm':
if not timestamp:
parser.print_help()
- logger.GetLogger().LogFatal("No timestamp specified for version=lkgm")
+ logger.GetLogger().LogFatal('No timestamp specified for version=lkgm')
manifests = manifest_versions.ManifestVersions()
version = manifests.TimeToVersion(timestamp)
- version, manifest = version.split(".", 1)
- logger.GetLogger().LogOutput("found version %s.%s for LKGM at timestamp %s"
+ version, manifest = version.split('.', 1)
+ logger.GetLogger().LogOutput('found version %s.%s for LKGM at timestamp %s'
% (version, manifest, timestamp))
- init = ("repo init -u %s -m paladin/buildspecs/%s/%s.xml" % (
- versions_repo, version, manifest))
+ init = ('repo init -u %s -m paladin/buildspecs/%s/%s.xml' %
+ (versions_repo, version, manifest))
del manifests
- elif version == "latest_common":
+ elif version == 'latest_common':
version = TimeToCommonVersion(time.mktime(time.gmtime()))
- version, manifest = version.split(".", 1)
- logger.GetLogger().LogOutput("found version %s.%s for latest Common image" %
+ version, manifest = version.split('.', 1)
+ logger.GetLogger().LogOutput('found version %s.%s for latest Common image' %
(version, manifest))
- init = ("repo init -u %s -m buildspecs/%s/%s.xml" % (
- versions_repo, version, manifest))
- elif version == "common":
+ init = ('repo init -u %s -m buildspecs/%s/%s.xml' % (versions_repo, version,
+ manifest))
+ elif version == 'common':
if not timestamp:
parser.print_help()
- logger.GetLogger().LogFatal("No timestamp specified for version=lkgm")
+ logger.GetLogger().LogFatal('No timestamp specified for version=lkgm')
version = TimeToCommonVersion(timestamp)
- version, manifest = version.split(".", 1)
- logger.GetLogger().LogOutput("found version %s.%s for latest common image "
- "at timestamp %s" % (
- version, manifest, timestamp))
- init = ("repo init -u %s -m buildspecs/%s/%s.xml" % (
- versions_repo, version, manifest))
+ version, manifest = version.split('.', 1)
+ logger.GetLogger().LogOutput('found version %s.%s for latest common image '
+ 'at timestamp %s' % (version, manifest,
+ timestamp))
+ init = ('repo init -u %s -m buildspecs/%s/%s.xml' % (versions_repo, version,
+ manifest))
else:
# user specified a specific version number
version_spec_file = GetVersionSpecFile(version, versions_repo)
if not version_spec_file:
return 1
- init = "repo init -u %s -m %s" % (versions_repo, version_spec_file)
+ init = 'repo init -u %s -m %s' % (versions_repo, version_spec_file)
if options.minilayout:
- init += " -g minilayout"
+ init += ' -g minilayout'
- init += " --repo-url=https://chromium.googlesource.com/external/repo.git"
+ init += ' --repo-url=https://chromium.googlesource.com/external/repo.git'
# crosbug#31837 - "Sources need to be world-readable to properly
# function inside the chroot"
- sync = "umask 022 && repo sync"
+ sync = 'umask 022 && repo sync'
if options.jobs:
- sync += " -j %s" % options.jobs
+ sync += ' -j %s' % options.jobs
- commands = ["mkdir -p %s" % directory,
- "cd %s" % directory,
- init,
- sync]
+ commands = ['mkdir -p %s' % directory, 'cd %s' % directory, init, sync]
cmd_executer = command_executer.GetCommandExecuter()
ret = cmd_executer.RunCommands(commands)
if ret:
return ret
return cmd_executer.RunCommand(
- "git ls-remote "
- "https://chrome-internal.googlesource.com/chrome/src-internal.git "
- "> /dev/null")
+ 'git ls-remote '
+ 'https://chrome-internal.googlesource.com/chrome/src-internal.git '
+ '> /dev/null')
-if __name__ == "__main__":
+if __name__ == '__main__':
retval = Main(sys.argv)
sys.exit(retval)