Merge branch 'develop'

This commit is contained in:
Dimitris Zlatanidis 2022-05-12 17:34:33 +03:00
commit 640ca044fc
56 changed files with 586 additions and 451 deletions

1
.gitignore vendored
View file

@ -4,6 +4,7 @@
*.pyc *.pyc
__pycache__ __pycache__
.pipy .pipy
.idea
*.egg-info/ *.egg-info/
/slpkg_Build /slpkg_Build
.ropeproject/ .ropeproject/

View file

@ -1,4 +1,14 @@
3.9.5 - 02/04/2022 3.9.7 - 09/05/2022
Fixed:
- Stderr error output
Updated:
- Improve dependencies resolve speed
- Renamed --repositories to --repos flag
Bugfix:
- Update custom repositories
- Passing repositories manual
3.9.6 - 02/04/2022
Updated: Updated:
- Compared packages version when distribution upgrade - Compared packages version when distribution upgrade

View file

@ -1,4 +1,4 @@
# slpkg 3.9.6 # slpkg 3.9.7
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

@ -11,7 +11,7 @@
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details. .\" GNU General Public License for more details.
.\" .\"
.TH Slpkg "14" "01" 2019" "slpkg" .TH Slpkg "11" "05" 2022" "slpkg"
.SH NAME .SH NAME
Slpkg is a user-friendly package manager for Slackware installations Slpkg is a user-friendly package manager for Slackware installations
.SH SYNOPSIS .SH SYNOPSIS
@ -34,24 +34,24 @@ Print the version of program and exit.
The following commands are available. The following commands are available.
.SS update, create and update packages list .SS update, create and update packages list
\fBslpkg\fP \fBupdate\fP, \fB--repositories=[repositories...]\fP \fBslpkg\fP \fBupdate\fP, \fB--repos=[repositories...]\fP
.PP .PP
Used to re-synchronize the package lists and create some important files. Used to re-synchronize the package lists and create some important files.
This command must run every new repository is added or new updates is available. This command must run every new repository is added or new updates is available.
.PP .PP
Additional options: Additional options:
.PP .PP
\fB--repositories=[repositories...]\fP : Update at specifically repositories separate by comma. \fB--repos=[repositories...]\fP : Update at specifically repositories separate by comma.
.SS upgrade, recreate packages list .SS upgrade, recreate packages list
\fBslpkg\fP \fBupgrade\fP, \fB--repositories=[repositories...]\fP \fBslpkg\fP \fBupgrade\fP, \fB--repos=[repositories...]\fP
.PP .PP
It is sometimes useful to create all of the base file from the beginning so this It is sometimes useful to create all of the base file from the beginning so this
command delete all the package lists and recreated. command delete all the package lists and recreated.
.PP .PP
Additional options: Additional options:
.PP .PP
\fB--repositories=[repositories...]\fP : Update at specifically repositories separate by comma. \fB--repos=[repositories...]\fP : Update at specifically repositories separate by comma.
.SS repo-add, add custom repository .SS repo-add, add custom repository
\fBslpkg\fP \fBrepo-add\fP <\fIrepository name\fP> <\fIURL\fP> \fBslpkg\fP \fBrepo-add\fP <\fIrepository name\fP> <\fIURL\fP>
@ -404,7 +404,7 @@ Dimitris Zlatanidis <d.zlatanidis@gmail.com>
.SH HOMEPAGE .SH HOMEPAGE
https://dslackw.gitlab.io/slpkg/ https://dslackw.gitlab.io/slpkg/
.SH COPYRIGHT .SH COPYRIGHT
Copyright \(co 2014-2019 Dimitris Zlatanidis Copyright \(co 2014-2022 Dimitris Zlatanidis
.SH SEE ALSO .SH SEE ALSO
installpkg(8), upgradepkg(8), removepkg(8), pkgtool(8), slackpkg(8), explodepkg(8), installpkg(8), upgradepkg(8), removepkg(8), pkgtool(8), slackpkg(8), explodepkg(8),

View file

@ -1,5 +1,5 @@
<!-- Creator : groff version 1.22.3 --> <!-- Creator : groff version 1.22.3 -->
<!-- CreationDate: Sat Dec 28 15:39:55 2019 --> <!-- CreationDate: Wed May 11 22:58:05 2022 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"> "http://www.w3.org/TR/html4/loose.dtd">
<html> <html>
@ -93,7 +93,7 @@ commands are available.</p>
<p style="margin-left:11%; margin-top: 1em"><b>update, <p style="margin-left:11%; margin-top: 1em"><b>update,
create and update packages list <br> create and update packages list <br>
slpkg update</b>, slpkg update</b>,
<b>--repositories=[repositories...]</b></p> <b>--repos=[repositories...]</b></p>
<p style="margin-left:11%; margin-top: 1em">Used to <p style="margin-left:11%; margin-top: 1em">Used to
re-synchronize the package lists and create some important re-synchronize the package lists and create some important
@ -104,13 +104,13 @@ or new updates is available.</p>
options:</p> options:</p>
<p style="margin-left:11%; margin-top: 1em"><b>--repositories=[repositories...]</b> <p style="margin-left:11%; margin-top: 1em"><b>--repos=[repositories...]</b>
: Update at specifically repositories separate by comma.</p> : Update at specifically repositories separate by comma.</p>
<p style="margin-left:11%; margin-top: 1em"><b>upgrade, <p style="margin-left:11%; margin-top: 1em"><b>upgrade,
recreate packages list <br> recreate packages list <br>
slpkg upgrade</b>, slpkg upgrade</b>,
<b>--repositories=[repositories...]</b></p> <b>--repos=[repositories...]</b></p>
<p style="margin-left:11%; margin-top: 1em">It is sometimes <p style="margin-left:11%; margin-top: 1em">It is sometimes
useful to create all of the base file from the beginning so useful to create all of the base file from the beginning so
@ -120,7 +120,7 @@ this command delete all the package lists and recreated.</p>
options:</p> options:</p>
<p style="margin-left:11%; margin-top: 1em"><b>--repositories=[repositories...]</b> <p style="margin-left:11%; margin-top: 1em"><b>--repos=[repositories...]</b>
: Update at specifically repositories separate by comma.</p> : Update at specifically repositories separate by comma.</p>
<p style="margin-left:11%; margin-top: 1em"><b>repo-add, <p style="margin-left:11%; margin-top: 1em"><b>repo-add,
@ -728,7 +728,7 @@ Zlatanidis &lt;d.zlatanidis@gmail.com&gt;</p>
<p style="margin-left:11%; margin-top: 1em">Copyright <p style="margin-left:11%; margin-top: 1em">Copyright
&copy; 2014-2019 Dimitris Zlatanidis</p> &copy; 2014-2022 Dimitris Zlatanidis</p>
<h2>SEE ALSO <h2>SEE ALSO
<a name="SEE ALSO"></a> <a name="SEE ALSO"></a>

View file

@ -1,4 +0,0 @@
[pytest]
python_files = test_*
python_classes = *Tests
python_functions = test_*

View file

@ -11,4 +11,3 @@
# perl 5 language and graph-easy >= 0.75 (drawing dependencies ascii diagram) # perl 5 language and graph-easy >= 0.75 (drawing dependencies ascii diagram)
# python3-pythondialog >= 3.5.0 (Python interface to the UNIX dialog utility) # python3-pythondialog >= 3.5.0 (Python interface to the UNIX dialog utility)
# flake8 >= 3.5.0 # flake8 >= 3.5.0
# pytest >= 5.3.2

View file

@ -32,9 +32,7 @@ except ImportError:
from distutils.core import setup from distutils.core import setup
docs_requires = [] docs_requires = []
tests_requires = [ tests_requires = []
"pytest>=5.3.2"
]
install_requires = [] install_requires = []
optional_requires = [ optional_requires = [
"pythondialog>=3.5.1", "pythondialog>=3.5.1",

View file

@ -25,6 +25,11 @@
import os import os
# Slackware distribution branches
STABLE = "stable"
CURRENT = "current"
def remove_repositories(repositories, default_repositories): def remove_repositories(repositories, default_repositories):
""" """
Remove no default repositories Remove no default repositories
@ -67,7 +72,7 @@ def select_slack_release(slack_rel):
Warning message if Slackware release not defined or Warning message if Slackware release not defined or
defined wrong defined wrong
""" """
if slack_rel not in ["stable", "current"]: if slack_rel not in [STABLE, CURRENT]:
return "FAULT" return "FAULT"
return slack_rel return slack_rel
@ -76,7 +81,7 @@ class MetaData:
__all__ = "slpkg" __all__ = "slpkg"
__author__ = "dslackw" __author__ = "dslackw"
__version_info__ = (3, 9, 6) __version_info__ = (3, 9, 7)
__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"
@ -84,7 +89,7 @@ class MetaData:
__homepage__ = "https://dslackw.gitlab.io/slpkg/" __homepage__ = "https://dslackw.gitlab.io/slpkg/"
# Default Slackware release # Default Slackware release
slack_rel = "stable" slack_rel = STABLE
# Configuration path # Configuration path
conf_path = f"/etc/{__all__}/" conf_path = f"/etc/{__all__}/"
@ -95,7 +100,7 @@ class MetaData:
# Default configuration values # Default configuration values
_conf_slpkg = { _conf_slpkg = {
"RELEASE": "stable", "RELEASE": STABLE,
"SLACKWARE_VERSION": "off", "SLACKWARE_VERSION": "off",
"COMP_ARCH": "off", "COMP_ARCH": "off",
"REPOSITORIES": ["slack", "sbo", "rlw", "alien", "REPOSITORIES": ["slack", "sbo", "rlw", "alien",

View file

@ -48,10 +48,10 @@ Usage: slpkg [COMMANDS|OPTIONS] {repository|package...}
_Slackware package manager_______ _Slackware package manager_______
Commands: Commands:
update, --repositories=[...] Run this command to update all update, --repos=[...] Run this command to update all
the packages lists. the packages lists.
upgrade, --repositories=[...] Delete and recreate all packages upgrade, --repos=[...] Delete and recreate all packages
lists. lists.
repo-add [repository name] [URL] Add custom repository. repo-add [repository name] [URL] Add custom repository.
@ -171,12 +171,12 @@ Homepage: https://dslackw.gitlab.io/slpkg/
print(options.__doc__) print(options.__doc__)
def usage(repo): def usage(repo, stderr):
"""Usage: slpkg [COMMANDS|OPTIONS] {repository|package...} """Usage: slpkg [COMMANDS|OPTIONS] {repository|package...}
Commands: Commands:
[update, --repositories=[...]] [update, --repos=[...]]
[upgrade, --repositories=[...]] [upgrade, --repos=[...]]
[repo-add [repository name] [URL]] [repo-add [repository name] [URL]]
[repo-remove [repository]] [repo-remove [repository]]
[repo-enable] [repo-enable]
@ -225,7 +225,8 @@ def usage(repo):
else: else:
error_repo = (f"slpkg: Error: Repository '{repo}' does not exist" error_repo = (f"slpkg: Error: Repository '{repo}' does not exist"
"\n") "\n")
print("\n" + error_repo) raise(f"\n {error_repo}")
raise SystemExit(1)
print(usage.__doc__) print(usage.__doc__)
print("For more information try 'slpkg -h, --help' or view manpage\n") print("For more information try 'slpkg -h, --help' or view manpage\n")
if stderr == 1:
raise SystemExit(stderr)

View file

@ -55,7 +55,8 @@ class Auto:
print("| Choose a Slackware command:") print("| Choose a Slackware command:")
self.msg.template(78) self.msg.template(78)
for com in sorted(self.commands): for com in sorted(self.commands):
print(f"| {self.red}{com}{self.endc}) {self.green}{self.commands[com]}{self.endc}") print(f"| {self.red}{com}{self.endc}) {self.green}"
f"{self.commands[com]}{self.endc}")
self.msg.template(78) self.msg.template(78)
try: try:
self.choice = input(" > ") self.choice = input(" > ")
@ -63,7 +64,8 @@ class Auto:
print() print()
raise SystemExit() raise SystemExit()
if self.choice in self.commands.keys(): if self.choice in self.commands.keys():
print(f" \x1b[1A{self.cyan}{self.commands[self.choice]}{self.endc}", end="\n\n") print(f" \x1b[1A{self.cyan}{self.commands[self.choice]}"
f"{self.endc}", end="\n\n")
print(end="", flush=True) print(end="", flush=True)
self.execute() self.execute()

View file

@ -23,6 +23,7 @@
import sys import sys
from functools import lru_cache
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
@ -49,11 +50,12 @@ class Dependencies:
for req in requires: for req in requires:
if req and req not in self.black: if req and req not in self.black:
dependencies.append(req) dependencies.append(req)
self.deep_check(dependencies, flag) self.deep_check(tuple(dependencies), tuple(flag))
return self.dep_results return self.dep_results
else: else:
return [] return []
@lru_cache
def deep_check(self, dependencies, flag): def deep_check(self, dependencies, flag):
"""Checking if dependencies are finnished """Checking if dependencies are finnished
""" """

View file

@ -22,6 +22,7 @@
# 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 functools import lru_cache
from slpkg.utils import Utils from slpkg.utils import Utils
from slpkg.splitting import split_package from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
@ -193,7 +194,8 @@ class Requires:
else: else:
return "" return ""
else: else:
PACKAGES_TXT = Utils().read_file(f"{_meta_.lib_path}{self.repo}_repo/PACKAGES.TXT") PACKAGES_TXT = Utils().read_file(f"{_meta_.lib_path}"
f"{self.repo}_repo/PACKAGES.TXT")
for line in PACKAGES_TXT.splitlines(): for line in PACKAGES_TXT.splitlines():
if line.startswith("PACKAGE NAME:"): if line.startswith("PACKAGE NAME:"):
pkg_name = split_package(line[14:].strip())[0] pkg_name = split_package(line[14:].strip())[0]
@ -202,9 +204,10 @@ class Requires:
if line[18:].strip(): if line[18:].strip():
return self._req_fix(line) return self._req_fix(line)
@lru_cache
def _req_fix(self, line): def _req_fix(self, line):
"""Fix slacky and salix requirements because many dependencies splitting """Fix slacky and salix requirements because many dependencies
with "," and others with "|" splitting with "," and others with "|"
""" """
deps = [] deps = []
for dep in line[18:].strip().split(","): for dep in line[18:].strip().split(","):

View file

@ -134,16 +134,16 @@ class BinaryInstall(BlackList, Utils):
if self.matching and [""] != self.packages: if self.matching and [""] != self.packages:
print("\nMatching summary") print("\nMatching summary")
print("=" * 79) print("=" * 79)
print(f"Total {sums[0]} matching packages\n") raise SystemExit(f"Total {sums[0]} matching packages\n")
raise SystemExit(1)
print("\nInstalling summary") print("\nInstalling summary")
print("=" * 79) print("=" * 79)
print(f"{self.grey}Total {sums[0]} {self.msg.pkg(sums[0])}.") print(f"{self.grey}Total {sums[0]} {self.msg.pkg(sums[0])}.")
print(f"{sums[3]} {self.msg.pkg(sums[3])} will be installed, {sums[2]} will be upgraded and " print(f"{sums[3]} {self.msg.pkg(sums[3])} will be installed, "
f"{sums[2]} will be upgraded and "
f"{sums[1]} will be reinstalled.") f"{sums[1]} will be reinstalled.")
print(f"Need to get {size[0]} {unit[0]} of archives.") print(f"Need to get {size[0]} {unit[0]} of archives.")
print(f"After this process, {size[1]} {unit[1]} of additional disk " print(f"After this process, {size[1]} {unit[1]} of additional "
f"space will be used.{self.endc}") f"disk space will be used.{self.endc}")
print() print()
self.if_all_installed() self.if_all_installed()
if self.msg.answer() in ["y", "Y"]: if self.msg.answer() in ["y", "Y"]:
@ -314,7 +314,8 @@ class BinaryInstall(BlackList, Utils):
"""Print packages status bar """Print packages status bar
""" """
self.msg.template(78) self.msg.template(78)
print(f"| Package{' ' * 17}New Version{' ' * 8}Arch{' ' * 4}Build{' ' * 2}Repos{' ' * 10}Size") print(f"| Package{' ' * 17}New Version{' ' * 8}Arch{' ' * 4}"
f"Build{' ' * 2}Repos{' ' * 10}Size")
self.msg.template(78) self.msg.template(78)
def store(self, packages): def store(self, packages):

View file

@ -102,7 +102,8 @@ class RepoInit(Utils):
if self.meta.arch == "x86_64": if self.meta.arch == "x86_64":
arch = "64" arch = "64"
self.mirror = (f"{self.def_repo_dict['slacke']}" self.mirror = (f"{self.def_repo_dict['slacke']}"
f"slacke{self.meta.slacke_sub_repo[1:-1]}/slackware{arch}-{slack_ver()}/") f"slacke{self.meta.slacke_sub_repo[1:-1]}/slackware"
f"{arch}-{slack_ver()}/")
def _init_salix(self): def _init_salix(self):
arch = "i486" arch = "i486"
@ -123,7 +124,8 @@ class RepoInit(Utils):
arch = "x86" arch = "x86"
if self.meta.arch == "x86_64": if self.meta.arch == "x86_64":
arch = "x86_64" arch = "x86_64"
self.mirror = f"{self.def_repo_dict['msb']}{slack_ver()}/{self.meta.msb_sub_repo[1:-1]}/{arch}/" self.mirror = (f"{self.def_repo_dict['msb']}{slack_ver()}/"
f"{self.meta.msb_sub_repo[1:-1]}/{arch}/")
def _init_csb(self): def _init_csb(self):
arch = "x86" arch = "x86"
@ -135,10 +137,13 @@ class RepoInit(Utils):
arch = "" arch = ""
if self.meta.arch == "x86_64": if self.meta.arch == "x86_64":
arch = "64" arch = "64"
self.mirror = f"{self.def_repo_dict['connos']}slack-n-free{arch}-{slack_ver()}/" self.mirror = (f"{self.def_repo_dict['connos']}slack-n-free"
f"{arch}-{slack_ver()}/")
def _init_mles(self): def _init_mles(self):
arch = "32" arch = "32"
if self.meta.arch == "x86_64": if self.meta.arch == "x86_64":
arch = "64" arch = "64"
self.mirror = f"{self.def_repo_dict['mles']}{self.meta.mles_sub_repo[1:-1]}-{slack_ver()}-{arch}bit/" self.mirror = (f"{self.def_repo_dict['mles']}"
f"{self.meta.mles_sub_repo[1:-1]}-"
f"{slack_ver()}-{arch}bit/")

View file

@ -35,7 +35,6 @@ class Updates:
self.repo = repo self.repo = repo
self.meta = _meta_ self.meta = _meta_
self.green = _meta_.color["GREEN"] self.green = _meta_.color["GREEN"]
self.grey = _meta_.color["GREY"]
self.endc = _meta_.color["ENDC"] self.endc = _meta_.color["ENDC"]
self.msg = Msg() self.msg = Msg()
self.check = 2 self.check = 2
@ -78,13 +77,11 @@ class Updates:
try: try:
self.check = self.all_repos[self.repo]() self.check = self.all_repos[self.repo]()
except OSError: except OSError:
usage(self.repo) usage(self.repo, 1)
raise SystemExit()
elif self.repo in self.meta.repositories: elif self.repo in self.meta.repositories:
self.check = self._init.custom(self.repo) self.check = self._init.custom(self.repo)
else: else:
usage(self.repo) usage(self.repo, 1)
raise SystemExit()
self.status_bar() self.status_bar()
self.status() self.status()
self.print_status(self.repo) self.print_status(self.repo)
@ -99,8 +96,7 @@ class Updates:
try: try:
self.check = self.all_repos[repo]() self.check = self.all_repos[repo]()
except OSError: except OSError:
usage(self.repo) usage(self.repo, 1)
raise SystemExit()
elif repo in self.meta.repositories: elif repo in self.meta.repositories:
self.check = self._init.custom(repo) self.check = self._init.custom(repo)
self.status() self.status()
@ -132,5 +128,5 @@ class Updates:
cmd = "Repository is updated." cmd = "Repository is updated."
if self.count_news > 0: if self.count_news > 0:
cmd = "Run the command 'slpkg update'." cmd = "Run the command 'slpkg update'."
print(f"{self.grey}From {self.count_repo} repositories need" print(f"From {self.count_repo} repositories need"
f" {self.count_news} updating. {cmd}{self.endc}", end="\n") f" {self.count_news} updating. {cmd}", end="\n")

View file

@ -52,11 +52,13 @@ class Graph:
try: try:
import pygraphviz as pgv import pygraphviz as pgv
except ImportError: except ImportError:
if self.image == "ascii" and not os.path.isfile("/usr/bin/graph-easy"): if (self.image == "ascii"
print("Require 'grap_easy': Install with 'slpkg -s sbo graph-easy'") and not os.path.isfile("/usr/bin/graph-easy")):
print("Require 'grap_easy': "
"Install with 'slpkg -s sbo graph-easy'")
else: else:
print("Require 'pygraphviz: Install with 'slpkg -s sbo pygraphviz'") raise SystemExit("Require 'pygraphviz: "
raise SystemExit() "Install with 'slpkg -s sbo pygraphviz'")
if self.image != "ascii": if self.image != "ascii":
self.check_file() self.check_file()
try: try:
@ -67,7 +69,7 @@ class Graph:
self.graph_easy() self.graph_easy()
G.draw(self.image) G.draw(self.image)
except IOError: except IOError:
raise SystemExit() raise SystemExit(1)
if os.path.isfile(self.image): if os.path.isfile(self.image):
print(f"Graph image file '{self.image}' created") print(f"Graph image file '{self.image}' created")
raise SystemExit() raise SystemExit()
@ -78,12 +80,11 @@ 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." raise SystemExit(f"Format: '{self.image.split('.')[1]}' not "
f" Use one of them:\n{', '.join(self.file_format)}") f"recognized. Use one of them:\n"
raise SystemExit() f"{', '.join(self.file_format)}")
except IndexError: except IndexError:
print("slpkg: Error: Image file suffix missing") raise SystemExit("slpkg: Error: Image file suffix missing")
raise SystemExit()
def graph_easy(self): def graph_easy(self):
"""Draw ascii diagram. graph-easy perl module require """Draw ascii diagram. graph-easy perl module require
@ -92,10 +93,10 @@ class Graph:
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(1)
subprocess.call(f"graph-easy {self.image}.dot", shell=True) subprocess.call(f"graph-easy {self.image}.dot", shell=True)
self.remove_dot() self.remove_dot()
raise SystemExit() raise SystemExit(1)
def remove_dot(self): def remove_dot(self):
"""Remove .dot files """Remove .dot files

View file

@ -33,11 +33,11 @@ def pkg_checksum(binary, repo):
""" """
md5 = "None" md5 = "None"
if repo == "slack_patches" and _meta_.slack_rel == "stable": if repo == "slack_patches" and _meta_.slack_rel == "stable":
CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "patches/")).reading() CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "patches/")).get_request()
elif repo == "slack_patches" and _meta_.slack_rel == "current": elif repo == "slack_patches" and _meta_.slack_rel == "current":
CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "")).reading() CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "")).get_request()
elif repo == "slpkg": elif repo == "slpkg":
CHECKSUMS_md5 = URL(_meta_.CHECKSUMS_link).reading() CHECKSUMS_md5 = URL(_meta_.CHECKSUMS_link).get_request()
else: else:
lib = f"{_meta_.lib_path}{repo}_repo/CHECKSUMS.md5" lib = f"{_meta_.lib_path}{repo}_repo/CHECKSUMS.md5"
f = open(lib, "r") f = open(lib, "r")

View file

@ -64,8 +64,7 @@ class PackageHealth:
elif not self.mode: elif not self.mode:
print(line) print(line)
except IOError: except IOError:
print() raise SystemExit("\n")
raise SystemExit()
def test(self): def test(self):
"""Get started test each package and read file list """Get started test each package and read file list

View file

@ -42,6 +42,8 @@ class Initialization(Utils):
def __init__(self, check): def __init__(self, check):
self.check = check self.check = check
self.meta = _meta_ self.meta = _meta_
self.arch = _meta_.arch
self.slack_ver = slack_ver()
self.def_repos_dict = Repo().default_repository() self.def_repos_dict = Repo().default_repository()
self.conf_path = self.meta.conf_path self.conf_path = self.meta.conf_path
self.log_path = self.meta.log_path self.log_path = self.meta.log_path
@ -56,22 +58,32 @@ class Initialization(Utils):
def constructing(self): def constructing(self):
"""Creating the all necessary directories """Creating the all necessary directories
""" """
if not os.path.exists(self.conf_path): paths_basic = [
os.mkdir(self.conf_path) self.conf_path,
if not os.path.exists(self.log_path): self.log_path,
os.mkdir(self.log_path) self.lib_path,
if not os.path.exists(self.lib_path): self.tmp_path
os.mkdir(self.lib_path) ]
if not os.path.exists(self.tmp_path):
os.mkdir(self.tmp_path) paths_extra = [
if not os.path.exists(self.build_path): self.build_path,
os.makedirs(self.build_path) self._SOURCES,
if not os.path.exists(self._SOURCES): self.slpkg_tmp_packages,
os.makedirs(self._SOURCES) self.slpkg_tmp_patches
if not os.path.exists(self.slpkg_tmp_packages): ]
os.makedirs(self.slpkg_tmp_packages)
if not os.path.exists(self.slpkg_tmp_patches): self.make_dir(paths_basic)
os.makedirs(self.slpkg_tmp_patches) self.make_dirs(paths_extra)
def make_dir(self, path: list):
for p in path:
if not os.path.exists(p):
os.mkdir(p)
def make_dirs(self, path: list):
for p in path:
if not os.path.exists(p):
os.makedirs(p)
def custom(self, name): def custom(self, name):
"""Creating user select repository local library """Creating user select repository local library
@ -84,10 +96,7 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
PACKAGES_TXT = f"{repo}/{lib_file}" PACKAGES_TXT = f"{repo}/{lib_file}"
FILELIST_TXT = "" FILELIST_TXT = ""
CHECKSUMS_MD5 = f"{repo}{md5_file}" CHECKSUMS_MD5 = f"{repo}{md5_file}"
@ -110,14 +119,11 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log):
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
dirs = ["core/", "extra/", "patches/"] dirs = ["core/", "extra/", "patches/"]
for d in dirs: self.make_dir([log, lib])
if not os.path.exists(lib + d): self.make_dir([f"{lib}{dirs[0]}",
os.mkdir(lib + d) f"{lib}{dirs[1]}",
f"{lib}{dirs[2]}"])
PACKAGES_TXT = mirrors(lib_file, "") PACKAGES_TXT = mirrors(lib_file, "")
FILELIST_TXT = "" FILELIST_TXT = ""
CHECKSUMS_MD5 = mirrors(md5_file, "") CHECKSUMS_MD5 = mirrors(md5_file, "")
@ -155,14 +161,11 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
# md5_file = "" # md5_file = ""
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log) SLACKBUILDS_TXT = f"{repo}{self.slack_ver}/{lib_file}"
if not os.path.exists(lib):
os.mkdir(lib)
SLACKBUILDS_TXT = f"{repo}{slack_ver()}/{lib_file}"
FILELIST_TXT = "" FILELIST_TXT = ""
CHECKSUMS_MD5 = "" CHECKSUMS_MD5 = ""
ChangeLog_txt = f"{repo}{slack_ver()}/{log_file}" ChangeLog_txt = f"{repo}{self.slack_ver}/{log_file}"
if self.check: if self.check:
return self.checks_logs(log, ChangeLog_txt) return self.checks_logs(log, ChangeLog_txt)
self.down(lib, SLACKBUILDS_TXT, repo_name) self.down(lib, SLACKBUILDS_TXT, repo_name)
@ -181,14 +184,11 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log) PACKAGES_TXT = f"{repo}{self.slack_ver}/{lib_file}"
if not os.path.exists(lib):
os.mkdir(lib)
PACKAGES_TXT = f"{repo}{slack_ver()}/{lib_file}"
FILELIST_TXT = "" FILELIST_TXT = ""
CHECKSUMS_MD5 = f"{repo}{slack_ver()}/{md5_file}" CHECKSUMS_MD5 = f"{repo}{self.slack_ver}/{md5_file}"
ChangeLog_txt = f"{repo}{slack_ver()}/{log_file}" ChangeLog_txt = f"{repo}{self.slack_ver}/{log_file}"
if self.check: if self.check:
return self.checks_logs(log, ChangeLog_txt) return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name) self.down(lib, PACKAGES_TXT, repo_name)
@ -201,8 +201,7 @@ class Initialization(Utils):
"""Creating alien local library """Creating alien local library
""" """
ar = "x86" ar = "x86"
ver = slack_ver() ver = self.slack_ver
arch = self.meta.arch
repo = self.def_repos_dict["alien"] repo = self.def_repos_dict["alien"]
log = self.log_path + "alien/" log = self.log_path + "alien/"
lib = self.lib_path + "alien_repo/" lib = self.lib_path + "alien_repo/"
@ -211,12 +210,9 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log) if self.arch == "x86_64":
if not os.path.exists(lib): ar = self.arch
os.mkdir(lib)
if arch == "x86_64":
ar = arch
if self.meta.slack_rel == "current": if self.meta.slack_rel == "current":
ver = self.meta.slack_rel ver = self.meta.slack_rel
PACKAGES_TXT = f"{repo}/{ver}/{ar}/{lib_file}" PACKAGES_TXT = f"{repo}/{ver}/{ar}/{lib_file}"
@ -235,7 +231,6 @@ class Initialization(Utils):
"""Creating slacky.eu local library """Creating slacky.eu local library
""" """
ar = "" ar = ""
arch = self.meta.arch
repo = self.def_repos_dict["slacky"] repo = self.def_repos_dict["slacky"]
log = self.log_path + "slacky/" log = self.log_path + "slacky/"
lib = self.lib_path + "slacky_repo/" lib = self.lib_path + "slacky_repo/"
@ -244,17 +239,14 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log) if self.arch == "x86_64":
if not os.path.exists(lib):
os.mkdir(lib)
if arch == "x86_64":
ar = "64" ar = "64"
PACKAGES_TXT = f"{repo}slackware{ar}-{slack_ver()}/{lib_file}" PACKAGES_TXT = f"{repo}slackware{ar}-{self.slack_ver}/{lib_file}"
FILELIST_TXT = "" FILELIST_TXT = ""
CHECKSUMS_MD5 = f"{repo}slackware{ar}-{slack_ver()}/{md5_file}" CHECKSUMS_MD5 = f"{repo}slackware{ar}-{self.slack_ver}/{md5_file}"
ChangeLog_txt = f"{repo}slackware{ar}-{slack_ver()}/{log_file}" ChangeLog_txt = f"{repo}slackware{ar}-{self.slack_ver}/{log_file}"
if self.check: if self.check:
return self.checks_logs(log, ChangeLog_txt) return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name) self.down(lib, PACKAGES_TXT, repo_name)
@ -274,10 +266,7 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
PACKAGES_TXT = f"{repo}{lib_file}" PACKAGES_TXT = f"{repo}{lib_file}"
FILELIST_TXT = "" FILELIST_TXT = ""
CHECKSUMS_MD5 = f"{repo}{md5_file}" CHECKSUMS_MD5 = f"{repo}{md5_file}"
@ -293,9 +282,7 @@ class Initialization(Utils):
def slonly(self): def slonly(self):
"""Creating slackers local library """Creating slackers local library
""" """
ver = slack_ver() ar = f"{self.slack_ver}-x86"
ar = f"{ver}-x86"
arch = self.meta.arch
repo = self.def_repos_dict["slonly"] repo = self.def_repos_dict["slonly"]
log = self.log_path + "slonly/" log = self.log_path + "slonly/"
lib = self.lib_path + "slonly_repo/" lib = self.lib_path + "slonly_repo/"
@ -304,15 +291,12 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log) if self.arch == "x86_64":
if not os.path.exists(lib): ar = f"{self.slack_ver}-x86_64"
os.mkdir(lib)
if arch == "x86_64":
ar = f"{ver}-x86_64"
if self.meta.slack_rel == "current": if self.meta.slack_rel == "current":
ar = f"{self.meta.slack_rel}-x86" ar = f"{self.meta.slack_rel}-x86"
if self.meta.slack_rel == "current" and arch == "x86_64": if self.meta.slack_rel == "current" and self.arch == "x86_64":
ar = f"{self.meta.slack_rel}-x86_64" ar = f"{self.meta.slack_rel}-x86_64"
PACKAGES_TXT = f"{repo}{ar}/{lib_file}" PACKAGES_TXT = f"{repo}{ar}/{lib_file}"
FILELIST_TXT = "" FILELIST_TXT = ""
@ -337,10 +321,7 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
PACKAGES_TXT = f"{repo}{lib_file}" PACKAGES_TXT = f"{repo}{lib_file}"
FILELIST_TXT = "" FILELIST_TXT = ""
CHECKSUMS_MD5 = f"{repo}{md5_file}" CHECKSUMS_MD5 = f"{repo}{md5_file}"
@ -356,7 +337,7 @@ class Initialization(Utils):
def multi(self): def multi(self):
"""Creating alien multilib local library """Creating alien multilib local library
""" """
ver = slack_ver() ver = self.slack_ver
repo = self.def_repos_dict["multi"] repo = self.def_repos_dict["multi"]
log = self.log_path + "multi/" log = self.log_path + "multi/"
lib = self.lib_path + "multi_repo/" lib = self.lib_path + "multi_repo/"
@ -365,10 +346,7 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
if self.meta.slack_rel == "current": if self.meta.slack_rel == "current":
ver = self.meta.slack_rel ver = self.meta.slack_rel
PACKAGES_TXT = f"{repo}{ver}/{lib_file}" PACKAGES_TXT = f"{repo}{ver}/{lib_file}"
@ -387,7 +365,6 @@ class Initialization(Utils):
"""Creating Slacke local library """Creating Slacke local library
""" """
ar = "" ar = ""
arch = self.meta.arch
repo = self.def_repos_dict["slacke"] repo = self.def_repos_dict["slacke"]
log = self.log_path + "slacke/" log = self.log_path + "slacke/"
lib = self.lib_path + "slacke_repo/" lib = self.lib_path + "slacke_repo/"
@ -396,17 +373,17 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log) if self.arch == "x86_64":
if not os.path.exists(lib):
os.mkdir(lib)
if arch == "x86_64":
ar = "64" ar = "64"
version = self.meta.slacke_sub_repo[1:-1] version = self.meta.slacke_sub_repo[1:-1]
PACKAGES_TXT = f"{repo}slacke{version}/slackware{ar}-{slack_ver()}/{lib_file}" PACKAGES_TXT = (f"{repo}slacke{version}/slackware{ar}-"
f"{self.slack_ver}/{lib_file}")
FILELIST_TXT = "" FILELIST_TXT = ""
CHECKSUMS_MD5 = f"{repo}slacke{version}/slackware{ar}-{slack_ver()}/{md5_file}" CHECKSUMS_MD5 = (f"{repo}slacke{version}/slackware{ar}-"
ChangeLog_txt = f"{repo}slacke{version}/slackware{ar}-{slack_ver()}/{log_file}" f"{self.slack_ver}/{md5_file}")
ChangeLog_txt = (f"{repo}slacke{version}/slackware{ar}-"
f"{self.slack_ver}/{log_file}")
if self.check: if self.check:
return self.checks_logs(log, ChangeLog_txt) return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name) self.down(lib, PACKAGES_TXT, repo_name)
@ -419,7 +396,6 @@ class Initialization(Utils):
"""Creating SalixOS local library """Creating SalixOS local library
""" """
ar = "i486" ar = "i486"
arch = self.meta.arch
repo = self.def_repos_dict["salix"] repo = self.def_repos_dict["salix"]
log = self.log_path + "salix/" log = self.log_path + "salix/"
lib = self.lib_path + "salix_repo/" lib = self.lib_path + "salix_repo/"
@ -428,16 +404,13 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log) if self.arch == "x86_64":
if not os.path.exists(lib):
os.mkdir(lib)
if arch == "x86_64":
ar = "x86_64" ar = "x86_64"
PACKAGES_TXT = f"{repo}{ar}/{slack_ver()}/{lib_file}" PACKAGES_TXT = f"{repo}{ar}/{self.slack_ver}/{lib_file}"
FILELIST_TXT = "" FILELIST_TXT = ""
CHECKSUMS_MD5 = f"{repo}{ar}/{slack_ver()}/{md5_file}" CHECKSUMS_MD5 = f"{repo}{ar}/{self.slack_ver}/{md5_file}"
ChangeLog_txt = f"{repo}{ar}/{slack_ver()}/{log_file}" ChangeLog_txt = f"{repo}{ar}/{self.slack_ver}/{log_file}"
if self.check: if self.check:
return self.checks_logs(log, ChangeLog_txt) return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name) self.down(lib, PACKAGES_TXT, repo_name)
@ -450,7 +423,6 @@ class Initialization(Utils):
"""Creating slackel.gr local library """Creating slackel.gr local library
""" """
ar = "i486" ar = "i486"
arch = self.meta.arch
repo = self.def_repos_dict["slackl"] repo = self.def_repos_dict["slackl"]
log = self.log_path + "slackl/" log = self.log_path + "slackl/"
lib = self.lib_path + "slackl_repo/" lib = self.lib_path + "slackl_repo/"
@ -459,11 +431,8 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log) if self.arch == "x86_64":
if not os.path.exists(lib):
os.mkdir(lib)
if arch == "x86_64":
ar = "x86_64" ar = "x86_64"
PACKAGES_TXT = f"{repo}{ar}/current/{lib_file}" PACKAGES_TXT = f"{repo}{ar}/current/{lib_file}"
FILELIST_TXT = "" FILELIST_TXT = ""
@ -488,10 +457,7 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
PACKAGES_TXT = f"{repo}{lib_file}" PACKAGES_TXT = f"{repo}{lib_file}"
FILELIST_TXT = "" FILELIST_TXT = ""
CHECKSUMS_MD5 = f"{repo}{md5_file}" CHECKSUMS_MD5 = f"{repo}{md5_file}"
@ -508,8 +474,7 @@ class Initialization(Utils):
"""Creating MATE local library """Creating MATE local library
""" """
ar = "x86" ar = "x86"
ver_slack = slack_ver() ver_slack = self.slack_ver
arch = self.meta.arch
repo = self.def_repos_dict["msb"] repo = self.def_repos_dict["msb"]
log = self.log_path + "msb/" log = self.log_path + "msb/"
lib = self.lib_path + "msb_repo/" lib = self.lib_path + "msb_repo/"
@ -518,11 +483,8 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log) if self.arch == "x86_64":
if not os.path.exists(lib):
os.mkdir(lib)
if arch == "x86_64":
ar = "x86_64" ar = "x86_64"
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":
@ -543,8 +505,7 @@ class Initialization(Utils):
"""Creating Cinnamon local library """Creating Cinnamon local library
""" """
ar = "x86" ar = "x86"
ver_slack = slack_ver() ver_slack = self.slack_ver
arch = self.meta.arch
repo = self.def_repos_dict["csb"] repo = self.def_repos_dict["csb"]
log = self.log_path + "csb/" log = self.log_path + "csb/"
lib = self.lib_path + "csb_repo/" lib = self.lib_path + "csb_repo/"
@ -553,11 +514,8 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log) if self.arch == "x86_64":
if not os.path.exists(lib):
os.mkdir(lib)
if arch == "x86_64":
ar = "x86_64" ar = "x86_64"
if self.meta.slack_rel == "current": if self.meta.slack_rel == "current":
ver_slack = self.meta.slack_rel ver_slack = self.meta.slack_rel
@ -578,7 +536,6 @@ class Initialization(Utils):
""" """
nickname = "slack-n-free" nickname = "slack-n-free"
ar = "" ar = ""
arch = self.meta.arch
repo = self.def_repos_dict["connos"] repo = self.def_repos_dict["connos"]
log = self.log_path + "connos/" log = self.log_path + "connos/"
lib = self.lib_path + "connos_repo/" lib = self.lib_path + "connos_repo/"
@ -587,16 +544,13 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log) if self.arch == "x86_64":
if not os.path.exists(lib):
os.mkdir(lib)
if arch == "x86_64":
ar = "64" ar = "64"
PACKAGES_TXT = f"{repo}{nickname}{ar}-{slack_ver()}/{lib_file}" PACKAGES_TXT = f"{repo}{nickname}{ar}-{self.slack_ver}/{lib_file}"
FILELIST_TXT = "" FILELIST_TXT = ""
CHECKSUMS_MD5 = f"{repo}{nickname}{ar}-{slack_ver()}/{md5_file}" CHECKSUMS_MD5 = f"{repo}{nickname}{ar}-{self.slack_ver}/{md5_file}"
ChangeLog_txt = f"{repo}{nickname}{ar}-{slack_ver()}/{log_file}" ChangeLog_txt = f"{repo}{nickname}{ar}-{self.slack_ver}/{log_file}"
if self.check: if self.check:
return self.checks_logs(log, ChangeLog_txt) return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name) self.down(lib, PACKAGES_TXT, repo_name)
@ -609,7 +563,6 @@ class Initialization(Utils):
"""Creating Microlinux local library """Creating Microlinux local library
""" """
ar = "32" ar = "32"
arch = self.meta.arch
repo = self.def_repos_dict["mles"] repo = self.def_repos_dict["mles"]
log = self.log_path + "mles/" log = self.log_path + "mles/"
lib = self.lib_path + "mles_repo/" lib = self.lib_path + "mles_repo/"
@ -618,17 +571,14 @@ class Initialization(Utils):
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt" log_file = "ChangeLog.txt"
if not os.path.exists(log): self.make_dir([log, lib])
os.mkdir(log) if self.arch == "x86_64":
if not os.path.exists(lib):
os.mkdir(lib)
if arch == "x86_64":
ar = "64" ar = "64"
version = self.meta.mles_sub_repo[1:-1] version = self.meta.mles_sub_repo[1:-1]
PACKAGES_TXT = f"{repo}{version}-{slack_ver()}-{ar}bit/{lib_file}" PACKAGES_TXT = f"{repo}{version}-{self.slack_ver}-{ar}bit/{lib_file}"
FILELIST_TXT = "" FILELIST_TXT = ""
CHECKSUMS_MD5 = f"{repo}{version}-{slack_ver()}-{ar}bit/{md5_file}" CHECKSUMS_MD5 = f"{repo}{version}-{self.slack_ver}-{ar}bit/{md5_file}"
ChangeLog_txt = f"{repo}{version}-{slack_ver()}-{ar}bit/{log_file}" ChangeLog_txt = f"{repo}{version}-{self.slack_ver}-{ar}bit/{log_file}"
if self.check: if self.check:
return self.checks_logs(log, ChangeLog_txt) return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name) self.down(lib, PACKAGES_TXT, repo_name)
@ -746,10 +696,11 @@ class Update:
def __init__(self): def __init__(self):
self.meta = _meta_ self.meta = _meta_
self.grey = _meta_.color["GREY"] self.grey = _meta_.color["GREY"]
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"]
self.endc = _meta_.color["ENDC"] self.endc = _meta_.color["ENDC"]
self.done = f"{self.grey}Done{self.endc}\n" self.done = f"{self.green}Done{self.endc}\n"
self.error = f"{self.red}Error{self.endc}\n" self.error = f"{self.red}Error{self.endc}\n"
def run(self, repos): def run(self, repos):
@ -758,6 +709,7 @@ class Update:
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
custom = Repo().custom_repository()
# Replace the enabled repositories from user defined # Replace the enabled repositories from user defined
if repos: if repos:
@ -766,11 +718,11 @@ class Update:
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) self.done_msg(repo)
if repo in default: if repo in default:
getattr(Initialization(False), repo)() getattr(Initialization(False), repo)()
print(self.done, end="") print(self.done, end="")
elif repo in enabled: elif repo in custom:
Initialization(False).custom(repo) Initialization(False).custom(repo)
print(self.done, end="") print(self.done, end="")
else: else:
@ -778,6 +730,11 @@ class Update:
print() # new line at end print() # new line at end
raise SystemExit() raise SystemExit()
def done_msg(self, repo):
print(f"{self.grey}Check repository "
f"[{self.cyan}{repo}{self.grey}] ... "
f"{self.endc}", end="", flush=True)
def check_exists_repositories(repo): def check_exists_repositories(repo):
"""Checking if repositories exists by PACKAGES.TXT file """Checking if repositories exists by PACKAGES.TXT file
@ -785,12 +742,10 @@ def check_exists_repositories(repo):
pkg_list = "PACKAGES.TXT" pkg_list = "PACKAGES.TXT"
if repo == "sbo": if repo == "sbo":
pkg_list = "SLACKBUILDS.TXT" pkg_list = "SLACKBUILDS.TXT"
if check_for_local_repos(repo) is True: elif check_for_local_repos(repo) is True:
pkg_list = "PACKAGES.TXT" pkg_list = "PACKAGES.TXT"
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}"):
return repo return False
return ""
def check_for_local_repos(repo): def check_for_local_repos(repo):

View file

@ -88,11 +88,7 @@ class ArgParse(BlackList):
"clean" "clean"
] ]
# checking if repositories exists options = [
enabled_repos = _meta_.repositories
if len(self.args) > 1:
repo = check_exists_repositories(args[1])
if len(self.args) > 1 and self.args[0] in [
"-c", "--check", "-c", "--check",
"-l", "--list", "-l", "--list",
"-c", "--check", "-c", "--check",
@ -101,11 +97,19 @@ class ArgParse(BlackList):
"-p", "--desc", "-p", "--desc",
"-F", "--FIND", "-F", "--FIND",
"-f", "--find" "-f", "--find"
] and self.args[1] == repo and repo in enabled_repos: ]
# checking if repositories exists
enabled_repos = _meta_.repositories
if len(self.args) > 1:
repo = self.args[1]
check = check_exists_repositories(repo)
if (len(self.args) > 1 and self.args[0] in options
and check is False and repo in enabled_repos):
print("\n Please update the packages lists. Run 'slpkg update'.\n" print("\n Please update the packages lists. Run 'slpkg update'.\n"
" This command should be used to synchronize the packages\n" " This command should be used to synchronize the packages\n"
" lists from the repositories that are enabled.\n") " lists from the repositories that are enabled.\n")
raise SystemExit() raise SystemExit(1)
def help_version(self): def help_version(self):
"""Help and version info """Help and version info
@ -117,7 +121,7 @@ class ArgParse(BlackList):
self.args[1:] == []): self.args[1:] == []):
prog_version() prog_version()
else: else:
usage("") usage("", 1)
def command_update(self): def command_update(self):
"""Update package lists repositories """Update package lists repositories
@ -126,14 +130,14 @@ class ArgParse(BlackList):
if len(self.args) == 1 and self.args[0] == "update": if len(self.args) == 1 and self.args[0] == "update":
update.run(repos="") 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("--repos=")):
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) usage(rp, 1)
update.run(repos) update.run(repos)
else: else:
usage("") usage("", 1)
def command_upgrade(self): def command_upgrade(self):
"""Recreate repositories package lists """Recreate repositories package lists
@ -142,14 +146,14 @@ class ArgParse(BlackList):
if len(self.args) == 1 and self.args[0] == "upgrade": if len(self.args) == 1 and self.args[0] == "upgrade":
upgrade.run(repos="") upgrade.run(repos="")
elif (len(self.args) == 2 and self.args[0] == "upgrade" and elif (len(self.args) == 2 and self.args[0] == "upgrade" and
self.args[1].startswith("--repositories=")): self.args[1].startswith("--repos=")):
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) usage(rp, 1)
upgrade.run(repos) upgrade.run(repos)
else: else:
usage("") usage("", 1)
def command_update_slpkg(self): def command_update_slpkg(self):
"""Slpkg it self update """Slpkg it self update
@ -157,7 +161,7 @@ class ArgParse(BlackList):
if len(self.args) == 2 and self.args[0] == "update-slpkg": if len(self.args) == 2 and self.args[0] == "update-slpkg":
it_self_update() it_self_update()
else: else:
usage("") usage("", 1)
def command_repo_enable(self): def command_repo_enable(self):
"""Repositories enable/disable """Repositories enable/disable
@ -166,7 +170,7 @@ class ArgParse(BlackList):
if len(self.args) == 1 and self.args[0] == "repo-enable": if len(self.args) == 1 and self.args[0] == "repo-enable":
RepoEnable().choose() RepoEnable().choose()
else: else:
usage("") usage("", 1)
def command_repo_list(self): def command_repo_list(self):
"""Repositories list """Repositories list
@ -174,7 +178,7 @@ class ArgParse(BlackList):
if len(self.args) == 1 and self.args[0] == "repo-list": if len(self.args) == 1 and self.args[0] == "repo-list":
RepoList().repos() RepoList().repos()
else: else:
usage("") usage("", 1)
def command_repo_add(self): def command_repo_add(self):
"""Add custom repositories """Add custom repositories
@ -182,7 +186,7 @@ class ArgParse(BlackList):
if len(self.args) == 3 and self.args[0] == "repo-add": if len(self.args) == 3 and self.args[0] == "repo-add":
Repo().add(self.args[1], self.args[2]) Repo().add(self.args[1], self.args[2])
else: else:
usage("") usage("", 1)
def command_repo_remove(self): def command_repo_remove(self):
"""Remove custom repositories """Remove custom repositories
@ -190,7 +194,7 @@ class ArgParse(BlackList):
if len(self.args) == 2 and self.args[0] == "repo-remove": if len(self.args) == 2 and self.args[0] == "repo-remove":
Repo().remove(self.args[1]) Repo().remove(self.args[1])
else: else:
usage("") usage("", 1)
def command_repo_info(self): def command_repo_info(self):
"""Repositories informations """Repositories informations
@ -201,9 +205,9 @@ class ArgParse(BlackList):
RepoInfo().view(self.args[1]) RepoInfo().view(self.args[1])
elif (len(self.args) > 1 and self.args[0] == "repo-info" and elif (len(self.args) > 1 and self.args[0] == "repo-info" and
self.args[1] not in RepoList().all_repos): self.args[1] not in RepoList().all_repos):
usage(self.args[1]) usage(self.args[1], 1)
else: else:
usage("") usage("", 1)
def command_health(self): def command_health(self):
"""Check package health """Check package health
@ -214,7 +218,7 @@ class ArgParse(BlackList):
self.args[1] == "--silent"): self.args[1] == "--silent"):
PackageHealth(mode=self.args[1]).test() PackageHealth(mode=self.args[1]).test()
else: else:
usage("") usage("", 1)
def command_deps_status(self): def command_deps_status(self):
"""Print dependencies status """Print dependencies status
@ -234,7 +238,7 @@ class ArgParse(BlackList):
"--tree" in self.args and image): "--tree" in self.args and image):
DependenciesStatus(image).tree() DependenciesStatus(image).tree()
else: else:
usage("") usage("", 1)
def command_new_config(self): def command_new_config(self):
"""Manage .new configuration files """Manage .new configuration files
@ -242,14 +246,14 @@ class ArgParse(BlackList):
if len(self.args) == 1 and self.args[0] == "new-config": if len(self.args) == 1 and self.args[0] == "new-config":
NewConfig().run() NewConfig().run()
else: else:
usage("") usage("", 1)
def command_clean_tmp(self): def command_clean_tmp(self):
"""Clean all downloaded packages and sources""" """Clean all downloaded packages and sources"""
if len(self.args) == 1 and self.args[0] == "clean-tmp": if len(self.args) == 1 and self.args[0] == "clean-tmp":
clean_tmp() clean_tmp()
else: else:
usage("") usage("", 1)
def auto_build(self): def auto_build(self):
"""Auto built tool """Auto built tool
@ -261,7 +265,7 @@ class ArgParse(BlackList):
if len(self.args) >= 3 and self.args[0] in options: if len(self.args) >= 3 and self.args[0] in options:
AutoBuild(self.args[1], self.args[2:], self.meta.path).run() AutoBuild(self.args[1], self.args[2:], self.meta.path).run()
else: else:
usage("") usage("", 1)
def pkg_list(self): def pkg_list(self):
"""List of packages by repository """List of packages by repository
@ -280,8 +284,7 @@ class ArgParse(BlackList):
if flag[2] == arg: if flag[2] == arg:
name = True name = True
if arg not in flag: if arg not in flag:
usage("") usage("", 1)
raise SystemExit()
if (len(self.args) > 1 and len(self.args) <= 5 and if (len(self.args) > 1 and len(self.args) <= 5 and
self.args[0] in options): self.args[0] in options):
if self.args[1] in self.meta.repositories: if self.args[1] in self.meta.repositories:
@ -290,9 +293,9 @@ class ArgParse(BlackList):
INDEX, INDEX,
installed) installed)
else: else:
usage(self.args[1]) usage(self.args[1], 1)
else: else:
usage("") usage("", 1)
def pkg_upgrade(self): def pkg_upgrade(self):
"""Check and upgrade packages by repository """Check and upgrade packages by repository
@ -327,16 +330,16 @@ class ArgParse(BlackList):
SBoInstall(sbo_upgrade(skip, flag), flag).start( SBoInstall(sbo_upgrade(skip, flag), flag).start(
is_upgrade=True) is_upgrade=True)
else: else:
usage(self.args[1]) usage(self.args[1], 1)
elif len(self.args) == 1 and self.args[0] in options: elif len(self.args) == 1 and self.args[0] in options:
Updates(repo="").ALL() Updates(repo="").ALL()
elif len(self.args) == 2 and self.args[0] in options: elif len(self.args) == 2 and self.args[0] in options:
Updates(self.args[1]).run() Updates(self.args[1]).run()
elif (len(self.args) >= 2 and self.args[0] in options and elif (len(self.args) >= 2 and self.args[0] in options and
self.args[1] not in self.meta.repositories): self.args[1] not in self.meta.repositories):
usage(self.args[1]) usage(self.args[1], 1)
else: else:
usage("") usage("", 1)
def __pkg_upgrade_flags(self, flags): def __pkg_upgrade_flags(self, flags):
"""Manage flags for package upgrade option """Manage flags for package upgrade option
@ -344,8 +347,7 @@ class ArgParse(BlackList):
# Check for typos or unssuported flags # Check for typos or unssuported flags
for arg in self.args[2:]: for arg in self.args[2:]:
if arg not in flags: if arg not in flags:
usage("") usage("", 1)
raise SystemExit()
flag, skip = [], "" flag, skip = [], ""
if flags[0] in self.args: if flags[0] in self.args:
@ -397,9 +399,9 @@ class ArgParse(BlackList):
self.args[1] in self.meta.repositories): self.args[1] in self.meta.repositories):
SBoInstall(self.args[2:], flag).start(is_upgrade=False) SBoInstall(self.args[2:], flag).start(is_upgrade=False)
else: else:
usage(self.args[1]) usage(self.args[1], 1)
else: else:
usage("") usage("", 1)
def pkg_tracking(self): def pkg_tracking(self):
"""Tracking package dependencies """Tracking package dependencies
@ -428,17 +430,16 @@ class ArgParse(BlackList):
for arg in self.args: for arg in self.args:
if arg.startswith("--"): if arg.startswith("--"):
if arg not in additional_options: if arg not in additional_options:
usage("") usage("", 1)
raise SystemExit()
if (len(self.args) >= 3 and len(self.args) <= 3 and if (len(self.args) >= 3 and len(self.args) <= 3 and
self.args[0] in options and self.args[0] in options and
self.args[1] in self.meta.repositories): self.args[1] in self.meta.repositories):
TrackingDeps(self.args[2], self.args[1], flag).run() TrackingDeps(self.args[2], self.args[1], flag).run()
elif (len(self.args) >= 2 and elif (len(self.args) >= 2 and
self.args[1] not in self.meta.repositories): self.args[1] not in self.meta.repositories):
usage(self.args[1]) usage(self.args[1], 1)
else: else:
usage("") usage("", 1)
def sbo_network(self): def sbo_network(self):
"""View slackbuilds packages """View slackbuilds packages
@ -466,7 +467,7 @@ class ArgParse(BlackList):
additional_options[0] in flag): additional_options[0] in flag):
SBoNetwork("", flag).view() SBoNetwork("", flag).view()
else: else:
usage("sbo") usage("sbo", 1)
def pkg_blacklist(self): def pkg_blacklist(self):
"""Manage blacklist packages """Manage blacklist packages
@ -496,7 +497,7 @@ class ArgParse(BlackList):
self.args.remove(flag[1]) self.args.remove(flag[1])
self.black_remove(self.args[1:]) self.black_remove(self.args[1:])
else: else:
usage("") usage("", 1)
def pkg_queue(self): def pkg_queue(self):
"""Manage packages in queue """Manage packages in queue
@ -542,7 +543,7 @@ class ArgParse(BlackList):
queue.build() queue.build()
queue.install() queue.install()
else: else:
usage("") usage("", 1)
def bin_install(self): def bin_install(self):
"""Install Slackware binary packages """Install Slackware binary packages
@ -570,7 +571,7 @@ class ArgParse(BlackList):
packages = self.args[2:] packages = self.args[2:]
PackageManager(packages).install(flag) PackageManager(packages).install(flag)
else: else:
usage("") usage("", 1)
def bin_upgrade(self): def bin_upgrade(self):
"""Install-upgrade Slackware binary packages """Install-upgrade Slackware binary packages
@ -593,7 +594,7 @@ class ArgParse(BlackList):
packages = self.args[2:] packages = self.args[2:]
PackageManager(packages).upgrade(flag) PackageManager(packages).upgrade(flag)
else: else:
usage("") usage("", 1)
def bin_remove(self): def bin_remove(self):
"""Remove Slackware packages """Remove Slackware packages
@ -637,7 +638,7 @@ class ArgParse(BlackList):
packages = [""] packages = [""]
PackageManager(packages).remove(flag, extra) PackageManager(packages).remove(flag, extra)
else: else:
usage("") usage("", 1)
def bin_find(self): def bin_find(self):
"""Find installed packages """Find installed packages
@ -663,7 +664,7 @@ class ArgParse(BlackList):
elif len(self.args) > 1 and self.args[0] in options: elif len(self.args) > 1 and self.args[0] in options:
PackageManager(packages).find(flag) PackageManager(packages).find(flag)
else: else:
usage("") usage("", 1)
def pkg_desc(self): def pkg_desc(self):
"""Print slack-desc by repository """Print slack-desc by repository
@ -687,8 +688,7 @@ class ArgParse(BlackList):
self.args.remove(arg) self.args.remove(arg)
break break
if tag and tag not in colors: if tag and tag not in colors:
print(f"\nslpkg: Error: Available colors {colors}\n") raise SystemExit(f"\nslpkg: Error: Available colors {colors}\n")
raise SystemExit()
if (len(self.args) == 3 and self.args[0] in options and if (len(self.args) == 3 and self.args[0] in options and
self.args[1] in self.meta.repositories and tag in colors): self.args[1] in self.meta.repositories and tag in colors):
PkgDesc(self.args[2], self.args[1], tag).view() PkgDesc(self.args[2], self.args[1], tag).view()
@ -697,9 +697,9 @@ class ArgParse(BlackList):
PkgDesc(self.args[2], self.args[1], paint="").view() PkgDesc(self.args[2], self.args[1], paint="").view()
elif (len(self.args) > 1 and self.args[0] in options and elif (len(self.args) > 1 and self.args[0] in options and
self.args[1] not in self.meta.repositories): self.args[1] not in self.meta.repositories):
usage(self.args[1]) usage(self.args[1], 1)
else: else:
usage("") usage("", 1)
def pkg_find(self): def pkg_find(self):
"""Find packages from all enabled repositories """Find packages from all enabled repositories
@ -718,7 +718,7 @@ class ArgParse(BlackList):
if len(self.args) > 1 and self.args[0] in options: if len(self.args) > 1 and self.args[0] in options:
FindFromRepos().find(packages, flag) FindFromRepos().find(packages, flag)
else: else:
usage("") usage("", 1)
def pkg_contents(self): def pkg_contents(self):
"""Print packages contents """Print packages contents
@ -731,7 +731,7 @@ class ArgParse(BlackList):
if len(self.args) > 1 and self.args[0] in options: if len(self.args) > 1 and self.args[0] in options:
PackageManager(packages).display() PackageManager(packages).display()
else: else:
usage("") usage("", 1)
def congiguration(self): def congiguration(self):
"""Manage slpkg configuration file """Manage slpkg configuration file
@ -756,7 +756,7 @@ class ArgParse(BlackList):
self.args[1] == (command[2])): self.args[1] == (command[2])):
conf.reset() conf.reset()
else: else:
usage("") usage("", 1)
def auto_detect(self, args): def auto_detect(self, args):
"""Check for already Slackware binary packages exist """Check for already Slackware binary packages exist
@ -781,15 +781,14 @@ class ArgParse(BlackList):
if not_found: if not_found:
for ntf in not_found: for ntf in not_found:
self.msg.pkg_not_found("", ntf, "Not installed", "") self.msg.pkg_not_found("", ntf, "Not installed", "")
raise SystemExit() raise SystemExit(1)
def if_checklist(self): def if_checklist(self):
try: try:
from dialog import Dialog from dialog import Dialog
except ImportError: except ImportError:
print("Require 'pythondialog': Install with 'slpkg -s sbo " raise SystemExit("Require 'pythondialog': Install with 'slpkg "
"python3-pythondialog'") "-s sbo python3-pythondialog'")
raise SystemExit()
def main(): def main():
@ -800,8 +799,7 @@ def main():
argparse = ArgParse(args) argparse = ArgParse(args)
if len(args) == 0: if len(args) == 0:
usage("") usage("", 1)
raise SystemExit()
argparse.auto_detect(args) argparse.auto_detect(args)
@ -861,7 +859,7 @@ def main():
try: try:
arguments[args[0]]() arguments[args[0]]()
except KeyError: except KeyError:
usage("") usage("", 1)
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -32,6 +32,7 @@ class Msg:
""" """
def __init__(self): def __init__(self):
self.meta = _meta_ self.meta = _meta_
self.green = _meta_.color["GREEN"]
self.grey = _meta_.color["GREY"] self.grey = _meta_.color["GREY"]
self.red = _meta_.color["RED"] self.red = _meta_.color["RED"]
self.cyan = _meta_.color["CYAN"] self.cyan = _meta_.color["CYAN"]
@ -56,9 +57,11 @@ class Msg:
"""Print error message if build failed """Print error message if build failed
""" """
self.template(78) self.template(78)
print(f"| Some error on the package {prgnam} [ {self.red}FAILED{self.endc} ]") print(f"| Some error on the package {prgnam} "
f"[ {self.red}FAILED{self.endc} ]")
self.template(78) self.template(78)
print(f"| See the log file in '{self.cyan}/var/log/slpkg/sbo/build_logs{self.endc}' " print(f"| See the log file in '{self.cyan}"
f"/var/log/slpkg/sbo/build_logs{self.endc}' "
f"directory or read the README file") f"directory or read the README file")
self.template(78) self.template(78)
print() # new line at end print() # new line at end
@ -76,17 +79,19 @@ class Msg:
def reading(self): def reading(self):
"""Message reading """Message reading
""" """
print(f"{self.grey}Reading package lists...{self.endc} ", end="", flush=True) print(f"{self.grey}Reading package lists...{self.endc} ",
end="", flush=True)
def resolving(self): def resolving(self):
"""Message resolving """Message resolving
""" """
print(f"{self.grey}Resolving dependencies...{self.endc} ", end="", flush=True) print(f"{self.grey}Resolving dependencies...{self.endc} ",
end="", flush=True)
def done(self): def done(self):
"""Message done """Message done
""" """
print(f"\b{self.grey}Done{self.endc}\n", end="") print(f"\b{self.green}Done{self.endc}\n", end="")
def pkg(self, count): def pkg(self, count):
"""Print singular plural """Print singular plural
@ -121,8 +126,7 @@ class Msg:
try: try:
answer = input("Would you like to continue [y/N]? ") answer = input("Would you like to continue [y/N]? ")
except EOFError: except EOFError:
print() raise SystemExit("\n")
raise SystemExit()
return answer return answer
def security_pkg(self, pkg): def security_pkg(self, pkg):
@ -157,5 +161,6 @@ class Msg:
def matching(self, packages): def matching(self, packages):
"""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 "
f"[ {self.cyan}{''.join(packages)}{self.endc} ]. "
"Matching packages:\nNOTE: Not dependencies are resolved\n") "Matching packages:\nNOTE: Not dependencies are resolved\n")

View file

@ -85,8 +85,7 @@ class NewConfig(Utils):
try: try:
choose = input("\nWhat would you like to do [K/O/R/P/Q]? ") choose = input("\nWhat would you like to do [K/O/R/P/Q]? ")
except EOFError: except EOFError:
print() raise SystemExit("\n")
raise SystemExit()
print() print()
if choose in ("K", "k"): if choose in ("K", "k"):
self.keep() self.keep()
@ -129,8 +128,7 @@ class NewConfig(Utils):
self.question(self.news[self.i]) self.question(self.news[self.i])
self.i += 1 self.i += 1
except EOFError: except EOFError:
print() raise SystemExit("\n")
raise SystemExit()
def question(self, n): def question(self, n):
"""Choose what do to file by file """Choose what do to file by file

View file

@ -76,8 +76,7 @@ class BuildPackage(Utils):
try: try:
tar = tarfile.open(self.script) tar = tarfile.open(self.script)
except Exception as err: except Exception as err:
print(err) raise SystemExit(err)
raise SystemExit()
tar.extractall() tar.extractall()
tar.close() tar.close()
self._makeflags() self._makeflags()

View file

@ -46,11 +46,11 @@ class GetFromInstalled:
""" """
if self.find: if self.find:
return split_package(self.find)[1] return split_package(self.find)[1]
return "" return self.find
def name(self): def name(self):
"""Return installed package name """Return installed package name
""" """
if self.find: if self.find:
return self.package return self.package
return "" return self.find

View file

@ -67,7 +67,7 @@ class PackageManager(Utils):
if os.path.isfile(self.meta.pkg_path + check): if os.path.isfile(self.meta.pkg_path + check):
print("Completed!\n") print("Completed!\n")
else: else:
raise SystemExit() raise SystemExit(1)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
self._not_found("Can't install", self.binary, pkg) self._not_found("Can't install", self.binary, pkg)
raise SystemExit(1) raise SystemExit(1)
@ -82,7 +82,7 @@ class PackageManager(Utils):
if os.path.isfile(self.meta.pkg_path + check): if os.path.isfile(self.meta.pkg_path + check):
print("Completed!\n") print("Completed!\n")
else: else:
raise SystemExit() raise SystemExit(1)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
self._not_found("Can't upgrade", self.binary, pkg) self._not_found("Can't upgrade", self.binary, pkg)
raise SystemExit(1) raise SystemExit(1)
@ -116,8 +116,7 @@ class PackageManager(Utils):
"\nAre you sure to remove {0} {1} [y/N]? ".format( "\nAre you sure to remove {0} {1} [y/N]? ".format(
str(len(self.removed)), msg)) str(len(self.removed)), msg))
except EOFError: except EOFError:
print() # new line at exit raise SystemExit(1)
raise SystemExit()
if remove_pkg in ["y", "Y"]: if remove_pkg in ["y", "Y"]:
self._check_if_used(self.binary) self._check_if_used(self.binary)
for rmv in self.removed: for rmv in self.removed:
@ -153,8 +152,7 @@ class PackageManager(Utils):
"other packages) [y/N]? ") "other packages) [y/N]? ")
print() print()
except EOFError: except EOFError:
print() # new line at exit raise SystemExit("\n")
raise SystemExit()
return remove_dep return remove_dep
def _get_removed(self): def _get_removed(self):
@ -296,8 +294,7 @@ class PackageManager(Utils):
if os.path.isfile(self.dep_path + package): if os.path.isfile(self.dep_path + package):
os.remove(self.dep_path + package) # remove log os.remove(self.dep_path + package) # remove log
except subprocess.CalledProcessError as er: except subprocess.CalledProcessError as er:
print(er) raise SystemExit(er)
raise SystemExit()
def _rmv_deps(self, dependencies, package): def _rmv_deps(self, dependencies, package):
"""Remove dependencies """Remove dependencies
@ -332,8 +329,7 @@ class PackageManager(Utils):
try: try:
self.skip = input(" > ").split() self.skip = input(" > ").split()
except EOFError: except EOFError:
print() raise SystemExit("\n")
raise SystemExit()
for s in self.skip: for s in self.skip:
if s in self.removed: if s in self.removed:
self.removed.remove(s) self.removed.remove(s)
@ -503,8 +499,7 @@ class PackageManager(Utils):
print(pkg) print(pkg)
print() # new line at end print() # new line at end
except (EOFError, KeyboardInterrupt, BrokenPipeError, IOError): except (EOFError, KeyboardInterrupt, BrokenPipeError, IOError):
print() # new line at exit raise SystemExit(1)
raise SystemExit()
def _splitting_packages(self, pkg, repo, name): def _splitting_packages(self, pkg, repo, name):
"""Return package name from repositories """Return package name from repositories

View file

@ -46,7 +46,8 @@ class FindFromRepos:
def find(self, pkg, flag): def find(self, pkg, flag):
"""Start to find packages and print """Start to find packages and print
""" """
print(f"Packages with name matching [ {self.cyan}{', '.join(pkg)}{self.endc} ]\n") print(f"Packages with name matching [ {self.cyan}"
f"{', '.join(pkg)}{self.endc} ]\n")
self.msg.template(78) self.msg.template(78)
print(f"| Repository Package {' ' * 54}Size") print(f"| Repository Package {' ' * 54}Size")
self.msg.template(78) self.msg.template(78)
@ -68,8 +69,9 @@ class FindFromRepos:
self.cache = repo self.cache = repo
self.count_pkg += 1 self.count_pkg += 1
ver = self.sbo_version(repo, find) ver = self.sbo_version(repo, find)
print(f" {self.cyan}{repo}{self.endc}{' ' * (12 - len(repo))}{find + ver} " print(f" {self.cyan}{repo}{self.endc}"
f"{' ' * (53 -len(find + ver))}{size:>11}") f"{' ' * (11 - len(repo))}{find + ver} "
f"{' ' * (54 -len(find + ver))}{size:>11}")
print("\nFound summary") print("\nFound summary")
print("=" * 79) print("=" * 79)
print(f"{self.grey}Total found {self.count_pkg} packages in " print(f"{self.grey}Total found {self.count_pkg} packages in "

View file

@ -63,7 +63,7 @@ Keys: SPACE select or deselect the highlighted repositories,
TAB move focus TAB move focus
ENTER press the focused button ENTER press the focused button
Disabled <-------- REPOSITORIES -------> Enabled""" Disabled <---------------- REPOSITORIES ----------------> Enabled"""
self.read_enabled() self.read_enabled()
self.read_disabled() self.read_disabled()
text, title, backtitle, status = keys, " Repositories ", "", False text, title, backtitle, status = keys, " Repositories ", "", False
@ -104,7 +104,8 @@ Keys: SPACE select or deselect the highlighted repositories,
"""Update repositories.conf file with enabled or disabled """Update repositories.conf file with enabled or disabled
repositories repositories
""" """
with open(f"{self.meta.conf_path}{self.repositories_conf}", "w") as new_conf: with open(f"{self.meta.conf_path}"
f"{self.repositories_conf}", "w") as new_conf:
for line in self.conf.splitlines(): for line in self.conf.splitlines():
line = line.lstrip() line = line.lstrip()
if self.tag in line: if self.tag in line:
@ -139,5 +140,6 @@ Keys: SPACE select or deselect the highlighted repositories,
self.msg.template(78) self.msg.template(78)
print(f"| {total_enabled}") print(f"| {total_enabled}")
self.msg.template(78) self.msg.template(78)
print(f"{self.grey}Total {len(self.selected)}/{len(self.enabled + self.disabled)} " print(f"{self.grey}Total {len(self.selected)}/"
f"{len(self.enabled + self.disabled)} "
f"repositories enabled.{self.endc}\n") f"repositories enabled.{self.endc}\n")

View file

@ -67,7 +67,8 @@ class RepoInfo(Utils):
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(f"{self.meta.lib_path}{repo}_repo/PACKAGES.TXT")): os.path.isfile(f"{self.meta.lib_path}"
f"{repo}_repo/PACKAGES.TXT")):
status = f"{self.green}enabled{self.endc}" status = f"{self.green}enabled{self.endc}"
if repo != "sbo": if repo != "sbo":
@ -75,10 +76,8 @@ class RepoInfo(Utils):
size = units(data[1], data[2]) size = units(data[1], data[2])
self.form["Repo id:"] = repo self.form["Repo id:"] = repo
self.form["Repo url:"] = self.all_repos[repo] self.form["Repo url:"] = self.all_repos[repo]
self.form["Total compressed packages:"] = "{0} {1}".format( self.form["Total compressed packages:"] = f"{str(size[1][0])} {str(size[0][0])}"
str(size[1][0]), str(size[0][0])) self.form["Total uncompressed packages:"] = f"{str(size[1][1])} {str(size[0][1])}"
self.form["Total uncompressed packages:"] = "{0} {1}".format(
str(size[1][1]), str(size[0][1]))
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]

View file

@ -47,8 +47,8 @@ class RepoList:
def_cnt, cus_cnt = 0, 0 def_cnt, cus_cnt = 0, 0
self.msg.template(78) self.msg.template(78)
print("{0}{1}{2}{3}{4}{5}{6}".format( print("{0}{1}{2}{3}{4}{5}{6}".format(
"| Repo id", " " * 2, "| Repo_id", " " * 2,
"Repo URL", " " * 44, "Repo_URL", " " * 44,
"Default", " " * 3, "Default", " " * 3,
"Status")) "Status"))
self.msg.template(78) self.msg.template(78)

View file

@ -54,14 +54,13 @@ class Repo(Utils):
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(f"\nRepository name '{repo}' exist, select different name.\n" raise SystemExit(f"\nRepository name '{repo}' exist, "
"View all repositories with command 'slpkg " f"select different name.\n"
"repo-list'.\n") f"View all repositories with command 'slpkg "
raise SystemExit(1) f"repo-list'.\n")
elif len(repo) > 6: elif len(repo) > 6:
print("\nslpkg: Error: Maximum repository name length must be " raise SystemExit("\nslpkg: Error: Maximum repository name length "
"six (6) characters\n") "must be six (6) characters\n")
raise SystemExit(1)
with open(self.custom_repo_file, "a") as repos: with open(self.custom_repo_file, "a") as repos:
new_line = f" {repo}{' ' * (10 - len(repo))}{url}\n" new_line = f" {repo}{' ' * (10 - len(repo))}{url}\n"
repos.write(new_line) repos.write(new_line)
@ -103,10 +102,11 @@ class Repo(Utils):
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(f"\nslpkg: Error: Repository name '{line.split()[0]}'" raise SystemExit(f"\nslpkg: Error: Repository name "
" is not default.\n Please check file: " f"'{line.split()[0]}'"
"/etc/slpkg/default-repositories\n") f" is not default.\n "
raise SystemExit(1) f"Please check file: "
f"/etc/slpkg/default-repositories\n")
return default_dict_repo return default_dict_repo
def slack(self): def slack(self):

View file

@ -64,9 +64,9 @@ class AutoBuild:
"""Check if SlackBuild archive.tar.gz and sources exist """Check if SlackBuild archive.tar.gz and sources exist
""" """
if not os.path.isfile(self.path + self.script): if not os.path.isfile(self.path + self.script):
print("\nslpkg: Error: SlackBuild archive.tar.gz not found\n") raise SystemExit("\nslpkg: Error: SlackBuild archive.tar.gz "
raise SystemExit() "not found\n")
for src in self.sources: for src in self.sources:
if not os.path.isfile(self.path + src): if not os.path.isfile(self.path + src):
print(f"\nslpkg: Error: Source file '{src}' not found\n") raise SystemExit(f"\nslpkg: Error: Source file '{src}' "
raise SystemExit() f"not found\n")

View file

@ -40,9 +40,11 @@ class BuildNumber(Utils):
def get(self): def get(self):
num = "NO_BUILD" num = "NO_BUILD"
if self.sbo_url: if self.sbo_url:
SlackBuild = URL(f"{self.sbo_url}{self.pkg}.SlackBuild").reading() SlackBuild = URL(f"{self.sbo_url}"
f"{self.pkg}.SlackBuild").get_request()
else: else:
SlackBuild = self.read_file(f"{self.meta.build_path}{self.pkg}/{self.pkg}.SlackBuild") SlackBuild = self.read_file(f"{self.meta.build_path}{self.pkg}/"
f"{self.pkg}.SlackBuild")
for line in SlackBuild.splitlines(): for line in SlackBuild.splitlines():
line = line.lstrip() line = line.lstrip()
if line.startswith("BUILD="): if line.startswith("BUILD="):

View file

@ -23,6 +23,7 @@
import sys import sys
from functools import lru_cache
from slpkg.blacklist import BlackList from slpkg.blacklist import BlackList
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
@ -41,6 +42,7 @@ class Requires(BlackList):
self.blacklist = list(self.get_black()) self.blacklist = list(self.get_black())
self.dep_results = [] self.dep_results = []
@lru_cache
def sbo(self, name): def sbo(self, name):
"""Build all dependencies of a package """Build all dependencies of a package
""" """
@ -55,11 +57,12 @@ class Requires(BlackList):
# if require in blacklist # if require in blacklist
if "%README%" not in req and req not in self.blacklist: if "%README%" not in req and req not in self.blacklist:
dependencies.append(req) dependencies.append(req)
self.deep_check(dependencies) self.deep_check(tuple(dependencies))
return self.dep_results return self.dep_results
else: else:
return [] return []
@lru_cache
def deep_check(self, dependencies): def deep_check(self, dependencies):
"""Checking if dependencies are finnished """Checking if dependencies are finnished
""" """

View file

@ -172,8 +172,7 @@ class SBoNetwork(BlackList, Utils):
message = " Choose an option > " message = " Choose an option > "
self.choice = input(f"{self.grey}{message}{self.endc}") self.choice = input(f"{self.grey}{message}{self.endc}")
except EOFError: except EOFError:
print() raise SystemExit('\n')
raise SystemExit()
try: try:
print("{0}\x1b[1A{1}{2}{3}\n".format( print("{0}\x1b[1A{1}{2}{3}\n".format(
" " * len(message), self.cyan, commands[self.choice], " " * len(message), self.cyan, commands[self.choice],
@ -301,10 +300,9 @@ class SBoNetwork(BlackList, Utils):
status = False status = False
pkg = DialogUtil(data, text, title, backtitle, status).checklist() pkg = DialogUtil(data, text, title, backtitle, status).checklist()
if pkg and len(pkg) > 1: if pkg and len(pkg) > 1:
print("\nslpkg: Error: Choose only one package") raise SystemExit("\nslpkg: Error: Choose only one package")
raise SystemExit()
if pkg is None: if pkg is None:
raise SystemExit() raise SystemExit(1)
self.name = "".join(pkg) self.name = "".join(pkg)
os.system("clear") os.system("clear")

View file

@ -136,8 +136,8 @@ class QueuePkgs(Utils):
BuildPackage(script, sources, self.meta.build_path, BuildPackage(script, sources, self.meta.build_path,
auto=False).build() auto=False).build()
else: else:
print("\nPackages not found in the queue for building\n") raise SystemExit("\nPackages not found in the queue for "
raise SystemExit(1) "building\n")
def install(self): def install(self):
"""Install packages from queue """Install packages from queue
@ -152,8 +152,8 @@ class QueuePkgs(Utils):
binary = slack_package(prgnam) binary = slack_package(prgnam)
PackageManager(binary).upgrade(flag="--install-new") PackageManager(binary).upgrade(flag="--install-new")
else: else:
print(f"\nPackage {prgnam} not found in the {self.meta.output} for " print(f"\nPackage {prgnam} not found in the "
f"installation\n") f"{self.meta.output} for installation\n")
else: else:
print("\nPackages not found in the queue for installation\n") raise SystemExit("\nPackages not found in the queue for "
raise SystemExit(1) "installation\n")

View file

@ -34,19 +34,19 @@ class ReadSBo:
def readme(self, sbo_readme): def readme(self, sbo_readme):
"""Read SlackBuild README file """Read SlackBuild README file
""" """
return URL(self.sbo_url + sbo_readme).reading() return URL(self.sbo_url + sbo_readme).get_request()
def info(self, name, sbo_file): def info(self, name, sbo_file):
"""Read info file """Read info file
""" """
return URL(self.sbo_url + name + sbo_file).reading() return URL(self.sbo_url + name + sbo_file).get_request()
def slackbuild(self, name, sbo_file): def slackbuild(self, name, sbo_file):
"""Read SlackBuild file """Read SlackBuild file
""" """
return URL(self.sbo_url + name + sbo_file).reading() return URL(self.sbo_url + name + sbo_file).get_request()
def doinst(self, doinst_sh): def doinst(self, doinst_sh):
"""Read SlackBuild doinst.sh """Read SlackBuild doinst.sh
""" """
return URL(self.sbo_url + doinst_sh).reading() return URL(self.sbo_url + doinst_sh).get_request()

View file

@ -153,12 +153,13 @@ class SBoInstall(BlackList, Utils):
if self.match and [""] != self.slackbuilds: if self.match and [""] != self.slackbuilds:
print("\nMatching summary") print("\nMatching summary")
print("=" * 79) print("=" * 79)
print(f"Total {count_total} matching packages\n") raise SystemExit(f"Total {count_total} matching packages\n")
raise SystemExit(1)
print("\nInstalling summary") print("\nInstalling summary")
print("=" * 79) print("=" * 79)
print(f"{self.grey}Total {count_total} {self.msg.pkg(count_total)}.") print(f"{self.grey}Total {count_total} "
print(f"{self.count_uni} {self.msg.pkg(self.count_uni)} will be installed, " f"{self.msg.pkg(count_total)}.")
print(f"{self.count_uni} {self.msg.pkg(self.count_uni)} "
f"will be installed, "
f"{self.count_ins} already installed and " f"{self.count_ins} already installed and "
f"{self.count_upg} {self.msg.pkg(self.count_upg)}") f"{self.count_upg} {self.msg.pkg(self.count_upg)}")
print(f"will be upgraded.{self.endc}\n") print(f"will be upgraded.{self.endc}\n")
@ -338,14 +339,16 @@ class SBoInstall(BlackList, Utils):
self.msg.template(78) self.msg.template(78)
elif self.unst[0] in src_link or self.unst[1] in src_link: elif self.unst[0] in src_link or self.unst[1] in src_link:
self.msg.template(78) self.msg.template(78)
print(f"| Package {prgnam} {self.red}{''.join(src_link)}{self.endc}") print(f"| Package {prgnam} {self.red}"
f"{''.join(src_link)}{self.endc}")
self.msg.template(78) self.msg.template(78)
else: else:
sbo_url = sbo_search_pkg(pkg) sbo_url = sbo_search_pkg(pkg)
sbo_link = SBoLink(sbo_url).tar_gz() sbo_link = SBoLink(sbo_url).tar_gz()
script = sbo_link.split("/")[-1] script = sbo_link.split("/")[-1]
if self.meta.sbosrcarch in ["on", "ON"]: if self.meta.sbosrcarch in ["on", "ON"]:
src_link = list(self.sbosrcarsh(prgnam, sbo_link, src_link)) src_link = list(self.sbosrcarsh(prgnam, sbo_link,
src_link))
Download(self.build_folder, sbo_link.split(), Download(self.build_folder, sbo_link.split(),
repo="sbo").start() repo="sbo").start()
Download(self._SOURCES, src_link, repo="sbo").start() Download(self._SOURCES, src_link, repo="sbo").start()
@ -357,10 +360,12 @@ class SBoInstall(BlackList, Utils):
binary = slack_package(prgnam) binary = slack_package(prgnam)
if os.path.isfile("".join(binary)): if os.path.isfile("".join(binary)):
if GetFromInstalled(pkg).name() == pkg: if GetFromInstalled(pkg).name() == pkg:
print(f"[ {self.yellow}Upgrading{self.endc} ] --> {prgnam}") print(f"[ {self.yellow}Upgrading{self.endc} ] --> "
f"{prgnam}")
upgraded.append(prgnam) upgraded.append(prgnam)
else: else:
print(f"[ {self.green}Installing{self.endc} ] --> {prgnam}") print(f"[ {self.green}Installing{self.endc} ] --> "
f"{prgnam}")
installs.append(prgnam) installs.append(prgnam)
if ("--rebuild" in self.flag and if ("--rebuild" in self.flag and
GetFromInstalled(pkg).name() == pkg): GetFromInstalled(pkg).name() == pkg):

View file

@ -68,11 +68,11 @@ class Patches(BlackList, Utils):
self.msg = Msg() self.msg = Msg()
self.version = self.meta.slack_rel self.version = self.meta.slack_rel
self.patch_path = self.meta.slpkg_tmp_patches self.patch_path = self.meta.slpkg_tmp_patches
self.count_added = 0
self.count_upg = 0
self.pkg_for_upgrade = [] self.pkg_for_upgrade = []
self.dwn_links = [] self.dwn_links = []
self.upgrade_all = [] self.upgrade_all = []
self.count_added = 0
self.count_upg = 0
self.upgraded = [] self.upgraded = []
self.installed = [] self.installed = []
self.comp_sum = [] self.comp_sum = []
@ -80,9 +80,9 @@ class Patches(BlackList, Utils):
self.msg.checking() self.msg.checking()
if self.version == "stable": if self.version == "stable":
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT",
"patches/")).reading() "patches/")).get_request()
else: else:
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "")).reading() self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "")).get_request()
def start(self): def start(self):
"""Install new patches from official Slackware mirrors """Install new patches from official Slackware mirrors
@ -251,8 +251,7 @@ class Patches(BlackList, Utils):
answer = input("\nThe kernel has been upgraded, " answer = input("\nThe kernel has been upgraded, "
"reinstall boot loader [L/E/G]? ") "reinstall boot loader [L/E/G]? ")
except EOFError: except EOFError:
print() raise SystemExit("\n")
raise SystemExit()
if answer in ["L"]: if answer in ["L"]:
subprocess.call("lilo", shell=True) subprocess.call("lilo", shell=True)
break break
@ -268,7 +267,7 @@ class Patches(BlackList, Utils):
"""This replace slackpkg ChangeLog.txt file with new """This replace slackpkg ChangeLog.txt file with new
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", "")).get_request()
if os.path.isfile(f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old"): if os.path.isfile(f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old"):
os.remove(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"): if os.path.isfile(f"{self.meta.slackpkg_lib_path}ChangeLog.txt"):

View file

@ -40,5 +40,4 @@ def slack_ver():
return (".".join(version[:2])) return (".".join(version[:2]))
else: else:
return (".".join(version)) return (".".join(version))
else:
return _meta_.slackware_version return _meta_.slackware_version

View file

@ -47,7 +47,7 @@ def it_self_update():
_meta_.__all__, _meta_.__all__,
branch, branch,
_meta_.__all__)) _meta_.__all__))
version_data = URL(ver_link).reading() version_data = URL(ver_link).get_request()
for line in version_data.splitlines(): for line in version_data.splitlines():
line = line.strip() line = line.strip()
@ -63,8 +63,7 @@ def it_self_update():
try: try:
answer = input("Would you like to upgrade [y/N]? ") answer = input("Would you like to upgrade [y/N]? ")
except EOFError: except EOFError:
print() raise SystemExit("\n")
raise SystemExit(1)
if answer in ["y", "Y"]: if answer in ["y", "Y"]:
print() # new line after answer print() # new line after answer
@ -96,5 +95,6 @@ def it_self_update():
subprocess.call("sh install.sh", shell=True) subprocess.call("sh install.sh", shell=True)
else: else:
print(f"\n{_meta_.__all__}: There is no new version, already used the last!\n") print(f"\n{_meta_.__all__}: There is no new version, "
"already you use the last!\n")
raise SystemExit() raise SystemExit()

View file

@ -118,10 +118,10 @@ class DependenciesStatus(Utils):
def no_logs(self): def no_logs(self):
"""Print message if no logs found """Print message if no logs found
""" """
print("\n There were no logs files. Obviously not used the\n" raise SystemExit("\n There were no logs files. "
"Obviously not used the\n"
" installation method with the command:\n" " installation method with the command:\n"
" '$ slpkg -s <repository> <packages>' yet.\n") " '$ slpkg -s <repository> <packages>' yet.\n")
raise SystemExit()
def summary(self): def summary(self):
"""Summary by packages and dependencies """Summary by packages and dependencies

View file

@ -30,13 +30,12 @@ def s_user():
"""Check for root user """Check for root user
""" """
if getpass.getuser() != "root": if getpass.getuser() != "root":
print("\nslpkg: Error: Must have root privileges\n") raise SystemExit("\nslpkg: Error: Must have root privileges\n")
raise SystemExit(1)
def virtual_env(): def virtual_env():
"""Check if a virtual enviroment exists """Check if a virtual enviroment exists
""" """
if "VIRTUAL_ENV" in os.environ.keys(): if "VIRTUAL_ENV" in os.environ.keys():
print("\nslpkg: Error: Please exit from virtual environment first\n") raise SystemExit("\nslpkg: Error: Please exit from virtual "
raise SystemExit(1) "environment first\n")

View file

@ -121,8 +121,7 @@ class TrackingDeps(BlackList, Utils):
self.graph() self.graph()
else: else:
self.msg.done() self.msg.done()
print("\nNo package was found to match\n") raise SystemExit("\nNo package was found to match\n")
raise SystemExit(1)
def repositories(self): def repositories(self):
"""Get dependencies by repositories """Get dependencies by repositories

View file

@ -40,12 +40,13 @@ class URL:
else: else:
self.http = urllib3.PoolManager() self.http = urllib3.PoolManager()
def reading(self): def get_request(self):
"""Open url and read """Open url and read
""" """
try: try:
f = self.http.request('GET', self.link) f = self.http.request('GET', self.link)
return f.data.decode("utf-8", "ignore") return f.data.decode("utf-8", "ignore")
except urllib3.exceptions.NewConnectionError: except urllib3.exceptions.NewConnectionError:
print(f"\n{self.red}Can't read the file '{self.link.split('/')[-1]}'{self.endc}") print(f"\n{self.red}Can't read the file "
f"'{self.link.split('/')[-1]}'{self.endc}")
return " " return " "

View file

@ -1,12 +1,19 @@
import unittest
from slpkg.file_size import FileSize from slpkg.file_size import FileSize
def test_FileSize(): class TestFileSize(unittest.TestCase):
def test_FileSize(self):
"""Testing the remote and local servers """Testing the remote and local servers
""" """
url = "https://mirrors.slackware.com/slackware/slackware64-14.2/ChangeLog.txt" url = "https://mirrors.slackware.com/slackware/slackware64-14.2/ChangeLog.txt"
lc = "tests/test_units.py" lc = "test_units.py"
fs1 = FileSize(url) fs1 = FileSize(url)
fs2 = FileSize(lc) fs2 = FileSize(lc)
assert fs1.server() is not None self.assertIsNotNone(fs1.server())
assert fs2.local() is not None self.assertIsNotNone(fs2.local())
if __name__ == "__main__":
unittest.main()

23
tests/test_installed.py Normal file
View file

@ -0,0 +1,23 @@
import unittest
from slpkg.pkg.installed import GetFromInstalled
class TestPkgInstalled(unittest.TestCase):
def setUp(self):
self.pkg_name = 'aaa_base'
self.pkg_ver = '15.0'
self.installed = GetFromInstalled('aaa_base')
def test_pkg_name(self):
"""Testing the installed package name
"""
self.assertEqual(self.pkg_name, self.installed.name())
def test_pkg_version(self):
"""Testing the version of installed package"""
self.assertEqual(self.pkg_ver, self.installed.version())
if __name__ == "__main__":
unittest.main()

View file

@ -1,15 +1,21 @@
import unittest
from slpkg.md5sum import md5 from slpkg.md5sum import md5
def test_md5_superuser(): class TestMd5(unittest.TestCase):
def test_md5_superuser(self):
"""Testing checksum for superuser.py file """Testing checksum for superuser.py file
""" """
result = md5('slpkg/superuser.py') result = md5('test_file_size.py')
assert result == "c6a3576c247bda199c75b43540bfc3d7" self.assertEqual(result, "e3e7b72be80efc922b0e1f1cd409a417")
def test_md5_security(self):
def test_md5_security():
"""Testing checksum for security.py file """Testing checksum for security.py file
""" """
result = md5('slpkg/security.py') result = md5('test_units.py')
assert result == "eb8dbea4dec6d72353d30475670389f0" self.assertEqual(result, "58a694171449e923414e3e3339a0097e")
if __name__ == "__main__":
unittest.main()

49
tests/test_sbo_grep.py Normal file
View file

@ -0,0 +1,49 @@
import unittest
from slpkg.sbo.greps import SBoGrep
class TestSBoGreps(unittest.TestCase):
def setUp(self):
self.grep = SBoGrep('Flask')
def test_source(self):
"""Test package source
"""
source = self.grep.source()
flask_source = ('https://files.pythonhosted.org/packages/4e/0b/'
'cb02268c90e67545a0e3a37ea1ca3d45de3aca43ceb7dbf'
'1712fb5127d5d/Flask-1.1.2.tar.gz')
self.assertEqual(source, flask_source)
def test_requires(self):
"""Test package requires
"""
requires = self.grep.requires()
flask_dep = ['werkzeug', 'python3-itsdangerous', 'click']
self.assertListEqual(requires, flask_dep)
def test_version(self):
"""Test package version
"""
version = self.grep.version()
flask_ver = '1.1.2'
self.assertEqual(version, flask_ver)
def test_checksum(self):
"""Test package checksum
"""
checksum = self.grep.checksum()
flask_md5 = ['0da4145d172993cd28a6c619630cc19c']
self.assertListEqual(checksum, flask_md5)
def test_description(self):
"""Test package description
"""
desc = self.grep.description()
flask_desc = 'Flask (Microframework for Python)'
self.assertEqual(desc, flask_desc)
if __name__ == "__main__":
unittest.main()

View file

@ -1,22 +1,25 @@
import pytest import unittest
from slpkg.binary.search import search_pkg from slpkg.binary.search import search_pkg
from slpkg.sbo.search import sbo_search_pkg from slpkg.sbo.search import sbo_search_pkg
@pytest.mark.skip(reason="no way of currently testing in Gitlab") class TestFindPkg(unittest.TestCase):
def test_search():
def test_search(self):
"""Testing found the name from binaries repos """Testing found the name from binaries repos
""" """
name = "vlc" name = "vlc"
repo = "alien" repo = "alien"
test = search_pkg(name, repo) test = search_pkg(name, repo)
assert name == test self.assertEqual(name, test)
def test_sbo_search(self):
@pytest.mark.skip(reason="no way of currently testing in Gtilab")
def test_sbo_search():
"""Testing found the name from binaries repos """Testing found the name from binaries repos
""" """
name = "slpkg" name = "slpkg"
test = sbo_search_pkg(name).split("/")[-2] test = sbo_search_pkg(name).split("/")[-2]
assert name == test self.assertEqual(name, test)
if __name__ == "__main__":
unittest.main()

View file

@ -0,0 +1,15 @@
import unittest
from slpkg.slack.slack_version import slack_ver
class TestSlackVersion(unittest.TestCase):
def test_slack_version(self):
"""Testing the current Slackware version
"""
ver = '15.0'
self.assertEqual(ver, slack_ver())
if __name__ == "__main__":
unittest.main()

View file

@ -0,0 +1,26 @@
import unittest
from slpkg.splitting import split_package
from slpkg.pkg.find import searching
class TestSplitting(unittest.TestCase):
def test_split_pkg(self):
path = '/var/log/packages/'
pkg_1 = ''.join(list(searching('slpkg', path)))
pkg_2 = ''.join(list(searching('akonadi-mime', path)))
pkg_3 = ''.join(list(searching('autoconf-archive', path)))
pkg_4 = ''.join(list(searching('bind', path)))
self.assertListEqual(['slpkg', '3.9.6', 'x86_64', '1'],
split_package(pkg_1))
self.assertListEqual(['akonadi-mime', '21.12.1', 'x86_64', '1'],
split_package(pkg_2))
self.assertListEqual(['autoconf-archive', '2021.02.19', 'noarch', '1'],
split_package(pkg_3))
self.assertListEqual(['bind', '9.16.27', 'x86_64', '1'],
split_package(pkg_4))
if __name__ == "__main__":
unittest.main()

View file

@ -1,7 +1,19 @@
import unittest
from slpkg.sizes import units from slpkg.sizes import units
def test_units(): class TetsUnits(unittest.TestCase):
def test_units(self):
"""Testing the units metrics """Testing the units metrics
""" """
assert ["Kb", "Kb"], ["100", "100"] == units(['100', ['100']]) self.assertCountEqual((["Kb", "Kb"], [100, 100]),
units(["100"], ["100"]))
self.assertCountEqual((["Mb", "Mb"], [1000, 1000]),
units(["1024000"], ["1024000"]))
self.assertCountEqual((["Gb", "Gb"], [976.56, 976.56]),
units(["1024000000"], ["1024000000"]))
if __name__ == "__main__":
unittest.main()

View file

@ -1,17 +1,34 @@
import unittest
from slpkg.utils import Utils from slpkg.utils import Utils
def test_dimensional_list(): class TestUtils(unittest.TestCase):
def setUp(self):
self.utils = Utils()
def test_dimensional_list(self):
"""Testing dimesional list util """Testing dimesional list util
""" """
lists = [[1, 2, 3, 4, 5]] lists = [[1, 2, 3, 4, 5]]
utils = Utils() self.assertListEqual([1, 2, 3, 4, 5],
assert [1, 2, 3, 4, 5] == utils.dimensional_list(lists) self.utils.dimensional_list(lists))
def test_remove_dbs(self):
def test_remove_dbs():
"""Testing removing doubles item from list """Testing removing doubles item from list
""" """
lists = [1, 2, 3, 3, 4, 5, 2, 1] lists = [1, 2, 3, 3, 4, 5, 2, 1]
utils = Utils() self.assertListEqual([1, 2, 3, 4, 5], self.utils.remove_dbs(lists))
assert [1, 2, 3, 4, 5] == utils.remove_dbs(lists)
def test_case_sensitive(self):
"""Testing case sensitive
"""
lists = ['Vlc', 'OpenOffice', 'APScheduler']
dictionary = {'vlc': 'Vlc',
'openoffice': 'OpenOffice',
'apscheduler': 'APScheduler'}
self.assertDictEqual(dictionary, self.utils.case_sensitive(lists))
if __name__ == "__main__":
unittest.main()