def get_portageq_envvars(self, varnames, board=None): """Returns the values of a given set of variables using portageq.""" if isinstance(varnames, basestring): varnames = [varnames] # See if the env already has these settings. If so, grab them directly. # This avoids the need to specify --board at all most of the time. try: board_vars = {} for varname in varnames: board_vars[varname] = os.environ[varname] return board_vars except KeyError: pass if board is None and not self.host: board = self.board # Portage will set this to an incomplete list which breaks portageq # walking all of the repos. Clear it and let the value be repopulated. os.environ.pop('PORTDIR_OVERLAY', None) return portage_util.PortageqEnvvars(varnames, board=board, allow_undefined=True)
def CalculateCompatId(board, extra_useflags): """Calculate the CompatId for board with the specified extra useflags. This function requires that the board has been set up first (e.g. using GenConfigsForBoard) Args: board: The board to use. extra_useflags: A sequence of use flags to enable or disable. Returns: A CompatId object for the board with the specified extra_useflags. """ assert cros_build_lib.IsInsideChroot() useflags = GetChromeUseFlags(board, extra_useflags) result = portage_util.PortageqEnvvars(['ARCH', 'CFLAGS'], board=board) return CompatId(result['ARCH'], useflags, result['CFLAGS'].split())
def InstallToolchain(sysroot, toolchain=None, force=False, configure=True): """Simplified entry point for the toolchain installation process.""" if not cros_build_lib.IsInsideChroot(): # Build the command to run inside the chroot instead. cmd = [ os.path.join(constants.CHROMITE_BIN_DIR, 'install_toolchain'), '--sysroot', sysroot.path ] if toolchain: cmd.append('--toolchain') cmd.append(toolchain) if force: cmd.append('--force') if not configure: cmd.append('--noconfigure') cros_build_lib.run(cmd, enter_chroot=True) else: envvars = portage_util.PortageqEnvvars(['CHOST', 'PKGDIR']) installer = ToolchainInstaller(force, configure, envvars['CHOST'], envvars['PKGDIR']) installer.Install(sysroot, board_chost=toolchain)
def SummarizeCompatibility(board): """Returns a string that will be the same for compatible boards.""" result = portage_util.PortageqEnvvars(['ARCH', 'CFLAGS'], board=board) return '%s %s' % (result['ARCH'], result['CFLAGS'])