Merge branch 'develop'

This commit is contained in:
Dimitris Zlatanidis 2020-02-21 21:46:27 +01:00
commit fbf816f69e
43 changed files with 191 additions and 115 deletions

View file

@ -1,3 +1,9 @@
3.8.3 - 21/02/2020
BugFix:
- Counting packages for binaries repositories
Added:
- Feature for proxy servers
3.8.2 - 15/02/2020 3.8.2 - 15/02/2020
Fixed: Fixed:
- SBo repository view Packages and New version - SBo repository view Packages and New version

View file

@ -1,4 +1,4 @@
# slpkg 3.8.2 # slpkg 3.8.3
Slpkg is a powerful software package manager that installs, updates, and removes packages on Slpkg is a powerful software package manager that installs, updates, and removes packages on
[Slackware](http://www.slackware.com/) based systems. It automatically computes dependencies and [Slackware](http://www.slackware.com/) based systems. It automatically computes dependencies and

View file

@ -123,3 +123,7 @@ EDITOR=nano
# Warning: Possible failure building packages or running applications after # Warning: Possible failure building packages or running applications after
# install. Default is "off". # install. Default is "off".
NOT_DOWNGRADE=off NOT_DOWNGRADE=off
# If you are working under a proxy server you need to set
# your proxy server here. Default is null.
HTTP_PROXY=

View file

@ -34,7 +34,8 @@ VERSION=${VERSION:-$(__version)}
# Installation script. # Installation script.
# With this script allows you to install the slpkg as a Slackware package binary file. # With this script allows you to install the slpkg as a Slackware package binary file.
# Support wget download. # Support wget download.
ARCHIVES="$PRGNAM-$VERSION.tar.gz $PRGNAM-$VERSION.zip v$VERSION.tar.gz v$VERSION.zip" ARCHIVES="$PRGNAM-$VERSION.tar.gz $PRGNAM-$VERSION.zip v$VERSION.tar.gz v$VERSION.zip \
$PRGNAM-$VERSION.tar.bz2"
cd .. cd ..
for file in $ARCHIVES; do for file in $ARCHIVES; do
if [ -f $file ]; then if [ -f $file ]; then

View file

@ -4,6 +4,10 @@ computes dependencies and figures out what things should occur
to install packages. Slpkg makes it easier to maintain groups to install packages. Slpkg makes it easier to maintain groups
of machines without having to manually update. of machines without having to manually update.
Hard dependencies:
python3, python-urllib3
Optional dependencies: Optional dependencies:
python3-pythondialog (for dialog box interface) python3-pythondialog (for dialog box interface)
pygraphviz (for drawing dependencies diagram) pygraphviz (for drawing dependencies diagram)

View file

@ -68,7 +68,8 @@ mkdir -p $TMP $PKG $OUTPUT
cd $TMP cd $TMP
rm -rf $PRGNAM-$VERSION rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz || tar xvf $CWD/v$VERSION.tar.gz \ tar xvf $CWD/$PRGNAM-$VERSION.tar.gz || tar xvf $CWD/v$VERSION.tar.gz \
|| unzip $CWD/$PRGNAM-$VERSION.zip || unzip $CWD/v$VERSION.zip || tar xvf $CWD/$PRGNAM-$VERSION.tar.bz2 || unzip $CWD/$PRGNAM-$VERSION.zip \
|| unzip $CWD/v$VERSION.zip
cd $PRGNAM-$VERSION cd $PRGNAM-$VERSION
chown -R root:root . chown -R root:root .
find -L . \ find -L . \

View file

@ -76,7 +76,7 @@ class MetaData:
__all__ = "slpkg" __all__ = "slpkg"
__author__ = "dslackw" __author__ = "dslackw"
__version_info__ = (3, 8, 2) __version_info__ = (3, 8, 3)
__version__ = "{0}.{1}.{2}".format(*__version_info__) __version__ = "{0}.{1}.{2}".format(*__version_info__)
__license__ = "GNU General Public License v3 (GPLv3)" __license__ = "GNU General Public License v3 (GPLv3)"
__email__ = "d.zlatanidis@gmail.com" __email__ = "d.zlatanidis@gmail.com"
@ -124,9 +124,9 @@ class MetaData:
"DOWNDER_OPTIONS": "-c -N", "DOWNDER_OPTIONS": "-c -N",
"SLACKPKG_LOG": "on", "SLACKPKG_LOG": "on",
"ONLY_INSTALLED": "off", "ONLY_INSTALLED": "off",
"PRG_BAR": "off",
"EDITOR": "nano", "EDITOR": "nano",
"NOT_DOWNGRADE": "off" "NOT_DOWNGRADE": "off",
"HTTP_PROXY": "",
} }
default_repositories = ["slack", "sbo", "rlw", "alien", "slacky", "conrad", default_repositories = ["slack", "sbo", "rlw", "alien", "slacky", "conrad",
@ -172,9 +172,9 @@ class MetaData:
downder_options = _conf_slpkg["DOWNDER_OPTIONS"] downder_options = _conf_slpkg["DOWNDER_OPTIONS"]
slackpkg_log = _conf_slpkg["SLACKPKG_LOG"] slackpkg_log = _conf_slpkg["SLACKPKG_LOG"]
only_installed = _conf_slpkg["ONLY_INSTALLED"] only_installed = _conf_slpkg["ONLY_INSTALLED"]
prg_bar = _conf_slpkg["PRG_BAR"]
editor = _conf_slpkg["EDITOR"] editor = _conf_slpkg["EDITOR"]
not_downgrade = _conf_slpkg["NOT_DOWNGRADE"] not_downgrade = _conf_slpkg["NOT_DOWNGRADE"]
http_proxy = _conf_slpkg["HTTP_PROXY"]
# SBo downloading sources path # SBo downloading sources path
SBo_SOURCES = build_path + "_SOURCES/" SBo_SOURCES = build_path + "_SOURCES/"

View file

@ -23,6 +23,7 @@
import os import os
from itertools import zip_longest
from pkg_resources import parse_version from pkg_resources import parse_version
from slpkg.utils import Utils from slpkg.utils import Utils
@ -47,7 +48,7 @@ from slpkg.binary.repo_init import RepoInit
from slpkg.binary.dependency import Dependencies from slpkg.binary.dependency import Dependencies
class BinaryInstall(BlackList): class BinaryInstall(BlackList, Utils):
"""Install binaries packages with all dependencies from """Install binaries packages with all dependencies from
repository repository
""" """
@ -64,7 +65,6 @@ class BinaryInstall(BlackList):
self.yellow = _meta_.color['YELLOW'] self.yellow = _meta_.color['YELLOW']
self.endc = _meta_.color["ENDC"] self.endc = _meta_.color["ENDC"]
self.msg = Msg() self.msg = Msg()
self.utils = Utils()
self.version = self.meta.slack_rel self.version = self.meta.slack_rel
self.tmp_path = self.meta.slpkg_tmp_packages self.tmp_path = self.meta.slpkg_tmp_packages
self.init_flags() self.init_flags()
@ -100,7 +100,7 @@ class BinaryInstall(BlackList):
self.case_insensitive() self.case_insensitive()
# fix if packages is for upgrade # fix if packages is for upgrade
self.is_upgrade = is_upgrade self.is_upgrade = is_upgrade
mas_sum = dep_sum = sums = [0, 0, 0] mas_sum = dep_sum = sums = 0, 0, 0, 0
self.msg.done() self.msg.done()
self.dependencies = self.resolving_deps() self.dependencies = self.resolving_deps()
self.update_deps() self.update_deps()
@ -124,22 +124,23 @@ class BinaryInstall(BlackList):
if self.dependencies: if self.dependencies:
print("Installing for dependencies:") print("Installing for dependencies:")
dep_sum = self.views(self.dep_install, self.dep_comp_sum) dep_sum = self.views(self.dep_install, self.dep_comp_sum)
# sums[0] --> installed # sums[0] --> total packages
# sums[1] --> upgraded # sums[1] --> reinstall
# sums[2] --> uninstall # sums[2] --> upgraded
sums = [sum(i) for i in zip(mas_sum, dep_sum)] # sums[3] --> uninstall
sums = [sum(s) for s in zip_longest(mas_sum, dep_sum)]
unit, size = units(self.comp_sum + self.dep_comp_sum, unit, size = units(self.comp_sum + self.dep_comp_sum,
self.uncomp_sum + self.dep_uncomp_sum) self.uncomp_sum + self.dep_uncomp_sum)
if self.matching and [""] != self.packages: if self.matching and [""] != self.packages:
print("\nMatching summary") print("\nMatching summary")
print("=" * 79) print("=" * 79)
print(f"Total {sum(sums)} matching packages\n") print(f"Total {sums[0]} matching packages\n")
raise SystemExit(1) raise SystemExit(1)
print("\nInstalling summary") print("\nInstalling summary")
print("=" * 79) print("=" * 79)
print(f"{self.grey}Total {sum(sums)} {self.msg.pkg(sum(sums))}.") print(f"{self.grey}Total {sums[0]} {self.msg.pkg(sums[0])}.")
print(f"{sums[2]} {self.msg.pkg(sums[2])} will be installed, {sums[1]} will be upgraded and " print(f"{sums[3]} {self.msg.pkg(sums[3])} will be installed, {sums[2]} will be upgraded and "
f"{sums[0]} will be reinstalled.") f"{sums[1]} will be reinstalled.")
print(f"Need to get {size[0]} {unit[0]} of archives.") print(f"Need to get {size[0]} {unit[0]} of archives.")
print(f"After this process, {size[1]} {unit[1]} of additional disk " print(f"After this process, {size[1]} {unit[1]} of additional disk "
f"space will be used.{self.endc}") f"space will be used.{self.endc}")
@ -161,9 +162,9 @@ class BinaryInstall(BlackList):
self.msg.template(78) self.msg.template(78)
if "--download-only" in self.flag: if "--download-only" in self.flag:
raise SystemExit() raise SystemExit()
self.dep_install = list(self.utils.check_downloaded( self.dep_install = list(self.check_downloaded(
self.tmp_path, self.dep_install)) self.tmp_path, self.dep_install))
self.install = list(self.utils.check_downloaded( self.install = list(self.check_downloaded(
self.tmp_path, self.install)) self.tmp_path, self.install))
ins, upg = self.install_packages() ins, upg = self.install_packages()
self.msg.reference(ins, upg) self.msg.reference(ins, upg)
@ -190,8 +191,8 @@ class BinaryInstall(BlackList):
lowercase lowercase
""" """
if "--case-ins" in self.flag: if "--case-ins" in self.flag:
data = list(self.utils.package_name(self.PACKAGES_TXT)) data = list(self.package_name(self.PACKAGES_TXT))
data_dict = self.utils.case_sensitive(data) data_dict = self.case_sensitive(data)
for pkg in self.packages: for pkg in self.packages:
index = self.packages.index(pkg) index = self.packages.index(pkg)
for key, value in data_dict.items(): for key, value in data_dict.items():
@ -202,7 +203,7 @@ class BinaryInstall(BlackList):
"""Update dependencies dictionary with all package """Update dependencies dictionary with all package
""" """
for dep in self.dependencies: for dep in self.dependencies:
deps = self.utils.dimensional_list(Dependencies( deps = self.dimensional_list(Dependencies(
self.repo, self.blacklist).binary( self.repo, self.blacklist).binary(
dep, self.flag)) dep, self.flag))
self.deps_dict[dep] = deps self.deps_dict[dep] = deps
@ -212,7 +213,7 @@ class BinaryInstall(BlackList):
or if added to install two or more times or if added to install two or more times
""" """
packages = [] packages = []
for mas in self.utils.remove_dbs(self.packages): for mas in self.remove_dbs(self.packages):
if mas not in self.dependencies: if mas not in self.dependencies:
packages.append(mas) packages.append(mas)
self.packages = packages self.packages = packages
@ -266,11 +267,11 @@ class BinaryInstall(BlackList):
self.msg.resolving() self.msg.resolving()
for dep in self.packages: for dep in self.packages:
dependencies = [] dependencies = []
dependencies = self.utils.dimensional_list(Dependencies( dependencies = self.dimensional_list(Dependencies(
self.repo, self.blacklist).binary(dep, self.flag)) self.repo, self.blacklist).binary(dep, self.flag))
requires += list(self._fix_deps_repos(dependencies)) requires += list(self._fix_deps_repos(dependencies))
self.deps_dict[dep] = self.utils.remove_dbs(requires) self.deps_dict[dep] = self.remove_dbs(requires)
return self.utils.remove_dbs(requires) return self.remove_dbs(requires)
def _fix_deps_repos(self, dependencies): def _fix_deps_repos(self, dependencies):
"""Fix store deps include in repository """Fix store deps include in repository
@ -282,14 +283,16 @@ class BinaryInstall(BlackList):
def views(self, install, comp_sum): def views(self, install, comp_sum):
"""Views packages """Views packages
""" """
pkg_sum = uni_sum = upg_sum = 0 pkg_sum = uni_sum = upg_sum = res_sum = 0
# fix repositories align # fix repositories align
repo = self.repo + (" " * (6 - (len(self.repo)))) repo = self.repo + (" " * (6 - (len(self.repo))))
for pkg, comp in zip(install, comp_sum): for pkg, comp in zip(install, comp_sum):
pkg_sum += 1
pkg_repo = split_package(pkg[:-4]) pkg_repo = split_package(pkg[:-4])
if find_package(pkg[:-4], self.meta.pkg_path): if find_package(pkg[:-4], self.meta.pkg_path):
if "--reinstall" in self.flag: if "--reinstall" in self.flag:
pkg_sum += 1 res_sum += 1
COLOR = self.meta.color["GREEN"] COLOR = self.meta.color["GREEN"]
elif pkg_repo[0] == GetFromInstalled(pkg_repo[0]).name(): elif pkg_repo[0] == GetFromInstalled(pkg_repo[0]).name():
COLOR = self.meta.color["YELLOW"] COLOR = self.meta.color["YELLOW"]
@ -303,7 +306,7 @@ class BinaryInstall(BlackList):
f"{' ' * (18-len(pkg_repo[1]))} {pkg_repo[2]}" f"{' ' * (18-len(pkg_repo[1]))} {pkg_repo[2]}"
f"{' ' * (8-len(pkg_repo[2]))}{pkg_repo[3]}" f"{' ' * (8-len(pkg_repo[2]))}{pkg_repo[3]}"
f"{' ' * (7-len(pkg_repo[3]))}{repo}{comp:>11}{' K'}") f"{' ' * (7-len(pkg_repo[3]))}{repo}{comp:>11}{' K'}")
return [pkg_sum, upg_sum, uni_sum] return [pkg_sum, res_sum, upg_sum, uni_sum]
def top_view(self): def top_view(self):
"""Print packages status bar """Print packages status bar

View file

@ -30,7 +30,7 @@ from slpkg.slack.mirrors import mirrors
from slpkg.slack.slack_version import slack_ver from slpkg.slack.slack_version import slack_ver
class RepoInit: class RepoInit(Utils):
"""Return PACKAGES.TXT and mirror by repository """Return PACKAGES.TXT and mirror by repository
""" """
def __init__(self, repo): def __init__(self, repo):
@ -45,7 +45,7 @@ class RepoInit:
else: else:
self._init_custom() self._init_custom()
self.lib = self.meta.lib_path + f"{self.repo}_repo/PACKAGES.TXT" self.lib = self.meta.lib_path + f"{self.repo}_repo/PACKAGES.TXT"
PACKAGES_TXT = Utils().read_file(self.lib) PACKAGES_TXT = self.read_file(self.lib)
return PACKAGES_TXT, self.mirror return PACKAGES_TXT, self.mirror
def _init_custom(self): def _init_custom(self):

View file

@ -31,8 +31,10 @@ def search_pkg(name, repo):
"""Search if package exists in PACKAGES.TXT file """Search if package exists in PACKAGES.TXT file
and return the name. and return the name.
""" """
PACKAGES_TXT = Utils().read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT") utils = Utils()
names = list(Utils().package_name(PACKAGES_TXT)) black = BlackList()
blacklist = list(BlackList().get_black()) text = utils.read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT")
if name in names and name not in blacklist: PACKAGES_TXT = list(utils.package_name(text))
blacklist = list(black.get_black())
if name in PACKAGES_TXT and name not in blacklist:
return name return name

View file

@ -46,7 +46,7 @@ def check_md5(pkg_md5, src_file):
print(f"| Found: {md5s}") print(f"| Found: {md5s}")
msg.template(78) msg.template(78)
print() print()
if not Msg().answer() in ["y", "Y"]: if not msg.answer() in ["y", "Y"]:
raise SystemExit() raise SystemExit()
else: else:
msg.template(78) msg.template(78)

View file

@ -30,13 +30,12 @@ from slpkg.utils import Utils
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
class Config: class Config(Utils):
"""Print or edit slpkg configuration file """Print or edit slpkg configuration file
""" """
def __init__(self): def __init__(self):
self.config_file = "/etc/slpkg/slpkg.conf" self.config_file = "/etc/slpkg/slpkg.conf"
self.meta = _meta_ self.meta = _meta_
self.utils = Utils()
self.green = _meta_.color["GREEN"] self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"] self.red = _meta_.color["RED"]
self.cyan = _meta_.color["CYAN"] self.cyan = _meta_.color["CYAN"]
@ -68,9 +67,10 @@ class Config:
"SLACKPKG_LOG", "SLACKPKG_LOG",
"ONLY_INSTALLED", "ONLY_INSTALLED",
"EDITOR", "EDITOR",
"NOT_DOWNGRADE" "NOT_DOWNGRADE",
"HTTP_PROXY",
] ]
read_conf = self.utils.read_file(self.config_file) read_conf = self.read_file(self.config_file)
for line in read_conf.splitlines(): for line in read_conf.splitlines():
if not line.startswith("#") and line.split("=")[0] in conf_args: if not line.startswith("#") and line.split("=")[0] in conf_args:
print(line) print(line)

View file

@ -29,7 +29,7 @@ from slpkg.__metadata__ import MetaData as _meta_
from slpkg.sbo.greps import SBoGrep from slpkg.sbo.greps import SBoGrep
class PkgDesc: class PkgDesc(Utils):
"""Print package description from the repository """Print package description from the repository
""" """
def __init__(self, name, repo, paint): def __init__(self, name, repo, paint):
@ -38,7 +38,6 @@ class PkgDesc:
self.paint = paint self.paint = paint
self.meta = _meta_ self.meta = _meta_
self.msg = Msg() self.msg = Msg()
self.utils = Utils()
self.lib = "" self.lib = ""
self.color = { self.color = {
"red": self.meta.color["RED"], "red": self.meta.color["RED"],
@ -58,7 +57,7 @@ class PkgDesc:
if self.repo == "sbo": if self.repo == "sbo":
description = SBoGrep(self.name).description() description = SBoGrep(self.name).description()
else: else:
PACKAGES_TXT = self.utils.read_file(self.lib) PACKAGES_TXT = self.read_file(self.lib)
for line in PACKAGES_TXT.splitlines(): for line in PACKAGES_TXT.splitlines():
if line.startswith(self.name + ":"): if line.startswith(self.name + ":"):
description += f"{line[len(self.name) + 2:]}\n" description += f"{line[len(self.name) + 2:]}\n"

View file

@ -32,7 +32,7 @@ from slpkg.slack.slack_version import slack_ver
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
class Download: class Download(Utils):
"""Downloader manager. Slpkg use wget by default but support """Downloader manager. Slpkg use wget by default but support
curl, aria2 and httpie curl, aria2 and httpie
""" """
@ -57,7 +57,7 @@ class Download:
dwn_count = 1 dwn_count = 1
self._directory_prefix() self._directory_prefix()
for dwn in self.url: for dwn in self.url:
self.file_name = Utils().fix_file_name(dwn.split("/")[-1]) self.file_name = self.fix_file_name(dwn.split("/")[-1])
if dwn.startswith("file:///"): if dwn.startswith("file:///"):
source_dir = dwn[7:-7].replace(slack_ver(), "") source_dir = dwn[7:-7].replace(slack_ver(), "")

View file

@ -25,12 +25,18 @@
import os import os
import urllib3 import urllib3
from slpkg.__metadata__ import MetaData as _meta_
class FileSize: class FileSize:
"""Check local or remote file size """Check local or remote file size
""" """
def __init__(self, registry): def __init__(self, registry):
self.meta = _meta_
self.registry = registry self.registry = registry
if self.meta.http_proxy:
self.http = urllib3.ProxyManager(self.meta.http_proxy)
else:
self.http = urllib3.PoolManager() self.http = urllib3.PoolManager()
def server(self): def server(self):

View file

@ -35,7 +35,7 @@ from slpkg.slack.mirrors import mirrors
from slpkg.slack.slack_version import slack_ver from slpkg.slack.slack_version import slack_ver
class Initialization: class Initialization(Utils):
"""Slpkg initialization start all from here. Create local """Slpkg initialization start all from here. Create local
package lists and update or upgrade these. package lists and update or upgrade these.
""" """
@ -685,8 +685,7 @@ class Initialization:
for f in infiles: for f in infiles:
if os.path.isfile(f"{path}{f}"): if os.path.isfile(f"{path}{f}"):
# checking the encoding before read the file # checking the encoding before read the file
utils = Utils() code = self.check_encoding(path, f)
code = utils.check_encoding(path, f)
with open(path + f, "r", encoding=code) as in_f: with open(path + f, "r", encoding=code) as in_f:
for line in in_f: for line in in_f:
out_f.write(line) out_f.write(line)

View file

@ -31,7 +31,7 @@ from slpkg.utils import Utils
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
class NewConfig: class NewConfig(Utils):
"""Manage .new configuration files """Manage .new configuration files
""" """
def __init__(self): def __init__(self):
@ -179,9 +179,9 @@ class NewConfig:
"""Print the differences between the two files """Print the differences between the two files
""" """
if os.path.isfile(n[:-4]): if os.path.isfile(n[:-4]):
diff1 = Utils().read_file(n[:-4]).splitlines() diff1 = self.read_file(n[:-4]).splitlines()
if os.path.isfile(n): if os.path.isfile(n):
diff2 = Utils().read_file(n).splitlines() diff2 = self.read_file(n).splitlines()
lines, ln, c = [], 0, 0 lines, ln, c = [], 0, 0
for a, b in itertools.izip_longest(diff1, diff2): for a, b in itertools.izip_longest(diff1, diff2):
ln += 1 ln += 1
@ -208,9 +208,9 @@ class NewConfig:
"""Merge new file into old """Merge new file into old
""" """
if os.path.isfile(n[:-4]): if os.path.isfile(n[:-4]):
old = Utils().read_file(n[:-4]).splitlines() old = self.read_file(n[:-4]).splitlines()
if os.path.isfile(n): if os.path.isfile(n):
new = Utils().read_file(n).splitlines() new = self.read_file(n).splitlines()
with open(n[:-4], "w") as out: with open(n[:-4], "w") as out:
for l1, l2 in itertools.izip_longest(old, new): for l1, l2 in itertools.izip_longest(old, new):
if l1 is None: if l1 is None:

View file

@ -39,7 +39,7 @@ from slpkg.__metadata__ import MetaData as _meta_
from slpkg.sbo.greps import SBoGrep from slpkg.sbo.greps import SBoGrep
class BuildPackage: class BuildPackage(Utils):
"""Build SBo packages from source """Build SBo packages from source
""" """
def __init__(self, script, sources, path, auto): def __init__(self, script, sources, path, auto):
@ -118,7 +118,7 @@ class BuildPackage:
""" """
new_sources = [] new_sources = []
for src in self.sources: for src in self.sources:
new_sources.append(Utils().fix_file_name(src)) new_sources.append(self.fix_file_name(src))
self.sources = new_sources self.sources = new_sources
def _create_md5_dict(self): def _create_md5_dict(self):

View file

@ -30,9 +30,10 @@ from slpkg.splitting import split_package
def searching(find_pkg, directory): def searching(find_pkg, directory):
"""Find packages """Find packages
""" """
black = BlackList()
if os.path.isdir(directory): if os.path.isdir(directory):
installed = os.listdir(directory) installed = os.listdir(directory)
blacklist = list(BlackList().get_black()) blacklist = list(black.get_black())
if os.path.exists(directory): if os.path.exists(directory):
for pkg in installed: for pkg in installed:
if (not pkg.startswith(".") and pkg.startswith(find_pkg) and if (not pkg.startswith(".") and pkg.startswith(find_pkg) and

View file

@ -39,7 +39,7 @@ from slpkg.__metadata__ import MetaData as _meta_
from slpkg.slack.slackware_repo import slackware_repository from slpkg.slack.slackware_repo import slackware_repository
class PackageManager: class PackageManager(Utils):
"""Package manager class for install, upgrade, """Package manager class for install, upgrade,
reinstall, remove, find and display packages""" reinstall, remove, find and display packages"""
def __init__(self, binary): def __init__(self, binary):
@ -253,7 +253,7 @@ class PackageManager:
""" """
self.size = 0 self.size = 0
packages = [] packages = []
dependencies = (Utils().read_file(path + package)).splitlines() dependencies = (self.read_file(path + package)).splitlines()
for dep in dependencies: for dep in dependencies:
if GetFromInstalled(dep).name(): if GetFromInstalled(dep).name():
ver = GetFromInstalled(dep).version() ver = GetFromInstalled(dep).version()
@ -343,7 +343,7 @@ class PackageManager:
if "--check-deps" in self.extra: if "--check-deps" in self.extra:
package, dependency, pkg_dep = [], [], [] package, dependency, pkg_dep = [], [], []
for pkg in find_package("", self.dep_path): for pkg in find_package("", self.dep_path):
deps = Utils().read_file(self.dep_path + pkg) deps = self.read_file(self.dep_path + pkg)
for rmv in removes: for rmv in removes:
if GetFromInstalled(rmv).name() and rmv in deps.split(): if GetFromInstalled(rmv).name() and rmv in deps.split():
pkg_dep.append(f"{rmv} is dependency of the package --> {pkg}") pkg_dep.append(f"{rmv} is dependency of the package --> {pkg}")
@ -435,7 +435,7 @@ class PackageManager:
def _sizes(self, package): def _sizes(self, package):
"""Package size summary """Package size summary
""" """
data = Utils().read_file(self.meta.pkg_path + package) data = self.read_file(self.meta.pkg_path + package)
for line in data.splitlines(): for line in data.splitlines():
if line.startswith("UNCOMPRESSED PACKAGE SIZE:"): if line.startswith("UNCOMPRESSED PACKAGE SIZE:"):
digit = float((''.join(re.findall( digit = float((''.join(re.findall(
@ -456,7 +456,7 @@ class PackageManager:
find = find_package(f"{name}{ver}{self.meta.sp}", find = find_package(f"{name}{ver}{self.meta.sp}",
self.meta.pkg_path) self.meta.pkg_path)
if find: if find:
package = Utils().read_file( package = self.read_file(
self.meta.pkg_path + "".join(find)) self.meta.pkg_path + "".join(find))
print(package) print(package)
else: else:
@ -537,12 +537,13 @@ class PackageManager:
if repo == "sbo": if repo == "sbo":
if (os.path.isfile( if (os.path.isfile(
self.meta.lib_path + "sbo_repo/SLACKBUILDS.TXT")): self.meta.lib_path + "sbo_repo/SLACKBUILDS.TXT")):
packages = Utils().read_file(self.meta.lib_path + "sbo_repo/SLACKBUILDS.TXT") packages = self.read_file(f"{self.meta.lib_path}"
"sbo_repo/SLACKBUILDS.TXT")
else: else:
if (os.path.isfile( if (os.path.isfile(
self.meta.lib_path + f"{repo}_repo/PACKAGES.TXT")): self.meta.lib_path + f"{repo}_repo/PACKAGES.TXT")):
packages = Utils().read_file(self.meta.lib_path + "{0}_repo/" packages = self.read_file(f"{self.meta.lib_path}"
"PACKAGES.TXT".format(repo)) f"{repo}_repo/PACKAGES.TXT")
return packages return packages
def list_color_tag(self, pkg): def list_color_tag(self, pkg):

View file

@ -30,7 +30,7 @@ from slpkg.dialog_box import DialogUtil
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
class RepoEnable: class RepoEnable(Utils):
"""Read repositories.conf file and update with new enabled or """Read repositories.conf file and update with new enabled or
disabled repositories disabled repositories
""" """
@ -43,8 +43,8 @@ class RepoEnable:
self.tag = "[REPOSITORIES]" self.tag = "[REPOSITORIES]"
self.tag_line = False self.tag_line = False
self.repositories_conf = "repositories.conf" self.repositories_conf = "repositories.conf"
self.conf = Utils().read_file( self.conf = self.read_file(f"{self.meta.conf_path}"
self.meta.conf_path + self.repositories_conf) f"{self.repositories_conf}")
self.enabled = [] self.enabled = []
self.disabled = [] self.disabled = []
self.selected = [] self.selected = []

View file

@ -29,7 +29,7 @@ from slpkg.url_read import URL
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
class BuildNumber: class BuildNumber(Utils):
"""Get build number from SlackBuild script """Get build number from SlackBuild script
""" """
def __init__(self, sbo_url, pkg): def __init__(self, sbo_url, pkg):
@ -42,7 +42,7 @@ class BuildNumber:
if self.sbo_url: if self.sbo_url:
SlackBuild = URL(f"{self.sbo_url}{self.pkg}.SlackBuild").reading() SlackBuild = URL(f"{self.sbo_url}{self.pkg}.SlackBuild").reading()
else: else:
SlackBuild = Utils().read_file(f"{self.meta.build_path}{self.pkg}/{self.pkg}.SlackBuild") SlackBuild = self.read_file(f"{self.meta.build_path}{self.pkg}/{self.pkg}.SlackBuild")
for line in SlackBuild.splitlines(): for line in SlackBuild.splitlines():
line = line.lstrip() line = line.lstrip()
if line.startswith("BUILD="): if line.startswith("BUILD="):

View file

@ -38,10 +38,11 @@ def sbo_upgrade(skip, flag):
"""Return packages for upgrade """Return packages for upgrade
""" """
msg = Msg() msg = Msg()
black = BlackList()
msg.checking() msg.checking()
upgrade_names = [] upgrade_names = []
data = SBoGrep(name="").names() data = SBoGrep(name="").names()
blacklist = list(BlackList().get_black()) blacklist = list(black.get_black())
for pkg in sbo_list(): for pkg in sbo_list():
name = split_package(pkg)[0] name = split_package(pkg)[0]
ver = split_package(pkg)[1] ver = split_package(pkg)[1]

View file

@ -26,7 +26,7 @@ from slpkg.utils import Utils
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
class SBoGrep: class SBoGrep(Utils):
"""Grab data from SLACKBUILDS.TXT file """Grab data from SLACKBUILDS.TXT file
""" """
def __init__(self, name): def __init__(self, name):
@ -45,7 +45,7 @@ class SBoGrep:
self.sbo_txt = self.meta.lib_path + "sbo_repo/SLACKBUILDS.TXT" self.sbo_txt = self.meta.lib_path + "sbo_repo/SLACKBUILDS.TXT"
self.answer = ["y", "Y"] self.answer = ["y", "Y"]
self.unst = ["UNSUPPORTED", "UNTESTED"] self.unst = ["UNSUPPORTED", "UNTESTED"]
self.SLACKBUILDS_TXT = Utils().read_file(self.sbo_txt) self.SLACKBUILDS_TXT = self.read_file(self.sbo_txt)
def _names_grabbing(self): def _names_grabbing(self):
"""Generator that collecting all packages names """Generator that collecting all packages names

View file

@ -48,7 +48,7 @@ from slpkg.sbo.slack_find import slack_package
from slpkg.slack.slack_version import slack_ver from slpkg.slack.slack_version import slack_ver
class SBoNetwork(BlackList): class SBoNetwork(BlackList, Utils):
"""View SBo site in terminal and also read, build or """View SBo site in terminal and also read, build or
install packages install packages
""" """
@ -135,7 +135,7 @@ class SBoNetwork(BlackList):
lowercase lowercase
""" """
if "--case-ins" in self.flag: if "--case-ins" in self.flag:
data_dict = Utils().case_sensitive(self.data) data_dict = self.case_sensitive(self.data)
for key, value in data_dict.items(): for key, value in data_dict.items():
if key == self.name.lower(): if key == self.name.lower():
self.name = value self.name = value

View file

@ -39,7 +39,7 @@ from slpkg.sbo.search import sbo_search_pkg
from slpkg.sbo.slack_find import slack_package from slpkg.sbo.slack_find import slack_package
class QueuePkgs: class QueuePkgs(Utils):
"""Manage SBo packages, add or remove for building or """Manage SBo packages, add or remove for building or
installation installation
""" """
@ -68,7 +68,7 @@ class QueuePkgs:
with open(self.queue_list, "w") as queue: with open(self.queue_list, "w") as queue:
for line in queue_file: for line in queue_file:
queue.write(line) queue.write(line)
self.queued = Utils().read_file(self.queue_list) self.queued = self.read_file(self.queue_list)
def packages(self): def packages(self):
"""Return queue list from /var/lib/queue/queue_list """Return queue list from /var/lib/queue/queue_list

View file

@ -34,10 +34,12 @@ def sbo_search_pkg(name):
return url return url
""" """
url = "" url = ""
repo = Repo().default_repository()["sbo"] utils = Utils()
sbo_url = f"{repo}{slack_ver()}/" repo = Repo()
SLACKBUILDS_TXT = Utils().read_file( sbo = repo.default_repository()["sbo"]
_meta_.lib_path + "sbo_repo/SLACKBUILDS.TXT") sbo_url = f"{sbo}{slack_ver()}/"
SLACKBUILDS_TXT = utils.read_file(
f"{_meta_.lib_path}sbo_repo/SLACKBUILDS.TXT")
for line in SLACKBUILDS_TXT.splitlines(): for line in SLACKBUILDS_TXT.splitlines():
if line.startswith("SLACKBUILD LOCATION"): if line.startswith("SLACKBUILD LOCATION"):
sbo_name = (line[23:].split("/")[-1].replace("\n", "")).strip() sbo_name = (line[23:].split("/")[-1].replace("\n", "")).strip()

View file

@ -33,6 +33,7 @@ from slpkg.pkg.find import find_package
def slack_package(prgnam): def slack_package(prgnam):
"""Return maximum binary Slackware package from output directory """Return maximum binary Slackware package from output directory
""" """
msg = Msg()
binaries, cache, binary = [], "0", "" binaries, cache, binary = [], "0", ""
for pkg in find_package(prgnam, _meta_.output): for pkg in find_package(prgnam, _meta_.output):
if pkg.startswith(prgnam) and pkg[:-4].endswith("_SBo"): if pkg.startswith(prgnam) and pkg[:-4].endswith("_SBo"):
@ -43,6 +44,6 @@ def slack_package(prgnam):
binary = bins binary = bins
cache = binary cache = binary
if not binary: if not binary:
Msg().build_FAILED(prgnam) msg.build_FAILED(prgnam)
raise SystemExit(1) raise SystemExit(1)
return ["".join(_meta_.output + binary)] return ["".join(_meta_.output + binary)]

View file

@ -29,8 +29,8 @@ from slpkg.messages import Msg
def pkg_security(pkgs): def pkg_security(pkgs):
"""Check packages before install or upgrade for security """Check packages before install or upgrade for security
reasons. Configuration file in the /etc/slpkg/pkg_security""" reasons. Configuration file in the /etc/slpkg/pkg_security"""
security_packages = Utils().read_file("/etc/slpkg/pkg_security") packages, msg, utils = [], Msg(), Utils()
packages, msg = [], Msg() security_packages = utils.read_file("/etc/slpkg/pkg_security")
for read in security_packages.splitlines(): for read in security_packages.splitlines():
read = read.lstrip() read = read.lstrip()
if not read.startswith("#"): if not read.startswith("#"):

View file

@ -34,20 +34,21 @@ def mirrors(name, location):
""" """
rel = _meta_.slack_rel rel = _meta_.slack_rel
ver = slack_ver() ver = slack_ver()
repo = Repo().slack() repo = Repo()
slack = repo.slack()
if _meta_.arch == "x86_64": if _meta_.arch == "x86_64":
if rel == "stable": if rel == "stable":
http = f"{repo}slackware64-{ver}/{location}{name}" http = f"{slack}slackware64-{ver}/{location}{name}"
else: else:
http = f"{repo}slackware64-{rel}/{location}{name}" http = f"{slack}slackware64-{rel}/{location}{name}"
elif _meta_.arch.startswith("arm"): elif _meta_.arch.startswith("arm"):
if rel == "stable": if rel == "stable":
http = f"{repo}slackwarearm-{ver}/{location}{name}" http = f"{slack}slackwarearm-{ver}/{location}{name}"
else: else:
http = f"{repo}slackwarearm-{rel}/{location}{name}" http = f"{slack}slackwarearm-{rel}/{location}{name}"
else: else:
if rel == "stable": if rel == "stable":
http = f"{repo}slackware-{ver}/{location}{name}" http = f"{slack}slackware-{ver}/{location}{name}"
else: else:
http = f"{repo}slackware-{rel}/{location}{name}" http = f"{slack}slackware-{rel}/{location}{name}"
return http return http

View file

@ -50,7 +50,7 @@ from slpkg.slack.mirrors import mirrors
from slpkg.slack.slack_version import slack_ver from slpkg.slack.slack_version import slack_ver
class Patches(BlackList): class Patches(BlackList, Utils):
"""Upgrade distribution from official Slackware mirrors """Upgrade distribution from official Slackware mirrors
""" """
def __init__(self, skip, flag): def __init__(self, skip, flag):
@ -75,7 +75,6 @@ class Patches(BlackList):
self.installed = [] self.installed = []
self.comp_sum = [] self.comp_sum = []
self.uncomp_sum = [] self.uncomp_sum = []
self.utils = Utils()
self.msg.checking() self.msg.checking()
if self.version == "stable": if self.version == "stable":
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT",
@ -111,7 +110,7 @@ class Patches(BlackList):
if self.msg.answer() in ["y", "Y"]: if self.msg.answer() in ["y", "Y"]:
Download(self.patch_path, self.dwn_links, Download(self.patch_path, self.dwn_links,
repo="slack").start() repo="slack").start()
self.upgrade_all = list(self.utils.check_downloaded( self.upgrade_all = list(self.check_downloaded(
self.patch_path, self.upgrade_all)) self.patch_path, self.upgrade_all))
self.upgrade() self.upgrade()
self.kernel() self.kernel()

View file

@ -32,8 +32,9 @@ def slack_ver():
""" """
Open file and read Slackware version Open file and read Slackware version
""" """
utils = Utils()
if _meta_.slackware_version in ["off", "OFF"]: if _meta_.slackware_version in ["off", "OFF"]:
sv = Utils().read_file("/etc/slackware-version") sv = utils.read_file("/etc/slackware-version")
version = re.findall(r"\d+", sv) version = re.findall(r"\d+", sv)
if len(sv) > 2: if len(sv) > 2:
return (".".join(version[:2])) return (".".join(version[:2]))

View file

@ -31,9 +31,10 @@ from slpkg.__metadata__ import MetaData as _meta_
def slackware_repository(): def slackware_repository():
"""Return all official Slackware packages """Return all official Slackware packages
""" """
utils = Utils()
slack_repo, packages, names = [], [], [] slack_repo, packages, names = [], [], []
slack_repo = repo_data( slack_repo = repo_data(
Utils().read_file(f"{_meta_.lib_path}slack_repo/PACKAGES.TXT"), utils.read_file(f"{_meta_.lib_path}slack_repo/PACKAGES.TXT"),
"slack", "") "slack", "")
for pkg in slack_repo[0]: for pkg in slack_repo[0]:
names.append(split_package(pkg)[0]) names.append(split_package(pkg)[0])

View file

@ -48,10 +48,12 @@ def it_self_update():
branch, branch,
_meta_.__all__)) _meta_.__all__))
version_data = URL(ver_link).reading() version_data = URL(ver_link).reading()
for line in version_data.splitlines(): for line in version_data.splitlines():
line = line.strip() line = line.strip()
if line.startswith("__version_info__"): if line.startswith("__version_info__"):
__new_version__ = ".".join(re.findall(r"\d+", line)) __new_version__ = ".".join(re.findall(r"\d+", line))
if __new_version__ > _meta_.__version__: if __new_version__ > _meta_.__version__:
if _meta_.default_answer in ["y", "Y"]: if _meta_.default_answer in ["y", "Y"]:
answer = _meta_.default_answer answer = _meta_.default_answer
@ -63,10 +65,12 @@ def it_self_update():
except EOFError: except EOFError:
print() print()
raise SystemExit(1) raise SystemExit(1)
if answer in ["y", "Y"]: if answer in ["y", "Y"]:
print() # new line after answer print() # new line after answer
else: else:
raise SystemExit() raise SystemExit()
dwn_link = ["https://{0}.com/{1}/{2}/-/archive/" dwn_link = ["https://{0}.com/{1}/{2}/-/archive/"
"{3}/{4}-{5}.tar.gz".format(repository, "{3}/{4}-{5}.tar.gz".format(repository,
_meta_.__author__, _meta_.__author__,
@ -74,8 +78,10 @@ def it_self_update():
__new_version__, __new_version__,
_meta_.__all__, _meta_.__all__,
__new_version__)] __new_version__)]
if not os.path.exists(_meta_.build_path): if not os.path.exists(_meta_.build_path):
os.makedirs(_meta_.build_path) os.makedirs(_meta_.build_path)
Download(_meta_.build_path, dwn_link, repo="").start() Download(_meta_.build_path, dwn_link, repo="").start()
os.chdir(_meta_.build_path) os.chdir(_meta_.build_path)
slpkg_tar_file = f"slpkg-{__new_version__}.tar.gz" slpkg_tar_file = f"slpkg-{__new_version__}.tar.gz"
@ -88,6 +94,7 @@ def it_self_update():
_meta_.build_path + slpkg_tar_file) _meta_.build_path + slpkg_tar_file)
subprocess.call("chmod +x {0}".format("install.sh"), shell=True) subprocess.call("chmod +x {0}".format("install.sh"), shell=True)
subprocess.call("sh install.sh", shell=True) subprocess.call("sh install.sh", shell=True)
else: else:
print(f"\n{_meta_.__all__}: There is no new version, already used the last!\n") print(f"\n{_meta_.__all__}: There is no new version, already used the last!\n")
raise SystemExit() raise SystemExit()

View file

@ -29,14 +29,18 @@ def split_package(package):
""" """
name = ver = arch = build = [] name = ver = arch = build = []
split = package.split("-") split = package.split("-")
if len(split) > 2: if len(split) > 2:
build = split[-1] build = split[-1]
build_a, build_b = "", "" build_a, build_b = "", ""
build_a = build[:1] build_a = build[:1]
if build[1:2].isdigit(): if build[1:2].isdigit():
build_b = build[1:2] build_b = build[1:2]
build = build_a + build_b build = build_a + build_b
arch = split[-2] arch = split[-2]
ver = split[-3] ver = split[-3]
name = "-".join(split[:-3]) name = "-".join(split[:-3])
return [name, ver, arch, build] return [name, ver, arch, build]

View file

@ -33,14 +33,13 @@ from slpkg.__metadata__ import MetaData as _meta_
from slpkg.pkg.find import find_package from slpkg.pkg.find import find_package
class DependenciesStatus: class DependenciesStatus(Utils):
"""Print dependencies status used by packages """Print dependencies status used by packages
""" """
def __init__(self, image): def __init__(self, image):
self.image = image self.image = image
self.meta = _meta_ self.meta = _meta_
self.msg = Msg() self.msg = Msg()
self.utils = Utils()
self.grey = self.meta.color["GREY"] self.grey = self.meta.color["GREY"]
self.green = self.meta.color["GREEN"] self.green = self.meta.color["GREEN"]
self.endc = self.meta.color["ENDC"] self.endc = self.meta.color["ENDC"]
@ -61,7 +60,7 @@ class DependenciesStatus:
if os.path.isfile(f"{self.meta.pkg_path}{pkg}"): if os.path.isfile(f"{self.meta.pkg_path}{pkg}"):
name = split_package(pkg)[0] name = split_package(pkg)[0]
for log in self.logs: for log in self.logs:
deps = self.utils.read_file(f"{self.dep_path}{log}") deps = self.read_file(f"{self.dep_path}{log}")
for dep in deps.splitlines(): for dep in deps.splitlines():
if name == dep: if name == dep:
if name not in self.dmap.keys(): if name not in self.dmap.keys():

View file

@ -38,7 +38,7 @@ from slpkg.binary.search import search_pkg
from slpkg.binary.dependency import Dependencies from slpkg.binary.dependency import Dependencies
class TrackingDeps(BlackList): class TrackingDeps(BlackList, Utils):
"""View tree of dependencies and also """View tree of dependencies and also
highlight packages with color green highlight packages with color green
if already installed and color red if already installed and color red
@ -51,7 +51,6 @@ class TrackingDeps(BlackList):
self.flag = flag self.flag = flag
self.meta = _meta_ self.meta = _meta_
self.msg = Msg() self.msg = Msg()
self.utils = Utils()
self.green = self.meta.color["GREEN"] self.green = self.meta.color["GREEN"]
self.yellow = self.meta.color["YELLOW"] self.yellow = self.meta.color["YELLOW"]
self.cyan = self.meta.color["CYAN"] self.cyan = self.meta.color["CYAN"]
@ -78,8 +77,8 @@ class TrackingDeps(BlackList):
self.repositories() self.repositories()
if self.find_pkg: if self.find_pkg:
self.dependencies_list.reverse() self.dependencies_list.reverse()
self.requires = self.utils.dimensional_list(self.dependencies_list) self.requires = self.dimensional_list(self.dependencies_list)
self.dependencies = self.utils.remove_dbs(self.requires) self.dependencies = self.remove_dbs(self.requires)
if self.dependencies == []: if self.dependencies == []:
self.dependencies = ["No dependencies"] self.dependencies = ["No dependencies"]
if "--graph=" in self.flag: if "--graph=" in self.flag:
@ -130,9 +129,9 @@ class TrackingDeps(BlackList):
if self.find_pkg: if self.find_pkg:
self.dependencies_list = Requires(self.flag).sbo(self.name) self.dependencies_list = Requires(self.flag).sbo(self.name)
else: else:
PACKAGES_TXT = self.utils.read_file( PACKAGES_TXT = self.read_file(
f"{self.meta.lib_path}{self.repo}_repo/PACKAGES.TXT") f"{self.meta.lib_path}{self.repo}_repo/PACKAGES.TXT")
self.names = list(self.utils.package_name(PACKAGES_TXT)) self.names = list(self.package_name(PACKAGES_TXT))
self.bin_case_insensitive() self.bin_case_insensitive()
self.find_pkg = search_pkg(self.name, self.repo) self.find_pkg = search_pkg(self.name, self.repo)
if self.find_pkg: if self.find_pkg:
@ -146,7 +145,7 @@ class TrackingDeps(BlackList):
""" """
if "--case-ins" in self.flag: if "--case-ins" in self.flag:
data = SBoGrep(name="").names() data = SBoGrep(name="").names()
data_dict = self.utils.case_sensitive(data) data_dict = self.case_sensitive(data)
for key, value in data_dict.items(): for key, value in data_dict.items():
if key == self.name.lower(): if key == self.name.lower():
self.name = value self.name = value
@ -156,7 +155,7 @@ class TrackingDeps(BlackList):
lowercase lowercase
""" """
if "--case-ins" in self.flag: if "--case-ins" in self.flag:
data_dict = self.utils.case_sensitive(self.names) data_dict = self.case_sensitive(self.names)
for key, value in data_dict.items(): for key, value in data_dict.items():
if key == self.name.lower(): if key == self.name.lower():
self.name = value self.name = value
@ -173,7 +172,7 @@ class TrackingDeps(BlackList):
dep_path = f"{self.meta.log_path}dep/" dep_path = f"{self.meta.log_path}dep/"
logs = find_package("", dep_path) logs = find_package("", dep_path)
for log in logs: for log in logs:
deps = self.utils.read_file(f"{dep_path}{log}") deps = self.read_file(f"{dep_path}{log}")
for dep in deps.splitlines(): for dep in deps.splitlines():
if pkg == dep: if pkg == dep:
used.append(log) used.append(log)
@ -187,12 +186,12 @@ class TrackingDeps(BlackList):
for dep in dependencies: for dep in dependencies:
deps = Requires(flag="").sbo(dep) deps = Requires(flag="").sbo(dep)
if dep not in self.deps_dict.values(): if dep not in self.deps_dict.values():
self.deps_dict[dep] = self.utils.dimensional_list(deps) self.deps_dict[dep] = self.dimensional_list(deps)
else: else:
for dep in dependencies: for dep in dependencies:
deps = Dependencies(self.repo, self.black).binary(dep, flag="") deps = Dependencies(self.repo, self.black).binary(dep, flag="")
if dep not in self.deps_dict.values(): if dep not in self.deps_dict.values():
self.deps_dict[dep] = self.utils.dimensional_list(deps) self.deps_dict[dep] = self.dimensional_list(deps)
def deps_used(self, pkg, used): def deps_used(self, pkg, used):
"""Create dependencies dictionary """Create dependencies dictionary

View file

@ -35,6 +35,9 @@ class URL:
self.meta = _meta_ self.meta = _meta_
self.red = _meta_.color["RED"] self.red = _meta_.color["RED"]
self.endc = _meta_.color["ENDC"] self.endc = _meta_.color["ENDC"]
if self.meta.http_proxy:
self.http = urllib3.ProxyManager(self.meta.http_proxy)
else:
self.http = urllib3.PoolManager() self.http = urllib3.PoolManager()
def reading(self): def reading(self):

View file

@ -2,6 +2,8 @@ from slpkg.file_size import FileSize
def test_FileSize(): def test_FileSize():
"""Testing the remote and local servers
"""
url = "https://mirrors.slackware.com/slackware/slackware64-14.2/ChangeLog.txt" url = "https://mirrors.slackware.com/slackware/slackware64-14.2/ChangeLog.txt"
lc = "tests/test_units.py" lc = "tests/test_units.py"
fs1 = FileSize(url) fs1 = FileSize(url)

View file

@ -2,10 +2,14 @@ from slpkg.md5sum import md5
def test_md5_superuser(): def test_md5_superuser():
"""Testing checksum for superuser.py file
"""
result = md5('slpkg/superuser.py') result = md5('slpkg/superuser.py')
assert result == "c6a3576c247bda199c75b43540bfc3d7" assert result == "c6a3576c247bda199c75b43540bfc3d7"
def test_md5_security(): def test_md5_security():
"""Testing checksum for security.py file
"""
result = md5('slpkg/security.py') result = md5('slpkg/security.py')
assert result == "36c3a9213a27ab0b49e9c1bdd5bd2db6" assert result == "eb8dbea4dec6d72353d30475670389f0"

View file

@ -0,0 +1,19 @@
from slpkg.binary.search import search_pkg
from slpkg.sbo.search import sbo_search_pkg
def test_search():
"""Testing found the name from binaries repos
"""
name = "vlc"
repo = "alien"
test = search_pkg(name, repo)
assert name == test
def test_sbo_search():
"""Testing found the name from binaries repos
"""
name = "slpkg"
test = sbo_search_pkg(name).split("/")[-2]
assert name == test

View file

@ -2,4 +2,6 @@ from slpkg.sizes import units
def test_units(): def test_units():
"""Testing the units metrics
"""
assert ["Kb", "Kb"], ["100", "100"] == units(['100', ['100']]) assert ["Kb", "Kb"], ["100", "100"] == units(['100', ['100']])

View file

@ -2,12 +2,16 @@ from slpkg.utils import Utils
def test_dimensional_list(): def test_dimensional_list():
"""Testing dimesional list util
"""
lists = [[1, 2, 3, 4, 5]] lists = [[1, 2, 3, 4, 5]]
utils = Utils() utils = Utils()
assert [1, 2, 3, 4, 5] == utils.dimensional_list(lists) assert [1, 2, 3, 4, 5] == utils.dimensional_list(lists)
def test_remove_dbs(): def test_remove_dbs():
"""Testing removing doubles item from list
"""
lists = [1, 2, 3, 3, 4, 5, 2, 1] lists = [1, 2, 3, 3, 4, 5, 2, 1]
utils = Utils() utils = Utils()
assert [1, 2, 3, 4, 5] == utils.remove_dbs(lists) assert [1, 2, 3, 4, 5] == utils.remove_dbs(lists)