level=logging.ERROR, noiselevel=-1)
def expand_set_arguments(myfiles, myaction, root_config):
- retval = os.EX_OK
- setconfig = root_config.setconfig
-
- sets = setconfig.getSets()
-
- # In order to know exactly which atoms/sets should be added to the
- # world file, the depgraph performs set expansion later. It will get
- # confused about where the atoms came from if it's not allowed to
- # expand them itself.
- do_not_expand = (None, )
- newargs = []
- for a in myfiles:
- if a in ("system", "world"):
- newargs.append(SETPREFIX+a)
- else:
- newargs.append(a)
- myfiles = newargs
- del newargs
- newargs = []
-
- # separators for set arguments
- ARG_START = "{"
- ARG_END = "}"
-
- # WARNING: all operators must be of equal length
- IS_OPERATOR = "/@"
- DIFF_OPERATOR = "-@"
- UNION_OPERATOR = "+@"
-
- for i in range(0, len(myfiles)):
- if myfiles[i].startswith(SETPREFIX):
- start = 0
- end = 0
- x = myfiles[i][len(SETPREFIX):]
- newset = ""
- while x:
- start = x.find(ARG_START)
- end = x.find(ARG_END)
- if start > 0 and start < end:
- namepart = x[:start]
- argpart = x[start+1:end]
-
- # TODO: implement proper quoting
- args = argpart.split(",")
- options = {}
- for a in args:
- if "=" in a:
- k, v = a.split("=", 1)
- options[k] = v
- else:
- options[a] = "True"
- setconfig.update(namepart, options)
- newset += (x[:start-len(namepart)]+namepart)
- x = x[end+len(ARG_END):]
- else:
- newset += x
- x = ""
- myfiles[i] = SETPREFIX+newset
-
- sets = setconfig.getSets()
- # display errors that occured while loading the SetConfig instance
- for e in setconfig.errors:
- print colorize("BAD", "Error during set creation: %s" % e)
-
- # emerge relies on the existance of sets with names "world" and "system"
- required_sets = ("world", "system")
-
- for s in required_sets:
- if s not in sets:
- msg = ["emerge: incomplete set configuration, " + \
- "no \"%s\" set defined" % s]
- msg.append(" sets defined: %s" % ", ".join(sets))
- for line in msg:
- sys.stderr.write(line + "\n")
- retval = 1
- unmerge_actions = ("unmerge", "prune", "clean", "depclean")
-
- for a in myfiles:
- if a.startswith(SETPREFIX):
- # support simple set operations (intersection, difference and union)
- # on the commandline. Expressions are evaluated strictly left-to-right
- if IS_OPERATOR in a or DIFF_OPERATOR in a or UNION_OPERATOR in a:
- expression = a[len(SETPREFIX):]
- expr_sets = []
- expr_ops = []
- while IS_OPERATOR in expression or DIFF_OPERATOR in expression or UNION_OPERATOR in expression:
- is_pos = expression.rfind(IS_OPERATOR)
- diff_pos = expression.rfind(DIFF_OPERATOR)
- union_pos = expression.rfind(UNION_OPERATOR)
- op_pos = max(is_pos, diff_pos, union_pos)
- s1 = expression[:op_pos]
- s2 = expression[op_pos+len(IS_OPERATOR):]
- op = expression[op_pos:op_pos+len(IS_OPERATOR)]
- if not s2 in sets:
- display_missing_pkg_set(root_config, s2)
- return (None, 1)
- expr_sets.insert(0, s2)
- expr_ops.insert(0, op)
- expression = s1
- if not expression in sets:
- display_missing_pkg_set(root_config, expression)
- return (None, 1)
- expr_sets.insert(0, expression)
- result = set(setconfig.getSetAtoms(expression))
- for i in range(0, len(expr_ops)):
- s2 = setconfig.getSetAtoms(expr_sets[i+1])
- if expr_ops[i] == IS_OPERATOR:
- result.intersection_update(s2)
- elif expr_ops[i] == DIFF_OPERATOR:
- result.difference_update(s2)
- elif expr_ops[i] == UNION_OPERATOR:
- result.update(s2)
- else:
- raise NotImplementedError("unknown set operator %s" % expr_ops[i])
- newargs.extend(result)
- else:
- s = a[len(SETPREFIX):]
- if s not in sets:
- display_missing_pkg_set(root_config, s)
- return (None, 1)
- setconfig.active.append(s)
- try:
- set_atoms = setconfig.getSetAtoms(s)
- except portage.exception.PackageSetNotFound, e:
- writemsg_level(("emerge: the given set '%s' " + \
- "contains a non-existent set named '%s'.\n") % \
- (s, e), level=logging.ERROR, noiselevel=-1)
- return (None, 1)
- if myaction in unmerge_actions and \
- not sets[s].supportsOperation("unmerge"):
- sys.stderr.write("emerge: the given set '%s' does " % s + \
- "not support unmerge operations\n")
- retval = 1
- elif not set_atoms:
- print "emerge: '%s' is an empty set" % s
- elif myaction not in do_not_expand:
- newargs.extend(set_atoms)
- else:
- newargs.append(SETPREFIX+s)
- for e in sets[s].errors:
- print e
- else:
- newargs.append(a)
- return (newargs, retval)
+ if myaction != "search":
+
+ world = False
+ system = False
+
+ for x in myfiles:
+ if x[:1] == SETPREFIX:
+ msg = []
+ msg.append("'%s' is not a valid package atom." % (x,))
+ msg.append("Please check ebuild(5) for full details.")
+ writemsg_level("".join("!!! %s\n" % line for line in msg),
+ level=logging.ERROR, noiselevel=-1)
+ return (myfiles, 1)
+ elif x == "system":
+ system = True
+ elif x == "world":
+ world = True
+
+ if myaction is not None:
+ if system:
+ multiple_actions("system", myaction)
+ return (myfiles, 1)
+ elif world:
+ multiple_actions("world", myaction)
+ return (myfiles, 1)
+
+ if system and world:
+ multiple_actions("system", "world")
+ return (myfiles, 1)
+
+ return (myfiles, os.EX_OK)
def emerge_main():
global portage # NFC why this is necessary now - genone