sys.exit(1)
searchinstance.output()
+def action_uninstall(settings, trees, ldpath_mtimes,
+ opts, action, files, spinner):
+
+ # For backward compat, some actions do not require leading '='.
+ ignore_missing_eq = action in ('clean', 'unmerge')
+ root = settings['ROOT']
+ vardb = trees[root]['vartree'].dbapi
+ valid_atoms = []
+ lookup_owners = []
+
+ # Ensure atoms are valid before calling unmerge().
+ # For backward compat, leading '=' is not required.
+ for x in files:
+ if is_valid_package_atom(x) or \
+ (ignore_missing_eq and is_valid_package_atom('=' + x)):
+
+ try:
+ valid_atoms.append(
+ portage.dep_expand(x, mydb=vardb, settings=settings))
+ except portage.exception.AmbiguousPackageName, e:
+ msg = "The short ebuild name \"" + x + \
+ "\" is ambiguous. Please specify " + \
+ "one of the following " + \
+ "fully-qualified ebuild names instead:"
+ for line in textwrap.wrap(msg, 70):
+ writemsg_level("!!! %s\n" % (line,),
+ level=logging.ERROR, noiselevel=-1)
+ for i in e[0]:
+ writemsg_level(" %s\n" % colorize("INFORM", i),
+ level=logging.ERROR, noiselevel=-1)
+ writemsg_level("\n", level=logging.ERROR, noiselevel=-1)
+ return 1
+
+ elif x.startswith(os.sep):
+ if not x.startswith(root):
+ writemsg_level(("!!! '%s' does not start with" + \
+ " $ROOT.\n") % x, level=logging.ERROR, noiselevel=-1)
+ return 1
+ # Queue these up since it's most efficient to handle
+ # multiple files in a single iter_owners() call.
+ lookup_owners.append(x)
+
+ else:
+ 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 1
+
+ if lookup_owners:
+ relative_paths = []
+ search_for_multiple = False
+ if len(lookup_owners) > 1:
+ search_for_multiple = True
+
+ for x in lookup_owners:
+ if not search_for_multiple and os.path.isdir(x):
+ search_for_multiple = True
+ relative_paths.append(x[len(root):])
+
+ owners = set()
+ for pkg, relative_path in \
+ vardb._owners.iter_owners(relative_paths):
+ owners.add(pkg.mycpv)
+ if not search_for_multiple:
+ break
+
+ if owners:
+ for cpv in owners:
+ slot = vardb.aux_get(cpv, ['SLOT'])[0]
+ if not slot:
+ # portage now masks packages with missing slot, but it's
+ # possible that one was installed by an older version
+ atom = portage.cpv_getkey(cpv)
+ else:
+ atom = '%s:%s' % (portage.cpv_getkey(cpv), slot)
+ valid_atoms.append(portage.dep.Atom(atom))
+ else:
+ writemsg_level(("!!! '%s' is not claimed " + \
+ "by any package.\n") % lookup_owners[0],
+ level=logging.WARNING, noiselevel=-1)
+
+ if files and not valid_atoms:
+ return 1
+
+ if action in ('clean', 'unmerge') or \
+ (action == 'prune' and "--nodeps" in opts):
+ # When given a list of atoms, unmerge them in the order given.
+ ordered = action == 'unmerge'
+ unmerge(trees[settings["ROOT"]]['root_config'], opts, action,
+ valid_atoms, ldpath_mtimes, ordered=ordered)
+ rval = os.EX_OK
+ else:
+ rval = action_depclean(settings, trees, ldpath_mtimes,
+ opts, action, valid_atoms, spinner)
+
+ return rval
+
def action_depclean(settings, trees, ldpath_mtimes,
myopts, action, myfiles, spinner):
# Kill packages that aren't explicitly merged or are required as a
import textwrap
args_set = InternalPackageSet()
if myfiles:
- for x in myfiles:
- if not is_valid_package_atom(x):
- writemsg_level("!!! '%s' is not a valid package atom.\n" % x,
- level=logging.ERROR, noiselevel=-1)
- writemsg_level("!!! Please check ebuild(5) for full details.\n")
- return
- try:
- atom = portage.dep_expand(x, mydb=vardb, settings=settings)
- except portage.exception.AmbiguousPackageName, e:
- msg = "The short ebuild name \"" + x + \
- "\" is ambiguous. Please specify " + \
- "one of the following " + \
- "fully-qualified ebuild names instead:"
- for line in textwrap.wrap(msg, 70):
- writemsg_level("!!! %s\n" % (line,),
- level=logging.ERROR, noiselevel=-1)
- for i in e[0]:
- writemsg_level(" %s\n" % colorize("INFORM", i),
- level=logging.ERROR, noiselevel=-1)
- writemsg_level("\n", level=logging.ERROR, noiselevel=-1)
- return
- args_set.add(atom)
+ args_set.update(myfiles)
matched_packages = False
for x in args_set:
if vardb.match(x):
validate_ebuild_environment(trees)
action_search(trees[settings["ROOT"]]["root_config"],
myopts, myfiles, spinner)
- elif myaction in ("clean", "unmerge") or \
- (myaction == "prune" and "--nodeps" in myopts):
- validate_ebuild_environment(trees)
-
- # Ensure atoms are valid before calling unmerge().
- # For backward compat, leading '=' is not required.
- for x in myfiles:
- if is_valid_package_atom(x) or \
- is_valid_package_atom("=" + x):
- continue
- 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 1
- # When given a list of atoms, unmerge
- # them in the order given.
- ordered = myaction == "unmerge"
- if 1 == unmerge(root_config, myopts, myaction, myfiles,
- mtimedb["ldpath"], ordered=ordered):
- if not (buildpkgonly or fetchonly or pretend):
- post_emerge(root_config, myopts, mtimedb, os.EX_OK)
+ elif myaction in ('clean', 'depclean', 'prune', 'unmerge'):
+ validate_ebuild_environment(trees)
+ rval = action_uninstall(settings, trees, mtimedb["ldpath"],
+ myopts, myaction, myfiles, spinner)
+ if not (buildpkgonly or fetchonly or pretend):
+ post_emerge(root_config, myopts, mtimedb, rval)
+ return rval
- elif myaction in ("depclean", "info", "prune"):
+ elif myaction == 'info':
# Ensure atoms are valid before calling unmerge().
vardb = trees[settings["ROOT"]]["vartree"].dbapi
level=logging.ERROR, noiselevel=-1)
return 1
- if myaction == "info":
- return action_info(settings, trees, myopts, valid_atoms)
+ return action_info(settings, trees, myopts, valid_atoms)
- validate_ebuild_environment(trees)
- action_depclean(settings, trees, mtimedb["ldpath"],
- myopts, myaction, valid_atoms, spinner)
- if not (buildpkgonly or fetchonly or pretend):
- post_emerge(root_config, myopts, mtimedb, os.EX_OK)
# "update", "system", or just process files:
else:
validate_ebuild_environment(trees)
sys.stderr.write(" "+str(e)+"\n\n");
raise
-bsd_chflags = None
-if platform.system() in ["FreeBSD"]:
- def bsd_chflags():
- pass
- def _chflags(path, flags, opts=""):
- cmd = "chflags %s %o '%s'" % (opts, flags, path)
- status, output = commands.getstatusoutput(cmd)
- if os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK:
- return
- # Try to generate an ENOENT error if appropriate.
- if "h" in opts:
- os.lstat(path)
- else:
- os.stat(path)
- # Make sure the binary exists.
- if not portage.process.find_binary("chflags"):
- raise portage.exception.CommandNotFound("chflags")
- # Now we're not sure exactly why it failed or what
- # the real errno was, so just report EPERM.
- e = OSError(errno.EPERM, output)
- e.errno = errno.EPERM
- e.filename = path
- e.message = output
- raise e
- def _lchflags(path, flags):
- return _chflags(path, flags, opts="-h")
- bsd_chflags.chflags = _chflags
- bsd_chflags.lchflags = _lchflags
-
try:
from portage.cache.cache_errors import CacheError
import portage.proxy.lazyimport
# END OF IMPORTS -- END OF IMPORTS -- END OF IMPORTS -- END OF IMPORTS -- END
# ===========================================================================
+def _shell_quote(s):
+ """
+ Quote a string in double-quotes and use backslashes to
+ escape any backslashes, double-quotes, dollar signs, or
+ backquotes in the string.
+ """
+ for letter in "\\\"$`":
+ if letter in s:
+ s = s.replace(letter, "\\" + letter)
+ return "\"%s\"" % s
+
+bsd_chflags = None
+
+if platform.system() in ('FreeBSD',):
+
+ class bsd_chflags(object):
+
+ @classmethod
+ def chflags(cls, path, flags, opts=""):
+ cmd = 'chflags %s %o %s' % (opts, flags, _shell_quote(path))
+ status, output = commands.getstatusoutput(cmd)
+ if os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK:
+ return
+ # Try to generate an ENOENT error if appropriate.
+ if 'h' in opts:
+ os.lstat(path)
+ else:
+ os.stat(path)
+ # Make sure the binary exists.
+ if not portage.process.find_binary('chflags'):
+ raise portage.exception.CommandNotFound('chflags')
+ # Now we're not sure exactly why it failed or what
+ # the real errno was, so just report EPERM.
+ e = OSError(errno.EPERM, output)
+ e.errno = errno.EPERM
+ e.filename = path
+ e.message = output
+ raise e
+
+ @classmethod
+ def lchflags(cls, path, flags):
+ return cls.chflags(path, flags, opts='-h')
def load_mod(name):
modname = ".".join(name.split(".")[:-1])
if "usersandbox" in self.features:
self.features.remove("usersandbox")
+ if bsd_chflags:
+ self.features.add('chflags')
+
self["FEATURES"] = " ".join(sorted(self.features))
self.backup_changes("FEATURES")
global _glep_55_enabled, _validate_cache_for_unsupported_eapis
keys = __iter__
items = iteritems
-def _shell_quote(s):
- """
- Quote a string in double-quotes and use backslashes to
- escape any backslashes, double-quotes, dollar signs, or
- backquotes in the string.
- """
- for letter in "\\\"$`":
- if letter in s:
- s = s.replace(letter, "\\" + letter)
- return "\"%s\"" % s
-
# In some cases, openpty can be slow when it fails. Therefore,
# stop trying to use it after the first failure.
if platform.system() in ["SunOS"]: