def GetFullVersion(self, version): """Add the release branch and build number to a ChromeOS platform version. This will specify where you can get the latest build for the given version for the current board. Args: version: A ChromeOS platform number of the form XXXX.XX.XX, i.e., 3918.0.0. Returns: The version with release branch and build number added, as needed. E.g. R28-3918.0.0-b1234. """ assert not version.startswith('R') with self.misc_cache.Lookup( ('full-version', self.board, version)) as ref: if ref.Exists(lock=True): return osutils.ReadFile(ref.path).strip() else: # Find out the newest version from the LATEST (or LATEST-%s) file. full_version = self._GetNewestFullVersion(version=version) if full_version is None: raise MissingSDK(self.board, version) ref.AssignText(full_version) return full_version
def GetFullVersion(self, version): """Add the release branch and build number to a ChromeOS platform version. This will specify where you can get the latest build for the given version for the current board. Args: version: A ChromeOS platform number of the form XXXX.XX.XX, i.e., 3918.0.0. Returns: The version with release branch and build number added, as needed. E.g. R28-3918.0.0-b1234. """ assert not version.startswith('R') with self.misc_cache.Lookup(('full-version', self.board, version)) as ref: if ref.Exists(lock=True): return osutils.ReadFile(ref.path).strip() else: # Find out the newest version from the LATEST (or LATEST-%s) file. full_version = self._GetNewestFullVersion(version=version) if full_version is None: raise MissingSDK(self.board, version) ref.AssignText(full_version) return full_version
def GetFullVersion(self, version): """Add the release branch to a ChromeOS platform version. Arguments: version: A ChromeOS platform number of the form XXXX.XX.XX, i.e., 3918.0.0. Returns: The version with release branch prepended. I.e., R28-3918.0.0. """ def DebugGsLs(*args, **kwargs): kwargs.setdefault('retries', 0) kwargs.setdefault('debug_level', logging.DEBUG) kwargs.setdefault('error_code_ok', True) return self.gs_ctx.LS(*args, **kwargs) assert not version.startswith('R') with self.misc_cache.Lookup(('full-version', version)) as ref: if ref.Exists(lock=True): return osutils.ReadFile(ref.path).strip() else: # First, assume crbug.com/230190 has been fixed, and we can just use # the bare version. The 'ls' we do here is a relatively cheap check # compared to the pattern matching we do below. # TODO(rcui): Rename this function to VerifyVersion() lines = DebugGsLs(os.path.join(self.gs_base, version) + '/').output.splitlines() full_version = version if not lines: # TODO(rcui): Remove this code when crbug.com/230190 is fixed. lines = DebugGsLs( os.path.join(self.gs_base, 'R*-%s' % version) + '/').output.splitlines() if not lines: raise SDKError('Invalid version %s' % version) real_path = lines[0] if not real_path.startswith(self.gs_base): raise AssertionError('%s does not start with %s' % (real_path, self.gs_base)) real_path = real_path[len(self.gs_base) + 1:] full_version = real_path.partition('/')[0] if not full_version.endswith(version): raise AssertionError('%s does not end with %s' % (full_version, version)) ref.AssignText(full_version) return full_version
def GetFullVersion(self, version): """Add the release branch to a ChromeOS platform version. Arguments: version: A ChromeOS platform number of the form XXXX.XX.XX, i.e., 3918.0.0. Returns: The version with release branch prepended. I.e., R28-3918.0.0. """ def DebugGsLs(*args, **kwargs): kwargs.setdefault('retries', 0) kwargs.setdefault('debug_level', logging.DEBUG) kwargs.setdefault('error_code_ok', True) return self.gs_ctx.LS(*args, **kwargs) assert not version.startswith('R') with self.misc_cache.Lookup(('full-version', version)) as ref: if ref.Exists(lock=True): return osutils.ReadFile(ref.path).strip() else: # First, assume crbug.com/230190 has been fixed, and we can just use # the bare version. The 'ls' we do here is a relatively cheap check # compared to the pattern matching we do below. # TODO(rcui): Rename this function to VerifyVersion() lines = DebugGsLs( os.path.join(self.gs_base, version) + '/').output.splitlines() full_version = version if not lines: # TODO(rcui): Remove this code when crbug.com/230190 is fixed. lines = DebugGsLs(os.path.join( self.gs_base, 'R*-%s' % version) + '/').output.splitlines() if not lines: raise SDKError('Invalid version %s' % version) real_path = lines[0] if not real_path.startswith(self.gs_base): raise AssertionError('%s does not start with %s' % (real_path, self.gs_base)) real_path = real_path[len(self.gs_base) + 1:] full_version = real_path.partition('/')[0] if not full_version.endswith(version): raise AssertionError('%s does not end with %s' % (full_version, version)) ref.AssignText(full_version) return full_version
def GetDefaultVersion(self): """Get the default SDK version to use. If we are in an existing SDK shell, the default version will just be the current version. Otherwise, we will try to calculate the appropriate version to use based on the checkout. """ if os.environ.get(self.SDK_BOARD_ENV) == self.board: sdk_version = os.environ.get(self.SDK_VERSION_ENV) if sdk_version is not None: return sdk_version with self.misc_cache.Lookup((self.board, 'latest')) as ref: if ref.Exists(lock=True): version = osutils.ReadFile(ref.path).strip() # Deal with the old version format. if version.startswith('R'): version = version.split('-')[1] return version else: return None
def GetDefaultVersion(self): """Get the default SDK version to use. If we are in an existing SDK shell, use the SDK version of the shell. Otherwise, use what we defaulted to last time. If there was no last time, returns None. """ if os.environ.get(self.SDK_BOARD_ENV) == self.board: sdk_version = os.environ.get(self.SDK_VERSION_ENV) if sdk_version is not None: return sdk_version with self.misc_cache.Lookup((self.board, 'latest')) as ref: if ref.Exists(lock=True): version = osutils.ReadFile(ref.path).strip() # Deal with the old version format. if version.startswith('R'): version = version.split('-')[1] return version else: return None
def GetFullVersion(self, version): """Add the release branch to a ChromeOS platform version. Args: version: A ChromeOS platform number of the form XXXX.XX.XX, i.e., 3918.0.0. Returns: The version with release branch prepended. I.e., R28-3918.0.0. """ assert not version.startswith('R') with self.misc_cache.Lookup(('full-version', version)) as ref: if ref.Exists(lock=True): return osutils.ReadFile(ref.path).strip() else: # Find out the newest version from the LATEST (or LATEST-%s) file. full_version = self._GetNewestFullVersion(version=version) if full_version is None: raise MissingSDK(self.board, version) ref.AssignText(full_version) return full_version
def ValidateVersion(version): if version.startswith('R') or len(version.split('.')) != 3: raise argparse.ArgumentTypeError( '--version should be in the format 3912.0.0') return version