From 1b3bcf96ba8ed5780ed26c055fe81f995f88b525 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 8 May 2024 18:33:02 +0300 Subject: [PATCH] Moved configs Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 5 +++++ configs/repositories.toml | 16 +++++++++++++--- configs/slpkg.toml | 12 +----------- slpkg/configs.py | 4 ---- slpkg/dialog_configs.py | 8 ++------ slpkg/repositories.py | 5 ++++- slpkg/upgrade.py | 4 ++-- tests/test_configs.py | 2 -- 8 files changed, 27 insertions(+), 29 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 71427beb..2b54964f 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,5 +1,10 @@ ## slpkg - ChangeLog +### 5.0.8 - 08/05/2024 + +- Updated: + * Moved configs NEW_PACKAGES and REMOVE_PACKAGES to the repositories.toml file + ### 5.0.7 - 07/05/2024 - Fixed: diff --git a/configs/repositories.toml b/configs/repositories.toml index 9faed619..f9a7bdd3 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -1,6 +1,6 @@ # This is the general repositories configuration file of slpkg: # /etc/slpkg/repositories.toml -# Updated: 01/05/2024, Version: 5.0.7 +# Updated: 08/05/2024, Version: 5.0.8 # Set 'true' or 'false' to enable or disable the repository you want. # You can use a mirror not included in this file. @@ -28,11 +28,21 @@ # https://repo.greeklug.gr/data/pub/linux/salix/x86_64/slackware-15.0/extra/ # https://repo.greeklug.gr/data/pub/linux/salix/x86_64/slackware-15.0/patches/ +[DEFAULT] # This is the DEFAULT REPOSITORY. # You can change it with one that you see below. # Make sure you have enabled it before. -[DEFAULT] -REPO = "sbo" +REPOSITORY = "sbo" + +[NEW_PACKAGES] +# Configure the repositories that you want new packages to be added +# when upgrading installed packages. Example ["slack", "gnome"]. +REPOSITORIES = [] + +[REMOVE_PACKAGES] +# Configure the repositories that you want to remove installed packages +# that no longer exist in the repository. Example ["slack", "gnome"]. +REPOSITORIES = [] [SBO] ENABLE = true diff --git a/configs/slpkg.toml b/configs/slpkg.toml index 6d88ee8b..07296620 100644 --- a/configs/slpkg.toml +++ b/configs/slpkg.toml @@ -1,6 +1,6 @@ # This is the general configuration file of slpkg: # /etc/slpkg/slpkg.toml -# Updated: 15/04/2024, Version: 5.0.6 +# Updated: 08/05/2024, Version: 5.0.8 [CONFIGS] @@ -33,16 +33,6 @@ CHECKSUM_MD5 = true # Default is true. [true/false] DIALOG = true -# This config is ONLY for -current users and slack repository, -# using with the upgrade command. Adds new packages to install -# added by Patrick. Default is false. [true/false] -NEW_PACKAGES = false - -# This config is also ONLY for -current users and slack repository, -# using with the upgrade command. Removes packages that no longer exist -# in the repository. Default is false. [true/false] -REMOVED_PACKAGES = false - # Choose ascii printable characters. # If true, it uses the extended characters, otherwise the basic ones. # Default is true. [true/false]. diff --git a/slpkg/configs.py b/slpkg/configs.py index d9b1f381..a75a6758 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -44,8 +44,6 @@ class Configs: # pylint: disable=[R0902] gpg_verification: bool = False checksum_md5: bool = True dialog: bool = True - new_packages: bool = False - removed_packages: bool = False downloader: str = 'wget' wget_options: str = '--c -q --progress=bar:force:noscroll --show-progress' curl_options: str = '' @@ -91,8 +89,6 @@ class Configs: # pylint: disable=[R0902] gpg_verification: bool = config['gpg_verification'] checksum_md5: bool = config['checksum_md5'] dialog: bool = config['dialog'] - new_packages: bool = config['new_packages'] - removed_packages: bool = config['removed_packages'] downloader: str = config['downloader'] wget_options: str = config['wget_options'] curl_options: str = config['curl_options'] diff --git a/slpkg/dialog_configs.py b/slpkg/dialog_configs.py index b4315d55..5087e267 100644 --- a/slpkg/dialog_configs.py +++ b/slpkg/dialog_configs.py @@ -94,9 +94,7 @@ class FormConfigs(Configs): 'URLLIB_RETRIES', 'URLLIB_REDIRECT', 'GPG_VERIFICATION', - 'CHECKSUM_MD5', - 'NEW_PACKAGES', - 'REMOVED_PACKAGES' + 'CHECKSUM_MD5' ] values: list = ['true', 'false'] @@ -150,9 +148,7 @@ class FormConfigs(Configs): 'URLLIB_REDIRECT =', 'URLLIB_TIMEOUT =', 'GPG_VERIFICATION =', - 'CHECKSUM_MD5 =', - 'NEW_PACKAGES =', - 'REMOVED_PACKAGES =') + 'CHECKSUM_MD5 =') ): line: str = line.replace('"', '') diff --git a/slpkg/repositories.py b/slpkg/repositories.py index 05a6805b..0c357ef9 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -171,7 +171,10 @@ class Repositories: # pylint: disable=[R0902] repos_config = utils.convert_dict_keys_to_lower(repos_config) - default_repository: str = repos_config['default']['repo'].lower() + default_repository: str = repos_config['default']['repository'].lower() + + new_packages = repos_config['new_packages']['repositories'] + remove_packages = repos_config['remove_packages']['repositories'] sbo_repo: bool = repos_config['sbo']['enable'] sbo_repo_mirror: str = repos_config['sbo']['mirror'] diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index 5b4d94eb..568629e8 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -85,11 +85,11 @@ class Upgrade(Configs): # pylint: disable=[R0902] if self.is_package_upgradeable(inst.name): yield name - if self.removed_packages: + if self.repository in self.repos.remove_packages: if name not in self.data.keys(): yield name + '_Removed.' - if self.new_packages: + if self.repository in self.repos.new_packages: for name in self.data.keys(): # if not self.utils.is_package_installed(name): if name not in self.installed_names: diff --git a/tests/test_configs.py b/tests/test_configs.py index 2ca5b167..d602368a 100644 --- a/tests/test_configs.py +++ b/tests/test_configs.py @@ -38,8 +38,6 @@ class TestConfigs(unittest.TestCase): self.assertEqual(False, self.configs.gpg_verification) self.assertEqual(True, self.configs.checksum_md5) self.assertEqual(True, self.configs.dialog) - self.assertEqual(False, self.configs.new_packages) - self.assertEqual(False, self.configs.removed_packages) self.assertEqual('wget', self.configs.downloader) self.assertEqual('-c -q --progress=bar:force:noscroll --show-progress', self.configs.wget_options) self.assertEqual('', self.configs.curl_options)