From c273607ae100f70b40753fa1e7a0ec6a548b40ae Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 1 Jun 2024 17:20:25 +0300 Subject: [PATCH] Added PACKAGE_METHOD config Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 5 ++++- configs/slpkg.toml | 10 ++++++++++ slpkg/configs.py | 2 ++ slpkg/dialog_configs.py | 2 ++ slpkg/upgrade.py | 26 ++++++++++++++++---------- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 20ff9788..7710cccc 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,9 @@ ## slpkg - ChangeLog -### 5.0.10 - 31/05/2024 +### 5.1.0 - 01/06/2024 + +- Added: + * Added PACKAGE_METHOD config to choose the upgrade method - Updated: * Updated message for invalid package version diff --git a/configs/slpkg.toml b/configs/slpkg.toml index b7d7c552..791e08ce 100644 --- a/configs/slpkg.toml +++ b/configs/slpkg.toml @@ -38,6 +38,16 @@ DIALOG = true # but not as main packages. Default is true. [true/false] VIEW_MISSING_DEPS = true +# There are two different methods to choose when you want to upgrade +# your installed packages, "version" method and "package" method. +# With the "version" method, it will compare the version and the +# build number of the packages following the semantic versioning, +# and with the "package" method it will compare the whole package +# between installed and repository and this means it will suggest +# also downgrades if the installed package is newer than the +# repository package. Default is false. [true/false] +PACKAGE_METHOD = false + # Delete downloaded sources after build or install packages. # Default is false. [true/false] DELETE_SOURCES = false diff --git a/slpkg/configs.py b/slpkg/configs.py index 1172647f..ac8af95a 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -46,6 +46,7 @@ class Configs: # pylint: disable=[R0902] checksum_md5: bool = True dialog: bool = True view_missing_deps: bool = True + package_method: bool = False delete_sources: bool = False downloader: str = 'wget' wget_options: str = '--c -q --progress=bar:force:noscroll --show-progress' @@ -94,6 +95,7 @@ class Configs: # pylint: disable=[R0902] checksum_md5: bool = config['checksum_md5'] dialog: bool = config['dialog'] view_missing_deps: bool = config['view_missing_deps'] + package_method: bool = config['package_method'] delete_sources: bool = config['delete_sources'] downloader: str = config['downloader'] wget_options: str = config['wget_options'] diff --git a/slpkg/dialog_configs.py b/slpkg/dialog_configs.py index fa09c7b2..3b6f4597 100644 --- a/slpkg/dialog_configs.py +++ b/slpkg/dialog_configs.py @@ -76,6 +76,7 @@ class FormConfigs(Configs): 'COLORS', 'DIALOG', 'VIEW_MISSING_DEPS', + 'PACKAGE_METHOD', 'DELETE_SOURCES', 'SILENT_MODE', 'ASCII_CHARACTERS', @@ -128,6 +129,7 @@ class FormConfigs(Configs): ('COLORS =', 'DIALOG =', 'VIEW_MISSING_DEPS =', + 'PACKAGE_METHOD =', 'DELETE_SOURCES =', 'SILENT_MODE =', 'ASCII_CHARACTERS =', diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index 14a7ab24..5856f375 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -116,18 +116,24 @@ class Upgrade(Configs): # pylint: disable=[R0902] inst_build: str = self.utils.split_package(installed)['build'] - try: - if parse(repo_version) > parse(inst_version): + if self.package_method: + repo_package: str = self.data[inst_name]['package'][:-4] # Get the repo package. + if installed != repo_package: return True - if parse(repo_version) == parse(inst_version) and int(repo_build) > int(inst_build): - return True - except InvalidVersion as err: - if repo_version > inst_version: # Try to compare the strings. - return True - if repo_version == inst_version and int(repo_build) > int(inst_build): - return True - self._write_log_file(installed, inst_name, err) + else: + try: + if parse(repo_version) > parse(inst_version): + return True + + if parse(repo_version) == parse(inst_version) and int(repo_build) > int(inst_build): + return True + except InvalidVersion as err: + if repo_version > inst_version: # Try to compare the strings. + return True + if repo_version == inst_version and int(repo_build) > int(inst_build): + return True + self._write_log_file(installed, inst_name, err) return False