duplicate ugly hacks/functions for blacklist support until its refactored, else 'pisi lu' shows blacklisted packages as upgradable
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import os
|
||||||
import optparse
|
import optparse
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
@@ -50,6 +51,34 @@ Lists the packages that will be upgraded.
|
|||||||
default=False, help=_("Show detailed install info"))
|
default=False, help=_("Show detailed install info"))
|
||||||
self.parser.add_option_group(group)
|
self.parser.add_option_group(group)
|
||||||
|
|
||||||
|
def exclude_from(self, packages, exfrom):
|
||||||
|
patterns = []
|
||||||
|
if os.path.exists(exfrom):
|
||||||
|
for line in open(exfrom, "r").readlines():
|
||||||
|
if not line.startswith('#') and not line == '\n':
|
||||||
|
patterns.append(line.strip())
|
||||||
|
if patterns:
|
||||||
|
return self.exclude(packages, patterns)
|
||||||
|
|
||||||
|
return packages
|
||||||
|
|
||||||
|
def exclude(self, packages, patterns):
|
||||||
|
from sets import Set as set
|
||||||
|
import fnmatch
|
||||||
|
|
||||||
|
packages = set(packages)
|
||||||
|
for pattern in patterns:
|
||||||
|
# match pattern in package names
|
||||||
|
match = fnmatch.filter(packages, pattern)
|
||||||
|
packages = packages - set(match)
|
||||||
|
|
||||||
|
if not match:
|
||||||
|
# match pattern in component names
|
||||||
|
for compare in fnmatch.filter(self.componentdb.list_components(), pattern):
|
||||||
|
packages = packages - set(self.componentdb.get_union_packages(compare, walk=True))
|
||||||
|
|
||||||
|
return list(packages)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.init(database = True, write = False)
|
self.init(database = True, write = False)
|
||||||
upgradable_pkgs = pisi.api.list_upgradable()
|
upgradable_pkgs = pisi.api.list_upgradable()
|
||||||
@@ -61,6 +90,9 @@ Lists the packages that will be upgraded.
|
|||||||
component_pkgs = self.componentdb.get_union_packages(component, walk=True)
|
component_pkgs = self.componentdb.get_union_packages(component, walk=True)
|
||||||
upgradable_pkgs = list(set(upgradable_pkgs) & set(component_pkgs))
|
upgradable_pkgs = list(set(upgradable_pkgs) & set(component_pkgs))
|
||||||
|
|
||||||
|
if os.path.exists(ctx.const.blacklist):
|
||||||
|
upgradable_pkgs = self.exclude_from(upgradable_pkgs, ctx.const.blacklist)
|
||||||
|
|
||||||
if not upgradable_pkgs:
|
if not upgradable_pkgs:
|
||||||
ctx.ui.info(_('No packages to upgrade.'))
|
ctx.ui.info(_('No packages to upgrade.'))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user