diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index 4e618a06..3e5c1942 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -1306,20 +1306,30 @@ Lists the packages that will be upgraded. buildno_opts(self, group) group.add_option("-l", "--long", action="store_true", default=False, help=_("show in long format")) + group.add_option("-c", "--component", action="store", + default=None, help=_("list upgradable packages under given component")) group.add_option("-i", "--install-info", action="store_true", default=False, help=_("show detailed install info")) self.parser.add_option_group(group) - def run(self): self.init(database = True, write = False) - list = pisi.api.list_upgradable() - if not list: + upgradable_pkgs = pisi.api.list_upgradable() + + component = ctx.get_option('component') + if component: + #FIXME: pisi api is insufficient to do this + from sets import Set as set + component_pkgs = ctx.componentdb.get_component(component, None).packages + upgradable_pkgs = list(set(upgradable_pkgs) & set(component_pkgs)) + + if not upgradable_pkgs: ctx.ui.info(_('No packages to upgrade.')) - list.sort() + + upgradable_pkgs.sort() if self.options.install_info: ctx.ui.info(_('Package Name |St| Version| Rel.| Build| Distro| Date')) print '========================================================================' - for pkg in list: + for pkg in upgradable_pkgs: package = ctx.packagedb.get_package(pkg, pisi.itembyrepodb.installed) inst_info = ctx.installdb.get_info(pkg) if self.options.long: