Changed equery list command to default to partial name matches
authorfuzzyray <fuzzyray@gentoo.org>
Wed, 23 Nov 2005 17:32:28 +0000 (17:32 -0000)
committerfuzzyray <fuzzyray@gentoo.org>
Wed, 23 Nov 2005 17:32:28 +0000 (17:32 -0000)
svn path=/; revision=262

trunk/ChangeLog
trunk/src/equery/equery
trunk/src/equery/equery.1

index 2d962b4a7bba550bdcd975aed0722185afef3093..c9e50e330bb956aeba80a868a74496847670ed28 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-23 Paul Varner <fuzzyray@gentoo.org>
+       * equery: Changed default behavior for equery list to search for
+       partial name matches. Added equery list examples to the equery man
+       page. (Bugs 113032, 113134)
+
 2005-11-15 Marius Mauch <genone@gentoo.org>
        * glsa-check: Changed several messages to stderr instead of stdout
        * glsa-check: Added new --cve option as requested by solar (bug 98589)
index 857cc73b0847ee136ead02957c5ea792ed4ed7b1..8807ee0324732a56c831ea5f359260f89f4cf65e 100755 (executable)
@@ -1127,6 +1127,7 @@ class CmdListPackages(Command):
                        "includeOverlayTree": 0,
                        "includeMasked": 1,
                        "regex": 0,
+                       "exact": 0,
                        "duplicates": 0
                        }
 
@@ -1159,6 +1160,9 @@ class CmdListPackages(Command):
                                opts["includeMasked"] = 0
                        elif x in ["-f", "--full-regex"]:
                                opts["regex"] = 1
+                               opts["exact"] = 1
+                       elif x in ["-e", "--exact-name"]:
+                               opts["exact"] = 1
                        elif x in ["-d", "--duplicates"]:
                                opts["duplicates"] = 1
                        else:
@@ -1215,16 +1219,18 @@ class CmdListPackages(Command):
                # replace empty strings with .* and escape regular expression syntax
                if query != "":
                        if not opts["regex"]:
-                               filter_fn = lambda x: (cat+"/"+name in x)
-                               matches = package_finder(filter_fn)
                                cat, name, ver, rev = [re.sub('^$', ".*", re.escape(x)) for x in cat, name, ver, rev]
                        else:
                                cat, name, ver, rev = [re.sub('^$', ".*", x) for x in cat, name, ver, rev]
-                               try:
+
+                       try:
+                               if opts["exact"]:
                                        filter_fn = lambda x: re.match(cat+"/"+name, x)
-                                       matches = package_finder(filter_fn)
-                               except:
-                                       die(2, "The query '" + pp.regexpquery(query) + "' does not appear to be a valid regular expression")
+                               else:
+                                       filter_fn = lambda x: re.match(cat+"/.*"+name, x)
+                               matches = package_finder(filter_fn)
+                       except:
+                               die(2, "The query '" + pp.regexpquery(query) + "' does not appear to be a valid regular expression")
                else:
                        cat, name, ver, rev = [re.sub('^$', ".*", x) for x in cat, name, ver, rev]
                        filter_fn = lambda x: True
@@ -1253,9 +1259,12 @@ class CmdListPackages(Command):
                if ver == ".*": ver = "[0-9]+[^-]*"
 
                if rev != ".*": # revision supplied
-                       rx = re.compile(cat + "/" + name + "-" + ver + "-" + rev)
-               else:
+                       ver = ver + "-" + rev
+
+               if opts["exact"]:
                        rx = re.compile(cat + "/" + name + "-" + ver)
+               else:
+                       rx = re.compile(cat + "/.*" + name + ".*-" + ver)
 
                if opts["includeInstalled"]:
                        self._print_installed(matches, rx)
@@ -1330,6 +1339,7 @@ class CmdListPackages(Command):
                           "  " + 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("-e, --exact-name") + "        - list only those packages that exactly match\n" + \
                           "  " + pp.localoption("-d, --duplicates") + "        - list only installed duplicate packages\n"
 
 class CmdFindUSEs(Command):
index 17565ff894feb4527171448281ff25f886f81e4e..9b070afc414f56ff46946ad961dd5c95ca728ad8 100644 (file)
@@ -174,14 +174,13 @@ also search in overlay tree (/usr/local/portage)
 .B list <local\-opts> pkgspec
 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.
+the portage overlay tree. By default the list command searches for partial name matches.
 
 <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],
-.I not
-the main portage tree.
+\fInot\fR the main portage tree.
 
 .B \-i, \-\-installed
 search installed packages (default)
@@ -198,10 +197,23 @@ also search in overlay tree (/usr/local/portage)
 .B \-f, \-\-full\-regex
 query is a regular expression
 .br 
+.B \-e, \-\-exact\-name
+list only those packages that exactly match
+.br 
 .B \-d, \-\-duplicates
 only list installed duplicate packages
+.br 
+
+\fBExamples:\fR
+
+equery list zilla \- list all installed versions of packages containing the string 'zilla'
+
+equery list \-\-exact\-name x11\-libs/gtk+  \- list all installed versions of x11\-libs/gtk+
+
+equery list \-\-full\-regex '(mozilla\-firefox|mozilla\-thunderbird)' \- list all installed versions of mozilla\-firefox and mozilla\-thunderbird 
+
+equery list \-\-duplicates \- list all installed slotted packages
 .PP 
-.TP 
 .B size <local\-opts> pkgspec
 This command outputs the number of files in the specified package, as well as
 their total size in an appropriate unit.