"includePortTree": 0,
"includeOverlayTree": 0,
"includeMasked": 1,
- "regex": 0
+ "regex": 0,
+ "duplicates": 0
}
def parseArgs(self, args):
opts["includeMasked"] = 0
elif x in ["-f", "--full-regex"]:
opts["regex"] = 1
+ elif x in ["-d", "--duplicates"]:
+ opts["duplicates"] = 1
else:
query = x
+ # Only search installed packages when listing duplicated packages
+ if opts["duplicates"]:
+ opts["includeInstalled"] = 1
+ opts["includePortTree"] = 0
+ opts["includeOverlayTree"] = 0
+
if need_help:
print_info(0, self.longHelp())
sys.exit(-1)
filter_fn = lambda x: True
matches = package_finder(filter_fn)
+ # Find duplicate packages
+ if opts["duplicates"]:
+ dups = {}
+ newmatches = []
+ for pkg in matches:
+ pkgname = pkg.get_name()
+ if dups.has_key(pkgname):
+ dups[pkgname].append(pkg)
+ else:
+ dups[pkgname] = [pkg]
+
+ for pkgname in dups.keys():
+ if len(dups[pkgname]) > 1:
+ newmatches += dups[pkgname]
+
+ matches = newmatches
+
matches = gentoolkit.sort_package_list(matches)
# If no version supplied, fix regular expression
" " + pp.localoption("-I, --exclude-installed") + " - do not search installed packages\n" + \
" " + pp.localoption("-p, --portage-tree") + " - also search in portage tree (" + gentoolkit.settings["PORTDIR"] + ")\n" + \
" " + pp.localoption("-o, --overlay-tree") + " - also search in overlay tree (" + gentoolkit.settings["PORTDIR_OVERLAY"] + ")\n" + \
- " " + pp.localoption("-f, --full-regex") + " - query is a regular expression\n"
+ " " + pp.localoption("-f, --full-regex") + " - query is a regular expression\n" + \
+ " " + pp.localoption("-d, --duplicates") + " - list only installed duplicate packages\n"
class CmdFindUSEs(Command):
"""Find all packages with a particular USE flag."""
of installed packages, packages which are not installed, the portage tree, and
the portage overlay tree.
-<local\-opts> must not include only \-I;
+<local\-opts> \-I cannot be used by itself;
if \-I is used, \-p and/or \-o must be also be present. By default, only installed
packages are searched. \-o searches only the overlay tree [and possibly
installed packages],
.br
.B \-f, \-\-full\-regex
query is a regular expression
+.br
+.B \-d, \-\-duplicates
+only list installed duplicate packages
.PP
.TP
.B size <local\-opts> pkgspec
"""Compares this package's version to another's CPV; returns -1, 0, 1"""
v1 = self._scpv
v2 = portage.catpkgsplit(other.get_cpv())
- if v1[0] != v2[0] or v1[1] != v2[1]:
- return 0
- return portage.pkgcmp(v1[1:],v2[1:])
+ # if category is different
+ if v1[0] != v2[0]:
+ return cmp(v1[0],v2[0])
+ # if name is different
+ elif v1[1] != v2[1]:
+ return cmp(v1[1],v2[1])
+ # Compaare versions
+ else:
+ return portage.pkgcmp(v1[1:],v2[1:])
def size(self):
"""Estimates the installed size of the contents of this package, if possible.