Add priority in blacklist

This commit is contained in:
Dimitris Zlatanidis 2015-06-19 06:38:13 +03:00
parent ed3b275dce
commit 15baa7b7be
5 changed files with 39 additions and 31 deletions

View file

@ -27,14 +27,13 @@ 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_
from slpkg.pkg.find import find_package
from repo_init import RepoInit
from greps import repo_data
from repo_init import RepoInit
def pkg_upgrade(repo, skip):
@ -50,7 +49,6 @@ def pkg_upgrade(repo, skip):
# size = data[2]
# unsize = data[3]
data = repo_data(PACKAGES_TXT, 2000, repo, flag="")
black = BlackList().packages(data[0], repo)
index, toolbar_width = 0, 1000
for pkg in installed():
index += 1
@ -62,7 +60,6 @@ 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 black and
inst_pkg[0] not in skip):
pkgs_for_upgrade.append(repo_pkg[0])
Msg().done()

View file

@ -69,7 +69,7 @@ class BinaryInstall(object):
self.PACKAGES_TXT, self.mirror = RepoInit(self.repo).fetch()
self.data = repo_data(self.PACKAGES_TXT, self.step, self.repo,
self.flag)
self.black = BlackList().packages(self.data[0], self.repo)
self.blacklist = BlackList().packages(self.data[0], self.repo)
def start(self, if_upgrade):
"""
@ -200,7 +200,8 @@ class BinaryInstall(object):
for dep in self.packages:
dependencies = []
dependencies = Utils().dimensional_list(Dependencies(
self.PACKAGES_TXT, self.repo, self.black).binary(dep, self.flag))
self.PACKAGES_TXT, self.repo, self.blacklist).binary(
dep, self.flag))
requires += dependencies
self.deps_dict[dep] = Utils().remove_dbs(dependencies)
return Utils().remove_dbs(requires)
@ -257,7 +258,7 @@ class BinaryInstall(object):
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.black):
name not in install and pkg not in self.blacklist):
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
install.append(name)
comp_sum.append(comp)
@ -267,7 +268,7 @@ class BinaryInstall(object):
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.black):
pkg not in self.blacklist):
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
install.append(name)
comp_sum.append(comp)

View file

@ -28,10 +28,8 @@ from __metadata__ import MetaData as _meta_
class BlackList(object):
"""
Blacklist class to add, remove or listed packages
in blacklist file.
"""
"""Blacklist class to add, remove or listed packages
in blacklist file."""
def __init__(self):
self.meta = _meta_
self.quit = False
@ -39,10 +37,8 @@ class BlackList(object):
self.black_conf = Utils().read_file(self.blackfile)
def get_black(self):
"""
Return blacklist packages from /etc/slpkg/blacklist
configuration file.
"""
"""Return blacklist packages from /etc/slpkg/blacklist
configuration file."""
blacklist = []
for read in self.black_conf.splitlines():
read = read.lstrip()
@ -51,8 +47,7 @@ class BlackList(object):
return blacklist
def listed(self):
"""
Print blacklist packages
"""Print blacklist packages
"""
print("\nPackages in blacklist:\n")
for black in self.get_black():
@ -64,8 +59,7 @@ class BlackList(object):
print("") # new line at exit
def add(self, pkgs):
"""
Add blacklist packages if not exist
"""Add blacklist packages if not exist
"""
blacklist = self.get_black()
pkgs = set(pkgs)
@ -82,8 +76,7 @@ class BlackList(object):
print("") # new line at exit
def remove(self, pkgs):
"""
Remove packages from blacklist
"""Remove packages from blacklist
"""
print("\nRemove packages from blacklist:\n")
with open(self.blackfile, "w") as remove:
@ -99,19 +92,32 @@ class BlackList(object):
print("") # new line at exit
def packages(self, pkgs, repo):
"""Return packages in blacklist or by repository
"""
black = []
for bl in self.get_black():
pr = bl.split(":")
for pkg in pkgs:
if (pr[0] == repo and pr[1].startswith("*") and
pr[1].endswith("*")):
if repo == "sbo" and pr[1][1:-1] in pkg:
black.append(pkg)
elif pr[1][1:-1] in pkg:
black.append(split_package(pkg)[0])
elif pr[0] == repo and pr[1].endswith("*"):
if repo == "sbo" and pkg.startswith(pr[1][:-1]):
black.append(pkg)
elif pkg.startswith(pr[1][:-1]):
black.append(split_package(pkg)[0])
if bl.startswith("*") and bl.endswith("*"):
if repo == "sbo":
if bl[1:-1] in pkg:
black.append(pkg)
else:
if repo == "sbo" and bl[1:-1] in pkg:
black.append(pkg)
elif bl[1:-1] in pkg:
black.append(split_package(pkg)[0])
elif bl.endswith("*"):
if pkg.startswith(bl[:-1]):
if repo == "sbo" and pkg.startswith(bl[:-1]):
black.append(pkg)
else:
elif pkg.startswith(bl[:-1]):
black.append(split_package(pkg)[0])
if bl not in black and "*" not in bl:
black.append(bl)

View file

@ -25,10 +25,10 @@
import sys
from slpkg.toolbar import status
from slpkg.blacklist import BlackList
from slpkg.__metadata__ import MetaData as _meta_
from greps import SBoGrep
from search import sbo_search_pkg
class Requires(object):
@ -36,6 +36,9 @@ class Requires(object):
def __init__(self, flag):
self.flag = flag
self.meta = _meta_
self.SLACKBUILDS_TXT = SBoGrep(name="").names()
self.blacklist = BlackList().packages(pkgs=self.SLACKBUILDS_TXT,
repo="sbo")
self.dep_results = []
def sbo(self, name):
@ -54,7 +57,7 @@ class Requires(object):
toolbar_width = status(index, toolbar_width, 1)
# avoid to add %README% as dependency and
# if require in blacklist
if "%README%" not in req and sbo_search_pkg(req):
if "%README%" not in req and req not in self.blacklist:
dependencies.append(req)
if dependencies:
self.dep_results.append(dependencies)

View file

@ -164,7 +164,8 @@ class SBoInstall(object):
f.close()
for sbo in self.package_not_found:
for line in SLACKBUILDS_TXT.splitlines():
if line.startswith("SLACKBUILD NAME: ") and sbo in line[17:]:
if (line.startswith("SLACKBUILD NAME: ") and
sbo in line[17:] and sbo_search_pkg(line[17:]).strip()):
self.package_found.append(line[17:])
def sbo_version_source(self, slackbuilds):