Added PACKAGE_METHOD config

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2024-06-01 17:20:25 +03:00
parent 0dfa4a85d3
commit c273607ae1
5 changed files with 34 additions and 11 deletions

View file

@ -1,6 +1,9 @@
## slpkg - ChangeLog ## 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:
* Updated message for invalid package version * Updated message for invalid package version

View file

@ -38,6 +38,16 @@ DIALOG = true
# but not as main packages. Default is true. [true/false] # but not as main packages. Default is true. [true/false]
VIEW_MISSING_DEPS = true 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. # Delete downloaded sources after build or install packages.
# Default is false. [true/false] # Default is false. [true/false]
DELETE_SOURCES = false DELETE_SOURCES = false

View file

@ -46,6 +46,7 @@ class Configs: # pylint: disable=[R0902]
checksum_md5: bool = True checksum_md5: bool = True
dialog: bool = True dialog: bool = True
view_missing_deps: bool = True view_missing_deps: bool = True
package_method: bool = False
delete_sources: bool = False delete_sources: bool = False
downloader: str = 'wget' downloader: str = 'wget'
wget_options: str = '--c -q --progress=bar:force:noscroll --show-progress' 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'] checksum_md5: bool = config['checksum_md5']
dialog: bool = config['dialog'] dialog: bool = config['dialog']
view_missing_deps: bool = config['view_missing_deps'] view_missing_deps: bool = config['view_missing_deps']
package_method: bool = config['package_method']
delete_sources: bool = config['delete_sources'] delete_sources: bool = config['delete_sources']
downloader: str = config['downloader'] downloader: str = config['downloader']
wget_options: str = config['wget_options'] wget_options: str = config['wget_options']

View file

@ -76,6 +76,7 @@ class FormConfigs(Configs):
'COLORS', 'COLORS',
'DIALOG', 'DIALOG',
'VIEW_MISSING_DEPS', 'VIEW_MISSING_DEPS',
'PACKAGE_METHOD',
'DELETE_SOURCES', 'DELETE_SOURCES',
'SILENT_MODE', 'SILENT_MODE',
'ASCII_CHARACTERS', 'ASCII_CHARACTERS',
@ -128,6 +129,7 @@ class FormConfigs(Configs):
('COLORS =', ('COLORS =',
'DIALOG =', 'DIALOG =',
'VIEW_MISSING_DEPS =', 'VIEW_MISSING_DEPS =',
'PACKAGE_METHOD =',
'DELETE_SOURCES =', 'DELETE_SOURCES =',
'SILENT_MODE =', 'SILENT_MODE =',
'ASCII_CHARACTERS =', 'ASCII_CHARACTERS =',

View file

@ -116,18 +116,24 @@ class Upgrade(Configs): # pylint: disable=[R0902]
inst_build: str = self.utils.split_package(installed)['build'] inst_build: str = self.utils.split_package(installed)['build']
try: if self.package_method:
if parse(repo_version) > parse(inst_version): repo_package: str = self.data[inst_name]['package'][:-4] # Get the repo package.
if installed != repo_package:
return True return True
if parse(repo_version) == parse(inst_version) and int(repo_build) > int(inst_build): else:
return True try:
except InvalidVersion as err: if parse(repo_version) > parse(inst_version):
if repo_version > inst_version: # Try to compare the strings. return True
return True
if repo_version == inst_version and int(repo_build) > int(inst_build): if parse(repo_version) == parse(inst_version) and int(repo_build) > int(inst_build):
return True return True
self._write_log_file(installed, inst_name, err) 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 return False