Added downgrade config

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2024-06-06 09:38:12 +03:00
parent 751d3501dc
commit 57a0b67118
6 changed files with 15 additions and 5 deletions

View file

@ -1,15 +1,15 @@
## slpkg - ChangeLog ## slpkg - ChangeLog
### 5.1.0 - 04/06/2024 ### 5.1.0 - 06/06/2024
- Added: - Added:
* Added PACKAGE_METHOD config to choose the upgrade method * Added PACKAGE_METHOD config to choose the upgrade method
* Added DOWNGRADE_PACKAGES config to allow to downgrade packages (Thanks to marav)
- Updated: - Updated:
* Updated message for invalid package version * Updated message for invalid package version
* Updated upgrade.log file to json format * Updated upgrade.log file to json format
* Separation of the process bar with progress bar * Separation of the process bar with progress bar
* Updated to check downgrade packages (Thanks to marav)
### 5.0.9 - 23/05/2024 ### 5.0.9 - 23/05/2024

View file

@ -1,6 +1,6 @@
# This is the general configuration file of slpkg: # This is the general configuration file of slpkg:
# /etc/slpkg/slpkg.toml # /etc/slpkg/slpkg.toml
# Updated: 01/06/2024, Version: 5.1.0 # Updated: 06/06/2024, Version: 5.1.0
[CONFIGS] [CONFIGS]
@ -48,6 +48,11 @@ VIEW_MISSING_DEPS = true
# is newer than the repository package. Default is false. [true/false] # is newer than the repository package. Default is false. [true/false]
PACKAGE_METHOD = false PACKAGE_METHOD = false
# This setting allows you to downgrade packages.
# It works if the package method it is false.
# Default is false. [true/false]
DOWNGRADE_PACKAGES = 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

@ -47,6 +47,7 @@ class Configs: # pylint: disable=[R0902]
dialog: bool = True dialog: bool = True
view_missing_deps: bool = True view_missing_deps: bool = True
package_method: bool = False package_method: bool = False
downgrade_packages: 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'
@ -96,6 +97,7 @@ class Configs: # pylint: disable=[R0902]
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'] package_method: bool = config['package_method']
downgrade_packages: bool = config['downgrade_packages']
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

@ -33,7 +33,7 @@ class FormConfigs(Configs):
"""Read and write the configuration file.""" """Read and write the configuration file."""
self.is_dialog_enabled() self.is_dialog_enabled()
elements: list = [] elements: list = []
height: int = 7 height: int = 0
width: int = 0 width: int = 0
form_height: int = 0 form_height: int = 0
text: str = f'Edit the configuration file: {self.config_file}' text: str = f'Edit the configuration file: {self.config_file}'
@ -77,6 +77,7 @@ class FormConfigs(Configs):
'DIALOG', 'DIALOG',
'VIEW_MISSING_DEPS', 'VIEW_MISSING_DEPS',
'PACKAGE_METHOD', 'PACKAGE_METHOD',
'DOWNGRADE_PACKAGES',
'DELETE_SOURCES', 'DELETE_SOURCES',
'SILENT_MODE', 'SILENT_MODE',
'ASCII_CHARACTERS', 'ASCII_CHARACTERS',
@ -130,6 +131,7 @@ class FormConfigs(Configs):
'DIALOG =', 'DIALOG =',
'VIEW_MISSING_DEPS =', 'VIEW_MISSING_DEPS =',
'PACKAGE_METHOD =', 'PACKAGE_METHOD =',
'DOWNGRADE_PACKAGES =',
'DELETE_SOURCES =', 'DELETE_SOURCES =',
'SILENT_MODE =', 'SILENT_MODE =',
'ASCII_CHARACTERS =', 'ASCII_CHARACTERS =',

View file

@ -129,7 +129,7 @@ class Upgrade(Configs): # pylint: disable=[R0902]
if parse(repo_version) == parse(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
if parse(repo_version) < parse(inst_version): if self.downgrade_packages and (parse(repo_version) < parse(inst_version)):
return True return True
except InvalidVersion as err: except InvalidVersion as err:
if repo_version > inst_version: # Try to compare the strings. if repo_version > inst_version: # Try to compare the strings.

View file

@ -38,6 +38,7 @@ class TestConfigs(unittest.TestCase):
self.assertEqual(True, self.configs.dialog) self.assertEqual(True, self.configs.dialog)
self.assertEqual(True, self.configs.view_missing_deps) self.assertEqual(True, self.configs.view_missing_deps)
self.assertEqual(False, self.configs.package_method) self.assertEqual(False, self.configs.package_method)
self.assertEqual(False, self.configs.downgrade_packages)
self.assertEqual(False, self.configs.delete_sources) self.assertEqual(False, self.configs.delete_sources)
self.assertEqual('wget', self.configs.downloader) self.assertEqual('wget', self.configs.downloader)
self.assertEqual('-c -q --progress=bar:force:noscroll --show-progress', self.configs.wget_options) self.assertEqual('-c -q --progress=bar:force:noscroll --show-progress', self.configs.wget_options)