Update blacklist options

This commit is contained in:
Dimitris Zlatanidis 2015-06-19 18:04:35 +03:00
parent 15baa7b7be
commit 78e9ecda3b
5 changed files with 48 additions and 19 deletions

View file

@ -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

View file

@ -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()

View file

@ -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()

View file

@ -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

View file

@ -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