installdb,cli/listinstalled: Thinko fix

The build host should be an empty string for old packages.
"pisi li -b ''" now returns old packages, too.
This commit is contained in:
Fatih Aşıcı
2010-10-06 20:53:09 +00:00
parent b2514b62cc
commit 4a7d58c51e
2 changed files with 12 additions and 6 deletions
+2 -2
View File
@@ -41,7 +41,7 @@ Usage: list-installed
group.add_option("-b", "--with-build-host", group.add_option("-b", "--with-build-host",
action="store", action="store",
default="localhost", default=None,
help=_("Only list the installed packages built " help=_("Only list the installed packages built "
"by the given host")) "by the given host"))
group.add_option("-l", "--long", action="store_true", group.add_option("-l", "--long", action="store_true",
@@ -57,7 +57,7 @@ Usage: list-installed
self.init(database = True, write = False) self.init(database = True, write = False)
build_host = ctx.get_option("with_build_host") build_host = ctx.get_option("with_build_host")
if not build_host: if build_host is None:
installed = self.installdb.list_installed() installed = self.installdb.list_installed()
else: else:
installed = self.installdb.list_installed_with_build_host(build_host) installed = self.installdb.list_installed_with_build_host(build_host)
+10 -4
View File
@@ -118,13 +118,19 @@ class InstallDB(lazydb.LazyDB):
return self.installed_db.has_key(package) return self.installed_db.has_key(package)
def list_installed_with_build_host(self, build_host): def list_installed_with_build_host(self, build_host):
xml_line = "<BuildHost>%s</BuildHost>" % re.escape(build_host) build_host_re = re.compile("<BuildHost>(.*?)</BuildHost>")
build_host_re = re.compile(xml_line)
found = [] found = []
for name in self.list_installed(): for name in self.list_installed():
xml = open(os.path.join(self.package_path(name), ctx.const.metadata_xml)).read() xml = open(os.path.join(self.package_path(name), ctx.const.metadata_xml)).read()
if build_host_re.search(xml): matched = build_host_re.search(xml)
found.append(name) if matched:
if build_host != matched.groups()[0]:
continue
elif build_host:
continue
found.append(name)
return found return found
def __get_version(self, meta_doc): def __get_version(self, meta_doc):