Example #1
0
	def _visible(self, cpv, metadata):
		eapi = metadata["EAPI"]
		if not eapi_is_supported(eapi):
			return False
		if _eapi_is_deprecated(eapi):
			return False
		if not metadata["SLOT"]:
			return False

		settings = self.settings
		if settings._getMaskAtom(cpv, metadata):
			return False
		if settings._getMissingKeywords(cpv, metadata):
			return False
		if settings.local_config:
			metadata['CHOST'] = settings.get('CHOST', '')
			if not settings._accept_chost(cpv, metadata):
				return False
			metadata["USE"] = ""
			if "?" in metadata["LICENSE"] or \
				"?" in metadata["PROPERTIES"]:
				self.doebuild_settings.setcpv(cpv, mydb=metadata)
				metadata['USE'] = self.doebuild_settings['PORTAGE_USE']
			try:
				if settings._getMissingLicenses(cpv, metadata):
					return False
				if settings._getMissingProperties(cpv, metadata):
					return False
				if settings._getMissingRestrict(cpv, metadata):
					return False
			except InvalidDependString:
				return False

		return True
Example #2
0
	def _visible(self, cpv, metadata):
		eapi = metadata["EAPI"]
		if not eapi_is_supported(eapi):
			return False
		if _eapi_is_deprecated(eapi):
			return False
		if not metadata["SLOT"]:
			return False

		settings = self.settings
		if settings._getMaskAtom(cpv, metadata):
			return False
		if settings._getMissingKeywords(cpv, metadata):
			return False
		if settings.local_config:
			metadata['CHOST'] = settings.get('CHOST', '')
			if not settings._accept_chost(cpv, metadata):
				return False
			metadata["USE"] = ""
			if "?" in metadata["LICENSE"] or \
				"?" in metadata["PROPERTIES"]:
				self.doebuild_settings.setcpv(cpv, mydb=metadata)
				metadata['USE'] = self.doebuild_settings['PORTAGE_USE']
			try:
				if settings._getMissingLicenses(cpv, metadata):
					return False
				if settings._getMissingProperties(cpv, metadata):
					return False
				if settings._getMissingRestrict(cpv, metadata):
					return False
			except InvalidDependString:
				return False

		return True
	def xmatch(self,level,origdep,mydep=None,mykey=None,mylist=None):
		"caching match function; very trick stuff"
		#if no updates are being made to the tree, we can consult our xcache...
		if self.frozen:
			try:
				return self.xcache[level][origdep][:]
			except KeyError:
				pass

		if not mydep:
			#this stuff only runs on first call of xmatch()
			#create mydep, mykey from origdep
			mydep = dep_expand(origdep, mydb=self, settings=self.settings)
			mykey = mydep.cp

		if level == "list-visible":
			#a list of all visible packages, not called directly (just by xmatch())
			#myval = self.visible(self.cp_list(mykey))

			myval = self.gvisible(self.visible(self.cp_list(mykey)))
		elif level == "minimum-all":
			# Find the minimum matching version. This is optimized to
			# minimize the number of metadata accesses (improves performance
			# especially in cases where metadata needs to be generated).
			cpv_iter = iter(self.cp_list(mykey))
			if mydep != mykey:
				cpv_iter = self._iter_match(mydep, cpv_iter)
			try:
				myval = next(cpv_iter)
			except StopIteration:
				myval = ""

		elif level in ("minimum-visible", "bestmatch-visible"):
			# Find the minimum matching visible version. This is optimized to
			# minimize the number of metadata accesses (improves performance
			# especially in cases where metadata needs to be generated).
			if mydep == mykey:
				mylist = self.cp_list(mykey)
			else:
				mylist = match_from_list(mydep, self.cp_list(mykey))
			myval = ""
			settings = self.settings
			local_config = settings.local_config
			aux_keys = list(self._aux_cache_keys)
			if level == "minimum-visible":
				iterfunc = iter
			else:
				iterfunc = reversed
			for cpv in iterfunc(mylist):
				try:
					metadata = dict(zip(aux_keys,
						self.aux_get(cpv, aux_keys)))
				except KeyError:
					# ebuild masked by corruption
					continue
				if not eapi_is_supported(metadata["EAPI"]):
					continue
				if mydep.slot and mydep.slot != metadata["SLOT"]:
					continue
				if settings._getMissingKeywords(cpv, metadata):
					continue
				if settings._getMaskAtom(cpv, metadata):
					continue
				if settings._getProfileMaskAtom(cpv, metadata):
					continue
				if local_config:
					metadata["USE"] = ""
					if "?" in metadata["LICENSE"] or "?" in metadata["PROPERTIES"]:
						self.doebuild_settings.setcpv(cpv, mydb=metadata)
						metadata["USE"] = self.doebuild_settings.get("USE", "")
					try:
						if settings._getMissingLicenses(cpv, metadata):
							continue
						if settings._getMissingProperties(cpv, metadata):
							continue
					except InvalidDependString:
						continue
				if mydep.use:
					has_iuse = False
					for has_iuse in self._iter_match_use(mydep, [cpv]):
						break
					if not has_iuse:
						continue
				myval = cpv
				break
		elif level == "bestmatch-list":
			#dep match -- find best match but restrict search to sublist
			#no point in calling xmatch again since we're not caching list deps

			myval = best(list(self._iter_match(mydep, mylist)))
		elif level == "match-list":
			#dep match -- find all matches but restrict search to sublist (used in 2nd half of visible())

			myval = list(self._iter_match(mydep, mylist))
		elif level == "match-visible":
			#dep match -- find all visible matches
			#get all visible packages, then get the matching ones

			myval = list(self._iter_match(mydep,
				self.xmatch("list-visible", mykey, mydep=mykey, mykey=mykey)))
		elif level == "match-all":
			#match *all* visible *and* masked packages
			if mydep == mykey:
				myval = self.cp_list(mykey)
			else:
				myval = list(self._iter_match(mydep, self.cp_list(mykey)))
		else:
			raise AssertionError(
				"Invalid level argument: '%s'" % level)

		if self.frozen and (level not in ["match-list", "bestmatch-list"]):
			self.xcache[level][mydep] = myval
			if origdep and origdep != mydep:
				self.xcache[level][origdep] = myval
		return myval[:]
Example #4
0
    def xmatch(self, level, origdep, mydep=None, mykey=None, mylist=None):
        "caching match function; very trick stuff"
        #if no updates are being made to the tree, we can consult our xcache...
        if self.frozen:
            try:
                return self.xcache[level][origdep][:]
            except KeyError:
                pass

        if not mydep:
            #this stuff only runs on first call of xmatch()
            #create mydep, mykey from origdep
            mydep = dep_expand(origdep, mydb=self, settings=self.settings)
            mykey = mydep.cp

        if level == "list-visible":
            #a list of all visible packages, not called directly (just by xmatch())
            #myval = self.visible(self.cp_list(mykey))

            myval = self.gvisible(self.visible(self.cp_list(mykey)))
        elif level == "minimum-all":
            # Find the minimum matching version. This is optimized to
            # minimize the number of metadata accesses (improves performance
            # especially in cases where metadata needs to be generated).
            cpv_iter = iter(self.cp_list(mykey))
            if mydep != mykey:
                cpv_iter = self._iter_match(mydep, cpv_iter)
            try:
                myval = next(cpv_iter)
            except StopIteration:
                myval = ""

        elif level in ("minimum-visible", "bestmatch-visible"):
            # Find the minimum matching visible version. This is optimized to
            # minimize the number of metadata accesses (improves performance
            # especially in cases where metadata needs to be generated).
            if mydep == mykey:
                mylist = self.cp_list(mykey)
            else:
                mylist = match_from_list(mydep, self.cp_list(mykey))
            myval = ""
            settings = self.settings
            local_config = settings.local_config
            aux_keys = list(self._aux_cache_keys)
            if level == "minimum-visible":
                iterfunc = iter
            else:
                iterfunc = reversed
            for cpv in iterfunc(mylist):
                try:
                    metadata = dict(zip(aux_keys, self.aux_get(cpv, aux_keys)))
                except KeyError:
                    # ebuild masked by corruption
                    continue
                if not eapi_is_supported(metadata["EAPI"]):
                    continue
                if mydep.slot and mydep.slot != metadata["SLOT"]:
                    continue
                if settings._getMissingKeywords(cpv, metadata):
                    continue
                if settings._getMaskAtom(cpv, metadata):
                    continue
                if settings._getProfileMaskAtom(cpv, metadata):
                    continue
                if local_config:
                    metadata["USE"] = ""
                    if "?" in metadata["LICENSE"] or "?" in metadata[
                            "PROPERTIES"]:
                        self.doebuild_settings.setcpv(cpv, mydb=metadata)
                        metadata["USE"] = self.doebuild_settings.get("USE", "")
                    try:
                        if settings._getMissingLicenses(cpv, metadata):
                            continue
                        if settings._getMissingProperties(cpv, metadata):
                            continue
                    except InvalidDependString:
                        continue
                if mydep.use:
                    has_iuse = False
                    for has_iuse in self._iter_match_use(mydep, [cpv]):
                        break
                    if not has_iuse:
                        continue
                myval = cpv
                break
        elif level == "bestmatch-list":
            #dep match -- find best match but restrict search to sublist
            #no point in calling xmatch again since we're not caching list deps

            myval = best(list(self._iter_match(mydep, mylist)))
        elif level == "match-list":
            #dep match -- find all matches but restrict search to sublist (used in 2nd half of visible())

            myval = list(self._iter_match(mydep, mylist))
        elif level == "match-visible":
            #dep match -- find all visible matches
            #get all visible packages, then get the matching ones

            myval = list(
                self._iter_match(
                    mydep,
                    self.xmatch("list-visible",
                                mykey,
                                mydep=mykey,
                                mykey=mykey)))
        elif level == "match-all":
            #match *all* visible *and* masked packages
            if mydep == mykey:
                myval = self.cp_list(mykey)
            else:
                myval = list(self._iter_match(mydep, self.cp_list(mykey)))
        else:
            raise AssertionError("Invalid level argument: '%s'" % level)

        if self.frozen and (level not in ["match-list", "bestmatch-list"]):
            self.xcache[level][mydep] = myval
            if origdep and origdep != mydep:
                self.xcache[level][origdep] = myval
        return myval[:]