Exemple #1
0
def _merge_flags(new_flags, old_flags=None, conf="any"):
    """
    Merges multiple lists of flags removing duplicates and resolving conflicts
    giving priority to lasts lists.
    """
    if not old_flags:
        old_flags = []
    args = [old_flags, new_flags]
    if conf == "accept_keywords":
        tmp = new_flags + [i for i in old_flags if _check_accept_keywords(new_flags, i)]
    else:
        tmp = portage.flatten(args)
    flags = {}
    for flag in tmp:
        if flag[0] == "-":
            flags[flag[1:]] = False
        else:
            flags[flag] = True
    tmp = []
    for key, val in flags.items():
        if val:
            tmp.append(key)
        else:
            tmp.append("-" + key)

    # Next sort is just aesthetic, can be commented for a small performance
    # boost
    tmp.sort(key=lambda x: x.lstrip("-"))
    return tmp
Exemple #2
0
def _merge_flags(new_flags, old_flags=None, conf='any'):
    '''
    Merges multiple lists of flags removing duplicates and resolving conflicts
    giving priority to lasts lists.
    '''
    if not old_flags:
        old_flags = []
    args = [old_flags, new_flags]
    if conf == 'accept_keywords':
        tmp = new_flags+ \
            [i for i in old_flags if _check_accept_keywords(new_flags, i)]
    else:
        tmp = portage.flatten(args)
    flags = {}
    for flag in tmp:
        if flag[0] == '-':
            flags[flag[1:]] = False
        else:
            flags[flag] = True
    tmp = []
    for k, v in flags.iteritems():
        if v:
            tmp.append(k)
        else:
            tmp.append('-' + k)

    # Next sort is just aesthetic, can be commented for a small performance
    # boost
    tmp.sort(cmp=lambda x, y: cmp(x.lstrip('-'), y.lstrip('-')))
    return tmp
Exemple #3
0
def _merge_flags(new_flags, old_flags=None, conf='any'):
    '''
    Merges multiple lists of flags removing duplicates and resolving conflicts
    giving priority to lasts lists.
    '''
    if not old_flags:
        old_flags = []
    args = [old_flags, new_flags]
    if conf == 'accept_keywords':
        tmp = new_flags + \
            [i for i in old_flags if _check_accept_keywords(new_flags, i)]
    else:
        tmp = portage.flatten(args)
    flags = {}
    for flag in tmp:
        if flag[0] == '-':
            flags[flag[1:]] = False
        else:
            flags[flag] = True
    tmp = []
    for key, val in six.iteritems(flags):
        if val:
            tmp.append(key)
        else:
            tmp.append('-' + key)

    # Next sort is just aesthetic, can be commented for a small performance
    # boost
    tmp.sort(cmp=lambda x, y: cmp(x.lstrip('-'), y.lstrip('-')))
    return tmp
Exemple #4
0
 def __setitem__(self, k, v):
     _PackageMetadataWrapperBase.__setitem__(self, k, v)
     if k in self._wrapped_keys:
         getattr(self, "_set_" + k.lower())(k, v)
     elif k in self._use_conditional_keys:
         try:
             reduced = use_reduce(paren_reduce(v), matchall=1)
         except portage.exception.InvalidDependString as e:
             self._pkg._invalid_metadata(k + ".syntax", "%s: %s" % (k, e))
         else:
             if reduced and k == 'PROVIDE':
                 for x in portage.flatten(reduced):
                     if not isvalidatom(x):
                         self._pkg._invalid_metadata(
                             k + ".syntax", "%s: %s" % (k, x))
	def __setitem__(self, k, v):
		_PackageMetadataWrapperBase.__setitem__(self, k, v)
		if k in self._wrapped_keys:
			getattr(self, "_set_" + k.lower())(k, v)
		elif k in self._use_conditional_keys:
			try:
				reduced = use_reduce(paren_reduce(v), matchall=1)
			except portage.exception.InvalidDependString as e:
				self._pkg._invalid_metadata(k + ".syntax", "%s: %s" % (k, e))
			else:
				if reduced and k == 'PROVIDE':
					for x in portage.flatten(reduced):
						if not isvalidatom(x):
							self._pkg._invalid_metadata(k + ".syntax",
								"%s: %s" % (k, x))
Exemple #6
0
def fix_nesting(nested_list):
    """Takes a list of unknown nesting depth, and gives a nice list with each
    element of the form [cpv, [kws]]"""
    index = 0
    cpv_index = -1
    nice_list = []
    # Has an unpredictable nesting of lists; so we flatten it...
    flat_list = portage.flatten(nested_list)
    # ... and re-create a nice list for us to use
    while index < len(flat_list):
        if portage.catpkgsplit(flat_list[index]):
            cpv_index += 1
            nice_list.append([flat_list[index], []])
        else:
            nice_list[cpv_index][1].append(flat_list[index])
        index += 1
    return nice_list
Exemple #7
0
def _merge_flags(*args):
    '''
    Merges multiple lists of flags removing duplicates and resolving conflicts giving priority to lasts lists.
    '''
    tmp = portage.flatten(args)
    flags = {}
    for flag in tmp:
        if flag[0] == '-':
            flags[flag[1:]] = False
        else:
            flags[flag] = True
    tmp = []
    for k, v in flags.iteritems():
        if v:
            tmp.append(k)
        else:
            tmp.append('-' + k)
    tmp.sort(cmp=lambda x, y: cmp(x.lstrip('-'), y.lstrip('-'))) # just aesthetic, can be commented for a small perfomance boost
    return tmp
Exemple #8
0
def _merge_flags(*args):
    '''
    Merges multiple lists of flags removing duplicates and resolving conflicts
    giving priority to lasts lists.
    '''
    tmp = portage.flatten(args)
    flags = {}
    for flag in tmp:
        if flag[0] == '-':
            flags[flag[1:]] = False
        else:
            flags[flag] = True
    tmp = []
    for k, v in flags.iteritems():
        if v:
            tmp.append(k)
        else:
            tmp.append('-' + k)

    # Next sort is just aesthetic, can be commented for a small performance
    # boost
    tmp.sort(cmp=lambda x, y: cmp(x.lstrip('-'), y.lstrip('-')))
    return tmp
Exemple #9
0
def getDepString(deps):
    depString = "Dependencies should be reformated and check for correctness"
    for dep in portage.flatten(portage.tokenize(deps)):
        depString += "\n        <Dependency>" + dep + "</Dependency>"

    return depString
Exemple #10
0
	def __adjust_env(self,mydo,mysettings,myebuild,myroot,debug=0,listonly=0,fetchonly=0,cleanup=0,dbkey=None,\
			use_cache=1,fetchall=0,tree="porttree",use_info_env=True,verbosity=0):
		"""formerly portage.doebuild, since it's specific to ebuilds, it's now a method of ebuild handling.
		severely gutted, and in need of cleansing/exorcism"""
		from portage import db,ExtractKernelVersion,fetch,features, \
			digestgen,digestcheck,root,flatten, digestParseFile
		from portage_data import portage_uid,portage_gid,secpass
		import portage_dep
		from portage_util import writemsg

		ebuild_path = os.path.abspath(myebuild)
		pkg_dir     = os.path.dirname(ebuild_path)
	
		if mysettings.configdict["pkg"].has_key("CATEGORY"):
			cat = mysettings.configdict["pkg"]["CATEGORY"]
		else:
			cat         = os.path.basename(os.path.normpath(pkg_dir+"/.."))
		mypv        = os.path.basename(ebuild_path)[:-7]
		mycpv       = cat+"/"+mypv
	
		mysplit=portage_versions.pkgsplit(mypv,silent=0)
		if mysplit==None:
			writemsg("!!! Error: PF is null '%s'; exiting.\n" % mypv)
			return 1

		if mydo == "clean":
			cleanup=True
	
		if mydo != "depend":
			# XXX: We're doing a little hack here to curtain the gvisible locking
			# XXX: that creates a deadlock... Really need to isolate that.
			mysettings.reset(use_cache=use_cache)
			
		mysettings.setcpv(mycpv,use_cache=use_cache)
	
		if not os.path.exists(myebuild):
			writemsg("!!! doebuild: "+str(myebuild)+" not found for "+str(mydo)+"\n")
			return 1

		if debug: # Otherwise it overrides emerge's settings.
			# We have no other way to set debug... debug can't be passed in
			# due to how it's coded... Don't overwrite this so we can use it.
			mysettings["PORTAGE_DEBUG"]=str(debug)
	
		mysettings["ROOT"]     = myroot
	
		mysettings["EBUILD"]   = ebuild_path
		mysettings["O"]        = pkg_dir
		mysettings["CATEGORY"] = cat
		mysettings["FILESDIR"] = pkg_dir+"/files"
		mysettings["PF"]       = mypv
		
		mysettings["ECLASSDIR"]   = mysettings["PORTDIR"]+"/eclass"

		mysettings["PROFILE_PATHS"] = PROFILE_PATH+"\n"+CUSTOM_PROFILE_PATH
		mysettings["P"]  = mysplit[0]+"-"+mysplit[1]
		mysettings["PN"] = mysplit[0]
		mysettings["PV"] = mysplit[1]
		mysettings["PR"] = mysplit[2]

		# ensure this is set for all phases, setup included.
		# Should be ok again to set $T, as sandbox does not depend on it
		mysettings["BUILD_PREFIX"] = mysettings["PORTAGE_TMPDIR"]+"/portage"
		mysettings["PORTAGE_BUILDDIR"]	= mysettings["BUILD_PREFIX"]+"/"+mysettings["PF"]
		mysettings["T"]		= mysettings["PORTAGE_BUILDDIR"]+"/temp"
		mysettings["WORKDIR"] 	= mysettings["PORTAGE_BUILDDIR"]+"/work"
		mysettings["D"]		= mysettings["PORTAGE_BUILDDIR"]+"/image/"
	

		# bailing now, probably horks a few things up, but neh.
		# got to break a few eggs to make an omelot after all (spelling is wrong, too) :)
		if mydo=="unmerge":
			return 0

		if mydo!="depend":
			try:
				mysettings["INHERITED"],mysettings["RESTRICT"] = db[root][tree].dbapi.aux_get(
					mycpv,["INHERITED","RESTRICT"])

				mysettings["PORTAGE_RESTRICT"]=string.join(flatten(portage_dep.use_reduce(
					portage_dep.paren_reduce(mysettings["RESTRICT"]), 
					uselist=mysettings["USE"].split() )),' ')

			except SystemExit, e:
				raise
			except Exception, e:
				print "caught exception %s in ebd_proc:doebuild" % str(e)
				mysettings["RESTRICT"] = mysettings["PORTAGE_RESTRICT"] = ""
				pass