Пример #1
0
def get_output_descriptions(pkg, global_usedesc):
	"""Prepare descriptions and usage information for each USE flag."""

	if pkg.metadata is None:
		local_usedesc = []
	else:
		local_usedesc = pkg.metadata.use()

	iuse, final_use = get_flags(pkg.cpv, final_setting=True)
	usevar = reduce_flags(iuse)
	usevar.sort()

	if QUERY_OPTS['ignore_l10n']:
		for a in usevar[:]:
			#TODO: Remove linguas after transition to l10n is complete
			if a.startswith("l10n_") or a.startswith("linguas_"):
				usevar.remove(a)


	if pkg.is_installed():
		used_flags = pkg.use().split()
	else:
		used_flags = settings["USE"].split()

	# store (inuse, inused, flag, desc, restrict)
	output = []
	for flag in usevar:
		inuse = False
		inused = False

		local_use = None
		for use in local_usedesc:
			if use.name == flag:
				local_use = use
				break

		try:
			desc = local_use.description
		except AttributeError:
			try:
				desc = global_usedesc[flag]
			except KeyError:
				desc = ""

		try:
			restrict = local_use.restrict
			restrict = restrict if restrict is not None else ""
		except AttributeError:
			restrict = ""

		if flag in final_use:
			inuse = True
		if flag in used_flags:
			inused = True

		output.append((inuse, inused, flag, desc, restrict))

	return output
Пример #2
0
def findUseFlagCombis (package, config, port):
    """
    Generate combinations of use flags to test
    The output will be a list each containing a ready to use USE=... string
    """
    uselist = sorted(reduce_flags(get_flags(dep_getcpv(package.packageString()))))
    # The uselist could have duplicates due to slot-conditional
    # output of equery
    uselist=unique(uselist)
    for i in config['ignoreprefix']:
        uselist=[u for u in uselist if not re.match(i,u)]

    ruse = " ".join(port.aux_get(dep_getcpv(package.packageString()), ["REQUIRED_USE"]))
    swlist = []
    if config['usecombis'] == 0:
        # Do only all and nothing:
        if check_uses(ruse, uselist, 0, package):
            swlist.append(0)
        if check_uses(ruse, uselist, 2**len(uselist) - 1):
            swlist.append(2**len(uselist) - 1)
    # Test if we can exhaust all USE-combis by computing the binary logarithm.
    elif len(uselist) > math.log(config['usecombis'],2):
        # Generate a sample of USE combis
        s = 2**(len (uselist))
        rnds = set()
        random.seed()
        while len(swlist) < config['usecombis'] and len(rnds) < s:
            r = random.randint(0, s-1)
            if r in rnds:
                # already checked
                continue
            rnds.add(r)

            if not check_uses(ruse, uselist, r, package):
                # invalid combination
                continue

            swlist.append(r)

        swlist.sort()
    else:
        # Yes we can: generate all combinations
        for pos in range(2**len(uselist)):
            if check_uses(ruse, uselist, pos, package):
                swlist.append(pos)

    usecombis=[]
    for sw in swlist:
        mod = []
        for pos in range(len(uselist)):
            if ((2**pos) & sw):
                mod.append("")
            else:
                mod.append("-")
        usecombis.append(" ".join(["".join(uf) for uf in list(zip(mod, uselist))]))

    # Merge everything to a USE="" string
    return ["USE=\'" + uc + "\'" for uc in usecombis]
Пример #3
0
def get_output_descriptions(pkg, global_usedesc):
	"""Prepare descriptions and usage information for each USE flag."""

	if pkg.metadata is None:
		local_usedesc = []
	else:
		local_usedesc = pkg.metadata.use()

	iuse, final_use = get_flags(pkg.cpv, final_setting=True)
	usevar = reduce_flags(iuse)
	usevar.sort()

	if QUERY_OPTS['ignore_linguas']:
		for a in usevar[:]:
			if a.startswith("linguas_"):
				usevar.remove(a)


	if pkg.is_installed():
		used_flags = pkg.use().split()
	else:
		used_flags = settings["USE"].split()

	# store (inuse, inused, flag, desc, restrict)
	output = []
	for flag in usevar:
		inuse = False
		inused = False

		local_use = None
		for use in local_usedesc:
			if use.name == flag:
				local_use = use
				break

		try:
			desc = local_use.description
		except AttributeError:
			try:
				desc = global_usedesc[flag]
			except KeyError:
				desc = ""

		try:
			restrict = local_use.restrict
			restrict = restrict if restrict is not None else ""
		except AttributeError:
			restrict = ""

		if flag in final_use:
			inuse = True
		if flag in used_flags:
			inused = True

		output.append((inuse, inused, flag, desc, restrict))

	return output
Пример #4
0
def get_output_descriptions(pkg, global_usedesc):
	"""Prepare descriptions and usage information for each USE flag."""

	if pkg.metadata is None:
		local_usedesc = []
	else:
		local_usedesc = pkg.metadata.use()

	iuse, final_use = get_flags(pkg.cpv, final_setting=True)
	usevar = reduce_flags(iuse)
	usevar.sort()
	

	if pkg.is_installed():
		used_flags = pkg.use().split()
	else:
		used_flags = settings["USE"].split()

	# store (inuse, inused, flag, desc, restrict)
	output = []
	for flag in usevar:
		inuse = False
		inused = False

		local_use = None
		for use in local_usedesc:
			if use.name == flag:
				local_use = use
				break

		try:
			desc = local_use.description
		except AttributeError:
			try:
				desc = global_usedesc[flag]
			except KeyError:
				desc = ""

		try:
			restrict = local_use.restrict
			restrict = restrict if restrict is not None else ""
		except AttributeError:
			restrict = ""

		if flag in final_use:
			inuse = True
		if flag in used_flags:
			inused = True

		output.append((inuse, inused, flag, desc, restrict))

	return output
Пример #5
0
    def use_status(self):
        """Returns the USE flags active for installation."""

        iuse, final_flags = get_flags(self.cpv, final_setting=True)
        return final_flags
Пример #6
0
	def use_status(self):
		"""Returns the USE flags active for installation."""

		iuse, final_flags = get_flags(self.cpv, final_setting=True)
		return final_flags
Пример #7
0
def findUseFlagCombis(package, config, port):
    """
    Generate combinations of use flags to test
    The output will be a list each containing a ready to use USE=... string
    """
    uselist = sorted(
        reduce_flags(get_flags(dep_getcpv(package.packageString()))))
    # The uselist could have duplicates due to slot-conditional
    # output of equery
    uselist = unique(uselist)
    for i in config['ignoreprefix']:
        uselist = [u for u in uselist if not re.match(i, u)]

    ruse = " ".join(
        port.aux_get(dep_getcpv(package.packageString()), ["REQUIRED_USE"]))
    swlist = []
    if config['usecombis'] == 0:
        # Do only all and nothing:
        if check_uses(ruse, uselist, 0, package):
            swlist.append(0)
        if check_uses(ruse, uselist, 2**len(uselist) - 1):
            swlist.append(2**len(uselist) - 1)
    # Test if we can exhaust all USE-combis by computing the binary logarithm.
    elif len(uselist) > math.log(config['usecombis'], 2):
        # Generate a sample of USE combis
        s = 2**(len(uselist))
        rnds = set()
        random.seed()
        while len(swlist) < config['usecombis'] and len(rnds) < s:
            r = random.randint(0, s - 1)
            if r in rnds:
                # already checked
                continue
            rnds.add(r)

            if not check_uses(ruse, uselist, r, package):
                # invalid combination
                continue

            swlist.append(r)

        swlist.sort()
    else:
        # Yes we can: generate all combinations
        for pos in range(2**len(uselist)):
            if check_uses(ruse, uselist, pos, package):
                swlist.append(pos)

    usecombis = []
    for sw in swlist:
        mod = []
        for pos in range(len(uselist)):
            if ((2**pos) & sw):
                mod.append("")
            else:
                mod.append("-")
        usecombis.append(" ".join(
            ["".join(uf) for uf in list(zip(mod, uselist))]))

    # Merge everything to a USE="" string
    return ["USE=\'" + uc + "\'" for uc in usecombis]
Пример #8
0
def findUseFlagCombis(package, config, port):
    """
    Generate combinations of use flags to test
    The output will be a list each containing a ready to use USE=... string
    """
    uselist = sorted(
        reduce_flags(get_flags(dep_getcpv(package.packageString()))))
    # The uselist could have duplicates due to slot-conditional
    # output of equery
    uselist = unique(uselist)
    for i in config['ignoreprefix']:
        uselist = [u for u in uselist if not re.match(i, u)]

    ruse = " ".join(
        port.aux_get(dep_getcpv(package.packageString()), ["REQUIRED_USE"]))
    swlist = []
    if config['usecombis'] == 0:
        # Do only all and nothing:
        if check_uses(ruse, uselist, 0, package):
            swlist.append(0)
        if check_uses(ruse, uselist, 2**len(uselist) - 1):
            swlist.append(2**len(uselist) - 1)
    # Test if we can exhaust all USE-combis by computing the binary logarithm.
    elif len(uselist) > math.log(config['usecombis'], 2):

        # Generate a sample of USE combis
        s = 2**(len(uselist))
        rnds = set()
        random.seed()

        attempts = 0
        ignore_use_expand = False

        while len(swlist) < config['usecombis'] and len(rnds) < s:
            if attempts >= 10000:
                if not ignore_use_expand:
                    # After 10000 attempts, let's give up on USE_EXPAND.
                    ignore_use_expand = True
                    attempts = 0

                    print(
                        "Giving up on USE_EXPAND after {0} tries to find valid USE combinations"
                        .format(attempts))
                    print("We've found {0} USE combinations so far".format(
                        len(swlist)))
                    uselist = [use for use in uselist if not "_" in use]
                else:
                    # Let's give up entirely and use what we have.
                    print(
                        "Giving up on finding more USE combinations after {0} further attempts"
                        .format(attempts))
                    print("We've found {0} USE combinations".format(
                        len(swlist)))
                    break

            r = random.randint(0, s - 1)
            if r in rnds:
                # already checked
                continue
            rnds.add(r)

            if not check_uses(ruse, uselist, r, package):
                attempts += 1
                # invalid combination
                continue

            swlist.append(r)

        swlist.sort()
    else:
        # Yes we can: generate all combinations
        for pos in range(2**len(uselist)):
            if check_uses(ruse, uselist, pos, package):
                swlist.append(pos)

    usecombis = []
    for sw in swlist:
        mod = []
        for pos in range(len(uselist)):
            if ((2**pos) & sw):
                mod.append("")
            else:
                mod.append("-")
        usecombis.append(" ".join(
            ["".join(uf) for uf in list(zip(mod, uselist))]))

    # Merge everything to a USE="" string
    return ["USE=\'" + uc + "\'" for uc in usecombis]