From cdd28f019742d952da25803c23f336db088f6a58 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 30 Mar 2023 16:27:42 +0300 Subject: [PATCH] Fixed for install --- slpkg/binaries/install.py | 18 +++++++----------- slpkg/upgrade.py | 12 ++++++------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py index 6d3be84a..78589f0b 100644 --- a/slpkg/binaries/install.py +++ b/slpkg/binaries/install.py @@ -100,10 +100,7 @@ class Packages(Configs): for pkg in self.install_order: - skip_package: str = self.skip_installed_package(pkg) - - if not skip_package: - + if self.is_for_install(pkg): mirror: str = BinQueries(pkg, self.repo).mirror() location: str = BinQueries(pkg, self.repo).location() package: str = BinQueries(pkg, self.repo).package_bin() @@ -111,9 +108,8 @@ class Packages(Configs): 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.utils.split_binary_pkg(skip_package)[1] + version: str = BinQueries(pkg, self.repo).version() self.view_message.view_skipping_packages(pkg, version) if pkg_urls: @@ -121,13 +117,13 @@ class Packages(Configs): down.download() print() - def skip_installed_package(self, package) -> str: + def is_for_install(self, name) -> bool: """ Skip installed package when the option --skip-installed is applied. """ - installed_package: str = self.utils.is_package_installed(package) + if self.utils.is_option(self.flag_skip_installed, self.flags): + return False - if (installed_package and self.mode == 'upgrade' and not self.upgrade.is_package_upgradeable(package) - or self.mode == 'install' and not self.utils.is_option(self.flag_reinstall, self.flags)): - return installed_package + if self.upgrade.is_package_upgradeable(name) or self.utils.is_option(self.flag_reinstall, self.flags): + return True def checksum(self) -> None: """ Packages checksums. """ diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index 0a7b3b2e..e610e291 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -37,18 +37,18 @@ class Upgrade(Configs): if self.is_package_upgradeable(inst_package): yield inst_package - def is_package_upgradeable(self, package: str) -> bool: + def is_package_upgradeable(self, name: str) -> bool: """ Checks for installed and upgradeable packages. """ - inst_package: str = self.utils.is_package_installed(package) + inst_package: str = self.utils.is_package_installed(name) inst_version: str = self.utils.split_binary_pkg(inst_package)[1] inst_build: str = self.utils.split_binary_pkg(inst_package)[3] if self.utils.is_option(self.flag_bin_repository, self.flags): - repo_package: str = BinQueries(package, self.repo).package_bin() - repo_version: str = BinQueries(package, self.repo).version() + repo_package: str = BinQueries(name, self.repo).package_bin() + repo_version: str = BinQueries(name, self.repo).version() repo_build: str = self.utils.split_binary_pkg(repo_package)[3] else: - repo_version: str = SBoQueries(package).version() - repo_build: str = self.utils.read_sbo_build_tag(package) + repo_version: str = SBoQueries(name).version() + repo_build: str = self.utils.read_sbo_build_tag(name) return parse(repo_version + repo_build) > parse(inst_version + inst_build)