From de88819ff3240d31260a449d226037d1228a8d07 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 20 Mar 2011 10:41:24 -0700 Subject: [PATCH] portageq owners: list orphans via stderr --- bin/portageq | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/bin/portageq b/bin/portageq index 2f254ca81..069ece238 100755 --- a/bin/portageq +++ b/bin/portageq @@ -255,6 +255,8 @@ def owners(argv): pass files = [] + orphan_abs_paths = set() + orphan_basenames = set() for f in argv[1:]: f = portage.normalize_path(f) is_basename = os.sep not in f @@ -271,8 +273,10 @@ def owners(argv): return 2 if is_basename: files.append(f) + orphan_basenames.add(f) else: files.append(f[len(root)-1:]) + orphan_abs_paths.add(f) owners = vardb._owners.get_owners(files) @@ -281,16 +285,28 @@ def owners(argv): cpv = pkg.mycpv msg.append("%s\n" % cpv) for f in sorted(owned_files): - msg.append("\t%s\n" % \ - os.path.join(root, f.lstrip(os.path.sep))) + f_abs = os.path.join(root, f.lstrip(os.path.sep)) + msg.append("\t%s\n" % (f_abs,)) + orphan_abs_paths.discard(f_abs) + if orphan_basenames: + orphan_basenames.discard(os.path.basename(f_abs)) writemsg_stdout(''.join(msg), noiselevel=-1) + if orphan_abs_paths or orphan_basenames: + orphans = [] + orphans.extend(orphan_abs_paths) + orphans.extend(orphan_basenames) + orphans.sort() + msg = [] + msg.append("None of the installed packages claim these files:\n") + for f in orphans: + msg.append("\t%s\n" % (f,)) + sys.stderr.write("".join(msg)) + sys.stderr.flush() + if owners: return 0 - - sys.stderr.write("None of the installed packages claim the file(s).\n") - sys.stderr.flush() return 1 owners.uses_root = True -- 2.26.2