From 8bf7934465ca6a6078efa3c56b28164ed2a0e2c0 Mon Sep 17 00:00:00 2001 From: karltk Date: Sun, 10 Oct 2004 00:28:37 +0000 Subject: [PATCH] Fixes #53432. svn path=/; revision=151 --- trunk/src/equery/ChangeLog | 1 + trunk/src/equery/equery | 93 ++++++++++++++++++------------ trunk/src/gentoolkit/ChangeLog | 3 + trunk/src/gentoolkit/gentoolkit.py | 2 +- 4 files changed, 62 insertions(+), 37 deletions(-) diff --git a/trunk/src/equery/ChangeLog b/trunk/src/equery/ChangeLog index 8531a70..96dac7b 100644 --- a/trunk/src/equery/ChangeLog +++ b/trunk/src/equery/ChangeLog @@ -1,5 +1,6 @@ 2004-10-10 Karl Trygve Kalleberg * Added unit tests for all supported commands + * Fixed printing order and recognition of overlay, #53432. 2004-09-30 Karl Trygve Kalleberg * Added unit tests for --help diff --git a/trunk/src/equery/equery b/trunk/src/equery/equery index e31fc70..dea4d7b 100755 --- a/trunk/src/equery/equery +++ b/trunk/src/equery/equery @@ -1074,50 +1074,71 @@ class CmdListPackages(Command): if name == ".*": sname = "all packages" if not Config["piping"]: - print_info(1, "Searching for " + pp.cpv(sname) + " in " + pp.cpv(scat) + " among:") - if opts["includeInstalled"]: - print_info(1, pp.section(" *") + " installed packages") - if opts["includePortTree"]: - print_info(1, pp.section(" *") + " Portage tree (" + pp.path(gentoolkit.settings["PORTDIR"]) + ")") - if opts["includeOverlayTree"]: - print_info(1, pp.section(" *") + " overlay tree (" + pp.path(gentoolkit.settings["PORTDIR_OVERLAY"]) + ")") - - matches = package_finder(filter_fn) + print_info(1, "[ Searching for " + pp.cpv(sname) + " in " + pp.cpv(scat) + " among: ]") + rx = re.compile(cat + "/" + name + "-" + ver + "(-" + rev + ")?") + + matches = package_finder(filter_fn) + + if opts["includeInstalled"]: + self._print_installed(matches, rx) + + if opts["includePortTree"]: + self._print_porttree(matches, rx) + + if opts["includeOverlayTree"]: + self._print_overlay(matches, rx) + + def _get_mask_status(self, pkg): + pkgmask = 0 + if pkg.is_masked(): + pkgmask = pkgmask + 3 + keywords = pkg.get_env_var("KEYWORDS").split() + if "~" + gentoolkit.settings["ARCH"] in keywords: + pkgmask = pkgmask + 1 + elif "-*" in keywords or "-" + gentoolkit.settings["ARCH"] in keywords: + pkgmask = pkgmask + 2 + return pkgmask + + def _generic_print(self, header, exclude, matches, rx, status): + print_info(1, header) + pfxmodes = [ "---", "I--", "-P-", "--O" ] maskmodes = [ " ", " ~", " -", "M ", "M~", "M-" ] - for pkg in matches: - status = 0 - if pkg.is_installed(): - status = 1 - elif pkg.is_overlay(): - status = 3 - else: - status = 2 - # Determining mask status - pkgmask = 0 - if pkg.is_masked(): - pkgmask = pkgmask + 3 - keywords = pkg.get_env_var("KEYWORDS").split() - if "~" + gentoolkit.settings["ARCH"] in keywords: - pkgmask = pkgmask + 1 - elif "-*" in keywords or "-" + gentoolkit.settings["ARCH"] in keywords: - pkgmask = pkgmask + 2 + for pkg in matches: + if exclude(pkg): + continue - # Determining SLOT value + pkgmask = self._get_mask_status(pkg) + slot = pkg.get_env_var("SLOT") - if (status == 1 and opts["includeInstalled"]) or \ - (status == 2 and opts["includePortTree"]) or \ - (status == 3 and opts["includeOverlayTree"]): - if rx.search(pkg.get_cpv()): - if Config["piping"]: - print_info(0, pkg.get_cpv()) - else: - print_info(0, "[" + pp.installedflag(pfxmodes[status]) + "] [" + pp.maskflag(maskmodes[pkgmask]) + "] " + pp.cpv(pkg.get_cpv()) + " (" + pp.slot(slot) + ")") - + if rx.search(pkg.get_cpv()): + if Config["piping"]: + print_info(0, pkg.get_cpv()) + else: + print_info(0, "[" + pp.installedflag(pfxmodes[status]) + "] [" + pp.maskflag(maskmodes[pkgmask]) + "] " + pp.cpv(pkg.get_cpv()) + " (" + pp.slot(slot) + ")") + + def _print_overlay(self, matches, rx): + self._generic_print( + pp.section(" *") + " overlay tree (" + pp.path(gentoolkit.settings["PORTDIR_OVERLAY"]) + ")", + lambda x: not x.is_overlay(), + matches, rx, 3) + + def _print_porttree(self, matches, rx): + self._generic_print( + pp.section(" *") + " Portage tree (" + pp.path(gentoolkit.settings["PORTDIR"]) + ")", + lambda x: x.is_overlay() or x.is_installed(), + matches, rx, 2) + + def _print_installed(self, matches, rx): + self._generic_print( + pp.section(" *") + " installed packages", + lambda x: not x.is_installed(), + matches, rx, 1) + def shortHelp(self): return pp.localoption(" ") + pp.pkgquery("pkgspec") + " - list all packages matching " + pp.pkgquery("pkgspec") def longHelp(self): diff --git a/trunk/src/gentoolkit/ChangeLog b/trunk/src/gentoolkit/ChangeLog index 5ea8ae4..72b05fe 100644 --- a/trunk/src/gentoolkit/ChangeLog +++ b/trunk/src/gentoolkit/ChangeLog @@ -1,3 +1,6 @@ +2004-10-10: Karl Trygve Kalleberg + * Fixed is_overlay() to report properly, #53432. + 2004-09-27: Karl Trygve Kalleberg * Added find_installed_packages diff --git a/trunk/src/gentoolkit/gentoolkit.py b/trunk/src/gentoolkit/gentoolkit.py index 50aad81..07eea39 100644 --- a/trunk/src/gentoolkit/gentoolkit.py +++ b/trunk/src/gentoolkit/gentoolkit.py @@ -118,7 +118,7 @@ class Package: return os.path.exists(self._db.getpath()) def is_overlay(self): dir,ovl=portage.portdb.findname2(self._cpv) - return ovl + return ovl != settings["PORTDIR"] def is_masked(self): """Returns true if this package is masked against installation. Note: We blindly assume that the package actually exists on disk somewhere.""" -- 2.26.2