summaryrefslogtreecommitdiff
path: root/trunk/src
diff options
context:
space:
mode:
authorfuzzyray <fuzzyray@gentoo.org>2005-10-14 05:20:38 +0000
committerfuzzyray <fuzzyray@gentoo.org>2005-10-14 05:20:38 +0000
commitff812973f68caff6b8e12fa7723d924d29905193 (patch)
tree45cb8bdee7a83cbbd7054faa3ae7c416ab3cb6b9 /trunk/src
parente634a73027598a23fa07aaa5a44fc907fa564ae6 (diff)
downloadgentoolkit-ff812973f68caff6b8e12fa7723d924d29905193.tar.gz
Add qpkg --dups functionality to equery list command
svn path=/; revision=246
Diffstat (limited to 'trunk/src')
-rwxr-xr-xtrunk/src/equery/equery31
-rw-r--r--trunk/src/equery/equery.15
-rw-r--r--trunk/src/gentoolkit/package.py12
3 files changed, 42 insertions, 6 deletions
diff --git a/trunk/src/equery/equery b/trunk/src/equery/equery
index 7e10225..cde8cd0 100755
--- a/trunk/src/equery/equery
+++ b/trunk/src/equery/equery
@@ -1123,7 +1123,8 @@ class CmdListPackages(Command):
"includePortTree": 0,
"includeOverlayTree": 0,
"includeMasked": 1,
- "regex": 0
+ "regex": 0,
+ "duplicates": 0
}
def parseArgs(self, args):
@@ -1155,9 +1156,17 @@ class CmdListPackages(Command):
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)
@@ -1215,6 +1224,23 @@ class CmdListPackages(Command):
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
@@ -1297,7 +1323,8 @@ class CmdListPackages(Command):
" " + 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."""
diff --git a/trunk/src/equery/equery.1 b/trunk/src/equery/equery.1
index 05cb0af..17565ff 100644
--- a/trunk/src/equery/equery.1
+++ b/trunk/src/equery/equery.1
@@ -176,7 +176,7 @@ This command lists packages matching pkgspec in a user\-specified combination
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],
@@ -197,6 +197,9 @@ also search in overlay tree (/usr/local/portage)
.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
diff --git a/trunk/src/gentoolkit/package.py b/trunk/src/gentoolkit/package.py
index e1d0a0d..2bf27fc 100644
--- a/trunk/src/gentoolkit/package.py
+++ b/trunk/src/gentoolkit/package.py
@@ -163,9 +163,15 @@ class Package:
"""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.