From 78e9ecda3b350ded5f2500910492ddfc8609b703 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 19 Jun 2015 18:04:35 +0300 Subject: [PATCH] Update blacklist options --- conf/blacklist | 16 ++++++++++------ slpkg/binary/check.py | 3 +++ slpkg/binary/install.py | 25 +++++++++++++------------ slpkg/blacklist.py | 17 +++++++++++++++++ slpkg/pkg/find.py | 6 +++++- 5 files changed, 48 insertions(+), 19 deletions(-) diff --git a/conf/blacklist b/conf/blacklist index 32901a8e..6ca4d1a8 100644 --- a/conf/blacklist +++ b/conf/blacklist @@ -2,14 +2,18 @@ # installed be upgraded be find or deleted. # NOTE: The settings here affect all repositories. # -# An example syntax is as follows: -# add a package from SBo repository: -# brasero -# -# Add package from slackware repository: -# example add package 'wicd-1.7.2.4-x86_64-4.txz': +# To blacklist the package 'wicd-1.7.2.4-x86_64-4.txz' the line will be: # wicd # +# This one will blacklist all packages include string "lib" in package name: +# *lib* +# +# Exclude packages with repository priority: +# sbo:py* `excluded all packages from sbo starts with 'py'` +# sbo:jdk `excluded jdk package from sbo repository` +# slack:*multi* `excluded packages include string 'multi' from slack` +# msb:*.txz `excluded packages ends with '.txz' from msb repository` +# # Sometimes the automatic kernel update creates problems because you # may need to file intervention 'lilo'. The slpkg automatically detects # if the core has been upgraded and running 'lilo'. If you want to avoid diff --git a/slpkg/binary/check.py b/slpkg/binary/check.py index 7fd8b0b1..a12d483f 100644 --- a/slpkg/binary/check.py +++ b/slpkg/binary/check.py @@ -27,6 +27,7 @@ from distutils.version import LooseVersion from slpkg.messages import Msg from slpkg.toolbar import status +from slpkg.blacklist import BlackList from slpkg.splitting import split_package from slpkg.__metadata__ import MetaData as _meta_ @@ -49,6 +50,7 @@ def pkg_upgrade(repo, skip): # size = data[2] # unsize = data[3] data = repo_data(PACKAGES_TXT, 2000, repo, flag="") + blacklist = BlackList().packages(data[0], repo) index, toolbar_width = 0, 1000 for pkg in installed(): index += 1 @@ -60,6 +62,7 @@ def pkg_upgrade(repo, skip): if (repo_pkg[0] == inst_pkg[0] and LooseVersion(repo_pkg[1]) > LooseVersion(inst_pkg[1]) and repo_pkg[3] >= inst_pkg[3] and + inst_pkg[0] not in blacklist and inst_pkg[0] not in skip): pkgs_for_upgrade.append(repo_pkg[0]) Msg().done() diff --git a/slpkg/binary/install.py b/slpkg/binary/install.py index 680933b1..11048d16 100644 --- a/slpkg/binary/install.py +++ b/slpkg/binary/install.py @@ -255,22 +255,23 @@ class BinaryInstall(object): # size = data[2] # unsize = data[3] for pkg in packages: - for name, loc, comp, uncomp in zip(self.data[0], self.data[1], - self.data[2], self.data[3]): - if (name and name.startswith(pkg + self.meta.sp) and - name not in install and pkg not in self.blacklist): - dwn.append("{0}{1}/{2}".format(self.mirror, loc, name)) - install.append(name) + for pk, loc, comp, uncomp in zip(self.data[0], self.data[1], + self.data[2], self.data[3]): + if (pk and pk.startswith(pkg + self.meta.sp) and + pk not in install and + split_package(pk)[0] not in self.blacklist): + dwn.append("{0}{1}/{2}".format(self.mirror, loc, pk)) + install.append(pk) comp_sum.append(comp) uncomp_sum.append(uncomp) if not install: for pkg in packages: - for name, loc, comp, uncomp in zip(self.data[0], self.data[1], - self.data[2], self.data[3]): - if (name and pkg in split_package(name)[0] and - pkg not in self.blacklist): - dwn.append("{0}{1}/{2}".format(self.mirror, loc, name)) - install.append(name) + for pk, loc, comp, uncomp in zip(self.data[0], self.data[1], + self.data[2], self.data[3]): + name = split_package(pk)[0] + if (pk and pkg in name and name not in self.blacklist): + dwn.append("{0}{1}/{2}".format(self.mirror, loc, pk)) + install.append(pk) comp_sum.append(comp) uncomp_sum.append(uncomp) dwn.reverse() diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index 37653a78..cb7d1184 100644 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -98,6 +98,7 @@ class BlackList(object): for bl in self.get_black(): pr = bl.split(":") for pkg in pkgs: + # blacklist packages by repository priority if (pr[0] == repo and pr[1].startswith("*") and pr[1].endswith("*")): if repo == "sbo" and pr[1][1:-1] in pkg: @@ -109,6 +110,17 @@ class BlackList(object): black.append(pkg) elif pkg.startswith(pr[1][:-1]): black.append(split_package(pkg)[0]) + elif pr[0] == repo and pr[1].startswith("*"): + if repo == "sbo" and pkg.endswith(pr[1][1:]): + black.append(pkg) + elif pkg.endswith(pr[1][1:]): + black.append(split_package(pkg)[0]) + elif pr[0] == repo and "*" not in pr[1]: + if repo == "sbo": + black.append(pr[1]) + else: + black.append(split_package(pkg)[0]) + # normal blacklist packages if bl.startswith("*") and bl.endswith("*"): if repo == "sbo" and bl[1:-1] in pkg: black.append(pkg) @@ -119,6 +131,11 @@ class BlackList(object): black.append(pkg) elif pkg.startswith(bl[:-1]): black.append(split_package(pkg)[0]) + elif bl.startswith("*"): + if repo == "sbo" and pkg.endswith(bl[1:]): + black.append(pkg) + elif pkg.endswith(bl[1:]): + black.append(split_package(pkg)[0]) if bl not in black and "*" not in bl: black.append(bl) return black diff --git a/slpkg/pkg/find.py b/slpkg/pkg/find.py index 6e4ce373..ba62504a 100644 --- a/slpkg/pkg/find.py +++ b/slpkg/pkg/find.py @@ -23,6 +23,8 @@ import os +from slpkg.blacklist import BlackList +from slpkg.splitting import split_package def find_package(find_pkg, directory): @@ -31,8 +33,10 @@ def find_package(find_pkg, directory): """ pkgs = [] installed = sorted(os.listdir(directory)) + blacklist = BlackList().packages(pkgs=installed, repo="local") if os.path.exists(directory): for pkg in installed: - if not pkg.startswith(".") and pkg.startswith(find_pkg): + if (not pkg.startswith(".") and pkg.startswith(find_pkg) and + split_package(pkg)[0] not in blacklist): pkgs.append(pkg) return pkgs