mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-02-07 08:46:21 +01:00
Add priority in blacklist
This commit is contained in:
parent
ed3b275dce
commit
15baa7b7be
5 changed files with 39 additions and 31 deletions
|
@ -27,14 +27,13 @@ from distutils.version import LooseVersion
|
||||||
|
|
||||||
from slpkg.messages import Msg
|
from slpkg.messages import Msg
|
||||||
from slpkg.toolbar import status
|
from slpkg.toolbar import status
|
||||||
from slpkg.blacklist import BlackList
|
|
||||||
from slpkg.splitting import split_package
|
from slpkg.splitting import split_package
|
||||||
from slpkg.__metadata__ import MetaData as _meta_
|
from slpkg.__metadata__ import MetaData as _meta_
|
||||||
|
|
||||||
from slpkg.pkg.find import find_package
|
from slpkg.pkg.find import find_package
|
||||||
|
|
||||||
from repo_init import RepoInit
|
|
||||||
from greps import repo_data
|
from greps import repo_data
|
||||||
|
from repo_init import RepoInit
|
||||||
|
|
||||||
|
|
||||||
def pkg_upgrade(repo, skip):
|
def pkg_upgrade(repo, skip):
|
||||||
|
@ -50,7 +49,6 @@ def pkg_upgrade(repo, skip):
|
||||||
# size = data[2]
|
# size = data[2]
|
||||||
# unsize = data[3]
|
# unsize = data[3]
|
||||||
data = repo_data(PACKAGES_TXT, 2000, repo, flag="")
|
data = repo_data(PACKAGES_TXT, 2000, repo, flag="")
|
||||||
black = BlackList().packages(data[0], repo)
|
|
||||||
index, toolbar_width = 0, 1000
|
index, toolbar_width = 0, 1000
|
||||||
for pkg in installed():
|
for pkg in installed():
|
||||||
index += 1
|
index += 1
|
||||||
|
@ -62,7 +60,6 @@ def pkg_upgrade(repo, skip):
|
||||||
if (repo_pkg[0] == inst_pkg[0] and
|
if (repo_pkg[0] == inst_pkg[0] and
|
||||||
LooseVersion(repo_pkg[1]) > LooseVersion(inst_pkg[1]) and
|
LooseVersion(repo_pkg[1]) > LooseVersion(inst_pkg[1]) and
|
||||||
repo_pkg[3] >= inst_pkg[3] and
|
repo_pkg[3] >= inst_pkg[3] and
|
||||||
inst_pkg[0] not in black and
|
|
||||||
inst_pkg[0] not in skip):
|
inst_pkg[0] not in skip):
|
||||||
pkgs_for_upgrade.append(repo_pkg[0])
|
pkgs_for_upgrade.append(repo_pkg[0])
|
||||||
Msg().done()
|
Msg().done()
|
||||||
|
|
|
@ -69,7 +69,7 @@ class BinaryInstall(object):
|
||||||
self.PACKAGES_TXT, self.mirror = RepoInit(self.repo).fetch()
|
self.PACKAGES_TXT, self.mirror = RepoInit(self.repo).fetch()
|
||||||
self.data = repo_data(self.PACKAGES_TXT, self.step, self.repo,
|
self.data = repo_data(self.PACKAGES_TXT, self.step, self.repo,
|
||||||
self.flag)
|
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):
|
def start(self, if_upgrade):
|
||||||
"""
|
"""
|
||||||
|
@ -200,7 +200,8 @@ class BinaryInstall(object):
|
||||||
for dep in self.packages:
|
for dep in self.packages:
|
||||||
dependencies = []
|
dependencies = []
|
||||||
dependencies = Utils().dimensional_list(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
|
requires += dependencies
|
||||||
self.deps_dict[dep] = Utils().remove_dbs(dependencies)
|
self.deps_dict[dep] = Utils().remove_dbs(dependencies)
|
||||||
return Utils().remove_dbs(requires)
|
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],
|
for name, loc, comp, uncomp in zip(self.data[0], self.data[1],
|
||||||
self.data[2], self.data[3]):
|
self.data[2], self.data[3]):
|
||||||
if (name and name.startswith(pkg + self.meta.sp) and
|
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))
|
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
|
||||||
install.append(name)
|
install.append(name)
|
||||||
comp_sum.append(comp)
|
comp_sum.append(comp)
|
||||||
|
@ -267,7 +268,7 @@ class BinaryInstall(object):
|
||||||
for name, loc, comp, uncomp in zip(self.data[0], self.data[1],
|
for name, loc, comp, uncomp in zip(self.data[0], self.data[1],
|
||||||
self.data[2], self.data[3]):
|
self.data[2], self.data[3]):
|
||||||
if (name and pkg in split_package(name)[0] and
|
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))
|
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
|
||||||
install.append(name)
|
install.append(name)
|
||||||
comp_sum.append(comp)
|
comp_sum.append(comp)
|
||||||
|
|
|
@ -28,10 +28,8 @@ from __metadata__ import MetaData as _meta_
|
||||||
|
|
||||||
|
|
||||||
class BlackList(object):
|
class BlackList(object):
|
||||||
"""
|
"""Blacklist class to add, remove or listed packages
|
||||||
Blacklist class to add, remove or listed packages
|
in blacklist file."""
|
||||||
in blacklist file.
|
|
||||||
"""
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.meta = _meta_
|
self.meta = _meta_
|
||||||
self.quit = False
|
self.quit = False
|
||||||
|
@ -39,10 +37,8 @@ class BlackList(object):
|
||||||
self.black_conf = Utils().read_file(self.blackfile)
|
self.black_conf = Utils().read_file(self.blackfile)
|
||||||
|
|
||||||
def get_black(self):
|
def get_black(self):
|
||||||
"""
|
"""Return blacklist packages from /etc/slpkg/blacklist
|
||||||
Return blacklist packages from /etc/slpkg/blacklist
|
configuration file."""
|
||||||
configuration file.
|
|
||||||
"""
|
|
||||||
blacklist = []
|
blacklist = []
|
||||||
for read in self.black_conf.splitlines():
|
for read in self.black_conf.splitlines():
|
||||||
read = read.lstrip()
|
read = read.lstrip()
|
||||||
|
@ -51,8 +47,7 @@ class BlackList(object):
|
||||||
return blacklist
|
return blacklist
|
||||||
|
|
||||||
def listed(self):
|
def listed(self):
|
||||||
"""
|
"""Print blacklist packages
|
||||||
Print blacklist packages
|
|
||||||
"""
|
"""
|
||||||
print("\nPackages in blacklist:\n")
|
print("\nPackages in blacklist:\n")
|
||||||
for black in self.get_black():
|
for black in self.get_black():
|
||||||
|
@ -64,8 +59,7 @@ class BlackList(object):
|
||||||
print("") # new line at exit
|
print("") # new line at exit
|
||||||
|
|
||||||
def add(self, pkgs):
|
def add(self, pkgs):
|
||||||
"""
|
"""Add blacklist packages if not exist
|
||||||
Add blacklist packages if not exist
|
|
||||||
"""
|
"""
|
||||||
blacklist = self.get_black()
|
blacklist = self.get_black()
|
||||||
pkgs = set(pkgs)
|
pkgs = set(pkgs)
|
||||||
|
@ -82,8 +76,7 @@ class BlackList(object):
|
||||||
print("") # new line at exit
|
print("") # new line at exit
|
||||||
|
|
||||||
def remove(self, pkgs):
|
def remove(self, pkgs):
|
||||||
"""
|
"""Remove packages from blacklist
|
||||||
Remove packages from blacklist
|
|
||||||
"""
|
"""
|
||||||
print("\nRemove packages from blacklist:\n")
|
print("\nRemove packages from blacklist:\n")
|
||||||
with open(self.blackfile, "w") as remove:
|
with open(self.blackfile, "w") as remove:
|
||||||
|
@ -99,19 +92,32 @@ class BlackList(object):
|
||||||
print("") # new line at exit
|
print("") # new line at exit
|
||||||
|
|
||||||
def packages(self, pkgs, repo):
|
def packages(self, pkgs, repo):
|
||||||
|
"""Return packages in blacklist or by repository
|
||||||
|
"""
|
||||||
black = []
|
black = []
|
||||||
for bl in self.get_black():
|
for bl in self.get_black():
|
||||||
|
pr = bl.split(":")
|
||||||
for pkg in pkgs:
|
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 bl.startswith("*") and bl.endswith("*"):
|
||||||
if repo == "sbo":
|
if repo == "sbo" and bl[1:-1] in pkg:
|
||||||
if bl[1:-1] in pkg:
|
black.append(pkg)
|
||||||
black.append(pkg)
|
elif bl[1:-1] in pkg:
|
||||||
else:
|
|
||||||
black.append(split_package(pkg)[0])
|
black.append(split_package(pkg)[0])
|
||||||
elif bl.endswith("*"):
|
elif bl.endswith("*"):
|
||||||
if pkg.startswith(bl[:-1]):
|
if repo == "sbo" and pkg.startswith(bl[:-1]):
|
||||||
black.append(pkg)
|
black.append(pkg)
|
||||||
else:
|
elif pkg.startswith(bl[:-1]):
|
||||||
black.append(split_package(pkg)[0])
|
black.append(split_package(pkg)[0])
|
||||||
if bl not in black and "*" not in bl:
|
if bl not in black and "*" not in bl:
|
||||||
black.append(bl)
|
black.append(bl)
|
||||||
|
|
|
@ -25,10 +25,10 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from slpkg.toolbar import status
|
from slpkg.toolbar import status
|
||||||
|
from slpkg.blacklist import BlackList
|
||||||
from slpkg.__metadata__ import MetaData as _meta_
|
from slpkg.__metadata__ import MetaData as _meta_
|
||||||
|
|
||||||
from greps import SBoGrep
|
from greps import SBoGrep
|
||||||
from search import sbo_search_pkg
|
|
||||||
|
|
||||||
|
|
||||||
class Requires(object):
|
class Requires(object):
|
||||||
|
@ -36,6 +36,9 @@ class Requires(object):
|
||||||
def __init__(self, flag):
|
def __init__(self, flag):
|
||||||
self.flag = flag
|
self.flag = flag
|
||||||
self.meta = _meta_
|
self.meta = _meta_
|
||||||
|
self.SLACKBUILDS_TXT = SBoGrep(name="").names()
|
||||||
|
self.blacklist = BlackList().packages(pkgs=self.SLACKBUILDS_TXT,
|
||||||
|
repo="sbo")
|
||||||
self.dep_results = []
|
self.dep_results = []
|
||||||
|
|
||||||
def sbo(self, name):
|
def sbo(self, name):
|
||||||
|
@ -54,7 +57,7 @@ class Requires(object):
|
||||||
toolbar_width = status(index, toolbar_width, 1)
|
toolbar_width = status(index, toolbar_width, 1)
|
||||||
# avoid to add %README% as dependency and
|
# avoid to add %README% as dependency and
|
||||||
# if require in blacklist
|
# 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)
|
dependencies.append(req)
|
||||||
if dependencies:
|
if dependencies:
|
||||||
self.dep_results.append(dependencies)
|
self.dep_results.append(dependencies)
|
||||||
|
|
|
@ -164,7 +164,8 @@ class SBoInstall(object):
|
||||||
f.close()
|
f.close()
|
||||||
for sbo in self.package_not_found:
|
for sbo in self.package_not_found:
|
||||||
for line in SLACKBUILDS_TXT.splitlines():
|
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:])
|
self.package_found.append(line[17:])
|
||||||
|
|
||||||
def sbo_version_source(self, slackbuilds):
|
def sbo_version_source(self, slackbuilds):
|
||||||
|
|
Loading…
Add table
Reference in a new issue