From 9d5d981f8126d3758406d39edfd2ce9dad9fefaa Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 25 Mar 2024 00:34:27 +0200 Subject: [PATCH] Updated for -current users --- ChangeLog.txt | 3 ++- configs/slpkg.toml | 5 +++++ slpkg/configs.py | 2 ++ slpkg/main.py | 11 +++++++++++ slpkg/upgrade.py | 6 ++++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 8a2e7455..236309e3 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -21,7 +21,8 @@ * Check for upgrade packages using the option --check * MAKEFLAGS config to specify the number of jobs * Support GPG verification - * Config NEW_PACKAGES for -current users + * Config NEW_PACKAGES for -current users and upgrade command + * Config REMOVED_PACKAGES for -current users upgrade command - Bugfixes: * Double view message when update repositories diff --git a/configs/slpkg.toml b/configs/slpkg.toml index 72fce9a7..508f8e8f 100644 --- a/configs/slpkg.toml +++ b/configs/slpkg.toml @@ -38,6 +38,11 @@ DIALOG = true # Default is false. [true/false] NEW_PACKAGES = false +# This config is also for -current users and remove packages that are no longer +# exist in the repository when you run the upgrade command. +# 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 0943b68c..943ed915 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -39,6 +39,7 @@ class Configs: 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 = '' @@ -84,6 +85,7 @@ class Configs: checksum_md5: bool = config['CHECKSUM_MD5'] dialog: str = 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/main.py b/slpkg/main.py index c944d311..930fe3c9 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -428,6 +428,7 @@ class Menu(Configs): def upgrade(self) -> None: command: str = Menu.upgrade.__name__ + removed: list = [] if len(self.args) == 1: @@ -443,6 +444,16 @@ class Menu(Configs): upgrade = Upgrade(self.repository, self.data) packages: list = list(upgrade.packages()) + for package in packages: + if package.endswith('_Removed.'): + removed.append(package.replace('_Removed.', '')) + + if removed: + print('\nFound packages that are not existing in the repository:') + packages = [pkg for pkg in packages if not pkg.endswith('_Removed.')] + remove = RemovePackages(removed, self.flags) + remove.remove() + packages: list = self.choose.packages(self.data, packages, command) if not packages: diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index 9520d883..64408dd1 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -27,6 +27,7 @@ class Upgrade(Configs): def packages(self) -> Generator: """ Returns the upgradable packages. """ print('\rRetrieving packages... ', end='') + if self.repository in [self.repos.slack_repo_name, self.repos.salixos_repo_name]: installed_packages: list = [] installed: Generator = self.log_packages.glob('*') @@ -43,10 +44,15 @@ class Upgrade(Configs): if self.is_package_upgradeable(inst.name): yield name + if self.repository == self.repos.slack_repo_name and self.removed_packages: + if name not in self.data.keys(): + yield name + '_Removed.' + if self.repository == self.repos.slack_repo_name and self.new_packages: for name in self.data.keys(): if not self.utils.is_package_installed(name): yield name + print(f'{self.bgreen}{self.ascii.done}{self.endc}') def is_package_upgradeable(self, installed: str) -> bool: