mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-18 10:26:29 +01:00
Added regex for blacklist
This commit is contained in:
parent
7fec0ab6ba
commit
a911f60881
16 changed files with 77 additions and 80 deletions
|
@ -50,6 +50,7 @@ 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
|
||||
|
@ -61,7 +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().packages() and
|
||||
inst_pkg[0] not in black and
|
||||
inst_pkg[0] not in skip):
|
||||
pkgs_for_upgrade.append(repo_pkg[0])
|
||||
Msg().done()
|
||||
|
|
|
@ -26,7 +26,6 @@ import sys
|
|||
|
||||
from slpkg.utils import Utils
|
||||
from slpkg.toolbar import status
|
||||
from slpkg.blacklist import BlackList
|
||||
from slpkg.__metadata__ import MetaData as _meta_
|
||||
|
||||
from greps import Requires
|
||||
|
@ -34,12 +33,13 @@ from greps import Requires
|
|||
|
||||
class Dependencies(object):
|
||||
|
||||
def __init__(self, PACKAGES_TXT, repo):
|
||||
def __init__(self, PACKAGES_TXT, repo, black):
|
||||
self.packages = PACKAGES_TXT
|
||||
self.repo = repo
|
||||
self.black = black
|
||||
self.names = Utils().package_name(PACKAGES_TXT, self.repo)
|
||||
self.dep_results = []
|
||||
self.packages = Utils().package_name(PACKAGES_TXT, repo)
|
||||
self.meta = _meta_
|
||||
self.black = BlackList().packages()
|
||||
|
||||
def binary(self, name, flag):
|
||||
"""
|
||||
|
@ -55,7 +55,7 @@ class Dependencies(object):
|
|||
for req in requires:
|
||||
index += 1
|
||||
toolbar_width = status(index, toolbar_width, 7)
|
||||
if (req and req in self.packages and
|
||||
if (req and req in self.names and
|
||||
req not in self.black):
|
||||
dependencies.append(req)
|
||||
if dependencies:
|
||||
|
|
|
@ -44,7 +44,6 @@ from slpkg.pkg.manager import PackageManager
|
|||
from slpkg.slack.slack_version import slack_ver
|
||||
|
||||
from greps import repo_data
|
||||
from search import search_pkg
|
||||
from repo_init import RepoInit
|
||||
from dependency import Dependencies
|
||||
|
||||
|
@ -65,9 +64,12 @@ class BinaryInstall(object):
|
|||
self.dependencies = []
|
||||
self.deps_dict = {}
|
||||
self.answer = ""
|
||||
self.step = 0
|
||||
Msg().reading()
|
||||
self.PACKAGES_TXT, self.mirror = RepoInit(self.repo).fetch()
|
||||
self.step = 0
|
||||
self.data = repo_data(self.PACKAGES_TXT, self.step, self.repo,
|
||||
self.flag)
|
||||
self.black = BlackList().packages(self.data[0], self.repo)
|
||||
|
||||
def start(self, if_upgrade):
|
||||
"""
|
||||
|
@ -77,7 +79,6 @@ class BinaryInstall(object):
|
|||
# fix if packages is for upgrade
|
||||
self.if_upgrade = if_upgrade
|
||||
mas_sum = dep_sum = sums = [0, 0, 0]
|
||||
self.pkg_exist()
|
||||
Msg().done()
|
||||
self.dependencies = self.resolving_deps()
|
||||
(self.dep_dwn, self.dep_install, self.dep_comp_sum,
|
||||
|
@ -136,21 +137,6 @@ class BinaryInstall(object):
|
|||
print("") # new line at exit
|
||||
sys.exit(0)
|
||||
|
||||
def pkg_exist(self):
|
||||
"""
|
||||
Search if package exist
|
||||
"""
|
||||
pkg_found, pkg_not_found = [], []
|
||||
for pkg in self.packages:
|
||||
if search_pkg(pkg, self.repo):
|
||||
pkg_found.append(pkg)
|
||||
else:
|
||||
pkg_not_found.append(pkg)
|
||||
if pkg_found:
|
||||
self.packages = pkg_found
|
||||
else:
|
||||
self.packages = pkg_not_found
|
||||
|
||||
def clear_masters(self):
|
||||
"""
|
||||
Clear master packages if already exist in dependencies
|
||||
|
@ -214,7 +200,7 @@ class BinaryInstall(object):
|
|||
for dep in self.packages:
|
||||
dependencies = []
|
||||
dependencies = Utils().dimensional_list(Dependencies(
|
||||
self.PACKAGES_TXT, self.repo).binary(dep, self.flag))
|
||||
self.PACKAGES_TXT, self.repo, self.black).binary(dep, self.flag))
|
||||
requires += dependencies
|
||||
self.deps_dict[dep] = Utils().remove_dbs(dependencies)
|
||||
return Utils().remove_dbs(requires)
|
||||
|
@ -263,27 +249,25 @@ class BinaryInstall(object):
|
|||
Store and return packages for install
|
||||
"""
|
||||
dwn, install, comp_sum, uncomp_sum = ([] for i in range(4))
|
||||
black = BlackList().packages()
|
||||
# name = data[0]
|
||||
# location = data[1]
|
||||
# size = data[2]
|
||||
# unsize = data[3]
|
||||
data = repo_data(self.PACKAGES_TXT, self.step, self.repo, self.flag)
|
||||
for pkg in packages:
|
||||
for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
|
||||
data[3]):
|
||||
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 black):
|
||||
name not in install and pkg not in self.black):
|
||||
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
|
||||
install.append(name)
|
||||
comp_sum.append(comp)
|
||||
uncomp_sum.append(uncomp)
|
||||
if not install:
|
||||
for pkg in packages:
|
||||
for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
|
||||
data[3]):
|
||||
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 black):
|
||||
pkg not in self.black):
|
||||
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
|
||||
install.append(name)
|
||||
comp_sum.append(comp)
|
||||
|
|
|
@ -56,7 +56,7 @@ class RepoInit(object):
|
|||
self.mirror = "{0}".format(Repo().custom_repository()[self.repo])
|
||||
|
||||
def _init_slack(self):
|
||||
self.mirror = mirrors("", "")
|
||||
self.mirror = mirrors(name="", location="")
|
||||
|
||||
def _init_rlw(self):
|
||||
self.mirror = "{0}{1}/".format(Repo().rlw(), slack_ver())
|
||||
|
|
|
@ -37,9 +37,10 @@ def search_pkg(name, repo):
|
|||
and return the name.
|
||||
"""
|
||||
try:
|
||||
blacklist = BlackList().packages()
|
||||
PACKAGES_TXT = Utils().read_file(_meta_.lib_path + "{0}_repo/"
|
||||
"PACKAGES.TXT".format(repo))
|
||||
names = Utils().package_name(PACKAGES_TXT, repo)
|
||||
blacklist = BlackList().packages(pkgs=names, repo=repo)
|
||||
num_lines = sum(1 for line in PACKAGES_TXT)
|
||||
toolbar_width, index, step = 2, 0, num_lines
|
||||
for line in PACKAGES_TXT.splitlines():
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
|
||||
from utils import Utils
|
||||
from splitting import split_package
|
||||
from __metadata__ import MetaData as _meta_
|
||||
|
||||
|
||||
|
@ -37,7 +38,7 @@ class BlackList(object):
|
|||
self.blackfile = "/etc/slpkg/blacklist"
|
||||
self.black_conf = Utils().read_file(self.blackfile)
|
||||
|
||||
def packages(self):
|
||||
def get_black(self):
|
||||
"""
|
||||
Return blacklist packages from /etc/slpkg/blacklist
|
||||
configuration file.
|
||||
|
@ -54,7 +55,7 @@ class BlackList(object):
|
|||
Print blacklist packages
|
||||
"""
|
||||
print("\nPackages in blacklist:\n")
|
||||
for black in self.packages():
|
||||
for black in self.get_black():
|
||||
if black:
|
||||
print("{0}{1}{2}".format(self.meta.color["GREEN"], black,
|
||||
self.meta.color["ENDC"]))
|
||||
|
@ -66,7 +67,7 @@ class BlackList(object):
|
|||
"""
|
||||
Add blacklist packages if not exist
|
||||
"""
|
||||
blacklist = self.packages()
|
||||
blacklist = self.get_black()
|
||||
pkgs = set(pkgs)
|
||||
print("\nAdd packages in blacklist:\n")
|
||||
with open(self.blackfile, "a") as black_conf:
|
||||
|
@ -96,3 +97,22 @@ class BlackList(object):
|
|||
remove.close()
|
||||
if self.quit:
|
||||
print("") # new line at exit
|
||||
|
||||
def packages(self, pkgs, repo):
|
||||
black = []
|
||||
for bl in self.get_black():
|
||||
for pkg in pkgs:
|
||||
if bl.startswith("*") and bl.endswith("*"):
|
||||
if repo == "sbo":
|
||||
if bl[1:-1] in pkg:
|
||||
black.append(pkg)
|
||||
else:
|
||||
black.append(split_package(pkg)[0])
|
||||
elif bl.endswith("*"):
|
||||
if pkg.startswith(bl[:-1]):
|
||||
black.append(pkg)
|
||||
else:
|
||||
black.append(split_package(pkg)[0])
|
||||
if bl not in black and "*" not in bl:
|
||||
black.append(bl)
|
||||
return black
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
|
||||
import os
|
||||
|
||||
from slpkg.__metadata__ import MetaData as _meta_
|
||||
from __metadata__ import MetaData as _meta_
|
||||
|
||||
from slpkg.pkg.find import find_package
|
||||
from pkg.find import find_package
|
||||
|
||||
|
||||
def write_deps(deps_dict):
|
||||
|
|
|
@ -26,7 +26,7 @@ import sys
|
|||
|
||||
from __metadata__ import MetaData as _meta_
|
||||
|
||||
from slpkg.pkg.find import find_package
|
||||
from pkg.find import find_package
|
||||
|
||||
|
||||
class Msg(object):
|
||||
|
|
|
@ -24,19 +24,15 @@
|
|||
|
||||
import os
|
||||
|
||||
from slpkg.blacklist import BlackList
|
||||
from slpkg.splitting import split_package
|
||||
|
||||
|
||||
def find_package(find_pkg, directory):
|
||||
"""
|
||||
Find packages
|
||||
"""
|
||||
pkgs = []
|
||||
blacklist = BlackList().packages()
|
||||
installed = sorted(os.listdir(directory))
|
||||
if os.path.exists(directory):
|
||||
for pkg in sorted(os.listdir(directory)):
|
||||
if (not pkg.startswith(".") and pkg.startswith(find_pkg) and
|
||||
split_package(pkg)[0] not in blacklist):
|
||||
for pkg in installed:
|
||||
if not pkg.startswith(".") and pkg.startswith(find_pkg):
|
||||
pkgs.append(pkg)
|
||||
return pkgs
|
||||
|
|
|
@ -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):
|
||||
|
@ -37,7 +37,6 @@ class Requires(object):
|
|||
self.flag = flag
|
||||
self.meta = _meta_
|
||||
self.dep_results = []
|
||||
self.black = BlackList().packages()
|
||||
|
||||
def sbo(self, name):
|
||||
"""
|
||||
|
@ -55,7 +54,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 req not in self.black:
|
||||
if "%README%" not in req and sbo_search_pkg(req):
|
||||
dependencies.append(req)
|
||||
if dependencies:
|
||||
self.dep_results.append(dependencies)
|
||||
|
|
|
@ -47,9 +47,17 @@ class SBoGrep(object):
|
|||
self.unst = ["UNSUPPORTED", "UNTESTED"]
|
||||
self.SLACKBUILDS_TXT = Utils().read_file(self.sbo_txt)
|
||||
|
||||
def source(self):
|
||||
def names(self):
|
||||
"""Grab all packages name
|
||||
"""
|
||||
Grab sources downloads links
|
||||
pkg_names = []
|
||||
for line in self.SLACKBUILDS_TXT.splitlines():
|
||||
if line.startswith(self.line_name):
|
||||
pkg_names.append(line[17:].strip())
|
||||
return pkg_names
|
||||
|
||||
def source(self):
|
||||
"""Grab sources downloads links
|
||||
"""
|
||||
source, source64, = "", ""
|
||||
for line in self.SLACKBUILDS_TXT.splitlines():
|
||||
|
@ -80,8 +88,7 @@ class SBoGrep(object):
|
|||
return src
|
||||
|
||||
def requires(self):
|
||||
"""
|
||||
Grab package requirements
|
||||
"""Grab package requirements
|
||||
"""
|
||||
for line in self.SLACKBUILDS_TXT.splitlines():
|
||||
if line.startswith(self.line_name):
|
||||
|
@ -91,8 +98,7 @@ class SBoGrep(object):
|
|||
return line[21:].strip().split()
|
||||
|
||||
def version(self):
|
||||
"""
|
||||
Grab package version
|
||||
"""Grab package version
|
||||
"""
|
||||
for line in self.SLACKBUILDS_TXT.splitlines():
|
||||
if line.startswith(self.line_name):
|
||||
|
@ -102,8 +108,7 @@ class SBoGrep(object):
|
|||
return line[20:].strip()
|
||||
|
||||
def checksum(self):
|
||||
"""
|
||||
Grab checksum string
|
||||
"""Grab checksum string
|
||||
"""
|
||||
md5sum, md5sum64, = [], []
|
||||
for line in self.SLACKBUILDS_TXT.splitlines():
|
||||
|
@ -134,8 +139,7 @@ class SBoGrep(object):
|
|||
return md5
|
||||
|
||||
def description(self):
|
||||
"""
|
||||
Grab package verion
|
||||
"""Grab package verion
|
||||
"""
|
||||
for line in self.SLACKBUILDS_TXT.splitlines():
|
||||
if line.startswith(self.line_name):
|
||||
|
|
|
@ -31,6 +31,8 @@ from slpkg.__metadata__ import MetaData as _meta_
|
|||
|
||||
from slpkg.slack.slack_version import slack_ver
|
||||
|
||||
from greps import SBoGrep
|
||||
|
||||
|
||||
def sbo_search_pkg(name):
|
||||
"""
|
||||
|
@ -38,7 +40,8 @@ def sbo_search_pkg(name):
|
|||
"""
|
||||
try:
|
||||
repo = Repo().sbo()
|
||||
blacklist = BlackList().packages()
|
||||
SLACKBUILDS_TXT = SBoGrep(name="").names()
|
||||
blacklist = BlackList().packages(pkgs=SLACKBUILDS_TXT, repo="sbo")
|
||||
sbo_url = "{0}{1}/".format(repo, slack_ver())
|
||||
SLACKBUILDS_TXT = Utils().read_file(
|
||||
_meta_.lib_path + "sbo_repo/SLACKBUILDS.TXT")
|
||||
|
|
|
@ -28,7 +28,6 @@ import sys
|
|||
from slpkg.utils import Utils
|
||||
from slpkg.messages import Msg
|
||||
from slpkg.toolbar import status
|
||||
from slpkg.blacklist import BlackList
|
||||
from slpkg.log_deps import write_deps
|
||||
from slpkg.downloader import Download
|
||||
from slpkg.splitting import split_package
|
||||
|
@ -69,7 +68,7 @@ class SBoInstall(object):
|
|||
try:
|
||||
tagc = ""
|
||||
count_ins = count_upg = count_uni = 0
|
||||
self._remove_blacklist()
|
||||
# self._remove_blacklist()
|
||||
for _sbo in self.slackbuilds:
|
||||
self.index += 1
|
||||
self.toolbar_width = status(self.index, self.toolbar_width, 4)
|
||||
|
@ -133,16 +132,6 @@ class SBoInstall(object):
|
|||
print("") # new line at exit
|
||||
sys.exit(0)
|
||||
|
||||
def _remove_blacklist(self):
|
||||
"""
|
||||
Remove packages in blacklist
|
||||
"""
|
||||
rmv_black = []
|
||||
for sbo in self.slackbuilds:
|
||||
if sbo not in BlackList().packages():
|
||||
rmv_black.append(sbo)
|
||||
self.slackbuilds = rmv_black
|
||||
|
||||
def _continue_to_install(self):
|
||||
"""Continue to install ?
|
||||
"""
|
||||
|
|
|
@ -136,7 +136,7 @@ class Patches(object):
|
|||
Store and return packages for upgrading
|
||||
"""
|
||||
data = repo_data(self.PACKAGES_TXT, self.step, "slack", self.flag)
|
||||
black = BlackList().packages()
|
||||
black = BlackList().packages(pkgs=data[0], repo="slack")
|
||||
for name, loc, comp, uncomp in zip(data[0], data[1], data[2], data[3]):
|
||||
repo_pkg_name = split_package(name)[0]
|
||||
if (not os.path.isfile(self.meta.pkg_path + name[:-4]) and
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
from utils import Utils
|
||||
from messages import Msg
|
||||
from blacklist import BlackList
|
||||
from __metadata__ import MetaData as _meta_
|
||||
|
||||
from pkg.find import find_package
|
||||
|
@ -49,7 +50,9 @@ def track_dep(name, repo):
|
|||
else:
|
||||
PACKAGES_TXT = Utils().read_file(_meta_.lib_path + "{0}_repo/"
|
||||
"PACKAGES.TXT".format(repo))
|
||||
dependencies_list = Dependencies(PACKAGES_TXT, repo).binary(
|
||||
names = Utils().package_name(PACKAGES_TXT, repo)
|
||||
black = BlackList().packages(names, repo)
|
||||
dependencies_list = Dependencies(names, repo, black).binary(
|
||||
name, flag="")
|
||||
find_pkg = search_pkg(name, repo)
|
||||
Msg().done()
|
||||
|
|
|
@ -64,10 +64,7 @@ class Utils(object):
|
|||
packages = []
|
||||
for line in PACKAGES_TXT.splitlines():
|
||||
if line.startswith("PACKAGE NAME:"):
|
||||
if repo == "slackr":
|
||||
packages.append(line[14:].strip())
|
||||
else:
|
||||
packages.append(split_package(line[14:].strip())[0])
|
||||
packages.append(split_package(line[14:].strip())[0])
|
||||
return packages
|
||||
|
||||
def check_downloaded(self, path, maybe_downloaded):
|
||||
|
|
Loading…
Reference in a new issue