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 3.8.1 - 13/02/2020
Fixed: Fixed:
- Bugfix double install packages from slack regular repo - 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) $ slpkg -q build-install (build and install)
``` ```
Add or remove the packages in blacklist file manually from '`/etc/slpkg/blacklist`' or Add or remove packages in blacklist file manually from the '`/etc/slpkg/blacklist`' file or with the following options:
with the following options:
``` ```
$ slpkg -b live555 speex faac --add $ 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 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

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

View file

@ -76,7 +76,7 @@ class MetaData:
__all__ = "slpkg" __all__ = "slpkg"
__author__ = "dslackw" __author__ = "dslackw"
__version_info__ = (3, 8, 1) __version_info__ = (3, 8, 2)
__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"

View file

@ -38,7 +38,8 @@ from slpkg.binary.repo_init import RepoInit
def pkg_upgrade(repo, skip, flag): def pkg_upgrade(repo, skip, flag):
"""Checking packages for upgrade """Checking packages for upgrade
""" """
Msg().checking() msg = Msg()
msg.checking()
PACKAGES_TXT = RepoInit(repo).fetch()[0] PACKAGES_TXT = RepoInit(repo).fetch()[0]
pkgs_for_upgrade = [] pkgs_for_upgrade = []
# name = data[0] # name = data[0]
@ -57,7 +58,7 @@ def pkg_upgrade(repo, skip, flag):
inst_pkg[0] not in skip and inst_pkg[0] not in skip and
repo_pkg[1] != "blacklist"): repo_pkg[1] != "blacklist"):
pkgs_for_upgrade.append(repo_pkg[0]) pkgs_for_upgrade.append(repo_pkg[0])
Msg().done() msg.done()
if "--checklist" in flag: if "--checklist" in flag:
pkgs_for_upgrade = choose_upg(pkgs_for_upgrade) pkgs_for_upgrade = choose_upg(pkgs_for_upgrade)
return 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):"): if line.startswith("PACKAGE SIZE (uncompressed):"):
unsize.append(line[30:-2].strip()) unsize.append(line[30:-2].strip())
if repo == "slack": if repo == "slack" and "--upgrade" not in flag:
(rname, (rname,
rlocation, rlocation,
rsize, rsize,

View file

@ -47,11 +47,12 @@ from slpkg.binary.repo_init import RepoInit
from slpkg.binary.dependency import Dependencies from slpkg.binary.dependency import Dependencies
class BinaryInstall: class BinaryInstall(BlackList):
"""Install binaries packages with all dependencies from """Install binaries packages with all dependencies from
repository repository
""" """
def __init__(self, packages, repo, flag): def __init__(self, packages, repo, flag):
super().__init__()
self.packages = packages self.packages = packages
pkg_security(packages) pkg_security(packages)
self.repo = repo self.repo = repo
@ -63,6 +64,7 @@ class BinaryInstall:
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()
@ -79,7 +81,7 @@ class BinaryInstall:
self.repo_pkg_names = [] self.repo_pkg_names = []
for name in self.data[0]: for name in self.data[0]:
self.repo_pkg_names.append(split_package(name)[0]) self.repo_pkg_names.append(split_package(name)[0])
self.blacklist = BlackList().get_black() self.blacklist = list(self.get_black())
self.matching = False self.matching = False
def init_flags(self): def init_flags(self):
@ -159,10 +161,10 @@ class BinaryInstall:
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 = Utils().check_downloaded( self.dep_install = list(self.utils.check_downloaded(
self.tmp_path, self.dep_install) self.tmp_path, self.dep_install))
self.install = Utils().check_downloaded( self.install = list(self.utils.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)
write_deps(self.deps_dict) write_deps(self.deps_dict)
@ -188,8 +190,8 @@ class BinaryInstall:
lowercase lowercase
""" """
if "--case-ins" in self.flag: if "--case-ins" in self.flag:
data = list(Utils().package_name(self.PACKAGES_TXT)) data = list(self.utils.package_name(self.PACKAGES_TXT))
data_dict = Utils().case_sensitive(data) data_dict = self.utils.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():
@ -200,7 +202,7 @@ class BinaryInstall:
"""Update dependencies dictionary with all package """Update dependencies dictionary with all package
""" """
for dep in self.dependencies: for dep in self.dependencies:
deps = Utils().dimensional_list(Dependencies( deps = self.utils.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
@ -210,7 +212,7 @@ class BinaryInstall:
or if added to install two or more times or if added to install two or more times
""" """
packages = [] packages = []
for mas in Utils().remove_dbs(self.packages): for mas in self.utils.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
@ -264,11 +266,11 @@ class BinaryInstall:
self.msg.resolving() self.msg.resolving()
for dep in self.packages: for dep in self.packages:
dependencies = [] dependencies = []
dependencies = Utils().dimensional_list(Dependencies( dependencies = self.utils.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] = Utils().remove_dbs(requires) self.deps_dict[dep] = self.utils.remove_dbs(requires)
return Utils().remove_dbs(requires) return self.utils.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

View file

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

View file

@ -25,10 +25,11 @@
import os import os
from slpkg.utils import Utils from slpkg.utils import Utils
from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
class BlackList: class BlackList(Utils):
"""Blacklist class to add, remove or listed packages """Blacklist class to add, remove or listed packages
in blacklist file.""" in blacklist file."""
def __init__(self): def __init__(self):
@ -38,30 +39,43 @@ class BlackList:
self.blackfile = "/etc/slpkg/blacklist" self.blackfile = "/etc/slpkg/blacklist"
self.black_conf = "" self.black_conf = ""
if os.path.isfile(self.blackfile): 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): def get_black(self):
"""Return blacklist packages from /etc/slpkg/blacklist """Return blacklist packages from /etc/slpkg/blacklist
configuration file.""" 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(): for read in self.black_conf.splitlines():
read = read.lstrip() read = read.lstrip()
if not read.startswith("#"): if not read.startswith("#"):
blacklist.append(read.replace("\n", "")) yield read.replace("\n", "")
return blacklist
def listed(self): def black_listed(self):
"""Print blacklist packages """Print blacklist packages
""" """
print("Packages in the blacklist:\n") print("Packages in the blacklist:\n")
for black in self.get_black(): for black in list(self.black_filter()):
if black: if black:
print(f"{self.green}{black}{self.endc}") print(f"{self.green}{black}{self.endc}")
def add(self, pkgs): def black_add(self, pkgs):
"""Add blacklist packages if not exist """Add blacklist packages if not exist
""" """
blacklist = self.get_black() blacklist = list(self.black_filter())
pkgs = set(pkgs) pkgs = set(pkgs)
print("Add packages in the blacklist:\n") print("Add packages in the blacklist:\n")
with open(self.blackfile, "a") as black_conf: with open(self.blackfile, "a") as black_conf:
@ -70,7 +84,7 @@ class BlackList:
print(f"{self.green}{pkg}{self.endc}") print(f"{self.green}{pkg}{self.endc}")
black_conf.write(pkg + "\n") black_conf.write(pkg + "\n")
def remove(self, pkgs): def black_remove(self, pkgs):
"""Remove packages from blacklist """Remove packages from blacklist
""" """
print("Remove packages from the blacklist:\n") 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): def check_md5(pkg_md5, src_file):
"""MD5 Checksum """MD5 Checksum
""" """
msg = Msg()
red = _meta_.color["RED"] red = _meta_.color["RED"]
green = _meta_.color["GREEN"] green = _meta_.color["GREEN"]
endc = _meta_.color["ENDC"] endc = _meta_.color["ENDC"]
@ -37,19 +38,19 @@ def check_md5(pkg_md5, src_file):
print() print()
md5s = md5(src_file) md5s = md5(src_file)
if pkg_md5 != md5s: if pkg_md5 != md5s:
Msg().template(78) msg.template(78)
print(f"| MD5SUM check for {src_file.split('/')[-1]}" print(f"| MD5SUM check for {src_file.split('/')[-1]}"
f" [ {red}FAILED{endc} ]") f" [ {red}FAILED{endc} ]")
Msg().template(78) msg.template(78)
print(f"| Expected: {pkg_md5}") print(f"| Expected: {pkg_md5}")
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)
print(f"| MD5SUM check for {src_file.split('/')[-1]}" print(f"| MD5SUM check for {src_file.split('/')[-1]}"
f" [ {green}PASSED{endc} ]") f" [ {green}PASSED{endc} ]")
Msg().template(78) msg.template(78)
print() # new line after pass checksum print() # new line after pass checksum

View file

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

View file

@ -36,6 +36,7 @@ class Config:
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"]
@ -66,11 +67,10 @@ class Config:
"DOWNDER_OPTIONS", "DOWNDER_OPTIONS",
"SLACKPKG_LOG", "SLACKPKG_LOG",
"ONLY_INSTALLED", "ONLY_INSTALLED",
"PRG_BAR",
"EDITOR", "EDITOR",
"NOT_DOWNGRADE" "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(): 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

@ -38,6 +38,7 @@ 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"],
@ -57,10 +58,10 @@ class PkgDesc:
if self.repo == "sbo": if self.repo == "sbo":
description = SBoGrep(self.name).description() description = SBoGrep(self.name).description()
else: else:
PACKAGES_TXT = Utils().read_file(self.lib) PACKAGES_TXT = self.utils.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 += line[len(self.name) + 2:] + "\n" description += f"{line[len(self.name) + 2:]}\n"
count += 1 count += 1
if count == 11: if count == 11:
break break

View file

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

View file

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

View file

@ -73,7 +73,7 @@ class PackageHealth:
self.packages() self.packages()
self.cf = 0 self.cf = 0
for pkg in self.installed: 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 self.lf = 0
with open(self.pkg_path + pkg, "r") as fopen: with open(self.pkg_path + pkg, "r") as fopen:
for line in fopen: for line in fopen:

View file

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

View file

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

View file

@ -34,13 +34,13 @@ def write_deps(deps_dict):
into directory `/var/log/slpkg/dep/` into directory `/var/log/slpkg/dep/`
""" """
for name, dependencies in deps_dict.items(): for name, dependencies in deps_dict.items():
if find_package(name + _meta_.sp, _meta_.pkg_path): if find_package(f"{name}-", _meta_.pkg_path):
dep_path = _meta_.log_path + "dep/" dep_path = f"{_meta_.log_path}dep/"
if not os.path.exists(dep_path): if not os.path.exists(dep_path):
os.mkdir(dep_path) os.mkdir(dep_path)
if os.path.isfile(dep_path + name): if os.path.isfile(f"{dep_path}{name}"):
os.remove(dep_path + name) os.remove(f"{dep_path}{name}")
if len(dependencies) >= 1: 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: 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 ( from slpkg.init import (
Update, Update,
Initialization, Upgrade,
check_exists_repositories check_exists_repositories
) )
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
@ -66,9 +66,10 @@ from slpkg.binary.check import pkg_upgrade
from slpkg.binary.install import BinaryInstall from slpkg.binary.install import BinaryInstall
class ArgParse: class ArgParse(BlackList):
def __init__(self, args): def __init__(self, args):
super().__init__()
self.args = args self.args = args
self.meta = _meta_ self.meta = _meta_
self.msg = Msg() self.msg = Msg()
@ -121,15 +122,32 @@ class ArgParse:
def command_update(self): def command_update(self):
"""Update package lists repositories """Update package lists repositories
""" """
update = Update()
if len(self.args) == 1 and self.args[0] == "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 elif (len(self.args) == 2 and self.args[0] == "update" and
self.args[1].startswith("--repositories=")): self.args[1].startswith("--repositories=")):
repos = self.args[1].split("=")[-1].split(",") repos = self.args[1].split("=")[-1].split(",")
for rp in repos: for rp in repos:
if rp not in self.meta.repositories: if rp not in self.meta.repositories:
repos.remove(rp) 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: else:
usage("") usage("")
@ -174,21 +192,6 @@ class ArgParse:
else: else:
usage("") 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): def command_repo_info(self):
"""Repositories informations """Repositories informations
""" """
@ -317,7 +320,7 @@ class ArgParse:
BinaryInstall(pkg_upgrade("slack", skip, flag), BinaryInstall(pkg_upgrade("slack", skip, flag),
"slack", flag).start(is_upgrade=True) "slack", flag).start(is_upgrade=True)
else: else:
Patches(skip, flag).start() Patches(skip, flags[0]).start()
elif self.args[1] == "sbo": elif self.args[1] == "sbo":
SBoInstall(sbo_upgrade(skip, flag), flag).start( SBoInstall(sbo_upgrade(skip, flag), flag).start(
is_upgrade=True) is_upgrade=True)
@ -460,7 +463,6 @@ class ArgParse:
def pkg_blacklist(self): def pkg_blacklist(self):
"""Manage blacklist packages """Manage blacklist packages
""" """
blacklist = BlackList()
options = [ options = [
"-b", "-b",
"--blacklist" "--blacklist"
@ -472,19 +474,19 @@ class ArgParse:
command = ["list"] command = ["list"]
if (len(self.args) == 2 and self.args[0] in options and if (len(self.args) == 2 and self.args[0] in options and
self.args[1] == command[0]): self.args[1] == command[0]):
blacklist.listed() self.black_listed()
elif (len(self.args) > 2 and self.args[0] in options and elif (len(self.args) > 2 and self.args[0] in options and
flag[0] in self.args): flag[0] in self.args):
self.args.remove(flag[0]) 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 elif (len(self.args) == 2 and self.args[0] in options and
flag[1] in self.args): flag[1] in self.args):
self.args.remove(flag[1]) 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 elif (len(self.args) > 2 and self.args[0] in options and
flag[1] in self.args): flag[1] in self.args):
self.args.remove(flag[1]) self.args.remove(flag[1])
blacklist.remove(self.args[1:]) self.black_remove(self.args[1:])
else: else:
usage("") usage("")

View file

@ -158,4 +158,4 @@ class Msg:
"""Message for matching packages """Message for matching packages
""" """
print(f"\nNot found package with the name [ {self.cyan}{''.join(packages)}{self.endc} ]. " 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() self.find_new()
for n in self.news: for n in self.news:
print(f"{n}") print(n)
print() print()
self.msg.template(78) self.msg.template(78)
print(f"| Installed {len(self.news)} new configuration files:") 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): if os.path.isdir(directory):
installed = os.listdir(directory) installed = os.listdir(directory)
blacklist = BlackList().get_black() blacklist = list(BlackList().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

@ -34,7 +34,7 @@ def delete_package(path, packages):
""" """
if _meta_.del_all in ["on", "ON"]: if _meta_.del_all in ["on", "ON"]:
for pkg in packages: for pkg in packages:
os.remove(path + pkg) os.remove(f"{path}{pkg}")
def delete_folder(folder): 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("#"): if self.tag_line and line.startswith("#"):
repo = "".join(line.split("#")).strip() repo = "".join(line.split("#")).strip()
if repo in self.selected: if repo in self.selected:
new_conf.write(line.replace(line, repo + "\n")) new_conf.write(line.replace(line, f"{repo}\n"))
continue continue
if (self.tag_line and not line.startswith("#") and if (self.tag_line and not line.startswith("#") and
line != self.tag): line != self.tag):
repo = line.strip() repo = line.strip()
if repo not in self.selected: if repo not in self.selected:
new_conf.write(line.replace(line, "# " + line + "\n")) new_conf.write(line.replace(line, f"# {line}\n"))
continue continue
new_conf.write(line + "\n") new_conf.write(f"{line}\n")
def clear_screen(self): def clear_screen(self):
"""Clear screen """Clear screen

View file

@ -31,13 +31,14 @@ from slpkg.repolist import RepoList
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
class RepoInfo: class RepoInfo(Utils):
"""Repository information """Repository information
""" """
def __init__(self): def __init__(self):
self.green = _meta_.color["GREEN"] self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"] self.red = _meta_.color["RED"]
self.endc = _meta_.color["ENDC"] self.endc = _meta_.color["ENDC"]
self.repo = Repo()
self.form = { self.form = {
"Last updated:": "", "Last updated:": "",
"Number of packages:": "", "Number of packages:": "",
@ -49,9 +50,9 @@ class RepoInfo:
"Total uncompressed packages:": "" "Total uncompressed packages:": ""
} }
self.meta = _meta_ self.meta = _meta_
self.all_repos = Repo().default_repository() self.all_repos = self.repo.default_repository()
self.all_repos["slack"] = Repo().slack() self.all_repos["slack"] = self.repo.slack()
self.all_repos.update(Repo().custom_repository()) self.all_repos.update(self.repo.custom_repository())
del RepoList().all_repos del RepoList().all_repos
def view(self, repo): def view(self, repo):
@ -66,7 +67,7 @@ class RepoInfo:
self.form["Default:"] = "yes" self.form["Default:"] = "yes"
if (repo in self.meta.repositories and 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}" status = f"{self.green}enabled{self.endc}"
if repo != "sbo": if repo != "sbo":
@ -81,19 +82,20 @@ class RepoInfo:
self.form["Number of packages:"] = data[0] self.form["Number of packages:"] = data[0]
self.form["Status:"] = status self.form["Status:"] = status
self.form["Last updated:"] = data[3] self.form["Last updated:"] = data[3]
elif (repo == "sbo" and os.path.isfile( 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}" status = f"{self.green}enabled{self.endc}"
sum_sbo_pkgs = 0 sum_sbo_pkgs = 0
for line in (Utils().read_file( for line in (self.read_file(
self.meta.lib_path + "sbo_repo/SLACKBUILDS." f"{self.meta.lib_path}sbo_repo/SLACKBUILDS."
"TXT").splitlines()): "TXT").splitlines()):
if line.startswith("SLACKBUILD NAME: "): if line.startswith("SLACKBUILD NAME: "):
sum_sbo_pkgs += 1 sum_sbo_pkgs += 1
changelog_txt = Utils().read_file( changelog_txt = self.read_file(
self.meta.log_path + "sbo/ChangeLog.txt") f"{self.meta.log_path}sbo/ChangeLog.txt")
last_upd = changelog_txt.split("\n", 1)[0] last_upd = changelog_txt.split("\n", 1)[0]
self.form["Repo id:"] = repo self.form["Repo id:"] = repo
@ -108,13 +110,12 @@ class RepoInfo:
print(f"{self.green}{key}{self.endc} {value}") print(f"{self.green}{key}{self.endc} {value}")
def repository_data(self, repo): def repository_data(self, repo):
""" """Grap data packages
Grap data packages
""" """
sum_pkgs, size, unsize, last_upd = 0, [], [], "" sum_pkgs, size, unsize, last_upd = 0, [], [], ""
f = f"{self.meta.lib_path}{repo}_repo/PACKAGES.TXT" 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;"): if line.startswith("PACKAGES.TXT;"):
last_upd = line[14:].strip() last_upd = line[14:].strip()
if line.startswith("PACKAGE NAME:"): if line.startswith("PACKAGE NAME:"):
@ -125,8 +126,8 @@ class RepoInfo:
unsize.append(line[30:-2].strip()) unsize.append(line[30:-2].strip())
if repo in ["salix", "slackl"]: if repo in ["salix", "slackl"]:
log = Utils().read_file( log = self.read_file(
self.meta.log_path + f"{repo}/ChangeLog.txt") f"{self.meta.log_path}{repo}/ChangeLog.txt")
last_upd = log.split("\n", 1)[0] last_upd = log.split("\n", 1)[0]
return [sum_pkgs, size, unsize, last_upd] 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_ from slpkg.__metadata__ import MetaData as _meta_
class Repo: class Repo(Utils):
"""Manage repositories configuration files """Manage repositories configuration files
""" """
def __init__(self): def __init__(self):
@ -36,9 +36,9 @@ class Repo:
self.DEFAULT_REPOS_NAMES = self.meta.default_repositories self.DEFAULT_REPOS_NAMES = self.meta.default_repositories
self.custom_repo_file = "/etc/slpkg/custom-repositories" self.custom_repo_file = "/etc/slpkg/custom-repositories"
self.default_repo_file = "/etc/slpkg/default-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.custom_repo_file)
self.default_repositories_list = Utils().read_file( self.default_repositories_list = self.read_file(
self.default_repo_file) self.default_repo_file)
self.default_repository() self.default_repository()
@ -47,27 +47,25 @@ class Repo:
""" """
repo_name = [] repo_name = []
if not url.endswith("/"): if not url.endswith("/"):
url = url + "/" url += "/"
for line in self.custom_repositories_list.splitlines(): for line in self.custom_repositories_list.splitlines():
line = line.lstrip() line = line.lstrip()
if line and not line.startswith("#"): if line and not line.startswith("#"):
repo_name.append(line.split()[0]) repo_name.append(line.split()[0])
if (repo in self.meta.repositories or repo in repo_name or if (repo in self.meta.repositories or repo in repo_name or
repo in self.meta.default_repositories): 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 " "View all repositories with command 'slpkg "
"repo-list'.\n".format(repo)) "repo-list'.\n")
raise SystemExit() raise SystemExit(1)
elif len(repo) > 6: elif len(repo) > 6:
print("\nslpkg: Error: Maximum repository name length must be " print("\nslpkg: Error: Maximum repository name length must be "
"six (6) characters\n") "six (6) characters\n")
raise SystemExit() raise SystemExit(1)
with open(self.custom_repo_file, "a") as repos: with open(self.custom_repo_file, "a") as repos:
new_line = " {0}{1}{2}\n".format(repo, " " * (10 - len(repo)), new_line = f" {repo}{' ' * (10 - len(repo))}{url}\n"
url)
repos.write(new_line) repos.write(new_line)
print("\nRepository '{0}' successfully added\n".format(repo)) print(f"\nRepository '{repo}' successfully added\n")
raise SystemExit()
def remove(self, repo): def remove(self, repo):
"""Remove custom repository """Remove custom repository
@ -77,14 +75,13 @@ class Repo:
for line in self.custom_repositories_list.splitlines(): for line in self.custom_repositories_list.splitlines():
repo_name = line.split()[0] repo_name = line.split()[0]
if repo_name != repo: if repo_name != repo:
repos.write(line + "\n") repos.write(f"{line}\n")
else: else:
print("\nRepository '{0}' successfully " print(f"\nRepository '{repo}' successfully "
"removed\n".format(repo)) "removed\n")
rem_repo = True rem_repo = True
if not rem_repo: if not rem_repo:
print("\nRepository '{0}' doesn't exist\n".format(repo)) print(f"\nRepository '{repo}' doesn't exist\n")
raise SystemExit()
def custom_repository(self): def custom_repository(self):
"""Return dictionary with repo name and url (used external) """Return dictionary with repo name and url (used external)
@ -106,11 +103,10 @@ class Repo:
if line.split()[0] in self.DEFAULT_REPOS_NAMES: if line.split()[0] in self.DEFAULT_REPOS_NAMES:
default_dict_repo[line.split()[0]] = line.split()[1] default_dict_repo[line.split()[0]] = line.split()[1]
else: else:
print("\nslpkg: Error: Repository name '{0}' is not " print(f"\nslpkg: Error: Repository name '{line.split()[0]}'"
"default.\n Please check file: " " is not default.\n Please check file: "
"/etc/slpkg/default-repositories\n".format( "/etc/slpkg/default-repositories\n")
line.split()[0])) raise SystemExit(1)
raise SystemExit()
return default_dict_repo return default_dict_repo
def slack(self): def slack(self):
@ -120,8 +116,8 @@ class Repo:
if self.meta.arch.startswith("arm"): if self.meta.arch.startswith("arm"):
default = "http://ftp.arm.slackware.com/slackwarearm/" default = "http://ftp.arm.slackware.com/slackwarearm/"
if os.path.isfile("/etc/slpkg/slackware-mirrors"): if os.path.isfile("/etc/slpkg/slackware-mirrors"):
mirrors = Utils().read_file( mirrors = self.read_file(
self.meta.conf_path + "slackware-mirrors") f"{self.meta.conf_path}slackware-mirrors")
for line in mirrors.splitlines(): for line in mirrors.splitlines():
line = line.rstrip() line = line.rstrip()
if not line.startswith("#") and line: if not line.startswith("#") and line:

View file

@ -41,7 +41,7 @@ def sbo_upgrade(skip, flag):
msg.checking() msg.checking()
upgrade_names = [] upgrade_names = []
data = SBoGrep(name="").names() data = SBoGrep(name="").names()
blacklist = BlackList().get_black() blacklist = list(BlackList().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

@ -29,7 +29,6 @@ class SBoLink:
self.sbo_url = sbo_url self.sbo_url = sbo_url
def tar_gz(self): def tar_gz(self):
"""Return link slackbuild tar.gz archive
""" """
Return link slackbuild tar.gz archive return f"{self.sbo_url[:-1]}.tar.gz"
"""
return (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 from slpkg.sbo.greps import SBoGrep
class Requires: class Requires(BlackList):
"""Resolving SBo dependencies """Resolving SBo dependencies
""" """
def __init__(self, flag): def __init__(self, flag):
super().__init__()
self.flag = flag self.flag = flag
self.meta = _meta_ self.meta = _meta_
self.SLACKBUILDS_TXT = SBoGrep(name="").names() self.SLACKBUILDS_TXT = SBoGrep(name="").names()
self.blacklist = BlackList().get_black() self.blacklist = list(self.get_black())
self.dep_results = [] self.dep_results = []
def sbo(self, name): 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 from slpkg.slack.slack_version import slack_ver
class SBoNetwork: class SBoNetwork(BlackList):
"""View SBo site in terminal and also read, build or """View SBo site in terminal and also read, build or
install packages install packages
""" """
def __init__(self, name, flag): def __init__(self, name, flag):
super().__init__()
self.name = name self.name = name
self.flag = flag self.flag = flag
self.meta = _meta_ self.meta = _meta_
@ -76,7 +77,6 @@ class SBoNetwork:
self.with_checklist() self.with_checklist()
grep = SBoGrep(self.name) grep = SBoGrep(self.name)
self.sbo_files = grep.files() self.sbo_files = grep.files()
self.blacklist = BlackList().get_black()
self.sbo_url = sbo_search_pkg(self.name) self.sbo_url = sbo_search_pkg(self.name)
if self.sbo_url: if self.sbo_url:
self.sbo_desc = grep.description()[len(self.name) + 2:-1] self.sbo_desc = grep.description()[len(self.name) + 2:-1]
@ -92,7 +92,7 @@ class SBoNetwork:
"""View SlackBuild package, read or install them """View SlackBuild package, read or install them
from slackbuilds.org 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.prgnam = f"{self.name}-{self.sbo_version}"
self.view_sbo() self.view_sbo()
while True: while True:

View file

@ -30,9 +30,10 @@ from slpkg.slack.slack_version import slack_ver
def sbo_search_pkg(name): 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 return url
""" """
url = ""
repo = Repo().default_repository()["sbo"] repo = Repo().default_repository()["sbo"]
sbo_url = f"{repo}{slack_ver()}/" sbo_url = f"{repo}{slack_ver()}/"
SLACKBUILDS_TXT = Utils().read_file( SLACKBUILDS_TXT = Utils().read_file(
@ -41,5 +42,5 @@ def sbo_search_pkg(name):
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()
if name == sbo_name: if name == sbo_name:
return (sbo_url + line[23:].strip() + "/") url = f"{sbo_url}{line[23:].strip()}/"
return "" return url

View file

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

View file

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

View file

@ -50,10 +50,11 @@ from slpkg.slack.mirrors import mirrors
from slpkg.slack.slack_version import slack_ver from slpkg.slack.slack_version import slack_ver
class Patches: class Patches(BlackList):
"""Upgrade distribution from official Slackware mirrors """Upgrade distribution from official Slackware mirrors
""" """
def __init__(self, skip, flag): def __init__(self, skip, flag):
super().__init__()
self.skip = skip self.skip = skip
self.flag = flag self.flag = flag
self.meta = _meta_ self.meta = _meta_
@ -83,8 +84,7 @@ class Patches:
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "")).reading() self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "")).reading()
def start(self): def start(self):
""" """Install new patches from official Slackware mirrors
Install new patches from official Slackware mirrors
""" """
self.store() self.store()
self.msg.done() self.msg.done()
@ -111,8 +111,8 @@ class Patches:
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 = self.utils.check_downloaded( self.upgrade_all = list(self.utils.check_downloaded(
self.patch_path, self.upgrade_all) self.patch_path, self.upgrade_all))
self.upgrade() self.upgrade()
self.kernel() self.kernel()
if self.meta.slackpkg_log in ["on", "ON"]: if self.meta.slackpkg_log in ["on", "ON"]:
@ -131,11 +131,10 @@ class Patches:
f" distribution is up to date!\n") f" distribution is up to date!\n")
def store(self): def store(self):
""" """Store and return packages for upgrading
Store and return packages for upgrading
""" """
data = repo_data(self.PACKAGES_TXT, "slack", self.flag) 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]): for name, loc, comp, uncomp in zip(data[0], data[1], data[2], data[3]):
repo_pkg_name = split_package(name)[0] repo_pkg_name = split_package(name)[0]
if (not os.path.isfile(self.meta.pkg_path + name[:-4]) and if (not os.path.isfile(self.meta.pkg_path + name[:-4]) and
@ -179,8 +178,7 @@ class Patches:
raise SystemExit() raise SystemExit()
def views(self): def views(self):
""" """Views packages
Views packages
""" """
for upg, size in sorted(zip(self.upgrade_all, self.comp_sum)): for upg, size in sorted(zip(self.upgrade_all, self.comp_sum)):
pkg_repo = split_package(upg[:-4]) pkg_repo = split_package(upg[:-4])
@ -196,8 +194,7 @@ class Patches:
f"{' ' * (7-len(pkg_repo[3]))}Slack{size:>12} K") f"{' ' * (7-len(pkg_repo[3]))}Slack{size:>12} K")
def upgrade(self): def upgrade(self):
""" """Upgrade packages
Upgrade packages
""" """
for pkg in self.upgrade_all: for pkg in self.upgrade_all:
check_md5(pkg_checksum(pkg, "slack_patches"), check_md5(pkg_checksum(pkg, "slack_patches"),
@ -216,8 +213,7 @@ class Patches:
self.installed.append(pkg_ver) self.installed.append(pkg_ver)
def kernel(self): def kernel(self):
""" """Check if kernel upgraded if true
Check if kernel upgraded if true
then reinstall "lilo" then reinstall "lilo"
""" """
for core in self.upgrade_all: for core in self.upgrade_all:
@ -253,13 +249,13 @@ class Patches:
from Slackware official mirrors after update distribution. from Slackware official mirrors after update distribution.
""" """
NEW_ChangeLog_txt = URL(mirrors("ChangeLog.txt", "")).reading() NEW_ChangeLog_txt = URL(mirrors("ChangeLog.txt", "")).reading()
if os.path.isfile(self.meta.slackpkg_lib_path + "ChangeLog.txt.old"): if os.path.isfile(f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old"):
os.remove(self.meta.slackpkg_lib_path + "ChangeLog.txt.old") os.remove(f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old")
if os.path.isfile(self.meta.slackpkg_lib_path + "ChangeLog.txt"): if os.path.isfile(f"{self.meta.slackpkg_lib_path}ChangeLog.txt"):
shutil.copy2(self.meta.slackpkg_lib_path + "ChangeLog.txt", shutil.copy2(f"{self.meta.slackpkg_lib_path}ChangeLog.txt",
self.meta.slackpkg_lib_path + "ChangeLog.txt.old") f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old")
os.remove(self.meta.slackpkg_lib_path + "ChangeLog.txt") os.remove(f"{self.meta.slackpkg_lib_path}ChangeLog.txt")
with open(self.meta.slackpkg_lib_path + "ChangeLog.txt", "w") as log: with open(f"{self.meta.slackpkg_lib_path}ChangeLog.txt", "w") as log:
log.write(NEW_ChangeLog_txt) log.write(NEW_ChangeLog_txt)
def update_lists(self): def update_lists(self):
@ -269,4 +265,4 @@ class Patches:
print(f"{self.green}Update the package lists ?{self.endc}") print(f"{self.green}Update the package lists ?{self.endc}")
print("=" * 79) print("=" * 79)
if self.msg.answer() in ["y", "Y"]: 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(): def slackware_repository():
"""Return all official Slackware packages """Return all official Slackware packages
""" """
slack_repo, packages, names, name = [], [], [], "" 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]:
name = split_package(pkg)[0] names.append(split_package(pkg)[0])
names.append(name)
packages.append(pkg[:-4]) 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]? ") answer = input("Would you like to upgrade [y/N]? ")
except EOFError: except EOFError:
print() print()
raise SystemExit() 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:
@ -78,17 +78,16 @@ def it_self_update():
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 = "slpkg" + "-" + __new_version__ + ".tar.gz" slpkg_tar_file = f"slpkg-{__new_version__}.tar.gz"
tar = tarfile.open(slpkg_tar_file) tar = tarfile.open(slpkg_tar_file)
tar.extractall() tar.extractall()
tar.close() tar.close()
file_name = "{0}-{1}".format(_meta_.__all__, __new_version__) file_name = f"{_meta_.__all__}-{__new_version__}"
os.chdir(file_name) os.chdir(file_name)
check_md5(pkg_checksum(slpkg_tar_file, _meta_.__all__), check_md5(pkg_checksum(slpkg_tar_file, _meta_.__all__),
_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("\n{0}: There is no new version, already used the last!" print(f"\n{_meta_.__all__}: There is no new version, already used the last!\n")
"\n".format(_meta_.__all__))
raise SystemExit() raise SystemExit()

View file

@ -40,6 +40,7 @@ class DependenciesStatus:
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"]
@ -57,10 +58,10 @@ class DependenciesStatus:
dictionary database dictionary database
""" """
for pkg in self.installed: 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] name = split_package(pkg)[0]
for log in self.logs: 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(): 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():
@ -86,7 +87,7 @@ class DependenciesStatus:
self.data() self.data()
print() print()
self.msg.template(78) self.msg.template(78)
print("| {0}{1}{2}".format("Dependencies", " " * 20, "Packages")) print(f"| Dependencies{' ' * 20}Packages")
self.msg.template(78) self.msg.template(78)
for key, value in self.dmap.items(): for key, value in self.dmap.items():
print(" {0}{1}{2}{3}{4}".format( print(" {0}{1}{2}{3}{4}".format(
@ -105,12 +106,12 @@ class DependenciesStatus:
self.msg.template(78) self.msg.template(78)
self.data() self.data()
for pkg, dep in self.dmap.items(): 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("|") print("|")
for d in dep: for d in dep:
print("+-- {0}".format(d)) print(f"+-- {d}")
print("|") print("|")
print("\x1b[1A{0}\n".format(" "), end="", flush=True) print("\x1b[1A \n", end="", flush=True)
self.summary() self.summary()
if self.image: if self.image:
Graph(self.image).dependencies(self.dmap) Graph(self.image).dependencies(self.dmap)

View file

@ -30,4 +30,4 @@ def s_user():
""" """
if getpass.getuser() != "root": if getpass.getuser() != "root":
print("\nslpkg: Error: Must have root privileges\n") 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 from slpkg.binary.dependency import Dependencies
class TrackingDeps: class TrackingDeps(BlackList):
"""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
if not installed. if not installed.
""" """
def __init__(self, name, repo, flag): def __init__(self, name, repo, flag):
super().__init__()
self.name = name self.name = name
self.repo = repo self.repo = repo
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"]
@ -59,6 +61,11 @@ class TrackingDeps:
self.dependencies = [] self.dependencies = []
self.dependencies_list = [] self.dependencies_list = []
self.deps_dict = {} self.deps_dict = {}
self.init_flags()
def init_flags(self):
"""Flags initialization
"""
for i in range(0, len(self.flag)): for i in range(0, len(self.flag)):
if self.flag[i].startswith("--graph="): if self.flag[i].startswith("--graph="):
self.image = self.flag[i].split("=")[1] self.image = self.flag[i].split("=")[1]
@ -71,8 +78,8 @@ class TrackingDeps:
self.repositories() self.repositories()
if self.find_pkg: if self.find_pkg:
self.dependencies_list.reverse() self.dependencies_list.reverse()
self.requires = Utils().dimensional_list(self.dependencies_list) self.requires = self.utils.dimensional_list(self.dependencies_list)
self.dependencies = Utils().remove_dbs(self.requires) self.dependencies = self.utils.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:
@ -123,13 +130,13 @@ class TrackingDeps:
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 = Utils().read_file( PACKAGES_TXT = self.utils.read_file(
self.meta.lib_path + f"{self.repo}_repo/PACKAGES.TXT") f"{self.meta.lib_path}{self.repo}_repo/PACKAGES.TXT")
self.names = list(Utils().package_name(PACKAGES_TXT)) self.names = list(self.utils.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:
self.black = BlackList().get_black() self.black = list(self.get_black())
self.dependencies_list = Dependencies( self.dependencies_list = Dependencies(
self.repo, self.black).binary(self.name, self.flag) self.repo, self.black).binary(self.name, self.flag)
@ -139,7 +146,7 @@ class TrackingDeps:
""" """
if "--case-ins" in self.flag: if "--case-ins" in self.flag:
data = SBoGrep(name="").names() data = SBoGrep(name="").names()
data_dict = Utils().case_sensitive(data) data_dict = self.utils.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
@ -149,7 +156,7 @@ class TrackingDeps:
lowercase lowercase
""" """
if "--case-ins" in self.flag: 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(): for key, value in data_dict.items():
if key == self.name.lower(): if key == self.name.lower():
self.name = value self.name = value
@ -163,10 +170,10 @@ class TrackingDeps:
"""Check if dependencies used """Check if dependencies used
""" """
used = [] used = []
dep_path = 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 = Utils().read_file(dep_path + log) deps = self.utils.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)
@ -180,17 +187,17 @@ class TrackingDeps:
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] = Utils().dimensional_list(deps) self.deps_dict[dep] = self.utils.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] = Utils().dimensional_list(deps) self.deps_dict[dep] = self.utils.dimensional_list(deps)
def deps_used(self, pkg, used): def deps_used(self, pkg, used):
"""Create dependencies dictionary """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(): if pkg not in self.deps_dict.values():
self.deps_dict[pkg] = used self.deps_dict[pkg] = used
else: else:

View file

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

View file

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

View file

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