cli/listinstalled: Replace --without-buildno with --with-build-host
This renamed parameter is used to filter packages by their build host. e.g. pisi li -b localhost
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding:utf-8 -*-
|
# -*- 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
|
# 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
|
# 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 = optparse.OptionGroup(self.parser, _("list-installed options"))
|
||||||
|
|
||||||
group.add_option("-b", "--without-buildno", action="store_true",
|
group.add_option("-b", "--with-build-host",
|
||||||
default=False, help=_("Only list the installed packages without build nos"))
|
action="store",
|
||||||
|
default="localhost",
|
||||||
|
help=_("Only list the installed packages built "
|
||||||
|
"by the given host"))
|
||||||
group.add_option("-l", "--long", action="store_true",
|
group.add_option("-l", "--long", action="store_true",
|
||||||
default=False, help=_("Show in long format"))
|
default=False, help=_("Show in long format"))
|
||||||
group.add_option("-c", "--component", action="store",
|
group.add_option("-c", "--component", action="store",
|
||||||
@@ -53,10 +56,11 @@ Usage: list-installed
|
|||||||
def run(self):
|
def run(self):
|
||||||
self.init(database = True, write = False)
|
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()
|
installed = self.installdb.list_installed()
|
||||||
else:
|
else:
|
||||||
installed = self.installdb.list_installed_without_buildno()
|
installed = self.installdb.list_installed_with_build_host(build_host)
|
||||||
|
|
||||||
component = ctx.get_option('component')
|
component = ctx.get_option('component')
|
||||||
if component:
|
if component:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- 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
|
# 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
|
# 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):
|
def has_package(self, package):
|
||||||
return self.installed_db.has_key(package)
|
return self.installed_db.has_key(package)
|
||||||
|
|
||||||
def list_installed_without_buildno(self):
|
def list_installed_with_build_host(self, build_host):
|
||||||
rebuildno = '<Build>.*?</Build>'
|
xml_line = "<BuildHost>%s</BuildHost>" % re.escape(build_host)
|
||||||
|
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 not re.compile(rebuildno).search(xml):
|
if build_host_re.search(xml):
|
||||||
found.append(name)
|
found.append(name)
|
||||||
return found
|
return found
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user