Merge branch 'develop'

This commit is contained in:
Dimitris Zlatanidis 2020-02-16 18:23:42 +01:00
commit f29c56efff
46 changed files with 297 additions and 256 deletions

View file

@ -1,3 +1,12 @@
3.8.2 - 15/02/2020
Fixed:
- SBo repository view Packages and New version
- msb repository PACKAGES.txt file
BugFix:
- Upgrade distribution with option -c, --check
Added:
- Managing multi packages in blacklist file
3.8.1 - 13/02/2020
Fixed:
- Bugfix double install packages from slack regular repo

View file

@ -1175,8 +1175,7 @@ $ slpkg -q install (install packages from queue)
$ slpkg -q build-install (build and install)
```
Add or remove the packages in blacklist file manually from '`/etc/slpkg/blacklist`' or
with the following options:
Add or remove packages in blacklist file manually from the '`/etc/slpkg/blacklist`' file or with the following options:
```
$ slpkg -b live555 speex faac --add

View file

@ -1,4 +1,4 @@
# slpkg 3.8.1
# slpkg 3.8.2
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

View file

@ -10,6 +10,9 @@
# To blacklist the package 'wicd-1.7.2.4-x86_64-4.txz' the line will be:
# wicd
#
# To blacklist packages that start with name add * the end of the name:
# kernel*
#
#
# Sometimes the automatic kernel update creates problems because you
# may need to file intervention 'lilo'. The slpkg automatically detects

View file

@ -76,7 +76,7 @@ class MetaData:
__all__ = "slpkg"
__author__ = "dslackw"
__version_info__ = (3, 8, 1)
__version_info__ = (3, 8, 2)
__version__ = "{0}.{1}.{2}".format(*__version_info__)
__license__ = "GNU General Public License v3 (GPLv3)"
__email__ = "d.zlatanidis@gmail.com"

View file

@ -38,7 +38,8 @@ from slpkg.binary.repo_init import RepoInit
def pkg_upgrade(repo, skip, flag):
"""Checking packages for upgrade
"""
Msg().checking()
msg = Msg()
msg.checking()
PACKAGES_TXT = RepoInit(repo).fetch()[0]
pkgs_for_upgrade = []
# name = data[0]
@ -57,7 +58,7 @@ def pkg_upgrade(repo, skip, flag):
inst_pkg[0] not in skip and
repo_pkg[1] != "blacklist"):
pkgs_for_upgrade.append(repo_pkg[0])
Msg().done()
msg.done()
if "--checklist" in flag:
pkgs_for_upgrade = choose_upg(pkgs_for_upgrade)
return pkgs_for_upgrade

View file

@ -44,7 +44,7 @@ def repo_data(PACKAGES_TXT, repo, flag):
if line.startswith("PACKAGE SIZE (uncompressed):"):
unsize.append(line[30:-2].strip())
if repo == "slack":
if repo == "slack" and "--upgrade" not in flag:
(rname,
rlocation,
rsize,

View file

@ -47,11 +47,12 @@ from slpkg.binary.repo_init import RepoInit
from slpkg.binary.dependency import Dependencies
class BinaryInstall:
class BinaryInstall(BlackList):
"""Install binaries packages with all dependencies from
repository
"""
def __init__(self, packages, repo, flag):
super().__init__()
self.packages = packages
pkg_security(packages)
self.repo = repo
@ -63,6 +64,7 @@ class BinaryInstall:
self.yellow = _meta_.color['YELLOW']
self.endc = _meta_.color["ENDC"]
self.msg = Msg()
self.utils = Utils()
self.version = self.meta.slack_rel
self.tmp_path = self.meta.slpkg_tmp_packages
self.init_flags()
@ -79,7 +81,7 @@ class BinaryInstall:
self.repo_pkg_names = []
for name in self.data[0]:
self.repo_pkg_names.append(split_package(name)[0])
self.blacklist = BlackList().get_black()
self.blacklist = list(self.get_black())
self.matching = False
def init_flags(self):
@ -159,10 +161,10 @@ class BinaryInstall:
self.msg.template(78)
if "--download-only" in self.flag:
raise SystemExit()
self.dep_install = Utils().check_downloaded(
self.tmp_path, self.dep_install)
self.install = Utils().check_downloaded(
self.tmp_path, self.install)
self.dep_install = list(self.utils.check_downloaded(
self.tmp_path, self.dep_install))
self.install = list(self.utils.check_downloaded(
self.tmp_path, self.install))
ins, upg = self.install_packages()
self.msg.reference(ins, upg)
write_deps(self.deps_dict)
@ -188,8 +190,8 @@ class BinaryInstall:
lowercase
"""
if "--case-ins" in self.flag:
data = list(Utils().package_name(self.PACKAGES_TXT))
data_dict = Utils().case_sensitive(data)
data = list(self.utils.package_name(self.PACKAGES_TXT))
data_dict = self.utils.case_sensitive(data)
for pkg in self.packages:
index = self.packages.index(pkg)
for key, value in data_dict.items():
@ -200,7 +202,7 @@ class BinaryInstall:
"""Update dependencies dictionary with all package
"""
for dep in self.dependencies:
deps = Utils().dimensional_list(Dependencies(
deps = self.utils.dimensional_list(Dependencies(
self.repo, self.blacklist).binary(
dep, self.flag))
self.deps_dict[dep] = deps
@ -210,7 +212,7 @@ class BinaryInstall:
or if added to install two or more times
"""
packages = []
for mas in Utils().remove_dbs(self.packages):
for mas in self.utils.remove_dbs(self.packages):
if mas not in self.dependencies:
packages.append(mas)
self.packages = packages
@ -264,11 +266,11 @@ class BinaryInstall:
self.msg.resolving()
for dep in self.packages:
dependencies = []
dependencies = Utils().dimensional_list(Dependencies(
dependencies = self.utils.dimensional_list(Dependencies(
self.repo, self.blacklist).binary(dep, self.flag))
requires += list(self._fix_deps_repos(dependencies))
self.deps_dict[dep] = Utils().remove_dbs(requires)
return Utils().remove_dbs(requires)
self.deps_dict[dep] = self.utils.remove_dbs(requires)
return self.utils.remove_dbs(requires)
def _fix_deps_repos(self, dependencies):
"""Fix store deps include in repository

View file

@ -33,6 +33,6 @@ def search_pkg(name, repo):
"""
PACKAGES_TXT = Utils().read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT")
names = list(Utils().package_name(PACKAGES_TXT))
blacklist = BlackList().get_black()
blacklist = list(BlackList().get_black())
if name in names and name not in blacklist:
return name

View file

@ -25,10 +25,11 @@
import os
from slpkg.utils import Utils
from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _meta_
class BlackList:
class BlackList(Utils):
"""Blacklist class to add, remove or listed packages
in blacklist file."""
def __init__(self):
@ -38,30 +39,43 @@ class BlackList:
self.blackfile = "/etc/slpkg/blacklist"
self.black_conf = ""
if os.path.isfile(self.blackfile):
self.black_conf = Utils().read_file(self.blackfile)
self.black_conf = self.read_file(self.blackfile)
def get_black(self):
"""Return blacklist packages from /etc/slpkg/blacklist
configuration file."""
blacklist = []
blacklist = list(self.black_filter())
installed = os.listdir("/var/log/packages/")
for black in blacklist:
if black.endswith("*"):
for inst in installed:
if inst.startswith(black[:-1]):
yield split_package(inst)[0]
else:
yield black
def black_filter(self):
"""Return all the installed files that start
by the name*
"""
for read in self.black_conf.splitlines():
read = read.lstrip()
if not read.startswith("#"):
blacklist.append(read.replace("\n", ""))
return blacklist
yield read.replace("\n", "")
def listed(self):
def black_listed(self):
"""Print blacklist packages
"""
print("Packages in the blacklist:\n")
for black in self.get_black():
for black in list(self.black_filter()):
if black:
print(f"{self.green}{black}{self.endc}")
def add(self, pkgs):
def black_add(self, pkgs):
"""Add blacklist packages if not exist
"""
blacklist = self.get_black()
blacklist = list(self.black_filter())
pkgs = set(pkgs)
print("Add packages in the blacklist:\n")
with open(self.blackfile, "a") as black_conf:
@ -70,7 +84,7 @@ class BlackList:
print(f"{self.green}{pkg}{self.endc}")
black_conf.write(pkg + "\n")
def remove(self, pkgs):
def black_remove(self, pkgs):
"""Remove packages from blacklist
"""
print("Remove packages from the blacklist:\n")

View file

@ -30,6 +30,7 @@ from slpkg.__metadata__ import MetaData as _meta_
def check_md5(pkg_md5, src_file):
"""MD5 Checksum
"""
msg = Msg()
red = _meta_.color["RED"]
green = _meta_.color["GREEN"]
endc = _meta_.color["ENDC"]
@ -37,19 +38,19 @@ def check_md5(pkg_md5, src_file):
print()
md5s = md5(src_file)
if pkg_md5 != md5s:
Msg().template(78)
msg.template(78)
print(f"| MD5SUM check for {src_file.split('/')[-1]}"
f" [ {red}FAILED{endc} ]")
Msg().template(78)
msg.template(78)
print(f"| Expected: {pkg_md5}")
print(f"| Found: {md5s}")
Msg().template(78)
msg.template(78)
print()
if not Msg().answer() in ["y", "Y"]:
raise SystemExit()
else:
Msg().template(78)
msg.template(78)
print(f"| MD5SUM check for {src_file.split('/')[-1]}"
f" [ {green}PASSED{endc} ]")
Msg().template(78)
msg.template(78)
print() # new line after pass checksum

View file

@ -39,11 +39,10 @@ def clean_tmp():
# Delete a whole slpkg folder from the tmp directory
if os.path.exists(tmps[0]):
shutil.rmtree(tmps[0])
print("All packages and sources were deleted from: {0}".format(
tmps[0]))
print(f"All packages and sources were deleted from: {tmps[0]}")
# Recreate the paths again
if not os.path.exists(tmps[0]):
for tmp in tmps:
print("Created directory: {0}".format(tmp))
print(f"Created directory: {tmp}")
os.mkdir(tmp)
print("Done!")
print("Done!")

View file

@ -36,6 +36,7 @@ class Config:
def __init__(self):
self.config_file = "/etc/slpkg/slpkg.conf"
self.meta = _meta_
self.utils = Utils()
self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"]
self.cyan = _meta_.color["CYAN"]
@ -66,11 +67,10 @@ class Config:
"DOWNDER_OPTIONS",
"SLACKPKG_LOG",
"ONLY_INSTALLED",
"PRG_BAR",
"EDITOR",
"NOT_DOWNGRADE"
]
read_conf = Utils().read_file(self.config_file)
read_conf = self.utils.read_file(self.config_file)
for line in read_conf.splitlines():
if not line.startswith("#") and line.split("=")[0] in conf_args:
print(line)
@ -89,4 +89,4 @@ class Config:
if filecmp.cmp(f"{self.config_file}.orig", self.config_file):
print(f"{self.green}The reset was done{self.endc}")
else:
print(f"{self.red}Reset failed{self.endc}")
print(f"{self.red}Reset failed{self.endc}")

View file

@ -38,6 +38,7 @@ class PkgDesc:
self.paint = paint
self.meta = _meta_
self.msg = Msg()
self.utils = Utils()
self.lib = ""
self.color = {
"red": self.meta.color["RED"],
@ -57,10 +58,10 @@ class PkgDesc:
if self.repo == "sbo":
description = SBoGrep(self.name).description()
else:
PACKAGES_TXT = Utils().read_file(self.lib)
PACKAGES_TXT = self.utils.read_file(self.lib)
for line in PACKAGES_TXT.splitlines():
if line.startswith(self.name + ":"):
description += line[len(self.name) + 2:] + "\n"
description += f"{line[len(self.name) + 2:]}\n"
count += 1
if count == 11:
break

View file

@ -31,11 +31,7 @@ class DialogUtil:
"""Create dialog checklist
"""
def __init__(self, *args):
try:
from dialog import Dialog
except ImportError:
raise SystemExit()
self.d = Dialog(dialog="dialog", autowidgetsize=True)
self.imp_dialog()
self.data = args[0]
self.text = args[1]
self.title = args[2]
@ -44,6 +40,13 @@ class DialogUtil:
self.ununicode = []
self.tags = []
def imp_dialog(self):
try:
from dialog import Dialog
except ImportError:
raise SystemExit()
self.d = Dialog(dialog="dialog", autowidgetsize=True)
def checklist(self):
"""Run dialog checklist
"""

View file

@ -78,8 +78,8 @@ class Graph:
try:
image_type = f".{self.image.split('.')[1]}"
if image_type not in self.file_format:
print(f"Format: '{self.image.split('.')[1]}' not recognized. Use one of "
f"them:\n{', '.join(self.file_format)}")
print(f"Format: '{self.image.split('.')[1]}' not recognized."
f" Use one of them:\n{', '.join(self.file_format)}")
raise SystemExit()
except IndexError:
print("slpkg: Error: Image file suffix missing")
@ -89,8 +89,8 @@ class Graph:
"""Draw ascii diagram. graph-easy perl module require
"""
if not os.path.isfile("/usr/bin/graph-easy"):
print("Require 'graph-easy': Install with 'slpkg -s sbo "
"graph-easy'")
print("Require 'graph-easy': Install with 'slpkg -s sbo"
" graph-easy'")
self.remove_dot()
raise SystemExit()
subprocess.call(f"graph-easy {self.image}.dot", shell=True)

View file

@ -73,7 +73,7 @@ class PackageHealth:
self.packages()
self.cf = 0
for pkg in self.installed:
if os.path.isfile(self.meta.pkg_path + pkg):
if os.path.isfile(f"{self.meta.pkg_path}{pkg}"):
self.lf = 0
with open(self.pkg_path + pkg, "r") as fopen:
for line in fopen:

View file

@ -527,7 +527,7 @@ class Initialization:
version = self.meta.msb_sub_repo[1:-1]
if self.meta.slack_rel == "current":
ver_slack = self.meta.slack_rel
PACKAGES_TXT = f"{repo}{ver_slack}/{version}/{ar}/{md5_file}"
PACKAGES_TXT = f"{repo}{ver_slack}/{version}/{ar}/{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = f"{repo}{ver_slack}/{version}/{ar}/{md5_file}"
ChangeLog_txt = f"{repo}{log_file}"
@ -709,30 +709,42 @@ class Initialization:
return True
return False
def upgrade(self, only):
"""Remove all package lists with changelog and checksums files
and create lists again"""
class Upgrade:
def __init__(self):
self.meta = _meta_
self.log_path = self.meta.log_path
self.lib_path = self.meta.lib_path
def run(self, repos):
"""Removing and creating the packages lists
"""
repositories = self.meta.repositories
if only:
repositories = only
# Replace the enabled repositories from user defined
if repos:
repositories = repos
for repo in repositories:
changelogs = f"{self.log_path}{repo}/ChangeLog.txt"
if os.path.isfile(changelogs):
os.remove(changelogs)
if os.path.isdir(self.lib_path + f"{repo}_repo/"):
for f in (os.listdir(self.lib_path + f"{repo}_repo/")):
if os.path.isdir(f"{self.lib_path}{repo}_repo/"):
for f in os.listdir(f"{self.lib_path}{repo}_repo/"):
files = f"{self.lib_path}{repo}_repo/{f}"
if os.path.isfile(files):
os.remove(files)
elif os.path.isdir(files):
shutil.rmtree(files)
Update().repository(only)
update = Update()
update.run(repos)
class Update:
def __init__(self):
self.initialization = globals()['Initialization'](False)
self.meta = _meta_
self.grey = _meta_.color["GREY"]
self.red = _meta_.color["RED"]
@ -741,21 +753,23 @@ class Update:
self.done = f"{self.grey}Done{self.endc}\n"
self.error = f"{self.red}Error{self.endc}\n"
def repository(self, only):
def run(self, repos):
"""Update repositories lists
"""
print("\nCheck and update repositories:\n")
default = self.meta.default_repositories
enabled = self.meta.repositories
if only:
enabled = only
# Replace the enabled repositories from user defined
if repos:
enabled = repos
for repo in enabled:
if check_for_local_repos(repo) is True:
continue
print(f"{self.grey}Check repository [{self.cyan}{repo}{self.grey}] ... {self.endc}", end="", flush=True)
if repo in default:
update = getattr(self.initialization, repo)
update()
getattr(Initialization(False), repo)()
print(self.done, end="")
elif repo in enabled:
Initialization(False).custom(repo)
@ -776,7 +790,6 @@ def check_exists_repositories(repo):
pkg_list = "PACKAGES.TXT"
return ""
if not os.path.isfile(f"{_meta_.lib_path}{repo}_repo/{pkg_list}"):
# .format(_meta_.lib_path, repo, "_repo/{0}".format(pkg_list))):
return repo
return ""
@ -788,4 +801,4 @@ def check_for_local_repos(repo):
if repo in repos_dict:
repo_url = repos_dict[repo]
if repo_url.startswith("file:///"):
return True
return True

View file

@ -34,15 +34,18 @@ from slpkg.pkg.find import find_package
def library(repo):
"""Load packages from slpkg library and from local
"""
utils = Utils()
pkg_list, packages = [], ""
if repo == "sbo":
if (os.path.isfile(
f"{_meta_.lib_path}{repo}_repo/SLACKBUILDS.TXT")):
packages = Utils().read_file(f"{_meta_.lib_path}{repo}_repo/SLACKBUILDS.TXT")
packages = utils.read_file(
f"{_meta_.lib_path}{repo}_repo/SLACKBUILDS.TXT")
else:
if (os.path.isfile(
f"{_meta_.lib_path}{repo}_repo/PACKAGES.TXT")):
packages = Utils().read_file(f"{_meta_.lib_path}{repo}_repo/PACKAGES.TXT")
packages = utils.read_file(
f"{_meta_.lib_path}{repo}_repo/PACKAGES.TXT")
for line in packages.splitlines():
if repo == "sbo":
if line.startswith("SLACKBUILD NAME: "):

View file

@ -34,13 +34,13 @@ def write_deps(deps_dict):
into directory `/var/log/slpkg/dep/`
"""
for name, dependencies in deps_dict.items():
if find_package(name + _meta_.sp, _meta_.pkg_path):
dep_path = _meta_.log_path + "dep/"
if find_package(f"{name}-", _meta_.pkg_path):
dep_path = f"{_meta_.log_path}dep/"
if not os.path.exists(dep_path):
os.mkdir(dep_path)
if os.path.isfile(dep_path + name):
os.remove(dep_path + name)
if os.path.isfile(f"{dep_path}{name}"):
os.remove(f"{dep_path}{name}")
if len(dependencies) >= 1:
with open(dep_path + name, "w") as f:
with open(f"{dep_path}{name}", "w") as f:
for dep in dependencies:
f.write(dep + "\n")
f.write(f"{dep}\n")

View file

@ -48,7 +48,7 @@ from slpkg.status_deps import DependenciesStatus
from slpkg.init import (
Update,
Initialization,
Upgrade,
check_exists_repositories
)
from slpkg.__metadata__ import MetaData as _meta_
@ -66,9 +66,10 @@ from slpkg.binary.check import pkg_upgrade
from slpkg.binary.install import BinaryInstall
class ArgParse:
class ArgParse(BlackList):
def __init__(self, args):
super().__init__()
self.args = args
self.meta = _meta_
self.msg = Msg()
@ -121,15 +122,32 @@ class ArgParse:
def command_update(self):
"""Update package lists repositories
"""
update = Update()
if len(self.args) == 1 and self.args[0] == "update":
Update().repository(only="")
update.run(repos="")
elif (len(self.args) == 2 and self.args[0] == "update" and
self.args[1].startswith("--repositories=")):
repos = self.args[1].split("=")[-1].split(",")
for rp in repos:
if rp not in self.meta.repositories:
repos.remove(rp)
Update().repository(repos)
update.run(repos)
else:
usage("")
def command_upgrade(self):
"""Recreate repositories package lists
"""
upgrade = Upgrade()
if len(self.args) == 1 and self.args[0] == "upgrade":
upgrade.run(repos="")
elif (len(self.args) == 2 and self.args[0] == "upgrade" and
self.args[1].startswith("--repositories=")):
repos = self.args[1].split("=")[-1].split(",")
for rp in repos:
if rp not in self.meta.repositories:
repos.remove(rp)
upgrade.run(repos)
else:
usage("")
@ -174,21 +192,6 @@ class ArgParse:
else:
usage("")
def command_upgrade(self):
"""Recreate repositories package lists
"""
if len(self.args) == 1 and self.args[0] == "upgrade":
Initialization(False).upgrade(only="")
elif (len(self.args) == 2 and self.args[0] == "upgrade" and
self.args[1].startswith("--repositories=")):
repos = self.args[1].split("=")[-1].split(",")
for rp in repos:
if rp not in self.meta.repositories:
repos.remove(rp)
Initialization(False).upgrade(repos)
else:
usage("")
def command_repo_info(self):
"""Repositories informations
"""
@ -317,7 +320,7 @@ class ArgParse:
BinaryInstall(pkg_upgrade("slack", skip, flag),
"slack", flag).start(is_upgrade=True)
else:
Patches(skip, flag).start()
Patches(skip, flags[0]).start()
elif self.args[1] == "sbo":
SBoInstall(sbo_upgrade(skip, flag), flag).start(
is_upgrade=True)
@ -460,7 +463,6 @@ class ArgParse:
def pkg_blacklist(self):
"""Manage blacklist packages
"""
blacklist = BlackList()
options = [
"-b",
"--blacklist"
@ -472,19 +474,19 @@ class ArgParse:
command = ["list"]
if (len(self.args) == 2 and self.args[0] in options and
self.args[1] == command[0]):
blacklist.listed()
self.black_listed()
elif (len(self.args) > 2 and self.args[0] in options and
flag[0] in self.args):
self.args.remove(flag[0])
blacklist.add(self.args[1:])
self.black_add(self.args[1:])
elif (len(self.args) == 2 and self.args[0] in options and
flag[1] in self.args):
self.args.remove(flag[1])
blacklist.remove(blacklist.get_black())
self.black_remove(list(self.get_black()))
elif (len(self.args) > 2 and self.args[0] in options and
flag[1] in self.args):
self.args.remove(flag[1])
blacklist.remove(self.args[1:])
self.black_remove(self.args[1:])
else:
usage("")

View file

@ -158,4 +158,4 @@ class Msg:
"""Message for matching packages
"""
print(f"\nNot found package with the name [ {self.cyan}{''.join(packages)}{self.endc} ]. "
f"Matching packages:\nNOTE: Not dependencies are resolved\n")
"Matching packages:\nNOTE: Not dependencies are resolved\n")

View file

@ -51,7 +51,7 @@ class NewConfig:
"""
self.find_new()
for n in self.news:
print(f"{n}")
print(n)
print()
self.msg.template(78)
print(f"| Installed {len(self.news)} new configuration files:")

View file

@ -32,7 +32,7 @@ def searching(find_pkg, directory):
"""
if os.path.isdir(directory):
installed = os.listdir(directory)
blacklist = BlackList().get_black()
blacklist = list(BlackList().get_black())
if os.path.exists(directory):
for pkg in installed:
if (not pkg.startswith(".") and pkg.startswith(find_pkg) and

View file

@ -34,7 +34,7 @@ def delete_package(path, packages):
"""
if _meta_.del_all in ["on", "ON"]:
for pkg in packages:
os.remove(path + pkg)
os.remove(f"{path}{pkg}")
def delete_folder(folder):

View file

@ -112,15 +112,15 @@ Keys: SPACE select or deselect the highlighted repositories,
if self.tag_line and line.startswith("#"):
repo = "".join(line.split("#")).strip()
if repo in self.selected:
new_conf.write(line.replace(line, repo + "\n"))
new_conf.write(line.replace(line, f"{repo}\n"))
continue
if (self.tag_line and not line.startswith("#") and
line != self.tag):
repo = line.strip()
if repo not in self.selected:
new_conf.write(line.replace(line, "# " + line + "\n"))
new_conf.write(line.replace(line, f"# {line}\n"))
continue
new_conf.write(line + "\n")
new_conf.write(f"{line}\n")
def clear_screen(self):
"""Clear screen

View file

@ -31,13 +31,14 @@ from slpkg.repolist import RepoList
from slpkg.__metadata__ import MetaData as _meta_
class RepoInfo:
class RepoInfo(Utils):
"""Repository information
"""
def __init__(self):
self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"]
self.endc = _meta_.color["ENDC"]
self.repo = Repo()
self.form = {
"Last updated:": "",
"Number of packages:": "",
@ -49,9 +50,9 @@ class RepoInfo:
"Total uncompressed packages:": ""
}
self.meta = _meta_
self.all_repos = Repo().default_repository()
self.all_repos["slack"] = Repo().slack()
self.all_repos.update(Repo().custom_repository())
self.all_repos = self.repo.default_repository()
self.all_repos["slack"] = self.repo.slack()
self.all_repos.update(self.repo.custom_repository())
del RepoList().all_repos
def view(self, repo):
@ -66,7 +67,7 @@ class RepoInfo:
self.form["Default:"] = "yes"
if (repo in self.meta.repositories and
os.path.isfile(self.meta.lib_path + f"{repo}_repo/PACKAGES.TXT")):
os.path.isfile(f"{self.meta.lib_path}{repo}_repo/PACKAGES.TXT")):
status = f"{self.green}enabled{self.endc}"
if repo != "sbo":
@ -81,19 +82,20 @@ class RepoInfo:
self.form["Number of packages:"] = data[0]
self.form["Status:"] = status
self.form["Last updated:"] = data[3]
elif (repo == "sbo" and os.path.isfile(
self.meta.lib_path + f"{repo}_repo/SLACKBUILDS.TXT")):
f"{self.meta.lib_path}{repo}_repo/SLACKBUILDS.TXT")):
status = f"{self.green}enabled{self.endc}"
sum_sbo_pkgs = 0
for line in (Utils().read_file(
self.meta.lib_path + "sbo_repo/SLACKBUILDS."
for line in (self.read_file(
f"{self.meta.lib_path}sbo_repo/SLACKBUILDS."
"TXT").splitlines()):
if line.startswith("SLACKBUILD NAME: "):
sum_sbo_pkgs += 1
changelog_txt = Utils().read_file(
self.meta.log_path + "sbo/ChangeLog.txt")
changelog_txt = self.read_file(
f"{self.meta.log_path}sbo/ChangeLog.txt")
last_upd = changelog_txt.split("\n", 1)[0]
self.form["Repo id:"] = repo
@ -108,13 +110,12 @@ class RepoInfo:
print(f"{self.green}{key}{self.endc} {value}")
def repository_data(self, repo):
"""
Grap data packages
"""Grap data packages
"""
sum_pkgs, size, unsize, last_upd = 0, [], [], ""
f = f"{self.meta.lib_path}{repo}_repo/PACKAGES.TXT"
for line in Utils().read_file(f).splitlines():
for line in self.read_file(f).splitlines():
if line.startswith("PACKAGES.TXT;"):
last_upd = line[14:].strip()
if line.startswith("PACKAGE NAME:"):
@ -125,8 +126,8 @@ class RepoInfo:
unsize.append(line[30:-2].strip())
if repo in ["salix", "slackl"]:
log = Utils().read_file(
self.meta.log_path + f"{repo}/ChangeLog.txt")
log = self.read_file(
f"{self.meta.log_path}{repo}/ChangeLog.txt")
last_upd = log.split("\n", 1)[0]
return [sum_pkgs, size, unsize, last_upd]

View file

@ -28,7 +28,7 @@ from slpkg.utils import Utils
from slpkg.__metadata__ import MetaData as _meta_
class Repo:
class Repo(Utils):
"""Manage repositories configuration files
"""
def __init__(self):
@ -36,9 +36,9 @@ class Repo:
self.DEFAULT_REPOS_NAMES = self.meta.default_repositories
self.custom_repo_file = "/etc/slpkg/custom-repositories"
self.default_repo_file = "/etc/slpkg/default-repositories"
self.custom_repositories_list = Utils().read_file(
self.custom_repositories_list = self.read_file(
self.custom_repo_file)
self.default_repositories_list = Utils().read_file(
self.default_repositories_list = self.read_file(
self.default_repo_file)
self.default_repository()
@ -47,27 +47,25 @@ class Repo:
"""
repo_name = []
if not url.endswith("/"):
url = url + "/"
url += "/"
for line in self.custom_repositories_list.splitlines():
line = line.lstrip()
if line and not line.startswith("#"):
repo_name.append(line.split()[0])
if (repo in self.meta.repositories or repo in repo_name or
repo in self.meta.default_repositories):
print("\nRepository name '{0}' exist, select different name.\n"
print(f"\nRepository name '{repo}' exist, select different name.\n"
"View all repositories with command 'slpkg "
"repo-list'.\n".format(repo))
raise SystemExit()
"repo-list'.\n")
raise SystemExit(1)
elif len(repo) > 6:
print("\nslpkg: Error: Maximum repository name length must be "
"six (6) characters\n")
raise SystemExit()
raise SystemExit(1)
with open(self.custom_repo_file, "a") as repos:
new_line = " {0}{1}{2}\n".format(repo, " " * (10 - len(repo)),
url)
new_line = f" {repo}{' ' * (10 - len(repo))}{url}\n"
repos.write(new_line)
print("\nRepository '{0}' successfully added\n".format(repo))
raise SystemExit()
print(f"\nRepository '{repo}' successfully added\n")
def remove(self, repo):
"""Remove custom repository
@ -77,14 +75,13 @@ class Repo:
for line in self.custom_repositories_list.splitlines():
repo_name = line.split()[0]
if repo_name != repo:
repos.write(line + "\n")
repos.write(f"{line}\n")
else:
print("\nRepository '{0}' successfully "
"removed\n".format(repo))
print(f"\nRepository '{repo}' successfully "
"removed\n")
rem_repo = True
if not rem_repo:
print("\nRepository '{0}' doesn't exist\n".format(repo))
raise SystemExit()
print(f"\nRepository '{repo}' doesn't exist\n")
def custom_repository(self):
"""Return dictionary with repo name and url (used external)
@ -106,11 +103,10 @@ class Repo:
if line.split()[0] in self.DEFAULT_REPOS_NAMES:
default_dict_repo[line.split()[0]] = line.split()[1]
else:
print("\nslpkg: Error: Repository name '{0}' is not "
"default.\n Please check file: "
"/etc/slpkg/default-repositories\n".format(
line.split()[0]))
raise SystemExit()
print(f"\nslpkg: Error: Repository name '{line.split()[0]}'"
" is not default.\n Please check file: "
"/etc/slpkg/default-repositories\n")
raise SystemExit(1)
return default_dict_repo
def slack(self):
@ -120,12 +116,12 @@ class Repo:
if self.meta.arch.startswith("arm"):
default = "http://ftp.arm.slackware.com/slackwarearm/"
if os.path.isfile("/etc/slpkg/slackware-mirrors"):
mirrors = Utils().read_file(
self.meta.conf_path + "slackware-mirrors")
mirrors = self.read_file(
f"{self.meta.conf_path}slackware-mirrors")
for line in mirrors.splitlines():
line = line.rstrip()
if not line.startswith("#") and line:
default = line.split()[-1]
if not default.endswith("/"):
default += "/"
return default
return default

View file

@ -41,7 +41,7 @@ def sbo_upgrade(skip, flag):
msg.checking()
upgrade_names = []
data = SBoGrep(name="").names()
blacklist = BlackList().get_black()
blacklist = list(BlackList().get_black())
for pkg in sbo_list():
name = split_package(pkg)[0]
ver = split_package(pkg)[1]

View file

@ -29,7 +29,6 @@ class SBoLink:
self.sbo_url = sbo_url
def tar_gz(self):
"""Return link slackbuild tar.gz archive
"""
Return link slackbuild tar.gz archive
"""
return (self.sbo_url[:-1] + ".tar.gz")
return f"{self.sbo_url[:-1]}.tar.gz"

View file

@ -30,14 +30,15 @@ from slpkg.__metadata__ import MetaData as _meta_
from slpkg.sbo.greps import SBoGrep
class Requires:
class Requires(BlackList):
"""Resolving SBo dependencies
"""
def __init__(self, flag):
super().__init__()
self.flag = flag
self.meta = _meta_
self.SLACKBUILDS_TXT = SBoGrep(name="").names()
self.blacklist = BlackList().get_black()
self.blacklist = list(self.get_black())
self.dep_results = []
def sbo(self, name):

View file

@ -48,11 +48,12 @@ from slpkg.sbo.slack_find import slack_package
from slpkg.slack.slack_version import slack_ver
class SBoNetwork:
class SBoNetwork(BlackList):
"""View SBo site in terminal and also read, build or
install packages
"""
def __init__(self, name, flag):
super().__init__()
self.name = name
self.flag = flag
self.meta = _meta_
@ -76,7 +77,6 @@ class SBoNetwork:
self.with_checklist()
grep = SBoGrep(self.name)
self.sbo_files = grep.files()
self.blacklist = BlackList().get_black()
self.sbo_url = sbo_search_pkg(self.name)
if self.sbo_url:
self.sbo_desc = grep.description()[len(self.name) + 2:-1]
@ -92,7 +92,7 @@ class SBoNetwork:
"""View SlackBuild package, read or install them
from slackbuilds.org
"""
if self.sbo_url and self.name not in self.blacklist:
if self.sbo_url and self.name not in self.get_black():
self.prgnam = f"{self.name}-{self.sbo_version}"
self.view_sbo()
while True:

View file

@ -30,9 +30,10 @@ from slpkg.slack.slack_version import slack_ver
def sbo_search_pkg(name):
"""Search for package path from SLACKBUILDS.TXT file and
"""Search for package path in SLACKBUILDS.TXT file and
return url
"""
url = ""
repo = Repo().default_repository()["sbo"]
sbo_url = f"{repo}{slack_ver()}/"
SLACKBUILDS_TXT = Utils().read_file(
@ -41,5 +42,5 @@ def sbo_search_pkg(name):
if line.startswith("SLACKBUILD LOCATION"):
sbo_name = (line[23:].split("/")[-1].replace("\n", "")).strip()
if name == sbo_name:
return (sbo_url + line[23:].strip() + "/")
return ""
url = f"{sbo_url}{line[23:].strip()}/"
return url

View file

@ -25,7 +25,6 @@
import os
from pkg_resources import parse_version
from slpkg.utils import Utils
from slpkg.messages import Msg
from slpkg.log_deps import write_deps
@ -48,10 +47,11 @@ from slpkg.sbo.search import sbo_search_pkg
from slpkg.sbo.slack_find import slack_package
class SBoInstall:
class SBoInstall(BlackList, Utils):
"""Build and install SBo packages with all dependencies
"""
def __init__(self, slackbuilds, flag):
super().__init__()
self.slackbuilds = slackbuilds
pkg_security(self.slackbuilds)
self.flag = flag
@ -80,7 +80,7 @@ class SBoInstall:
self.count_uni = 0
self.msg.reading()
self.data = SBoGrep(name="").names()
self.blacklist = BlackList().get_black()
self.blacklist = list(self.get_black())
def init_flags(self):
"""Flags initialization
@ -172,7 +172,7 @@ class SBoInstall:
lowercase
"""
if "--case-ins" in self.flag:
data_dict = Utils().case_sensitive(self.data)
data_dict = self.case_sensitive(self.data)
for name in self.slackbuilds:
index = self.slackbuilds.index(name)
for key, value in data_dict.items():
@ -182,10 +182,9 @@ class SBoInstall:
def update_deps(self):
"""Update dependencies dictionary with all package
"""
utils = Utils()
onelist, dependencies = [], []
onelist = utils.dimensional_list(self.deps)
dependencies = utils.remove_dbs(onelist)
onelist = self.dimensional_list(self.deps)
dependencies = self.remove_dbs(onelist)
for dep in dependencies:
deps = Requires(self.flag).sbo(dep)
self.deps_dict[dep] = self.one_for_all(deps)
@ -213,7 +212,7 @@ class SBoInstall:
"""Clear master slackbuilds if already exist in dependencies
or if added to install two or more times
"""
self.master_packages = Utils().remove_dbs(self.master_packages)
self.master_packages = self.remove_dbs(self.master_packages)
for mas in self.master_packages:
if mas in self.dependencies:
self.master_packages.remove(mas)
@ -246,8 +245,8 @@ class SBoInstall:
deps.reverse()
# Inverting the list brings the
# dependencies in order to be installed.
requires = Utils().dimensional_list(deps)
dependencies = Utils().remove_dbs(requires)
requires = self.dimensional_list(deps)
dependencies = self.remove_dbs(requires)
return dependencies
def top_view(self):
@ -270,7 +269,7 @@ class SBoInstall:
args[3] arch
"""
ver = GetFromInstalled(args[1]).version()
print(f" {args[0]}{args[1] + ver}{self.endc}"
print(f" {args[0]}{args[1] + ver} {self.endc}"
f"{' ' * (24-len(args[1] + ver))}{args[2]}"
f"{' ' * (18-len(args[2]))} {args[3]}"
f"{' ' * (15-len(args[3]))}{''}"

View file

@ -30,7 +30,7 @@ def pkg_security(pkgs):
"""Check packages before install or upgrade for security
reasons. Configuration file in the /etc/slpkg/pkg_security"""
security_packages = Utils().read_file("/etc/slpkg/pkg_security")
packages = []
packages, msg = [], Msg()
for read in security_packages.splitlines():
read = read.lstrip()
if not read.startswith("#"):
@ -38,6 +38,6 @@ def pkg_security(pkgs):
for p in pkgs:
for pkg in packages:
if p == pkg:
Msg().security_pkg(p)
if not Msg().answer() in ["y", "Y"]:
msg.security_pkg(p)
if not msg.answer() in ["y", "Y"]:
raise SystemExit()

View file

@ -29,9 +29,8 @@ from slpkg.slack.slack_version import slack_ver
def mirrors(name, location):
"""
Select Slackware official mirror packages
based architecture and version.
"""Select Slackware official mirror packages
based architecture and version.
"""
rel = _meta_.slack_rel
ver = slack_ver()

View file

@ -50,10 +50,11 @@ from slpkg.slack.mirrors import mirrors
from slpkg.slack.slack_version import slack_ver
class Patches:
class Patches(BlackList):
"""Upgrade distribution from official Slackware mirrors
"""
def __init__(self, skip, flag):
super().__init__()
self.skip = skip
self.flag = flag
self.meta = _meta_
@ -83,8 +84,7 @@ class Patches:
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "")).reading()
def start(self):
"""
Install new patches from official Slackware mirrors
"""Install new patches from official Slackware mirrors
"""
self.store()
self.msg.done()
@ -111,8 +111,8 @@ class Patches:
if self.msg.answer() in ["y", "Y"]:
Download(self.patch_path, self.dwn_links,
repo="slack").start()
self.upgrade_all = self.utils.check_downloaded(
self.patch_path, self.upgrade_all)
self.upgrade_all = list(self.utils.check_downloaded(
self.patch_path, self.upgrade_all))
self.upgrade()
self.kernel()
if self.meta.slackpkg_log in ["on", "ON"]:
@ -131,11 +131,10 @@ class Patches:
f" distribution is up to date!\n")
def store(self):
"""
Store and return packages for upgrading
"""Store and return packages for upgrading
"""
data = repo_data(self.PACKAGES_TXT, "slack", self.flag)
black = BlackList().get_black()
black = list(self.get_black())
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
@ -179,8 +178,7 @@ class Patches:
raise SystemExit()
def views(self):
"""
Views packages
"""Views packages
"""
for upg, size in sorted(zip(self.upgrade_all, self.comp_sum)):
pkg_repo = split_package(upg[:-4])
@ -196,8 +194,7 @@ class Patches:
f"{' ' * (7-len(pkg_repo[3]))}Slack{size:>12} K")
def upgrade(self):
"""
Upgrade packages
"""Upgrade packages
"""
for pkg in self.upgrade_all:
check_md5(pkg_checksum(pkg, "slack_patches"),
@ -216,8 +213,7 @@ class Patches:
self.installed.append(pkg_ver)
def kernel(self):
"""
Check if kernel upgraded if true
"""Check if kernel upgraded if true
then reinstall "lilo"
"""
for core in self.upgrade_all:
@ -253,13 +249,13 @@ class Patches:
from Slackware official mirrors after update distribution.
"""
NEW_ChangeLog_txt = URL(mirrors("ChangeLog.txt", "")).reading()
if os.path.isfile(self.meta.slackpkg_lib_path + "ChangeLog.txt.old"):
os.remove(self.meta.slackpkg_lib_path + "ChangeLog.txt.old")
if os.path.isfile(self.meta.slackpkg_lib_path + "ChangeLog.txt"):
shutil.copy2(self.meta.slackpkg_lib_path + "ChangeLog.txt",
self.meta.slackpkg_lib_path + "ChangeLog.txt.old")
os.remove(self.meta.slackpkg_lib_path + "ChangeLog.txt")
with open(self.meta.slackpkg_lib_path + "ChangeLog.txt", "w") as log:
if os.path.isfile(f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old"):
os.remove(f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old")
if os.path.isfile(f"{self.meta.slackpkg_lib_path}ChangeLog.txt"):
shutil.copy2(f"{self.meta.slackpkg_lib_path}ChangeLog.txt",
f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old")
os.remove(f"{self.meta.slackpkg_lib_path}ChangeLog.txt")
with open(f"{self.meta.slackpkg_lib_path}ChangeLog.txt", "w") as log:
log.write(NEW_ChangeLog_txt)
def update_lists(self):
@ -269,4 +265,4 @@ class Patches:
print(f"{self.green}Update the package lists ?{self.endc}")
print("=" * 79)
if self.msg.answer() in ["y", "Y"]:
Update().repository(["slack"])
Update().run(["slack"])

View file

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

View file

@ -62,7 +62,7 @@ def it_self_update():
answer = input("Would you like to upgrade [y/N]? ")
except EOFError:
print()
raise SystemExit()
raise SystemExit(1)
if answer in ["y", "Y"]:
print() # new line after answer
else:
@ -78,17 +78,16 @@ def it_self_update():
os.makedirs(_meta_.build_path)
Download(_meta_.build_path, dwn_link, repo="").start()
os.chdir(_meta_.build_path)
slpkg_tar_file = "slpkg" + "-" + __new_version__ + ".tar.gz"
slpkg_tar_file = f"slpkg-{__new_version__}.tar.gz"
tar = tarfile.open(slpkg_tar_file)
tar.extractall()
tar.close()
file_name = "{0}-{1}".format(_meta_.__all__, __new_version__)
file_name = f"{_meta_.__all__}-{__new_version__}"
os.chdir(file_name)
check_md5(pkg_checksum(slpkg_tar_file, _meta_.__all__),
_meta_.build_path + slpkg_tar_file)
subprocess.call("chmod +x {0}".format("install.sh"), shell=True)
subprocess.call("sh install.sh", shell=True)
else:
print("\n{0}: There is no new version, already used the last!"
"\n".format(_meta_.__all__))
raise SystemExit()
print(f"\n{_meta_.__all__}: There is no new version, already used the last!\n")
raise SystemExit()

View file

@ -40,6 +40,7 @@ class DependenciesStatus:
self.image = image
self.meta = _meta_
self.msg = Msg()
self.utils = Utils()
self.grey = self.meta.color["GREY"]
self.green = self.meta.color["GREEN"]
self.endc = self.meta.color["ENDC"]
@ -57,10 +58,10 @@ class DependenciesStatus:
dictionary database
"""
for pkg in self.installed:
if os.path.isfile(self.meta.pkg_path + pkg):
if os.path.isfile(f"{self.meta.pkg_path}{pkg}"):
name = split_package(pkg)[0]
for log in self.logs:
deps = Utils().read_file(self.dep_path + log)
deps = self.utils.read_file(f"{self.dep_path}{log}")
for dep in deps.splitlines():
if name == dep:
if name not in self.dmap.keys():
@ -86,7 +87,7 @@ class DependenciesStatus:
self.data()
print()
self.msg.template(78)
print("| {0}{1}{2}".format("Dependencies", " " * 20, "Packages"))
print(f"| Dependencies{' ' * 20}Packages")
self.msg.template(78)
for key, value in self.dmap.items():
print(" {0}{1}{2}{3}{4}".format(
@ -105,12 +106,12 @@ class DependenciesStatus:
self.msg.template(78)
self.data()
for pkg, dep in self.dmap.items():
print("+ {0}{1}{2}".format(self.green, pkg, self.endc))
print(f"+ {self.green}{pkg}{self.endc}")
print("|")
for d in dep:
print("+-- {0}".format(d))
print(f"+-- {d}")
print("|")
print("\x1b[1A{0}\n".format(" "), end="", flush=True)
print("\x1b[1A \n", end="", flush=True)
self.summary()
if self.image:
Graph(self.image).dependencies(self.dmap)

View file

@ -30,4 +30,4 @@ def s_user():
"""
if getpass.getuser() != "root":
print("\nslpkg: Error: Must have root privileges\n")
raise SystemExit()
raise SystemExit(1)

View file

@ -38,18 +38,20 @@ from slpkg.binary.search import search_pkg
from slpkg.binary.dependency import Dependencies
class TrackingDeps:
class TrackingDeps(BlackList):
"""View tree of dependencies and also
highlight packages with color green
if already installed and color red
if not installed.
"""
def __init__(self, name, repo, flag):
super().__init__()
self.name = name
self.repo = repo
self.flag = flag
self.meta = _meta_
self.msg = Msg()
self.utils = Utils()
self.green = self.meta.color["GREEN"]
self.yellow = self.meta.color["YELLOW"]
self.cyan = self.meta.color["CYAN"]
@ -59,6 +61,11 @@ class TrackingDeps:
self.dependencies = []
self.dependencies_list = []
self.deps_dict = {}
self.init_flags()
def init_flags(self):
"""Flags initialization
"""
for i in range(0, len(self.flag)):
if self.flag[i].startswith("--graph="):
self.image = self.flag[i].split("=")[1]
@ -71,8 +78,8 @@ class TrackingDeps:
self.repositories()
if self.find_pkg:
self.dependencies_list.reverse()
self.requires = Utils().dimensional_list(self.dependencies_list)
self.dependencies = Utils().remove_dbs(self.requires)
self.requires = self.utils.dimensional_list(self.dependencies_list)
self.dependencies = self.utils.remove_dbs(self.requires)
if self.dependencies == []:
self.dependencies = ["No dependencies"]
if "--graph=" in self.flag:
@ -123,13 +130,13 @@ class TrackingDeps:
if self.find_pkg:
self.dependencies_list = Requires(self.flag).sbo(self.name)
else:
PACKAGES_TXT = Utils().read_file(
self.meta.lib_path + f"{self.repo}_repo/PACKAGES.TXT")
self.names = list(Utils().package_name(PACKAGES_TXT))
PACKAGES_TXT = self.utils.read_file(
f"{self.meta.lib_path}{self.repo}_repo/PACKAGES.TXT")
self.names = list(self.utils.package_name(PACKAGES_TXT))
self.bin_case_insensitive()
self.find_pkg = search_pkg(self.name, self.repo)
if self.find_pkg:
self.black = BlackList().get_black()
self.black = list(self.get_black())
self.dependencies_list = Dependencies(
self.repo, self.black).binary(self.name, self.flag)
@ -139,7 +146,7 @@ class TrackingDeps:
"""
if "--case-ins" in self.flag:
data = SBoGrep(name="").names()
data_dict = Utils().case_sensitive(data)
data_dict = self.utils.case_sensitive(data)
for key, value in data_dict.items():
if key == self.name.lower():
self.name = value
@ -149,7 +156,7 @@ class TrackingDeps:
lowercase
"""
if "--case-ins" in self.flag:
data_dict = Utils().case_sensitive(self.names)
data_dict = self.utils.case_sensitive(self.names)
for key, value in data_dict.items():
if key == self.name.lower():
self.name = value
@ -163,10 +170,10 @@ class TrackingDeps:
"""Check if dependencies used
"""
used = []
dep_path = self.meta.log_path + "dep/"
dep_path = f"{self.meta.log_path}dep/"
logs = find_package("", dep_path)
for log in logs:
deps = Utils().read_file(dep_path + log)
deps = self.utils.read_file(f"{dep_path}{log}")
for dep in deps.splitlines():
if pkg == dep:
used.append(log)
@ -180,17 +187,17 @@ class TrackingDeps:
for dep in dependencies:
deps = Requires(flag="").sbo(dep)
if dep not in self.deps_dict.values():
self.deps_dict[dep] = Utils().dimensional_list(deps)
self.deps_dict[dep] = self.utils.dimensional_list(deps)
else:
for dep in dependencies:
deps = Dependencies(self.repo, self.black).binary(dep, flag="")
if dep not in self.deps_dict.values():
self.deps_dict[dep] = Utils().dimensional_list(deps)
self.deps_dict[dep] = self.utils.dimensional_list(deps)
def deps_used(self, pkg, used):
"""Create dependencies dictionary
"""
if find_package(pkg + self.meta.sp, self.meta.pkg_path):
if find_package(f"{pkg}-", self.meta.pkg_path):
if pkg not in self.deps_dict.values():
self.deps_dict[pkg] = used
else:

View file

@ -70,15 +70,13 @@ class Utils:
if line.startswith("PACKAGE NAME:"):
yield split_package(line[14:].strip())[0]
def check_downloaded(self, path, maybe_downloaded):
def check_downloaded(self, path, downloaded):
"""Check if files downloaded and return downloaded
packages
"""
downloaded = []
for pkg in maybe_downloaded:
if os.path.isfile(path + pkg):
downloaded.append(pkg)
return downloaded
for pkg in downloaded:
if os.path.isfile(f"{path}{pkg}"):
yield pkg
def read_config(self, config):
"""Read config file and returns first uncomment line
@ -103,7 +101,7 @@ class Utils:
"""Checking the file encoding default is utf-8
"""
try:
with open(path + f, "r") as ftest:
with open(f"{path}{f}", "r") as ftest:
ftest.read()
except UnicodeDecodeError:
return "ISO-8859-1"

View file

@ -22,20 +22,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.__metadata__ import MetaData as m
def prog_version():
"""Print version, license and email
"""
print("Version : {0}\n"
"Licence : {1}\n"
"Email : {2}\n"
"Homepage : {3}\n"
"Twitter : {4}\n"
"Maintainer: {5}".format(_meta_.__version__,
_meta_.__license__,
_meta_.__email__,
_meta_.__homepage__,
_meta_.__twitter__,
_meta_.__maintainer__))
print(f"Version : {m.__version__}\n"
f"Licence : {m.__license__}\n"
f"Email : {m.__email__}\n"
f"Homepage : {m.__homepage__}\n"
f"Twitter : {m.__twitter__}\n"
f"Maintainer: {m.__maintainer__}")

View file

@ -3,9 +3,9 @@ from slpkg.md5sum import md5
def test_md5_superuser():
result = md5('slpkg/superuser.py')
assert result == "25ec85aa9c2803ece6397e4147449ea6"
assert result == "c6a3576c247bda199c75b43540bfc3d7"
def test_md5_security():
result = md5('slpkg/security.py')
assert result == "3f10bf99b21f66af879dc0882bcd92b3"
assert result == "36c3a9213a27ab0b49e9c1bdd5bd2db6"

View file

@ -10,4 +10,4 @@ def test_dimensional_list():
def test_remove_dbs():
lists = [1, 2, 3, 3, 4, 5, 2, 1]
utils = Utils()
assert [1, 2, 3, 4, 5] == utils.remove_dbs(lists)
assert [1, 2, 3, 4, 5] == utils.remove_dbs(lists)