mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-20 10:26:44 +01:00
updated for repo
This commit is contained in:
parent
dc2f5d0173
commit
c572bf437e
7 changed files with 61 additions and 60 deletions
|
@ -8,6 +8,7 @@ from multiprocessing import Process
|
|||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.checksum import Md5sum
|
||||
from slpkg.upgrade import Upgrade
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.dialog_box import DialogBox
|
||||
from slpkg.downloader import Downloader
|
||||
|
@ -34,7 +35,8 @@ class Packages(Configs):
|
|||
self.utils = Utilities()
|
||||
self.repos = Repositories()
|
||||
self.dialogbox = DialogBox()
|
||||
self.view_message = ViewMessage(self.flags)
|
||||
self.upgrade = Upgrade(self.flags, self.repo)
|
||||
self.view_message = ViewMessage(self.flags, self.repo)
|
||||
self.session = Session
|
||||
|
||||
self.output: int = 0
|
||||
|
@ -60,7 +62,7 @@ class Packages(Configs):
|
|||
def execute(self) -> None:
|
||||
self.dependencies()
|
||||
|
||||
self.view_message.install_packages(self.packages, self.mode, self.packages_requires, self.repo)
|
||||
self.view_message.install_packages(self.packages, self.mode, self.packages_requires)
|
||||
self.view_message.question()
|
||||
|
||||
start: float = time.time()
|
||||
|
@ -222,7 +224,7 @@ class Packages(Configs):
|
|||
|
||||
repo_ver: str = BinQueries(package, self.repo).version()
|
||||
help_text: str = f'Package: {package}-{repo_ver}'
|
||||
upgradable: str = self.utils.is_package_upgradeable(package, self.flags, self.repo)
|
||||
upgradable: bool = self.upgrade.is_package_upgradeable(package)
|
||||
|
||||
if self.mode == 'upgrade' and upgradable:
|
||||
status: bool = True
|
||||
|
|
|
@ -32,8 +32,8 @@ class Download(Configs):
|
|||
|
||||
def packages(self, packages: list, repo='*') -> None:
|
||||
""" Download the package only. """
|
||||
view = ViewMessage(self.flags)
|
||||
view.download_packages(packages, self.directory, repo)
|
||||
view = ViewMessage(self.flags, repo)
|
||||
view.download_packages(packages, self.directory)
|
||||
view.question()
|
||||
|
||||
download_path: Path = self.download_only_path
|
||||
|
|
|
@ -13,6 +13,7 @@ from multiprocessing import Process, cpu_count
|
|||
|
||||
from slpkg.checksum import Md5sum
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.upgrade import Upgrade
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.dialog_box import DialogBox
|
||||
from slpkg.downloader import Downloader
|
||||
|
@ -39,6 +40,7 @@ class Slackbuilds(Configs):
|
|||
self.utils = Utilities()
|
||||
self.progress = ProgressBar()
|
||||
self.dialogbox = DialogBox()
|
||||
self.upgrade = Upgrade(self.flags)
|
||||
self.view_message = ViewMessage(self.flags)
|
||||
self.color = self.colour()
|
||||
|
||||
|
@ -137,7 +139,7 @@ class Slackbuilds(Configs):
|
|||
def is_not_for_skipped(self, sbo: str) -> Literal[True]:
|
||||
""" Condition to check if slackbuild is for skipped. """
|
||||
return (not self.utils.is_package_installed(sbo) or
|
||||
self.utils.is_package_upgradeable(sbo) or
|
||||
self.upgrade.is_package_upgradeable(sbo) or
|
||||
self.mode == 'build' or self.utils.is_option(self.flag_reinstall, self.flags))
|
||||
|
||||
def prepare_slackbuilds_for_build(self) -> None:
|
||||
|
@ -361,7 +363,7 @@ class Slackbuilds(Configs):
|
|||
repo_ver: str = SBoQueries(package).version()
|
||||
description: str = SBoQueries(package).description()
|
||||
help_text: str = f'Description: {description}'
|
||||
upgradable: str = self.utils.is_package_upgradeable(package)
|
||||
upgradable: bool = self.upgrade.is_package_upgradeable(package)
|
||||
|
||||
if self.mode == 'build':
|
||||
status: bool = True
|
||||
|
|
|
@ -2,22 +2,23 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from typing import Generator
|
||||
from packaging.version import parse
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.sbos.dependencies import Requires
|
||||
from slpkg.sbos.queries import SBoQueries
|
||||
from slpkg.sbos.dependencies import Requires
|
||||
from slpkg.binaries.queries import BinQueries
|
||||
|
||||
|
||||
class Upgrade(Configs):
|
||||
""" Upgrade the installed packages. """
|
||||
|
||||
def __init__(self, flags: list, repo: str):
|
||||
def __init__(self, flags: list, repo='*'):
|
||||
super(Configs, self).__init__()
|
||||
self.flags = flags
|
||||
self.repo = repo
|
||||
self.utils = Utilities(self.flags)
|
||||
self.utils = Utilities()
|
||||
|
||||
self.flag_bin_repository: list = ['-B=', '--bin-repo=']
|
||||
|
||||
|
@ -36,7 +37,7 @@ class Upgrade(Configs):
|
|||
|
||||
if inst_pkg_name in repo_packages:
|
||||
|
||||
if self.utils.is_package_upgradeable(inst_pkg_name, self.repo):
|
||||
if self.is_package_upgradeable(inst_pkg_name):
|
||||
|
||||
if not self.utils.is_option(self.flag_bin_repository, self.flags):
|
||||
requires += Requires(inst_pkg_name).resolve()
|
||||
|
@ -47,3 +48,31 @@ class Upgrade(Configs):
|
|||
for pkg in upgrade:
|
||||
if pkg not in requires:
|
||||
yield pkg
|
||||
|
||||
def is_package_upgradeable(self, package: str) -> bool:
|
||||
""" Checks if the package is installed and if it is upgradeable, returns true. """
|
||||
installed_version: str = '0'
|
||||
installed = self.utils.is_package_installed(package)
|
||||
inst_build_tag: str = self.utils.split_binary_pkg(installed)[3]
|
||||
|
||||
if self.utils.is_option(self.flag_bin_repository, self.flags):
|
||||
repository_version = BinQueries(package, self.repo).version()
|
||||
repo_package: str = BinQueries(package, self.repo).package_bin()
|
||||
repo_build_tag: str = self.utils.split_binary_pkg(repo_package)[3]
|
||||
else:
|
||||
repository_version = SBoQueries(package).version()
|
||||
repo_build_tag: str = self.utils.read_sbo_build_tag(package)
|
||||
|
||||
if not repo_build_tag:
|
||||
repo_build_tag: str = ''
|
||||
|
||||
if not inst_build_tag:
|
||||
inst_build_tag: str = ''
|
||||
|
||||
if not repository_version:
|
||||
repository_version: str = '0'
|
||||
|
||||
if installed:
|
||||
installed_version: str = self.utils.split_binary_pkg(installed)[1]
|
||||
|
||||
return parse(repository_version + repo_build_tag) > parse(installed_version + inst_build_tag)
|
||||
|
|
|
@ -6,20 +6,17 @@ import time
|
|||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from packaging.version import parse
|
||||
from typing import Generator, Any, 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
|
||||
|
||||
|
||||
class Utilities:
|
||||
|
||||
def __init__(self, flags=None):
|
||||
self.flags = flags
|
||||
def __init__(self):
|
||||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
self.color = self.colors()
|
||||
|
@ -32,10 +29,6 @@ class Utilities:
|
|||
self.endc: str = self.color['endc']
|
||||
self.red: str = self.color['red']
|
||||
self.bred: str = f'{self.bold}{self.red}'
|
||||
self.flag_bin_repository: list = ['-B=', '--bin-repo=']
|
||||
|
||||
if self.flags is None:
|
||||
self.flags: list = []
|
||||
|
||||
self.installed_packages: list = list(self.all_installed())
|
||||
self.installed_package_names: list = list(self.all_installed_names())
|
||||
|
@ -115,34 +108,6 @@ class Utilities:
|
|||
time.strftime(f'[{self.cyan}%H:%M:%S{self.endc}]',
|
||||
time.gmtime(elapsed_time)))
|
||||
|
||||
def is_package_upgradeable(self, package: str, repo='*') -> Any:
|
||||
""" Checks if the package is installed and if it is upgradeable, returns true. """
|
||||
installed_version: str = '0'
|
||||
installed = self.is_package_installed(package)
|
||||
inst_build_tag: str = self.split_binary_pkg(installed)[3]
|
||||
|
||||
if self.is_option(self.flag_bin_repository, self.flags):
|
||||
repository_version = BinQueries(package, repo).version()
|
||||
repo_package: str = BinQueries(package, repo).package_bin()
|
||||
repo_build_tag: str = self.split_binary_pkg(repo_package)[3]
|
||||
else:
|
||||
repository_version = SBoQueries(package).version()
|
||||
repo_build_tag: str = self.read_sbo_build_tag(package)
|
||||
|
||||
if not repo_build_tag:
|
||||
repo_build_tag: str = ''
|
||||
|
||||
if not inst_build_tag:
|
||||
inst_build_tag: str = ''
|
||||
|
||||
if not repository_version:
|
||||
repository_version: str = '0'
|
||||
|
||||
if installed:
|
||||
installed_version: str = self.split_binary_pkg(installed)[1]
|
||||
|
||||
return parse(repository_version + repo_build_tag) > parse(installed_version + inst_build_tag)
|
||||
|
||||
def read_sbo_build_tag(self, sbo: str) -> str:
|
||||
""" Patching SBo TAG from the configuration file. """
|
||||
location: str = SBoQueries(sbo).location()
|
||||
|
|
|
@ -67,4 +67,4 @@ class Help(Configs):
|
|||
print(f"{self.bold}COMMAND{self.endc}: {self.cyan}{self.command}{self.endc}")
|
||||
print(f"{self.bold}OPTIONS:{self.endc} {self.yellow}{', '.join(self.flags)}{self.endc}\n")
|
||||
print('If you need more information try to use slpkg manpage.\n')
|
||||
raise SystemExit()
|
||||
raise SystemExit()
|
||||
|
|
|
@ -6,10 +6,11 @@ from typing import Any
|
|||
from pathlib import Path
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.upgrade import Upgrade
|
||||
from slpkg.views.ascii import Ascii
|
||||
from slpkg.sbos.queries import SBoQueries
|
||||
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
|
||||
|
@ -19,14 +20,16 @@ from slpkg.models.models import session as Session
|
|||
class ViewMessage(Configs):
|
||||
""" Print some messages before. """
|
||||
|
||||
def __init__(self, flags: list):
|
||||
def __init__(self, flags: list, repo='*'):
|
||||
super(Configs, self).__init__()
|
||||
self.flags: list = flags
|
||||
self.repo: str = repo
|
||||
|
||||
self.session = Session
|
||||
self.utils = Utilities()
|
||||
self.dialogbox = DialogBox()
|
||||
self.ascii = Ascii()
|
||||
self.upgrade = Upgrade(self.flags, self.repo)
|
||||
self.color = self.colour()
|
||||
self.repos = Repositories()
|
||||
|
||||
|
@ -43,15 +46,15 @@ class ViewMessage(Configs):
|
|||
self.flag_yes: list = ['-y', '--yes']
|
||||
self.flag_bin_repository: list = ['-B=', '--bin-repo=']
|
||||
|
||||
def view_packages(self, package: str, mode: str, repo='*') -> None:
|
||||
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 = BinQueries(package, repo).version()
|
||||
size: str = BinQueries(package, repo).size_comp()
|
||||
repo = BinQueries(package, repo).repository()
|
||||
version: str = BinQueries(package, self.repo).version()
|
||||
size: str = BinQueries(package, self.repo).size_comp()
|
||||
repo = BinQueries(package, self.repo).repository()
|
||||
else:
|
||||
version: str = SBoQueries(package).version()
|
||||
repo: str = SBoQueries('').repo_name()
|
||||
|
@ -89,7 +92,7 @@ class ViewMessage(Configs):
|
|||
|
||||
self.summary(slackbuilds, dependencies, option='build')
|
||||
|
||||
def install_packages(self, packages: list, mode: str, dependencies=None, repo='*') -> None:
|
||||
def install_packages(self, packages: list, mode: str, dependencies=None) -> None:
|
||||
""" View packages for install. """
|
||||
if dependencies is None:
|
||||
dependencies: list = []
|
||||
|
@ -101,18 +104,18 @@ class ViewMessage(Configs):
|
|||
self.ascii.draw_package_title_box('The following packages will be installed or upgraded:', title)
|
||||
|
||||
for pkg in packages:
|
||||
self.view_packages(pkg, mode, repo)
|
||||
self.view_packages(pkg, mode)
|
||||
|
||||
if dependencies:
|
||||
self.ascii.draw_middle_line()
|
||||
self.ascii.draw_dependency_line()
|
||||
|
||||
for pkg in dependencies:
|
||||
self.view_packages(pkg, mode, repo)
|
||||
self.view_packages(pkg, mode)
|
||||
|
||||
self.summary(packages, dependencies, option=mode)
|
||||
|
||||
def download_packages(self, slackbuilds: list, directory: Path, repo='*') -> None:
|
||||
def download_packages(self, slackbuilds: list, directory: Path) -> None:
|
||||
""" View downloaded packages. """
|
||||
mode = 'download'
|
||||
|
||||
|
@ -122,7 +125,7 @@ class ViewMessage(Configs):
|
|||
self.download_only: Path = directory
|
||||
|
||||
for sbo in slackbuilds:
|
||||
self.view_packages(sbo, mode, repo)
|
||||
self.view_packages(sbo, mode)
|
||||
|
||||
self.summary(slackbuilds, dependencies=[], option='download')
|
||||
|
||||
|
@ -204,7 +207,7 @@ class ViewMessage(Configs):
|
|||
|
||||
for pkg in packages:
|
||||
|
||||
upgradeable: str = self.utils.is_package_upgradeable(pkg)
|
||||
upgradeable: bool = self.upgrade.is_package_upgradeable(pkg)
|
||||
installed: str = self.utils.is_package_installed(pkg)
|
||||
|
||||
if not installed:
|
||||
|
|
Loading…
Reference in a new issue