mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-30 20:34:38 +01:00
Merge branch 'develop' of https://gitlab.com/dslackw/slpkg into develop
This commit is contained in:
commit
8833c0d2a8
7 changed files with 105 additions and 59 deletions
|
@ -17,9 +17,11 @@ class BinQueries(Configs):
|
||||||
self.repo: str = repo
|
self.repo: str = repo
|
||||||
self.session = Session
|
self.session = Session
|
||||||
self.repos = Repositories()
|
self.repos = Repositories()
|
||||||
|
self.bin_repo: list = []
|
||||||
|
|
||||||
self.bin_repo: list = self.repos.enabled_repositories
|
if self.repo is None or self.repo == '*':
|
||||||
if self.repo:
|
self.bin_repo: list = self.repos.enabled_repositories
|
||||||
|
elif self.repo:
|
||||||
self.bin_repo: list = [self.repo]
|
self.bin_repo: list = [self.repo]
|
||||||
|
|
||||||
self.black = Blacklist()
|
self.black = Blacklist()
|
||||||
|
@ -29,7 +31,7 @@ class BinQueries(Configs):
|
||||||
def all_name_packages(self) -> list:
|
def all_name_packages(self) -> list:
|
||||||
""" Returns all the names of the binaries packages. """
|
""" Returns all the names of the binaries packages. """
|
||||||
pkgs: tuple = self.session.query(
|
pkgs: tuple = self.session.query(
|
||||||
BinariesTable.name,
|
BinariesTable.name).where(
|
||||||
BinariesTable.repo.in_(self.bin_repo)).all()
|
BinariesTable.repo.in_(self.bin_repo)).all()
|
||||||
|
|
||||||
return [pkg[0] for pkg in pkgs]
|
return [pkg[0] for pkg in pkgs]
|
||||||
|
@ -37,7 +39,7 @@ class BinQueries(Configs):
|
||||||
def all_name_binaries_packages(self) -> list:
|
def all_name_binaries_packages(self) -> list:
|
||||||
""" Returns all the binaries packages. """
|
""" Returns all the binaries packages. """
|
||||||
pkgs: tuple = self.session.query(
|
pkgs: tuple = self.session.query(
|
||||||
BinariesTable.package,
|
BinariesTable.package).where(
|
||||||
BinariesTable.repo.in_(self.bin_repo)).all()
|
BinariesTable.repo.in_(self.bin_repo)).all()
|
||||||
|
|
||||||
return [pkg[0] for pkg in pkgs]
|
return [pkg[0] for pkg in pkgs]
|
||||||
|
@ -55,7 +57,7 @@ class BinQueries(Configs):
|
||||||
""" Returns the package name. """
|
""" Returns the package name. """
|
||||||
pkg: tuple = self.session.query(
|
pkg: tuple = self.session.query(
|
||||||
BinariesTable.name).filter(
|
BinariesTable.name).filter(
|
||||||
BinariesTable.name == self.name,
|
BinariesTable.name == self.name).where(
|
||||||
BinariesTable.repo.in_(self.bin_repo)).first()
|
BinariesTable.repo.in_(self.bin_repo)).first()
|
||||||
|
|
||||||
if pkg:
|
if pkg:
|
||||||
|
@ -66,7 +68,7 @@ class BinQueries(Configs):
|
||||||
""" Returns the binary package. """
|
""" Returns the binary package. """
|
||||||
pkg: tuple = self.session.query(
|
pkg: tuple = self.session.query(
|
||||||
BinariesTable.package).filter(
|
BinariesTable.package).filter(
|
||||||
BinariesTable.name == self.name,
|
BinariesTable.name == self.name).where(
|
||||||
BinariesTable.repo.in_(self.bin_repo)).first()
|
BinariesTable.repo.in_(self.bin_repo)).first()
|
||||||
|
|
||||||
if pkg:
|
if pkg:
|
||||||
|
@ -77,7 +79,7 @@ class BinQueries(Configs):
|
||||||
""" Returns the binary package checksum. """
|
""" Returns the binary package checksum. """
|
||||||
md5: tuple = self.session.query(
|
md5: tuple = self.session.query(
|
||||||
BinariesTable.checksum).filter(
|
BinariesTable.checksum).filter(
|
||||||
BinariesTable.package == self.name,
|
BinariesTable.package == self.name).where(
|
||||||
BinariesTable.repo.in_(self.bin_repo)).first()
|
BinariesTable.repo.in_(self.bin_repo)).first()
|
||||||
|
|
||||||
if md5:
|
if md5:
|
||||||
|
@ -88,7 +90,7 @@ class BinQueries(Configs):
|
||||||
""" Returns the package version. """
|
""" Returns the package version. """
|
||||||
pkg: tuple = self.session.query(
|
pkg: tuple = self.session.query(
|
||||||
BinariesTable.version).filter(
|
BinariesTable.version).filter(
|
||||||
BinariesTable.name == self.name,
|
BinariesTable.name == self.name).where(
|
||||||
BinariesTable.repo.in_(self.bin_repo)).first()
|
BinariesTable.repo.in_(self.bin_repo)).first()
|
||||||
|
|
||||||
if pkg:
|
if pkg:
|
||||||
|
@ -99,7 +101,7 @@ class BinQueries(Configs):
|
||||||
""" Returns the package mirror. """
|
""" Returns the package mirror. """
|
||||||
mir: tuple = self.session.query(
|
mir: tuple = self.session.query(
|
||||||
BinariesTable.mirror).filter(
|
BinariesTable.mirror).filter(
|
||||||
BinariesTable.name == self.name,
|
BinariesTable.name == self.name).where(
|
||||||
BinariesTable.repo.in_(self.bin_repo)).first()
|
BinariesTable.repo.in_(self.bin_repo)).first()
|
||||||
|
|
||||||
if mir:
|
if mir:
|
||||||
|
@ -110,7 +112,7 @@ class BinQueries(Configs):
|
||||||
""" Returns the package location. """
|
""" Returns the package location. """
|
||||||
loc: tuple = self.session.query(
|
loc: tuple = self.session.query(
|
||||||
BinariesTable.location).filter(
|
BinariesTable.location).filter(
|
||||||
BinariesTable.name == self.name,
|
BinariesTable.name == self.name).where(
|
||||||
BinariesTable.repo.in_(self.bin_repo)).first()
|
BinariesTable.repo.in_(self.bin_repo)).first()
|
||||||
|
|
||||||
if loc:
|
if loc:
|
||||||
|
@ -121,7 +123,7 @@ class BinQueries(Configs):
|
||||||
""" Returns the package comp size. """
|
""" Returns the package comp size. """
|
||||||
size: tuple = self.session.query(
|
size: tuple = self.session.query(
|
||||||
BinariesTable.size_comp).filter(
|
BinariesTable.size_comp).filter(
|
||||||
BinariesTable.name == self.name,
|
BinariesTable.name == self.name).where(
|
||||||
BinariesTable.repo.in_(self.bin_repo)).first()
|
BinariesTable.repo.in_(self.bin_repo)).first()
|
||||||
|
|
||||||
if size:
|
if size:
|
||||||
|
@ -132,7 +134,7 @@ class BinQueries(Configs):
|
||||||
""" Returns the package uncomp size. """
|
""" Returns the package uncomp size. """
|
||||||
size: tuple = self.session.query(
|
size: tuple = self.session.query(
|
||||||
BinariesTable.unsize_comp).filter(
|
BinariesTable.unsize_comp).filter(
|
||||||
BinariesTable.name == self.name,
|
BinariesTable.name == self.name).where(
|
||||||
BinariesTable.repo.in_(self.bin_repo)).first()
|
BinariesTable.repo.in_(self.bin_repo)).first()
|
||||||
|
|
||||||
if size:
|
if size:
|
||||||
|
@ -143,7 +145,7 @@ class BinQueries(Configs):
|
||||||
""" Returns the package required. """
|
""" Returns the package required. """
|
||||||
req: tuple = self.session.query(
|
req: tuple = self.session.query(
|
||||||
BinariesTable.required).filter(
|
BinariesTable.required).filter(
|
||||||
BinariesTable.name == self.name,
|
BinariesTable.name == self.name).where(
|
||||||
BinariesTable.repo.in_(self.bin_repo)).first()
|
BinariesTable.repo.in_(self.bin_repo)).first()
|
||||||
|
|
||||||
if req:
|
if req:
|
||||||
|
@ -154,7 +156,7 @@ class BinQueries(Configs):
|
||||||
""" Returns the package conflicts. """
|
""" Returns the package conflicts. """
|
||||||
con: tuple = self.session.query(
|
con: tuple = self.session.query(
|
||||||
BinariesTable.conflicts).filter(
|
BinariesTable.conflicts).filter(
|
||||||
BinariesTable.name == self.name,
|
BinariesTable.name == self.name).where(
|
||||||
BinariesTable.repo.in_(self.bin_repo)).first()
|
BinariesTable.repo.in_(self.bin_repo)).first()
|
||||||
|
|
||||||
if con:
|
if con:
|
||||||
|
@ -165,7 +167,7 @@ class BinQueries(Configs):
|
||||||
""" Returns the package suggests. """
|
""" Returns the package suggests. """
|
||||||
sug: tuple = self.session.query(
|
sug: tuple = self.session.query(
|
||||||
BinariesTable.suggests).filter(
|
BinariesTable.suggests).filter(
|
||||||
BinariesTable.name == self.name,
|
BinariesTable.name == self.name).where(
|
||||||
BinariesTable.repo.in_(self.bin_repo)).first()
|
BinariesTable.repo.in_(self.bin_repo)).first()
|
||||||
|
|
||||||
if sug:
|
if sug:
|
||||||
|
@ -176,7 +178,7 @@ class BinQueries(Configs):
|
||||||
""" Returns the package description. """
|
""" Returns the package description. """
|
||||||
desc: tuple = self.session.query(
|
desc: tuple = self.session.query(
|
||||||
BinariesTable.description).filter(
|
BinariesTable.description).filter(
|
||||||
BinariesTable.name == self.name,
|
BinariesTable.name == self.name).where(
|
||||||
BinariesTable.repo.in_(self.bin_repo)).first()
|
BinariesTable.repo.in_(self.bin_repo)).first()
|
||||||
|
|
||||||
if desc:
|
if desc:
|
||||||
|
|
|
@ -5,13 +5,14 @@ from slpkg.configs import Configs
|
||||||
from slpkg.utilities import Utilities
|
from slpkg.utilities import Utilities
|
||||||
|
|
||||||
|
|
||||||
class FindInstalled(Configs, Utilities):
|
class FindInstalled(Configs):
|
||||||
""" Find installed packages. """
|
""" Find installed packages. """
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Configs, self).__init__()
|
super(Configs, self).__init__()
|
||||||
super(Utilities, self).__init__()
|
|
||||||
self.color = self.colour()
|
self.color = self.colour()
|
||||||
|
self.utils = Utilities()
|
||||||
|
|
||||||
self.yellow: str = self.color['yellow']
|
self.yellow: str = self.color['yellow']
|
||||||
self.cyan: str = self.color['cyan']
|
self.cyan: str = self.color['cyan']
|
||||||
|
@ -20,19 +21,20 @@ class FindInstalled(Configs, Utilities):
|
||||||
self.endc: str = self.color['endc']
|
self.endc: str = self.color['endc']
|
||||||
self.grey: str = self.color['grey']
|
self.grey: str = self.color['grey']
|
||||||
|
|
||||||
|
self.installed: list = self.utils.installed_packages
|
||||||
|
|
||||||
def find(self, packages: list) -> None:
|
def find(self, packages: list) -> None:
|
||||||
""" Find the packages. """
|
""" Find the packages. """
|
||||||
matching: list = []
|
matching: list = []
|
||||||
|
|
||||||
installed: list = list(self.all_installed())
|
|
||||||
|
|
||||||
print(f'The list below shows the installed packages '
|
print(f'The list below shows the installed packages '
|
||||||
f'that contains \'{", ".join([p for p in packages])}\' files:\n')
|
f'that contains \'{", ".join([p for p in packages])}\' files:\n')
|
||||||
|
|
||||||
for pkg in packages:
|
for pkg in packages:
|
||||||
for package in installed:
|
for package in self.installed:
|
||||||
if pkg in package:
|
if pkg in package:
|
||||||
matching.append(package)
|
matching.append(package)
|
||||||
|
|
||||||
self.matched(matching)
|
self.matched(matching)
|
||||||
|
|
||||||
def matched(self, matching: list) -> None:
|
def matched(self, matching: list) -> None:
|
||||||
|
|
|
@ -9,7 +9,6 @@ from slpkg.checks import Check
|
||||||
from slpkg.upgrade import Upgrade
|
from slpkg.upgrade import Upgrade
|
||||||
from slpkg.configs import Configs
|
from slpkg.configs import Configs
|
||||||
from slpkg.tracking import Tracking
|
from slpkg.tracking import Tracking
|
||||||
from slpkg.sbos.queries import SBoQueries
|
|
||||||
from slpkg.dependees import Dependees
|
from slpkg.dependees import Dependees
|
||||||
from slpkg.utilities import Utilities
|
from slpkg.utilities import Utilities
|
||||||
from slpkg.search import SearchPackage
|
from slpkg.search import SearchPackage
|
||||||
|
@ -17,13 +16,15 @@ from slpkg.views.cli_menu import Usage
|
||||||
from slpkg.dialog_box import DialogBox
|
from slpkg.dialog_box import DialogBox
|
||||||
from slpkg.views.version import Version
|
from slpkg.views.version import Version
|
||||||
from slpkg.download_only import Download
|
from slpkg.download_only import Download
|
||||||
from slpkg.sbos.slackbuild import Slackbuilds
|
|
||||||
from slpkg.views.views import ViewMessage
|
from slpkg.views.views import ViewMessage
|
||||||
|
from slpkg.sbos.queries import SBoQueries
|
||||||
from slpkg.form_configs import FormConfigs
|
from slpkg.form_configs import FormConfigs
|
||||||
from slpkg.views.help_commands import Help
|
from slpkg.views.help_commands import Help
|
||||||
from slpkg.repositories import Repositories
|
from slpkg.repositories import Repositories
|
||||||
from slpkg.binaries.install import Packages
|
from slpkg.binaries.install import Packages
|
||||||
from slpkg.check_updates import CheckUpdates
|
from slpkg.check_updates import CheckUpdates
|
||||||
|
from slpkg.sbos.slackbuild import Slackbuilds
|
||||||
|
from slpkg.binaries.queries import BinQueries
|
||||||
from slpkg.find_installed import FindInstalled
|
from slpkg.find_installed import FindInstalled
|
||||||
from slpkg.views.view_package import ViewPackage
|
from slpkg.views.view_package import ViewPackage
|
||||||
from slpkg.remove_packages import RemovePackages
|
from slpkg.remove_packages import RemovePackages
|
||||||
|
@ -78,7 +79,7 @@ class Argparse(Configs):
|
||||||
self.flag_short_parallel: str = '-P'
|
self.flag_short_parallel: str = '-P'
|
||||||
self.flag_binary: str = '--binary'
|
self.flag_binary: str = '--binary'
|
||||||
self.flag_short_binary: str = '-B'
|
self.flag_short_binary: str = '-B'
|
||||||
self.flag_bin_repository: str = '--repository='
|
self.flag_bin_repository: str = '--bin-repo='
|
||||||
self.flag_short_bin_repository: str = '-O='
|
self.flag_short_bin_repository: str = '-O='
|
||||||
self.flag_directory: str = '--directory='
|
self.flag_directory: str = '--directory='
|
||||||
self.flag_short_directory: str = '-z='
|
self.flag_short_directory: str = '-z='
|
||||||
|
@ -143,6 +144,10 @@ class Argparse(Configs):
|
||||||
self.flag_short_reinstall,
|
self.flag_short_reinstall,
|
||||||
self.flag_no_silent,
|
self.flag_no_silent,
|
||||||
self.flag_short_no_silent,
|
self.flag_short_no_silent,
|
||||||
|
self.flag_binary,
|
||||||
|
self.flag_short_binary,
|
||||||
|
self.flag_bin_repository,
|
||||||
|
self.flag_short_bin_repository,
|
||||||
self.flag_parallel,
|
self.flag_parallel,
|
||||||
self.flag_short_parallel
|
self.flag_short_parallel
|
||||||
],
|
],
|
||||||
|
@ -274,6 +279,16 @@ class Argparse(Configs):
|
||||||
|
|
||||||
self.check = Check(self.flags)
|
self.check = Check(self.flags)
|
||||||
self.check.is_blacklist(self.args[1:])
|
self.check.is_blacklist(self.args[1:])
|
||||||
|
self.check_for_bin_repositories()
|
||||||
|
|
||||||
|
def check_for_bin_repositories(self) -> None:
|
||||||
|
""" Checks combination for binaries use repositories only and if repository exists. """
|
||||||
|
if (self.utils.is_option([self.flag_bin_repository, self.flag_short_bin_repository], self.flags) and not
|
||||||
|
self.utils.is_option([self.flag_binary, self.flag_short_binary], self.flags)):
|
||||||
|
self.usage.help_minimal(f"{self.prog_name}: invalid options '{', '.join(self.flags)}'")
|
||||||
|
|
||||||
|
if self.binary_repo and self.binary_repo not in self.repos.binaries_repositories_dict.keys():
|
||||||
|
self.usage.help_minimal(f"{self.prog_name}: invalid binary repository '{self.binary_repo}'")
|
||||||
|
|
||||||
def invalid_options(self) -> None:
|
def invalid_options(self) -> None:
|
||||||
""" Checks for invalid options. """
|
""" Checks for invalid options. """
|
||||||
|
@ -292,13 +307,11 @@ class Argparse(Configs):
|
||||||
|
|
||||||
# Fixed for recurring options.
|
# Fixed for recurring options.
|
||||||
if repeat:
|
if repeat:
|
||||||
print(f"{self.prog_name}: invalid recurring options '{', '.join(repeat)}'")
|
self.usage.help_minimal(f"{self.prog_name}: invalid recurring options '{', '.join(repeat)}'")
|
||||||
self.usage.help_minimal()
|
|
||||||
|
|
||||||
# Fixed for invalid commands combination.
|
# Fixed for invalid commands combination.
|
||||||
if len(commands) > 1:
|
if len(commands) > 1:
|
||||||
print(f"{self.prog_name}: invalid commands combination '{', '.join(commands)}'")
|
self.usage.help_minimal(f"{self.prog_name}: invalid commands combination '{', '.join(commands)}'")
|
||||||
self.usage.help_minimal()
|
|
||||||
|
|
||||||
# Fixed for correct options by command.
|
# Fixed for correct options by command.
|
||||||
try:
|
try:
|
||||||
|
@ -311,9 +324,7 @@ class Argparse(Configs):
|
||||||
|
|
||||||
# Prints error for invalid options.
|
# Prints error for invalid options.
|
||||||
if invalid:
|
if invalid:
|
||||||
for opt in invalid:
|
self.usage.help_minimal(f"{self.prog_name}: invalid options '{','.join(invalid)}'")
|
||||||
print(f"{self.prog_name}: invalid option '{opt}'")
|
|
||||||
self.usage.help_minimal()
|
|
||||||
|
|
||||||
def split_options(self) -> None:
|
def split_options(self) -> None:
|
||||||
""" Split options and commands, like: -iyjR
|
""" Split options and commands, like: -iyjR
|
||||||
|
@ -387,9 +398,12 @@ class Argparse(Configs):
|
||||||
list_height: int = 0
|
list_height: int = 0
|
||||||
choices: list = []
|
choices: list = []
|
||||||
title: str = f' Choose packages you want to {method} '
|
title: str = f' Choose packages you want to {method} '
|
||||||
repo_packages: list = SBoQueries('').sbos()
|
|
||||||
|
|
||||||
installed: list = list(self.utils.all_installed())
|
repo_packages: list = SBoQueries('').sbos()
|
||||||
|
if self.utils.is_option([self.flag_binary, self.flag_short_binary], self.flags):
|
||||||
|
repo_packages: list = BinQueries('', self.binary_repo).all_name_packages()
|
||||||
|
|
||||||
|
installed: list = self.utils.installed_packages
|
||||||
|
|
||||||
if method in ['remove', 'find']:
|
if method in ['remove', 'find']:
|
||||||
|
|
||||||
|
@ -406,12 +420,19 @@ class Argparse(Configs):
|
||||||
for package in repo_packages:
|
for package in repo_packages:
|
||||||
|
|
||||||
if pkg == package:
|
if pkg == package:
|
||||||
|
|
||||||
repo_ver: str = SBoQueries(package).version()
|
repo_ver: str = SBoQueries(package).version()
|
||||||
inst_pkg: str = self.utils.is_package_installed(package)
|
inst_pkg: str = self.utils.is_package_installed(package)
|
||||||
inst_ver: str = self.utils.split_binary_pkg(inst_pkg)[1]
|
inst_ver: str = self.utils.split_binary_pkg(inst_pkg)[1]
|
||||||
|
inst_build_tag: str = self.utils.split_binary_pkg(inst_pkg)[3]
|
||||||
|
|
||||||
repo_build_tag = self.utils.read_build_tag(package)
|
if self.utils.is_option([self.flag_binary, self.flag_short_binary], self.flags):
|
||||||
inst_build_tag = self.utils.split_binary_pkg(inst_pkg)[3]
|
repo_ver: str = BinQueries(package, self.binary_repo).version()
|
||||||
|
bin_pkg: str = BinQueries(package, self.binary_repo).package_bin()
|
||||||
|
repo_build_tag: str = self.utils.split_binary_pkg(bin_pkg[:-4])[3]
|
||||||
|
|
||||||
|
else:
|
||||||
|
repo_build_tag: str = self.utils.read_sbo_build_tag(package)
|
||||||
|
|
||||||
choices += [(package, f'{inst_ver} -> {repo_ver}', True,
|
choices += [(package, f'{inst_ver} -> {repo_ver}', True,
|
||||||
f'Installed: {package}-{inst_ver} Build: {inst_build_tag} -> '
|
f'Installed: {package}-{inst_ver} Build: {inst_build_tag} -> '
|
||||||
|
@ -422,7 +443,11 @@ class Argparse(Configs):
|
||||||
for package in repo_packages:
|
for package in repo_packages:
|
||||||
|
|
||||||
if pkg in package:
|
if pkg in package:
|
||||||
repo_ver = SBoQueries(package).version()
|
|
||||||
|
repo_ver: str = SBoQueries(package).version()
|
||||||
|
if self.utils.is_option([self.flag_binary, self.flag_short_binary], self.flags):
|
||||||
|
repo_ver: str = BinQueries(package, self.binary_repo).version()
|
||||||
|
|
||||||
choices += [(package, repo_ver, False, f'Package: {package}-{repo_ver}')]
|
choices += [(package, repo_ver, False, f'Package: {package}-{repo_ver}')]
|
||||||
|
|
||||||
if not choices:
|
if not choices:
|
||||||
|
@ -467,7 +492,7 @@ class Argparse(Configs):
|
||||||
if len(self.args) == 1:
|
if len(self.args) == 1:
|
||||||
self.check.is_empty_database()
|
self.check.is_empty_database()
|
||||||
|
|
||||||
upgrade = Upgrade()
|
upgrade = Upgrade(self.flags, self.binary_repo)
|
||||||
packages: list = list(upgrade.packages())
|
packages: list = list(upgrade.packages())
|
||||||
|
|
||||||
packages: list = self.choose_packages(packages, command)
|
packages: list = self.choose_packages(packages, command)
|
||||||
|
@ -476,8 +501,12 @@ class Argparse(Configs):
|
||||||
print('\nEverything is up-to-date.\n')
|
print('\nEverything is up-to-date.\n')
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
|
|
||||||
install = Slackbuilds(packages, self.flags, mode=command)
|
if self.utils.is_option([self.flag_binary, self.flag_short_binary], self.flags):
|
||||||
install.execute()
|
install = Packages(packages, self.flags, self.binary_repo, mode=command)
|
||||||
|
install.execute()
|
||||||
|
else:
|
||||||
|
install = Slackbuilds(packages, self.flags, mode=command)
|
||||||
|
install.execute()
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help_short(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
|
|
|
@ -4,33 +4,43 @@
|
||||||
from typing import Generator
|
from typing import Generator
|
||||||
|
|
||||||
from slpkg.configs import Configs
|
from slpkg.configs import Configs
|
||||||
from slpkg.sbos.queries import SBoQueries
|
|
||||||
from slpkg.utilities import Utilities
|
from slpkg.utilities import Utilities
|
||||||
from slpkg.dependencies import Requires
|
from slpkg.dependencies import Requires
|
||||||
|
from slpkg.sbos.queries import SBoQueries
|
||||||
|
from slpkg.binaries.queries import BinQueries
|
||||||
|
|
||||||
|
|
||||||
class Upgrade(Configs, Utilities):
|
class Upgrade(Configs):
|
||||||
""" Upgrade the installed packages. """
|
""" Upgrade the installed packages. """
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, flags: list, repo: str):
|
||||||
super(Configs, self).__init__()
|
super(Configs, self).__init__()
|
||||||
super(Utilities, self).__init__()
|
self.flags = flags
|
||||||
|
self.repo = repo
|
||||||
|
self.utils = Utilities()
|
||||||
|
|
||||||
|
self.flag_binary: list = ['-B', '--binary']
|
||||||
|
|
||||||
def packages(self) -> Generator[str, None, None]:
|
def packages(self) -> Generator[str, None, None]:
|
||||||
""" Compares version of packages and returns the maximum. """
|
""" Compares version of packages and returns the maximum. """
|
||||||
upgrade: list = []
|
upgrade, requires = [], []
|
||||||
requires: list = []
|
|
||||||
repo_packages: list = SBoQueries('').sbos()
|
|
||||||
|
|
||||||
installed: list = list(self.all_installed())
|
repo_packages: list = SBoQueries('').sbos()
|
||||||
|
if self.utils.is_option(self.flag_binary, self.flags):
|
||||||
|
repo_packages: list = BinQueries('', self.repo).all_name_packages()
|
||||||
|
|
||||||
|
installed: list = self.utils.installed_packages
|
||||||
|
|
||||||
for pkg in installed:
|
for pkg in installed:
|
||||||
inst_pkg_name: str = self.split_binary_pkg(pkg)[0]
|
inst_pkg_name: str = self.utils.split_binary_pkg(pkg)[0]
|
||||||
|
|
||||||
if inst_pkg_name in repo_packages:
|
if inst_pkg_name in repo_packages:
|
||||||
|
|
||||||
if self.is_package_upgradeable(inst_pkg_name):
|
if self.utils.is_package_upgradeable(inst_pkg_name):
|
||||||
requires += Requires(inst_pkg_name).resolve()
|
|
||||||
|
if not self.utils.is_option(self.flag_binary, self.flags):
|
||||||
|
requires += Requires(inst_pkg_name).resolve()
|
||||||
|
|
||||||
upgrade.append(inst_pkg_name)
|
upgrade.append(inst_pkg_name)
|
||||||
|
|
||||||
# Clean the packages if they are dependencies
|
# Clean the packages if they are dependencies
|
||||||
|
|
|
@ -91,13 +91,15 @@ class Utilities:
|
||||||
if not directory.exists():
|
if not directory.exists():
|
||||||
directory.mkdir(parents=True, exist_ok=True)
|
directory.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
def split_binary_pkg(self, package: str) -> list:
|
@staticmethod
|
||||||
|
def split_binary_pkg(package: str) -> list:
|
||||||
""" Split the package by the name, version, arch, build and tag. """
|
""" Split the package by the name, version, arch, build and tag. """
|
||||||
name: str = '-'.join(package.split('-')[:-3])
|
name: str = '-'.join(package.split('-')[:-3])
|
||||||
version: str = ''.join(package[len(name):].split('-')[:-2])
|
version: str = ''.join(package[len(name):].split('-')[:-2])
|
||||||
arch: str = ''.join(package[len(name + version) + 2:].split('-')[:-1])
|
arch: str = ''.join(package[len(name + version) + 2:].split('-')[:-1])
|
||||||
build: str = ''.join(package[len(name + version + arch) + 3:].split('-')).replace(self.repos.repo_tag, '')
|
build_tag: str = package.split('-')[-1]
|
||||||
tag: str = ''.join(package[len(name + version + arch + build) + 4:].split('-'))
|
build: str = ''.join(re.findall(r'\d+', build_tag[:2]))
|
||||||
|
tag: str = build_tag[len(build):].replace('_', '')
|
||||||
|
|
||||||
return [name, version, arch, build, tag]
|
return [name, version, arch, build, tag]
|
||||||
|
|
||||||
|
@ -112,7 +114,7 @@ class Utilities:
|
||||||
installed_version: str = '0'
|
installed_version: str = '0'
|
||||||
installed = self.is_package_installed(package)
|
installed = self.is_package_installed(package)
|
||||||
repository_version = str(SBoQueries(package).version())
|
repository_version = str(SBoQueries(package).version())
|
||||||
repo_build_tag: str = self.read_build_tag(package)
|
repo_build_tag: str = self.read_sbo_build_tag(package)
|
||||||
inst_build_tag: str = self.split_binary_pkg(installed)[3]
|
inst_build_tag: str = self.split_binary_pkg(installed)[3]
|
||||||
|
|
||||||
if not repo_build_tag:
|
if not repo_build_tag:
|
||||||
|
@ -129,7 +131,7 @@ class Utilities:
|
||||||
|
|
||||||
return parse(repository_version + repo_build_tag) > parse(installed_version + inst_build_tag)
|
return parse(repository_version + repo_build_tag) > parse(installed_version + inst_build_tag)
|
||||||
|
|
||||||
def read_build_tag(self, sbo: str) -> str:
|
def read_sbo_build_tag(self, sbo: str) -> str:
|
||||||
""" Patching SBo TAG from the configuration file. """
|
""" Patching SBo TAG from the configuration file. """
|
||||||
location: str = SBoQueries(sbo).location()
|
location: str = SBoQueries(sbo).location()
|
||||||
sbo_script = Path(self.repos.sbo_repo_path, location, sbo, f'{sbo}.SlackBuild')
|
sbo_script = Path(self.repos.sbo_repo_path, location, sbo, f'{sbo}.SlackBuild')
|
||||||
|
|
|
@ -17,8 +17,9 @@ class Usage(Configs):
|
||||||
self.yellow: str = color['yellow']
|
self.yellow: str = color['yellow']
|
||||||
self.endc: str = color['endc']
|
self.endc: str = color['endc']
|
||||||
|
|
||||||
def help_minimal(self) -> NoReturn:
|
def help_minimal(self, message: str) -> NoReturn:
|
||||||
""" Prints the minimal help menu. """
|
""" Prints the minimal help menu. """
|
||||||
|
print(message)
|
||||||
args: str = (
|
args: str = (
|
||||||
f'\nUsage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] '
|
f'\nUsage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] '
|
||||||
f'[FILELIST|PACKAGES...]\n'
|
f'[FILELIST|PACKAGES...]\n'
|
||||||
|
@ -40,7 +41,7 @@ class Usage(Configs):
|
||||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-y, --yes, -j, --jobs, -o, --resolve-off, -r, --reinstall]\n'
|
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-y, --yes, -j, --jobs, -o, --resolve-off, -r, --reinstall]\n'
|
||||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-k, --skip-installed, -E, --full-reverse, -S, --search]\n'
|
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-k, --skip-installed, -E, --full-reverse, -S, --search]\n'
|
||||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-n, --no-silent, -p, --pkg-version, -G, --generate-only]\n'
|
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-n, --no-silent, -p, --pkg-version, -G, --generate-only]\n'
|
||||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-P, --parallel, -B, --binary, -O, --repository=[REPO]]\n'
|
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-P, --parallel, -B, --binary, -O, --bin-repo=[REPO]]\n'
|
||||||
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-z, --directory=[PATH]]\n'
|
f' slpkg [{self.yellow}OPTIONS{self.endc}] [-z, --directory=[PATH]]\n'
|
||||||
" \nIf you need more information please try 'slpkg --help'.")
|
" \nIf you need more information please try 'slpkg --help'.")
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ class Usage(Configs):
|
||||||
f' {self.yellow}-G, --generate-only{self.endc} Generates only the SLACKBUILDS.TXT file.\n'
|
f' {self.yellow}-G, --generate-only{self.endc} Generates only the SLACKBUILDS.TXT file.\n'
|
||||||
f' {self.yellow}-P, --parallel{self.endc} Download files in parallel.\n'
|
f' {self.yellow}-P, --parallel{self.endc} Download files in parallel.\n'
|
||||||
f' {self.yellow}-B, --binary{self.endc} Switch with binaries repositories.\n'
|
f' {self.yellow}-B, --binary{self.endc} Switch with binaries repositories.\n'
|
||||||
f' {self.yellow}-O, --repository={self.endc}[REPO] Set the binary repository.\n'
|
f' {self.yellow}-O, --bin-repo={self.endc}[REPO] Set the binary repository.\n'
|
||||||
f' {self.yellow}-z, --directory={self.endc}[PATH] Download files to a specific path.\n'
|
f' {self.yellow}-z, --directory={self.endc}[PATH] Download files to a specific path.\n'
|
||||||
'\n -h, --help Show this message and exit.\n'
|
'\n -h, --help Show this message and exit.\n'
|
||||||
' -v, --version Print version and exit.\n'
|
' -v, --version Print version and exit.\n'
|
||||||
|
|
|
@ -65,7 +65,7 @@ class ViewPackage(Configs):
|
||||||
path = Path(self.repo_path, info[9], info[0], f'{info[0]}.info')
|
path = Path(self.repo_path, info[9], info[0], f'{info[0]}.info')
|
||||||
info_file = self.utils.read_file(path)
|
info_file = self.utils.read_file(path)
|
||||||
|
|
||||||
repo_build_tag = self.utils.read_build_tag(info[0])
|
repo_build_tag = self.utils.read_sbo_build_tag(info[0])
|
||||||
|
|
||||||
maintainer, email, homepage = '', '', ''
|
maintainer, email, homepage = '', '', ''
|
||||||
for line in info_file:
|
for line in info_file:
|
||||||
|
|
Loading…
Add table
Reference in a new issue