From 9888b9e81e5f0eb241997e2faf587472dec270f3 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 23 Jan 2023 23:42:00 +0200 Subject: [PATCH] Added option to upgrade --- man/slpkg.1 | 10 ++++++---- slpkg/main.py | 7 ++++--- slpkg/upgrade.py | 7 ++++--- slpkg/utilities.py | 6 +++--- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/man/slpkg.1 b/man/slpkg.1 index dc4811b6..0df19139 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -156,10 +156,12 @@ Print the repository package version. (to be used with: -e, dependees, -t, track .P --file-pattern=PATTERN .RS -Search for specific installed files with a pattern, such as: slpkg -f 'python' --file-pattern='*', -prints all installed packages that include the name 'python', not only the SBo packages. -Also when you want to see packages that you have installed from other repositories, like: -slpkg -i podman --file-pattern='*alien'. (to be used with: -i, install, -r, remove, -f, find) +Search for specific installed files with a pattern, such as `slpkg -f 'python' --file-pattern='*'`, +and prints all installed packages that include the name 'python', not only the SBo packages. +Also when you want to install and view packages that you have installed from other repositories, try like +`slpkg -i podman --file-pattern='*alien'` or if you want to check and upgrade packages from other repositories +`slpkg upgrade --file-pattern='*alien'` or remove packages with `slpkg -r --file-pattern='*'`. +(to be used with: upgrade, -i, install, -r, remove, -f, find) .RE .P -h | --help diff --git a/slpkg/main.py b/slpkg/main.py index 3a3f4c63..b3570d5e 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -110,7 +110,8 @@ class Argparse(Configs): self.flag_jobs, self.flag_resolve_off, self.flag_reinstall, - self.flag_no_silent + self.flag_no_silent, + self.flag_file_pattern ], 'check-updates': [], 'configs': [], @@ -216,7 +217,7 @@ class Argparse(Configs): if pkg == package: repo_ver = SBoQueries(package).version() - inst_pkg = self.utils.is_installed(package, pattern=f'*{self.sbo_repo_tag}') + inst_pkg = self.utils.is_installed(package, self.file_pattern) inst_ver = self.utils.split_installed_pkg(inst_pkg)[1] choices += [(package, f'{inst_ver} -> {repo_ver}', True)] @@ -271,7 +272,7 @@ class Argparse(Configs): if len(self.args) == 1: self.check.database() - upgrade = Upgrade() + upgrade = Upgrade(self.file_pattern) packages = list(upgrade.packages()) packages = self.choose_packages(packages, command) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index 0a79da6b..1e7c4af3 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -11,9 +11,10 @@ from slpkg.configs import Configs class Upgrade(Configs, Utilities): """ Upgrade the installed packages. """ - def __init__(self): + def __init__(self, file_pattern): super(Configs, self).__init__() super(Utilities, self).__init__() + self.file_pattern = file_pattern def packages(self): """ Compares version of packages and returns the maximum. """ @@ -21,14 +22,14 @@ class Upgrade(Configs, Utilities): black = Blacklist().get() upgrade, requires = [], [] - installed = self.all_installed(f'*{self.sbo_repo_tag}') + installed = self.all_installed(self.file_pattern) for pkg in installed: inst_pkg_name = self.split_installed_pkg(pkg)[0] if inst_pkg_name not in black and inst_pkg_name in repo_packages: - if self.is_repo_version_bigger(inst_pkg_name): + if self.is_repo_version_bigger(inst_pkg_name, self.file_pattern): requires += Requires(inst_pkg_name).resolve() upgrade.append(inst_pkg_name) diff --git a/slpkg/utilities.py b/slpkg/utilities.py index c10b1c9c..81edcab8 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -88,10 +88,10 @@ class Utilities: time.strftime(f'[{self.cyan}%H:%M:%S{self.endc}]', time.gmtime(elapsed_time))) - def is_repo_version_bigger(self, package: str) -> bool: + def is_repo_version_bigger(self, package: str, file_pattern: str) -> bool: """ Compare two versions. """ - pattern = f'*{self.configs.sbo_repo_tag}' - installed = self.is_installed(package, pattern) + # pattern = f'*{self.configs.sbo_repo_tag}' + installed = self.is_installed(package, file_pattern) if installed: installed_version = self.split_installed_pkg(installed)[1] repository_version = SBoQueries(package).version()