mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-29 20:34:22 +01:00
Updated for data
This commit is contained in:
parent
0f5eb1942f
commit
a6b161e4ee
14 changed files with 144 additions and 190 deletions
|
@ -22,10 +22,10 @@ from slpkg.models.models import session as Session
|
|||
|
||||
class Packages(Configs):
|
||||
|
||||
def __init__(self, bin_repo_dict: dict, packages: list, flags: list, repo: str, mode: str):
|
||||
__slots__ = 'bin_repo_dict', 'packages', 'flags', 'repo', 'mode'
|
||||
def __init__(self, data: dict, packages: list, flags: list, repo: str, mode: str):
|
||||
__slots__ = 'data', 'packages', 'flags', 'repo', 'mode'
|
||||
super(Configs, self).__init__()
|
||||
self.bin_repo_dict: dict = bin_repo_dict
|
||||
self.data: dict = data
|
||||
self.packages: list = packages
|
||||
self.flags: list = flags
|
||||
self.repo: str = repo
|
||||
|
@ -36,7 +36,7 @@ class Packages(Configs):
|
|||
self.utils = Utilities()
|
||||
self.repos = Repositories()
|
||||
self.dialogbox = DialogBox()
|
||||
self.upgrade = Upgrade(self.flags, self.repo)
|
||||
self.upgrade = Upgrade(self.flags, self.data, self.repo)
|
||||
self.view_message = ViewMessage(self.flags, self.repo)
|
||||
self.session = Session
|
||||
|
||||
|
@ -110,15 +110,15 @@ class Packages(Configs):
|
|||
for pkg in self.install_order:
|
||||
|
||||
if self.continue_install(pkg):
|
||||
package: str = self.bin_repo_dict[pkg][1]
|
||||
mirror: str = self.bin_repo_dict[pkg][2]
|
||||
location: str = self.bin_repo_dict[pkg][3]
|
||||
package: str = self.data[pkg][1]
|
||||
mirror: str = self.data[pkg][2]
|
||||
location: str = self.data[pkg][3]
|
||||
|
||||
pkg_urls.append(f'{mirror}{location}/{package}')
|
||||
self.binary_packages.append(package)
|
||||
self.utils.remove_file_if_exists(self.tmp_slpkg, package)
|
||||
else:
|
||||
version: str = self.bin_repo_dict[pkg][0]
|
||||
version: str = self.data[pkg][0]
|
||||
self.view_message.view_skipping_packages(pkg, version)
|
||||
|
||||
if pkg_urls:
|
||||
|
@ -147,7 +147,7 @@ class Packages(Configs):
|
|||
md5 = Md5sum(self.flags)
|
||||
for package in self.binary_packages:
|
||||
name: str = self.utils.split_binary_pkg(package[:-4])[0]
|
||||
pkg_checksum: str = self.bin_repo_dict[name][10]
|
||||
pkg_checksum: str = self.data[name][10]
|
||||
md5.check(self.tmp_slpkg, package, pkg_checksum)
|
||||
|
||||
def install_packages(self) -> None:
|
||||
|
@ -237,7 +237,7 @@ class Packages(Configs):
|
|||
for package in dependencies:
|
||||
status: bool = False
|
||||
|
||||
repo_ver: str = self.bin_repo_dict[package][0]
|
||||
repo_ver: str = self.data[package][0]
|
||||
help_text: str = f'Package: {package} {repo_ver}'
|
||||
upgradable: bool = self.upgrade.is_package_upgradeable(package)
|
||||
installed: str = self.utils.is_package_installed(package)
|
||||
|
|
|
@ -15,12 +15,11 @@ from slpkg.models.models import SBoTable, PonceTable, BinariesTable
|
|||
class Check(Configs):
|
||||
""" Some checks before proceed. """
|
||||
|
||||
def __init__(self, flags: list, sbo_repo_dict: dict, bin_repo_dict: dict):
|
||||
def __init__(self, flags: list, data: dict):
|
||||
__slots__ = 'flags', 'sbo_repo_dict', 'bin_repo_dict'
|
||||
super(Configs, self).__init__()
|
||||
self.flags: list = flags
|
||||
self.sbo_repo_dict: dict = sbo_repo_dict
|
||||
self.bin_repo_dict: dict = bin_repo_dict
|
||||
self.data: dict = data
|
||||
|
||||
self.black = Blacklist()
|
||||
self.utils = Utilities()
|
||||
|
@ -43,10 +42,10 @@ class Check(Configs):
|
|||
for pkg in packages:
|
||||
|
||||
if self.utils.is_option(self.flag_bin_repository, self.flags):
|
||||
if not self.bin_repo_dict.get(pkg) and pkg != '*':
|
||||
if not self.data.get(pkg) and pkg != '*':
|
||||
not_packages.append(pkg)
|
||||
else:
|
||||
if not self.sbo_repo_dict.get(pkg) and pkg != '*':
|
||||
if not self.data.get(pkg) and pkg != '*':
|
||||
not_packages.append(pkg)
|
||||
|
||||
if not_packages:
|
||||
|
@ -56,10 +55,10 @@ class Check(Configs):
|
|||
""" Checking for unsupported slackbuilds. """
|
||||
for sbo in slackbuilds:
|
||||
if sbo != '*':
|
||||
if self.os_arch == 'x86_64' and self.sbo_repo_dict[sbo][4]:
|
||||
sources: list = self.sbo_repo_dict[sbo][4].split()
|
||||
if self.os_arch == 'x86_64' and self.data[sbo][4]:
|
||||
sources: list = self.data[sbo][4].split()
|
||||
else:
|
||||
sources: list = self.sbo_repo_dict[sbo][3].split()
|
||||
sources: list = self.data[sbo][3].split()
|
||||
|
||||
if 'UNSUPPORTED' in sources:
|
||||
self.utils.raise_error_message(f"Package '{sbo}' unsupported by arch")
|
||||
|
|
|
@ -7,8 +7,8 @@ from typing import Union
|
|||
from urllib.parse import unquote
|
||||
|
||||
from slpkg.views.ascii import Ascii
|
||||
from slpkg.views.views import ViewMessage
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.views.views import ViewMessage
|
||||
|
||||
|
||||
class Md5sum:
|
||||
|
|
|
@ -5,17 +5,16 @@ from typing import Generator
|
|||
from slpkg.configs import Configs
|
||||
from slpkg.views.ascii import Ascii
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.sbos.queries import SBoQueries
|
||||
from slpkg.repositories import Repositories
|
||||
from slpkg.binaries.queries import BinQueries
|
||||
|
||||
|
||||
class Dependees(Configs):
|
||||
""" Show which packages depend. """
|
||||
|
||||
def __init__(self, packages: list, flags: list):
|
||||
def __init__(self, data: dict, packages: list, flags: list):
|
||||
__slots__ = 'packages', 'flags'
|
||||
super(Configs, self).__init__()
|
||||
self.data: dict = data
|
||||
self.packages: list = packages
|
||||
self.flags: list = flags
|
||||
|
||||
|
@ -24,8 +23,6 @@ class Dependees(Configs):
|
|||
self.color = self.colour()
|
||||
self.utils = Utilities()
|
||||
|
||||
self.bin_repo_dict: dict = {}
|
||||
self.sbo_repo_dict: dict = {}
|
||||
self.llc: str = self.ascii.lower_left_corner
|
||||
self.hl: str = self.ascii.horizontal_line
|
||||
self.var: str = self.ascii.vertical_and_right
|
||||
|
@ -40,17 +37,12 @@ class Dependees(Configs):
|
|||
self.flag_pkg_version: list = ['-p', '--pkg-version']
|
||||
self.flag_bin_repository: list = ['-B', '--bin-repo=']
|
||||
|
||||
def find(self, repo: str) -> None:
|
||||
def find(self) -> None:
|
||||
""" Collecting the dependees. """
|
||||
print(f"The list below shows the "
|
||||
f"packages that dependees on '{', '.join([p for p in self.packages])}':\n")
|
||||
|
||||
self.packages: list = self.utils.apply_package_pattern(self.flags, self.packages, repo)
|
||||
|
||||
if self.utils.is_option(self.flag_bin_repository, self.flags):
|
||||
self.bin_repo_dict: dict = BinQueries(repo).repository_data()
|
||||
else:
|
||||
self.sbo_repo_dict: dict = SBoQueries().repository_data()
|
||||
self.packages: list = self.utils.apply_package_pattern(self.data, self.packages)
|
||||
|
||||
for pkg in self.packages:
|
||||
dependees: list = list(self.find_requires(pkg))
|
||||
|
@ -59,9 +51,9 @@ class Dependees(Configs):
|
|||
|
||||
if self.utils.is_option(self.flag_pkg_version, self.flags):
|
||||
if self.utils.is_option(self.flag_bin_repository, self.flags):
|
||||
version: str = self.bin_repo_dict[pkg][0]
|
||||
version: str = self.data[pkg][0]
|
||||
else:
|
||||
version: str = self.sbo_repo_dict[pkg][2]
|
||||
version: str = self.data[pkg][2]
|
||||
|
||||
package: str = f'{self.byellow}{pkg} {version}{self.endc}'
|
||||
|
||||
|
@ -79,9 +71,9 @@ class Dependees(Configs):
|
|||
if self.utils.is_option(self.flag_pkg_version, self.flags):
|
||||
|
||||
if self.utils.is_option(self.flag_bin_repository, self.flags):
|
||||
version: str = self.bin_repo_dict[dep[0]][0]
|
||||
version: str = self.data[dep[0]][0]
|
||||
else:
|
||||
version: str = self.sbo_repo_dict[dep[0]][2]
|
||||
version: str = self.data[dep[0]][2]
|
||||
|
||||
dependency: str = (f'{self.cyan}{dep[0]}{self.endc} {self.yellow}'
|
||||
f'{version}{self.endc}')
|
||||
|
@ -103,14 +95,14 @@ class Dependees(Configs):
|
|||
""" Find requires that package dependees. """
|
||||
if self.utils.is_option(self.flag_bin_repository, self.flags):
|
||||
|
||||
for name, data in self.bin_repo_dict.items():
|
||||
for name, data in self.data.items():
|
||||
if name:
|
||||
for req in data[6].split():
|
||||
if req == pkg:
|
||||
|
||||
yield [name, data[6]]
|
||||
else:
|
||||
for name, data in self.sbo_repo_dict.items():
|
||||
for name, data in self.data.items():
|
||||
if name:
|
||||
for req in data[7].split():
|
||||
if req == pkg:
|
||||
|
|
|
@ -9,9 +9,7 @@ from slpkg.configs import Configs
|
|||
from slpkg.utilities import Utilities
|
||||
from slpkg.downloader import Downloader
|
||||
from slpkg.views.views import ViewMessage
|
||||
from slpkg.sbos.queries import SBoQueries
|
||||
from slpkg.repositories import Repositories
|
||||
from slpkg.binaries.queries import BinQueries
|
||||
from slpkg.models.models import session as Session
|
||||
|
||||
|
||||
|
@ -31,9 +29,9 @@ class Download(Configs):
|
|||
self.flag_directory: list = ['-z', '--directory=']
|
||||
self.flag_bin_repository: list = ['-B', '--bin-repo=']
|
||||
|
||||
def packages(self, packages: list, repo=None) -> None:
|
||||
def packages(self, data: dict, packages: list, repo=None) -> None:
|
||||
""" Download the package only. """
|
||||
packages: list = self.utils.apply_package_pattern(self.flags, packages, repo)
|
||||
packages: list = self.utils.apply_package_pattern(data, packages)
|
||||
view = ViewMessage(self.flags, repo)
|
||||
view.download_packages(packages, self.directory)
|
||||
view.question()
|
||||
|
@ -47,18 +45,16 @@ class Download(Configs):
|
|||
for pkg in packages:
|
||||
|
||||
if self.utils.is_option(self.flag_bin_repository, self.flags):
|
||||
bin_repo_dict: dict = BinQueries(repo).repository_data()
|
||||
package: str = bin_repo_dict[pkg][1]
|
||||
mirror: str = bin_repo_dict[pkg][2]
|
||||
location: str = bin_repo_dict[pkg][3]
|
||||
package: str = data[pkg][1]
|
||||
mirror: str = data[pkg][2]
|
||||
location: str = data[pkg][3]
|
||||
urls.append(f'{mirror}{location}/{package}')
|
||||
else:
|
||||
sbo_repo_dict: dict = SBoQueries().repository_data()
|
||||
location: str = sbo_repo_dict[pkg][0]
|
||||
if self.os_arch == 'x86_64' and sbo_repo_dict[pkg][4]:
|
||||
sources = sbo_repo_dict[pkg][4].split()
|
||||
location: str = data[pkg][0]
|
||||
if self.os_arch == 'x86_64' and data[pkg][4]:
|
||||
sources = data[pkg][4].split()
|
||||
else:
|
||||
sources = sbo_repo_dict[pkg][3].split()
|
||||
sources = data[pkg][3].split()
|
||||
|
||||
urls += sources
|
||||
|
||||
|
|
|
@ -59,8 +59,7 @@ class Argparse(Configs):
|
|||
if len(self.args) == 0 or '' in self.args:
|
||||
self.usage.help_short(1)
|
||||
|
||||
self.sbo_repo_dict: dict = {}
|
||||
self.bin_repo_dict: dict = {}
|
||||
self.data: dict = {}
|
||||
self.flag_yes: str = '--yes'
|
||||
self.flag_short_yes: str = '-y'
|
||||
self.flag_jobs: str = '--jobs'
|
||||
|
@ -286,11 +285,11 @@ class Argparse(Configs):
|
|||
self.check_for_bin_repositories()
|
||||
|
||||
if self.utils.is_option(self.flag_binaries, self.flags):
|
||||
self.bin_repo_dict: dict = BinQueries(self.binary_repo).repository_data()
|
||||
self.data: dict = BinQueries(self.binary_repo).repository_data()
|
||||
else:
|
||||
self.sbo_repo_dict: dict = SBoQueries().repository_data()
|
||||
self.data: dict = SBoQueries().repository_data()
|
||||
|
||||
self.check = Check(self.flags, self.sbo_repo_dict, self.bin_repo_dict)
|
||||
self.check = Check(self.flags, self.data)
|
||||
self.check.is_blacklist(self.args[1:])
|
||||
|
||||
logging.basicConfig(filename=LoggingConfig.log_file,
|
||||
|
@ -434,10 +433,7 @@ class Argparse(Configs):
|
|||
choices: list = []
|
||||
title: str = f' Choose packages you want to {method} '
|
||||
|
||||
if self.utils.is_option(self.flag_binaries, self.flags):
|
||||
repo_packages: list = list(self.bin_repo_dict.keys())
|
||||
else:
|
||||
repo_packages: list = list(self.sbo_repo_dict.keys())
|
||||
repo_packages: list = list(self.data.keys())
|
||||
|
||||
installed: list = self.utils.installed_packages
|
||||
|
||||
|
@ -460,12 +456,13 @@ class Argparse(Configs):
|
|||
split_inst_pkg: list = self.utils.split_binary_pkg(inst_pkg)
|
||||
|
||||
if self.utils.is_option(self.flag_binaries, self.flags):
|
||||
repo_ver: str = self.bin_repo_dict[package][0]
|
||||
bin_pkg: str = self.bin_repo_dict[package][1]
|
||||
repo_ver: str = self.data[package][0]
|
||||
bin_pkg: str = self.data[package][1]
|
||||
repo_build_tag: str = self.utils.split_binary_pkg(bin_pkg[:-4])[3]
|
||||
else:
|
||||
repo_ver: str = self.sbo_repo_dict[package][2]
|
||||
repo_build_tag: str = self.utils.read_sbo_build_tag(package)
|
||||
repo_ver: str = self.data[package][2]
|
||||
repo_location: str = self.data[package][0]
|
||||
repo_build_tag: str = self.utils.read_sbo_build_tag(package, repo_location)
|
||||
|
||||
choices += [(package, f'{split_inst_pkg[1]} -> {repo_ver}', True,
|
||||
f'Installed: {package}-{split_inst_pkg[1]} Build: {split_inst_pkg[3]} -> '
|
||||
|
@ -476,12 +473,12 @@ class Argparse(Configs):
|
|||
if pkg in package:
|
||||
if self.utils.is_option(self.flag_binaries, self.flags):
|
||||
try:
|
||||
repo_ver: str = self.bin_repo_dict[pkg][0]
|
||||
repo_ver: str = self.data[pkg][0]
|
||||
except KeyError:
|
||||
repo_ver: str = ''
|
||||
repo: str = self.binary_repo
|
||||
else:
|
||||
repo_ver: str = self.sbo_repo_dict[package][2]
|
||||
repo_ver: str = self.data[package][2]
|
||||
repo: str = self.repos.sbo_enabled_repository
|
||||
choices += [(package, repo_ver, False, f'Package: {package}-{repo_ver} '
|
||||
f'> {repo}')]
|
||||
|
@ -527,7 +524,7 @@ class Argparse(Configs):
|
|||
if len(self.args) == 1:
|
||||
self.check.is_empty_database()
|
||||
|
||||
upgrade = Upgrade(self.flags, self.binary_repo)
|
||||
upgrade = Upgrade(self.flags, self.data, self.binary_repo)
|
||||
packages: list = list(upgrade.packages())
|
||||
|
||||
packages: list = self.choose_packages(packages, command)
|
||||
|
@ -537,10 +534,10 @@ class Argparse(Configs):
|
|||
raise SystemExit()
|
||||
|
||||
if self.utils.is_option(self.flag_binaries, self.flags):
|
||||
install = Packages(self.bin_repo_dict, packages, self.flags, self.binary_repo, mode=command)
|
||||
install = Packages(self.data, packages, self.flags, self.binary_repo, mode=command)
|
||||
install.execute()
|
||||
else:
|
||||
install = Slackbuilds(self.sbo_repo_dict, packages, self.flags, mode=command)
|
||||
install = Slackbuilds(self.data, packages, self.flags, mode=command)
|
||||
install.execute()
|
||||
raise SystemExit()
|
||||
self.usage.help_short(1)
|
||||
|
@ -612,7 +609,7 @@ class Argparse(Configs):
|
|||
self.check.exists_in_the_database(packages)
|
||||
self.check.is_package_unsupported(packages)
|
||||
|
||||
build = Slackbuilds(self.sbo_repo_dict, packages, self.flags, mode=command)
|
||||
build = Slackbuilds(self.data, packages, self.flags, mode=command)
|
||||
build.execute()
|
||||
raise SystemExit()
|
||||
self.usage.help_short(1)
|
||||
|
@ -631,13 +628,13 @@ class Argparse(Configs):
|
|||
if self.utils.is_option(self.flag_binaries, self.flags):
|
||||
self.check.exists_in_the_database(packages)
|
||||
|
||||
install = Packages(self.bin_repo_dict, packages, self.flags, self.binary_repo, mode=command)
|
||||
install = Packages(self.data, packages, self.flags, self.binary_repo, mode=command)
|
||||
install.execute()
|
||||
else:
|
||||
self.check.exists_in_the_database(packages)
|
||||
self.check.is_package_unsupported(packages)
|
||||
|
||||
install = Slackbuilds(self.sbo_repo_dict, packages, self.flags, mode=command)
|
||||
install = Slackbuilds(self.data, packages, self.flags, mode=command)
|
||||
install.execute()
|
||||
raise SystemExit()
|
||||
self.usage.help_short(1)
|
||||
|
@ -655,7 +652,7 @@ class Argparse(Configs):
|
|||
|
||||
self.check.exists_in_the_database(packages)
|
||||
download = Download(self.directory, self.flags)
|
||||
download.packages(packages, self.binary_repo)
|
||||
download.packages(self.data, packages, self.binary_repo)
|
||||
raise SystemExit()
|
||||
self.usage.help_short(1)
|
||||
|
||||
|
@ -708,9 +705,9 @@ class Argparse(Configs):
|
|||
view = ViewPackage(self.flags)
|
||||
|
||||
if self.utils.is_option(self.flag_binaries, self.flags):
|
||||
view.package(packages, self.binary_repo)
|
||||
view.package(self.data, packages, self.binary_repo)
|
||||
else:
|
||||
view.slackbuild(packages)
|
||||
view.slackbuild(self.data, packages)
|
||||
raise SystemExit()
|
||||
self.usage.help_short(1)
|
||||
|
||||
|
@ -726,7 +723,7 @@ class Argparse(Configs):
|
|||
packages: list = self.choose_packages(packages, command)
|
||||
|
||||
search = SearchPackage(self.flags)
|
||||
search.package(packages, self.binary_repo)
|
||||
search.package(self.data, packages, self.binary_repo)
|
||||
raise SystemExit()
|
||||
self.usage.help_short(1)
|
||||
|
||||
|
@ -743,8 +740,8 @@ class Argparse(Configs):
|
|||
|
||||
self.check.exists_in_the_database(packages)
|
||||
|
||||
dependees = Dependees(packages, self.flags)
|
||||
dependees.find(self.binary_repo)
|
||||
dependees = Dependees(self.data, packages, self.flags)
|
||||
dependees.find()
|
||||
raise SystemExit()
|
||||
self.usage.help_short(1)
|
||||
|
||||
|
@ -762,7 +759,7 @@ class Argparse(Configs):
|
|||
self.check.exists_in_the_database(packages)
|
||||
|
||||
tracking = Tracking(self.flags)
|
||||
tracking.packages(packages, self.binary_repo)
|
||||
tracking.packages(self.data, packages)
|
||||
raise SystemExit()
|
||||
self.usage.help_short(1)
|
||||
|
||||
|
|
|
@ -1,31 +1,29 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from slpkg.sbos.queries import SBoQueries
|
||||
|
||||
|
||||
class Requires:
|
||||
""" Creates a list of dependencies with
|
||||
the right order to install. """
|
||||
|
||||
def __init__(self, name: str):
|
||||
__slots__ = 'name'
|
||||
def __init__(self, data: dict, name: str):
|
||||
__slots__ = 'data', 'name'
|
||||
self.data: dict = data
|
||||
self.name: str = name
|
||||
self.sbo_repo_dict: dict = SBoQueries().repository_data()
|
||||
|
||||
def resolve(self) -> list:
|
||||
""" Resolve the dependencies. """
|
||||
requires: list[str] = self.sbo_repo_dict[self.name][7].split()
|
||||
requires: list[str] = self.data[self.name][7].split()
|
||||
|
||||
for req in requires:
|
||||
|
||||
# Remove requirements that are included as dependencies,
|
||||
# but are not included in the repository.
|
||||
if req not in list(self.sbo_repo_dict.keys()):
|
||||
if req not in list(self.data.keys()):
|
||||
requires.remove(req)
|
||||
|
||||
if req:
|
||||
sub_requires: list[str] = self.sbo_repo_dict[req][7].split()
|
||||
sub_requires: list[str] = self.data[req][7].split()
|
||||
for sub in sub_requires:
|
||||
requires.append(sub)
|
||||
|
||||
|
|
|
@ -27,10 +27,10 @@ from slpkg.models.models import session as Session
|
|||
class Slackbuilds(Configs):
|
||||
""" Download build and install the SlackBuilds. """
|
||||
|
||||
def __init__(self, sbo_repo_dict: dict, slackbuilds: list, flags: list, mode: str):
|
||||
__slots__ = 'sbo_repo_dict', 'slackbuilds', 'flags', 'mode'
|
||||
def __init__(self, data: dict, slackbuilds: list, flags: list, mode: str):
|
||||
__slots__ = 'data', 'slackbuilds', 'flags', 'mode'
|
||||
super(Configs, self).__init__()
|
||||
self.sbo_repo_dict = sbo_repo_dict
|
||||
self.data = data
|
||||
self.slackbuilds: list = slackbuilds
|
||||
self.flags: list = flags
|
||||
self.mode: str = mode
|
||||
|
@ -40,8 +40,8 @@ class Slackbuilds(Configs):
|
|||
self.utils = Utilities()
|
||||
self.progress = ProgressBar()
|
||||
self.dialogbox = DialogBox()
|
||||
self.upgrade = Upgrade(self.flags)
|
||||
self.view_message = ViewMessage(self.flags)
|
||||
self.upgrade = Upgrade(self.flags, data)
|
||||
self.view_message = ViewMessage(self.flags, data)
|
||||
self.color = self.colour()
|
||||
|
||||
self.install_order: list = []
|
||||
|
@ -64,7 +64,7 @@ class Slackbuilds(Configs):
|
|||
self.flag_no_silent: list = ['-n', '--no-silent']
|
||||
self.flag_parallel: list = ['-P', '--parallel']
|
||||
|
||||
self.slackbuilds: list = self.utils.apply_package_pattern(self.flags, self.slackbuilds)
|
||||
self.slackbuilds: list = self.utils.apply_package_pattern(self.data, self.slackbuilds)
|
||||
|
||||
# Patch the TAG from configs.
|
||||
if self.repos.patch_repo_tag:
|
||||
|
@ -90,7 +90,7 @@ class Slackbuilds(Configs):
|
|||
if self.utils.is_option(self.flag_resolve_off, self.flags):
|
||||
self.sbos[sbo] = []
|
||||
else:
|
||||
self.sbos[sbo] = Requires(sbo).resolve()
|
||||
self.sbos[sbo] = Requires(self.data, sbo).resolve()
|
||||
|
||||
def creating_dependencies_for_build(self) -> None:
|
||||
""" List with the dependencies. """
|
||||
|
@ -163,7 +163,7 @@ class Slackbuilds(Configs):
|
|||
build_path: Path = Path(self.build_path, sbo)
|
||||
|
||||
self.utils.remove_folder_if_exists(build_path)
|
||||
location: str = self.sbo_repo_dict[sbo][0]
|
||||
location: str = self.data[sbo][0]
|
||||
slackbuild = Path(self.build_path, sbo, f'{sbo}.SlackBuild')
|
||||
|
||||
# Copy slackbuilds to the build folder.
|
||||
|
@ -176,12 +176,12 @@ class Slackbuilds(Configs):
|
|||
|
||||
os.chmod(slackbuild, 0o775)
|
||||
|
||||
if self.os_arch == 'x86_64' and self.sbo_repo_dict[sbo][4]:
|
||||
sources[sbo] = self.sbo_repo_dict[sbo][4].split()
|
||||
sources_urls += self.sbo_repo_dict[sbo][4].split()
|
||||
if self.os_arch == 'x86_64' and self.data[sbo][4]:
|
||||
sources[sbo] = self.data[sbo][4].split()
|
||||
sources_urls += self.data[sbo][4].split()
|
||||
else:
|
||||
sources[sbo] = self.sbo_repo_dict[sbo][3].split()
|
||||
sources_urls += self.sbo_repo_dict[sbo][3].split()
|
||||
sources[sbo] = self.data[sbo][3].split()
|
||||
sources_urls += self.data[sbo][3].split()
|
||||
|
||||
# Download the sources.
|
||||
if sources:
|
||||
|
@ -198,12 +198,12 @@ class Slackbuilds(Configs):
|
|||
for sbo in self.install_order:
|
||||
path = Path(self.build_path, sbo)
|
||||
|
||||
if self.os_arch == 'x86_64' and self.sbo_repo_dict[sbo][6]:
|
||||
checksums: list = self.sbo_repo_dict[sbo][6].split()
|
||||
sources: list = self.sbo_repo_dict[sbo][4].split()
|
||||
if self.os_arch == 'x86_64' and self.data[sbo][6]:
|
||||
checksums: list = self.data[sbo][6].split()
|
||||
sources: list = self.data[sbo][4].split()
|
||||
else:
|
||||
checksums: list = self.sbo_repo_dict[sbo][5].split()
|
||||
sources: list = self.sbo_repo_dict[sbo][3].split()
|
||||
checksums: list = self.data[sbo][5].split()
|
||||
sources: list = self.data[sbo][3].split()
|
||||
|
||||
for source, checksum in zip(sources, checksums):
|
||||
md5sum = Md5sum(self.flags)
|
||||
|
@ -251,7 +251,7 @@ class Slackbuilds(Configs):
|
|||
exist = self.session.query(LogsDependencies.name).filter(
|
||||
LogsDependencies.name == name).first()
|
||||
|
||||
requires: list = Requires(name).resolve()
|
||||
requires: list = Requires(self.data, name).resolve()
|
||||
|
||||
# Update the dependencies if exist else create it.
|
||||
if exist:
|
||||
|
@ -288,7 +288,7 @@ class Slackbuilds(Configs):
|
|||
def package_for_install(self, name: str) -> str:
|
||||
""" Returns the package for install. """
|
||||
package: str = ''
|
||||
version: str = self.sbo_repo_dict[name][2]
|
||||
version: str = self.data[name][2]
|
||||
pattern: str = f'{name}-{version}*{self.repos.repo_tag}*'
|
||||
|
||||
tmp = Path(self.tmp_path)
|
||||
|
@ -371,8 +371,8 @@ class Slackbuilds(Configs):
|
|||
for package in dependencies:
|
||||
status: bool = False
|
||||
|
||||
repo_ver: str = self.sbo_repo_dict[package][0]
|
||||
description: str = self.sbo_repo_dict[package][8]
|
||||
repo_ver: str = self.data[package][0]
|
||||
description: str = self.data[package][8]
|
||||
help_text: str = f'Description: {description}'
|
||||
upgradable: bool = self.upgrade.is_package_upgradeable(package)
|
||||
installed: str = self.utils.is_package_installed(package)
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.sbos.queries import SBoQueries
|
||||
from slpkg.repositories import Repositories
|
||||
from slpkg.binaries.queries import BinQueries
|
||||
|
||||
|
||||
class SearchPackage(Configs):
|
||||
|
@ -28,7 +26,7 @@ class SearchPackage(Configs):
|
|||
|
||||
self.flag_bin_repository: list = ['-B', '--bin-repo=']
|
||||
|
||||
def package(self, packages: list, repo=None) -> None:
|
||||
def package(self, data: dict, packages: list, repo=None) -> None:
|
||||
""" Searching and print the matched packages. """
|
||||
print(f'The list below shows the repo '
|
||||
f'packages that contains \'{", ".join([p for p in packages])}\':\n')
|
||||
|
@ -37,46 +35,44 @@ class SearchPackage(Configs):
|
|||
|
||||
# Searching for binaries.
|
||||
if self.utils.is_option(self.flag_bin_repository, self.flags):
|
||||
bin_repos_dict: dict = BinQueries('').repositories_data()
|
||||
|
||||
if repo == '*':
|
||||
for package in packages:
|
||||
for data in bin_repos_dict.values():
|
||||
for pkg in data.values():
|
||||
|
||||
if package in data[1] or package == '*':
|
||||
if package in pkg[1] or package == '*':
|
||||
matching += 1
|
||||
|
||||
version: str = data[2]
|
||||
desc: str = data[11]
|
||||
version: str = pkg[2]
|
||||
desc: str = pkg[11]
|
||||
|
||||
print(f'{data[0]}: {self.cyan}{data[1]}{self.endc} {self.yellow}{version}{self.endc}'
|
||||
print(f'{pkg[0]}: {self.cyan}{pkg[1]}{self.endc} {self.yellow}{version}{self.endc}'
|
||||
f'{self.green}{desc}{self.endc}')
|
||||
|
||||
else:
|
||||
for package in packages:
|
||||
for data in bin_repos_dict.values():
|
||||
for pkg in data.values():
|
||||
|
||||
if package in data[1] and repo == data[0] or package == '*' and repo == data[0]:
|
||||
if package in pkg[1] and repo == pkg[0] or package == '*' and repo == pkg[0]:
|
||||
matching += 1
|
||||
|
||||
version: str = data[2]
|
||||
desc: str = data[11]
|
||||
version: str = pkg[2]
|
||||
desc: str = pkg[11]
|
||||
|
||||
print(f'{data[0]}: {self.cyan}{data[1]}{self.endc} {self.yellow}{version}{self.endc}'
|
||||
print(f'{pkg[0]}: {self.cyan}{pkg[1]}{self.endc} {self.yellow}{version}{self.endc}'
|
||||
f'{self.green}{desc}{self.endc}')
|
||||
|
||||
else:
|
||||
# Searching for slackbuilds.
|
||||
sbo_repos_dict: dict = SBoQueries().repository_data()
|
||||
names: list = list(sbo_repos_dict.keys())
|
||||
names: list = list(data.keys())
|
||||
for package in packages:
|
||||
for name in names:
|
||||
|
||||
if package in name or package == '*':
|
||||
matching += 1
|
||||
|
||||
version: str = sbo_repos_dict[name][2]
|
||||
desc: str = sbo_repos_dict[name][8].replace(name, '')
|
||||
version: str = data[name][2]
|
||||
desc: str = data[name][8].replace(name, '')
|
||||
|
||||
print(f'{self.cyan}{name}{self.endc} {self.yellow}{version}{self.endc}'
|
||||
f'{self.green}{desc}{self.endc}')
|
||||
|
|
|
@ -5,8 +5,6 @@ from slpkg.configs import Configs
|
|||
from slpkg.views.ascii import Ascii
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.blacklist import Blacklist
|
||||
from slpkg.sbos.queries import SBoQueries
|
||||
from slpkg.binaries.queries import BinQueries
|
||||
|
||||
|
||||
class Tracking(Configs):
|
||||
|
@ -36,18 +34,18 @@ class Tracking(Configs):
|
|||
self.repo_for_binaries: bool = self.utils.is_option(
|
||||
['-B', '--bin-repo='], self.flags)
|
||||
|
||||
def packages(self, packages: list, repo: str) -> None:
|
||||
def packages(self, data: dict, packages: list) -> None:
|
||||
""" Prints the packages dependencies. """
|
||||
print(f"The list below shows the packages '{', '.join([p for p in packages])}' with dependencies:\n")
|
||||
sbo_repo_dict: dict = {}
|
||||
bin_repo_dict: dict = {}
|
||||
|
||||
packages: list = self.utils.apply_package_pattern(self.flags, packages, repo)
|
||||
packages: list = self.utils.apply_package_pattern(data, packages)
|
||||
|
||||
if self.repo_for_binaries:
|
||||
bin_repo_dict: dict = BinQueries(repo).repository_data()
|
||||
bin_repo_dict: dict = data
|
||||
else:
|
||||
sbo_repo_dict: dict = SBoQueries().repository_data()
|
||||
sbo_repo_dict: dict = data
|
||||
|
||||
char: str = f' {self.llc}{self.hl}'
|
||||
sp: str = ' ' * 4
|
||||
|
|
|
@ -7,8 +7,6 @@ from packaging.version import parse, InvalidVersion
|
|||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.sbos.queries import SBoQueries
|
||||
from slpkg.binaries.queries import BinQueries
|
||||
from slpkg.logging_config import LoggingConfig
|
||||
from slpkg.repositories import Repositories
|
||||
|
||||
|
@ -16,24 +14,17 @@ from slpkg.repositories import Repositories
|
|||
class Upgrade(Configs):
|
||||
""" Upgrade the installed packages. """
|
||||
|
||||
def __init__(self, flags: list, repo=None):
|
||||
__slots__ = 'flags', 'repo'
|
||||
def __init__(self, flags: list, data: dict, repo=None):
|
||||
__slots__ = 'flags', 'data', 'repo'
|
||||
super(Configs, self).__init__()
|
||||
self.flags: list = flags
|
||||
self.data: dict = data
|
||||
self.repo: str = repo
|
||||
self.utils = Utilities()
|
||||
self.repos = Repositories()
|
||||
|
||||
self.repo_for_binaries: bool = self.utils.is_option(['-B', '--bin-repo='], self.flags)
|
||||
|
||||
self.bin_repo_dict: dict = {}
|
||||
self.sbo_repo_dict: dict = {}
|
||||
|
||||
if self.repo_for_binaries:
|
||||
self.bin_repo_dict: dict = BinQueries(self.repo).repository_data()
|
||||
else:
|
||||
self.sbo_repo_dict: dict = SBoQueries().repository_data()
|
||||
|
||||
logging.basicConfig(filename=str(LoggingConfig.log_file),
|
||||
filemode='w',
|
||||
encoding='utf-8',
|
||||
|
@ -41,13 +32,10 @@ class Upgrade(Configs):
|
|||
|
||||
def packages(self) -> Generator[str, None, None]:
|
||||
""" Returns the upgradable packages. """
|
||||
if self.repo_for_binaries:
|
||||
repo_packages: list = list(self.bin_repo_dict.keys())
|
||||
else:
|
||||
repo_packages: list = list(self.sbo_repo_dict.keys())
|
||||
repo_packages_names: list = list(self.data.keys())
|
||||
|
||||
# Returns the matched packages between two lists.
|
||||
packages: list = list(set(self.utils.installed_package_names) & set(repo_packages))
|
||||
packages: list = list(set(self.utils.installed_package_names) & set(repo_packages_names))
|
||||
|
||||
for pkg in packages:
|
||||
|
||||
|
@ -68,14 +56,15 @@ class Upgrade(Configs):
|
|||
inst_version: str = self.utils.split_binary_pkg(inst_package)[1]
|
||||
inst_build: str = self.utils.split_binary_pkg(inst_package)[3]
|
||||
|
||||
if self.repo_for_binaries and self.bin_repo_dict.get(name):
|
||||
repo_version: str = self.bin_repo_dict[name][0]
|
||||
repo_package: str = self.bin_repo_dict[name][1]
|
||||
if self.repo_for_binaries and self.data.get(name):
|
||||
repo_version: str = self.data[name][0]
|
||||
repo_package: str = self.data[name][1]
|
||||
repo_build: str = self.utils.split_binary_pkg(repo_package)[3]
|
||||
|
||||
elif not self.repo_for_binaries and self.sbo_repo_dict.get(name):
|
||||
repo_version: str = self.sbo_repo_dict[name][2]
|
||||
repo_build: str = self.utils.read_sbo_build_tag(name)
|
||||
elif not self.repo_for_binaries and self.data.get(name):
|
||||
repo_version: str = self.data[name][2]
|
||||
repo_location: str = self.data[name][0]
|
||||
repo_build: str = self.utils.read_sbo_build_tag(name, repo_location)
|
||||
|
||||
try:
|
||||
if parse(repo_version) > parse(inst_version):
|
||||
|
|
|
@ -11,9 +11,7 @@ from typing import Generator, Union
|
|||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.blacklist import Blacklist
|
||||
from slpkg.sbos.queries import SBoQueries
|
||||
from slpkg.repositories import Repositories
|
||||
from slpkg.binaries.queries import BinQueries
|
||||
from slpkg.logging_config import LoggingConfig
|
||||
|
||||
|
||||
|
@ -110,11 +108,9 @@ class Utilities:
|
|||
time.strftime(f'[{self.cyan}%H:%M:%S{self.endc}]',
|
||||
time.gmtime(elapsed_time)))
|
||||
|
||||
def read_sbo_build_tag(self, sbo: str) -> str:
|
||||
def read_sbo_build_tag(self, sbo: str, location: str) -> str:
|
||||
""" Returns build tag from .SlackBuild file. """
|
||||
build: str = ''
|
||||
sbo_repo_dict: dict = SBoQueries().repository_data()
|
||||
location: str = sbo_repo_dict[sbo][0]
|
||||
|
||||
sbo_script = Path(self.repos.sbo_repo_path, location, sbo, f'{sbo}.SlackBuild')
|
||||
|
||||
|
@ -192,17 +188,19 @@ class Utilities:
|
|||
|
||||
return f'{str(round(file_size, 2))} {unit}'
|
||||
|
||||
def apply_package_pattern(self, flags: list, packages: list, repo=None) -> list:
|
||||
@staticmethod
|
||||
def apply_package_pattern(data: dict, packages: list) -> list:
|
||||
""" Apply the pattern. """
|
||||
for pkg in packages:
|
||||
if pkg == '*':
|
||||
packages.remove(pkg)
|
||||
packages += data.keys()
|
||||
|
||||
if self.is_option(self.flag_bin_repository, flags):
|
||||
bin_repo_dict: dict = BinQueries(repo).repository_data()
|
||||
packages += list(bin_repo_dict.keys())
|
||||
else:
|
||||
sbo_repo_dict: dict = SBoQueries().repository_data()
|
||||
packages += list(sbo_repo_dict.keys())
|
||||
# if self.is_option(self.flag_bin_repository, flags):
|
||||
# bin_repo_dict: dict = BinQueries(repo).repository_data()
|
||||
# packages += list(bin_repo_dict.keys())
|
||||
# else:
|
||||
# sbo_repo_dict: dict = SBoQueries().repository_data()
|
||||
# packages += list(sbo_repo_dict.keys())
|
||||
|
||||
return packages
|
||||
|
|
|
@ -5,9 +5,7 @@ from pathlib import Path
|
|||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.sbos.queries import SBoQueries
|
||||
from slpkg.repositories import Repositories
|
||||
from slpkg.binaries.queries import BinQueries
|
||||
from slpkg.models.models import session as Session
|
||||
from slpkg.models.models import (SBoTable, PonceTable,
|
||||
BinariesTable, LastRepoUpdated)
|
||||
|
@ -46,10 +44,9 @@ class ViewPackage(Configs):
|
|||
self.repo_path: Path = self.repos.ponce_repo_path
|
||||
self.repo_tar_suffix: str = ''
|
||||
|
||||
def slackbuild(self, slackbuilds: list) -> None:
|
||||
def slackbuild(self, data: dict, slackbuilds: list) -> None:
|
||||
""" View the packages from the repository. """
|
||||
slackbuilds: list = self.utils.apply_package_pattern(self.flags, slackbuilds)
|
||||
sbo_repo_dict: dict = SBoQueries().repository_data()
|
||||
slackbuilds: list = self.utils.apply_package_pattern(data, slackbuilds)
|
||||
|
||||
for sbo in slackbuilds:
|
||||
|
||||
|
@ -72,7 +69,7 @@ class ViewPackage(Configs):
|
|||
path = Path(self.repo_path, info[9], info[0], f'{info[0]}.info')
|
||||
info_file = self.utils.read_file(path)
|
||||
|
||||
repo_build_tag = self.utils.read_sbo_build_tag(info[0])
|
||||
repo_build_tag = self.utils.read_sbo_build_tag(info[0], info[9])
|
||||
|
||||
maintainer, email, homepage = '', '', ''
|
||||
for line in info_file:
|
||||
|
@ -86,7 +83,7 @@ class ViewPackage(Configs):
|
|||
deps: str = (', '.join([f'{self.cyan}{pkg}' for pkg in info[2].split()]))
|
||||
|
||||
if self.utils.is_option(self.flag_pkg_version, self.flags):
|
||||
deps: str = (', '.join([f'{self.cyan}{pkg}{self.endc}-{self.yellow}{sbo_repo_dict[pkg][2]}'
|
||||
deps: str = (', '.join([f'{self.cyan}{pkg}{self.endc}-{self.yellow}{data[pkg][2]}'
|
||||
f'{self.green}' for pkg in info[2].split()]))
|
||||
|
||||
print(f'Name: {self.green}{info[0]}{self.endc}\n'
|
||||
|
@ -109,9 +106,8 @@ class ViewPackage(Configs):
|
|||
f'Email: {self.yellow}{email}{self.endc}\n'
|
||||
f'\nREADME: {self.cyan}{"".join(readme)}{self.endc}')
|
||||
|
||||
def package(self, packages: list, repo: str) -> None:
|
||||
packages: list = self.utils.apply_package_pattern(self.flags, packages, repo)
|
||||
bin_repo_dict: dict = BinQueries(repo).repository_data()
|
||||
def package(self, data: dict, packages: list, repo: str) -> None:
|
||||
packages: list = self.utils.apply_package_pattern(data, packages)
|
||||
|
||||
for package in packages:
|
||||
|
||||
|
@ -140,7 +136,7 @@ class ViewPackage(Configs):
|
|||
|
||||
deps: str = (', '.join([f'{self.cyan}{pkg}' for pkg in info[9].split()]))
|
||||
if self.utils.is_option(self.flag_pkg_version, self.flags):
|
||||
deps: str = (', '.join([f'{self.cyan}{pkg}{self.endc}-{self.yellow}{bin_repo_dict[pkg][0]}'
|
||||
deps: str = (', '.join([f'{self.cyan}{pkg}{self.endc}-{self.yellow}{data[pkg][0]}'
|
||||
f'{self.green}' for pkg in info[9].split()]))
|
||||
|
||||
print(f'Repository: {self.yellow}{info[0]}{self.endc}\n'
|
||||
|
|
|
@ -12,24 +12,24 @@ from slpkg.utilities import Utilities
|
|||
from slpkg.dialog_box import DialogBox
|
||||
from slpkg.sbos.queries import SBoQueries
|
||||
from slpkg.repositories import Repositories
|
||||
from slpkg.binaries.queries import BinQueries
|
||||
from slpkg.models.models import LogsDependencies
|
||||
from slpkg.models.models import session as Session
|
||||
|
||||
|
||||
class ViewMessage(Configs):
|
||||
|
||||
def __init__(self, flags: list, repo=None):
|
||||
def __init__(self, flags: list, data=None, repo=None):
|
||||
__slots__ = 'flags', 'repo'
|
||||
super(Configs, self).__init__()
|
||||
self.flags: list = flags
|
||||
self.data: dict = data
|
||||
self.repo: str = repo
|
||||
|
||||
self.session = Session
|
||||
self.utils = Utilities()
|
||||
self.dialogbox = DialogBox()
|
||||
self.ascii = Ascii()
|
||||
self.upgrade = Upgrade(self.flags, self.repo)
|
||||
self.upgrade = Upgrade(self.flags, self.data, self.repo)
|
||||
self.color = self.colour()
|
||||
self.repos = Repositories()
|
||||
|
||||
|
@ -46,22 +46,17 @@ class ViewMessage(Configs):
|
|||
self.flag_yes: list = ['-y', '--yes']
|
||||
self.flag_bin_repository: list = ['-B', '--bin-repo=']
|
||||
|
||||
if self.utils.is_option(self.flag_bin_repository, flags):
|
||||
self.bin_repo_dict: dict = BinQueries(self.repo).repository_data()
|
||||
else:
|
||||
self.sbo_repo_dict: dict = SBoQueries().repository_data()
|
||||
|
||||
def view_packages(self, package: str, mode: str) -> None:
|
||||
""" Printing the main packages. """
|
||||
size: str = ''
|
||||
color: str = self.red
|
||||
|
||||
if self.utils.is_option(self.flag_bin_repository, self.flags):
|
||||
version: str = self.bin_repo_dict[package][0]
|
||||
size: str = self.bin_repo_dict[package][4]
|
||||
version: str = self.data[package][0]
|
||||
size: str = self.data[package][4]
|
||||
repo: str = self.repo
|
||||
else:
|
||||
version: str = self.sbo_repo_dict[package][2]
|
||||
version: str = self.data[package][2]
|
||||
repo: str = SBoQueries().repo_name()
|
||||
|
||||
if mode in ['install', 'download']:
|
||||
|
@ -196,7 +191,7 @@ class ViewMessage(Configs):
|
|||
title: str = " Choose dependencies you want to remove "
|
||||
|
||||
for package in dependencies:
|
||||
repo_ver: str = self.sbo_repo_dict[package][2]
|
||||
repo_ver: str = self.data[package][2]
|
||||
inst_pkg: str = self.utils.is_package_installed(package)
|
||||
choices += [(package, repo_ver, True, f'Package: {inst_pkg}')]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue