diff options
author | Caroline Tice <cmtice@google.com> | 2017-05-26 11:08:37 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-05-31 14:15:47 -0700 |
commit | 8ab698a91e101c218e58a67d810d1ae0691d7b29 (patch) | |
tree | 181e1fcec2855384a0cf7957e6decaa020b9ef75 | |
parent | 4c5de98c78520452b325f10f26981c47c52430a3 (diff) | |
download | toolchain-utils-8ab698a91e101c218e58a67d810d1ae0691d7b29.tar.gz |
Verify manifest is in paladin before trying to use it.
With increasing frequency the lumpy nightly test fails very early
because it ends up trying to get a manifest that only exists in
Android, not in ChromeOS. This CL adds code to verify the manifest
version actually exists in the paladins list before trying to use it.
BUG=chromium:726778
TEST=Tested this code in the nightly build tests and it worked.
Change-Id: I86f8eb9c8e28fd4a404bc63d49d8d9fb27de8b3b
Reviewed-on: https://chromium-review.googlesource.com/517266
Commit-Ready: Caroline Tice <cmtice@chromium.org>
Tested-by: Caroline Tice <cmtice@chromium.org>
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
-rw-r--r-- | cros_utils/manifest_versions.py | 79 | ||||
-rwxr-xr-x | setup_chromeos.py | 2 |
2 files changed, 69 insertions, 12 deletions
diff --git a/cros_utils/manifest_versions.py b/cros_utils/manifest_versions.py index 52fd700f..47e2fb20 100644 --- a/cros_utils/manifest_versions.py +++ b/cros_utils/manifest_versions.py @@ -7,6 +7,7 @@ from __future__ import print_function __author__ = 'llozano@google.com (Luis Lozano)' +import copy import os import re import shutil @@ -48,8 +49,10 @@ class ManifestVersions(object): else: versions_git = ( 'https://chromium.googlesource.com/chromiumos/manifest-versions.git') - commands = ['cd {0}'.format(self.clone_location), - 'git clone {0}'.format(versions_git)] + commands = [ + 'cd {0}'.format(self.clone_location), + 'git clone {0}'.format(versions_git) + ] ret = self.ce.RunCommands(commands) if ret: logger.GetLogger().LogFatal('Failed to clone manifest-versions.') @@ -58,26 +61,78 @@ class ManifestVersions(object): if self.clone_location: shutil.rmtree(self.clone_location) + def TimeToVersionChromeOS(self, my_time): + """Convert timestamp to version number, in ChromeOS/Paladin.""" + cur_time = time.mktime(time.gmtime()) + des_time = float(my_time) + if cur_time - des_time > 7000000: + logger.GetLogger().LogFatal('The time you specify is too early.') + commands = [ + 'cd {0}'.format(self.clone_location), 'cd manifest-versions', + 'git checkout -f $(git rev-list' + + ' --max-count=1 --before={0} origin/master)'.format(my_time) + ] + ret = self.ce.RunCommands(commands) + if ret: + logger.GetLogger().LogFatal('Failed to checkout manifest at ' + 'specified time') + path = os.path.realpath( + '{0}/manifest-versions/LKGM/lkgm.xml'.format(self.clone_location)) + pp = path.split('/') + new_list = copy.deepcopy(pp) + for i, e in enumerate(pp): + if e == 'android-LKGM-candidates': + new_list[i] = 'paladin' + chrome_path = '/'.join(new_list) + if not os.path.exists(chrome_path): + logger.GetLogger().LogOutput('LKGM path is %s' % path) + logger.GetLogger().LogOutput('Cannot find path %s' % chrome_path) + pieces = os.path.basename(chrome_path).split('.') + pieces = pieces[:-2] + new_base = '.'.join(pieces) + '*' + wild_path = os.path.join('/', '/'.join(new_list[:-1]), new_base) + command = 'ls %s' % wild_path + ret, out, _ = self.ce.RunCommandWOutput(command) + if ret == 0: + out = out.strip() + files = out.split('\n') + latest = files[-1] + small = os.path.basename(latest).split('.xml')[0] + version = pp[-2] + '.' + small + else: + small = os.path.basename(path).split('.xml')[0] + version = pp[-2] + '.' + small + commands = [ + 'cd {0}'.format(self.clone_location), 'cd manifest-versions', + 'git checkout master' + ] + self.ce.RunCommands(commands) + return version + def TimeToVersion(self, my_time): """Convert timestamp to version number.""" cur_time = time.mktime(time.gmtime()) des_time = float(my_time) if cur_time - des_time > 7000000: logger.GetLogger().LogFatal('The time you specify is too early.') - commands = ['cd {0}'.format(self.clone_location), 'cd manifest-versions', - 'git checkout -f $(git rev-list' + - ' --max-count=1 --before={0} origin/master)'.format(my_time)] + commands = [ + 'cd {0}'.format(self.clone_location), 'cd manifest-versions', + 'git checkout -f $(git rev-list' + + ' --max-count=1 --before={0} origin/master)'.format(my_time) + ] ret = self.ce.RunCommands(commands) if ret: logger.GetLogger().LogFatal('Failed to checkout manifest at ' 'specified time') - path = os.path.realpath('{0}/manifest-versions/LKGM/lkgm.xml'.format( - self.clone_location)) + path = os.path.realpath( + '{0}/manifest-versions/LKGM/lkgm.xml'.format(self.clone_location)) pp = path.split('/') small = os.path.basename(path).split('.xml')[0] version = pp[-2] + '.' + small - commands = ['cd {0}'.format(self.clone_location), 'cd manifest-versions', - 'git checkout master'] + commands = [ + 'cd {0}'.format(self.clone_location), 'cd manifest-versions', + 'git checkout master' + ] self.ce.RunCommands(commands) return version @@ -86,8 +141,10 @@ class ManifestVersions(object): assert not IsRFormatCrosVersion(version) version = version.split('.', 1)[1] os.chdir(self.clone_location) - files = [os.path.join(r, f) - for r, _, fs in os.walk('.') for f in fs if version in f] + files = [ + os.path.join(r, f) for r, _, fs in os.walk('.') for f in fs + if version in f + ] if files: command = 'cp {0} {1}'.format(files[0], to_file) ret = self.ce.RunCommand(command) diff --git a/setup_chromeos.py b/setup_chromeos.py index c81fae92..0b51d830 100755 --- a/setup_chromeos.py +++ b/setup_chromeos.py @@ -179,7 +179,7 @@ Default is 'latest_lkgm'.""") init = 'repo init -u %s' % manifest_repo elif version == 'latest_lkgm': manifests = manifest_versions.ManifestVersions() - version = manifests.TimeToVersion(time.mktime(time.gmtime())) + version = manifests.TimeToVersionChromeOS(time.mktime(time.gmtime())) version, manifest = version.split('.', 1) logger.GetLogger().LogOutput('found version %s.%s for latest LKGM' % (version, manifest)) |