diff --git a/pisi/cli/listinstalled.py b/pisi/cli/listinstalled.py index 8a71d771..fd328364 100644 --- a/pisi/cli/listinstalled.py +++ b/pisi/cli/listinstalled.py @@ -1,6 +1,6 @@ # -*- coding:utf-8 -*- # -# Copyright (C) 2005 - 2007, TUBITAK/UEKAE +# Copyright (C) 2005-2010, TUBITAK/UEKAE # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -39,8 +39,11 @@ Usage: list-installed group = optparse.OptionGroup(self.parser, _("list-installed options")) - group.add_option("-b", "--without-buildno", action="store_true", - default=False, help=_("Only list the installed packages without build nos")) + group.add_option("-b", "--with-build-host", + action="store", + default="localhost", + help=_("Only list the installed packages built " + "by the given host")) group.add_option("-l", "--long", action="store_true", default=False, help=_("Show in long format")) group.add_option("-c", "--component", action="store", @@ -53,10 +56,11 @@ Usage: list-installed def run(self): self.init(database = True, write = False) - if not ctx.get_option('without_buildno'): + build_host = ctx.get_option("with_build_host") + if not build_host: installed = self.installdb.list_installed() else: - installed = self.installdb.list_installed_without_buildno() + installed = self.installdb.list_installed_with_build_host(build_host) component = ctx.get_option('component') if component: diff --git a/pisi/db/installdb.py b/pisi/db/installdb.py index 67b98389..d77d73bd 100644 --- a/pisi/db/installdb.py +++ b/pisi/db/installdb.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2005 - 2010, TUBITAK/UEKAE +# Copyright (C) 2005-2010, TUBITAK/UEKAE # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -117,12 +117,13 @@ class InstallDB(lazydb.LazyDB): def has_package(self, package): return self.installed_db.has_key(package) - def list_installed_without_buildno(self): - rebuildno = '.*?' + def list_installed_with_build_host(self, build_host): + xml_line = "%s" % re.escape(build_host) + build_host_re = re.compile(xml_line) found = [] for name in self.list_installed(): xml = open(os.path.join(self.package_path(name), ctx.const.metadata_xml)).read() - if not re.compile(rebuildno).search(xml): + if build_host_re.search(xml): found.append(name) return found