mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-28 19:58:18 +01:00
Updated for remove pkg
This commit is contained in:
parent
c70dc13461
commit
e3fe73bf84
6 changed files with 48 additions and 16 deletions
|
@ -5,6 +5,8 @@ Updated:
|
|||
- Indicate colour for upgradable packages
|
||||
Added:
|
||||
- Packages list for multilib installation
|
||||
- To detect the dependencies before removing a package (Thanks to marav)
|
||||
- The flag -y, --yes to the remove command
|
||||
|
||||
4.7.5 - 04/04/2023
|
||||
BugFixed:
|
||||
|
|
|
@ -112,7 +112,7 @@ Suivre les dépendances des paquets.
|
|||
.B -y, --yes
|
||||
.RS
|
||||
Répondre \fBOui\fP à toutes les questions. (à utiliser avec: \fB-u, update, -U, upgrade, -L, clean-logs, -b, build,
|
||||
-i, install, -d, download\fP) (Non utilisée avec \fB-R, remove\fP, option supprimée pour des raisons de sécurité)
|
||||
-i, install, -R, remove, -d, download\fP) (Non utilisée avec \fB-R, remove\fP, option supprimée pour des raisons de sécurité)
|
||||
.RE
|
||||
.P
|
||||
.B -j, --jobs
|
||||
|
|
|
@ -114,7 +114,7 @@ Tracking the packages dependencies.
|
|||
.B -y, --yes
|
||||
.RS
|
||||
Answer Yes to all questions. (to be used with: -u, update, -U, upgrade, -L, clean-logs, -b, build,
|
||||
-i, install, -d, download,) (Not used with -R, remove, option removed for security reasons)
|
||||
-i, install, -R, remove, -d, download,) (Not used with -R, remove, option removed for security reasons)
|
||||
.RE
|
||||
.P
|
||||
.B -j, --jobs
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from slpkg.models.models import LogsDependencies
|
||||
|
||||
|
||||
class BinQueries(Configs):
|
||||
""" Queries class for the sbo repository. """
|
|
@ -207,6 +207,8 @@ class Argparse(Configs):
|
|||
self.flag_short_parallel
|
||||
],
|
||||
'remove': [
|
||||
self.flag_yes,
|
||||
self.flag_short_yes,
|
||||
self.flag_resolve_off,
|
||||
self.flag_short_resolve_off,
|
||||
self.flag_search,
|
||||
|
|
|
@ -25,6 +25,7 @@ class RemovePackages(Configs):
|
|||
self.color = self.colour()
|
||||
self.utils = Utilities()
|
||||
self.progress = ProgressBar()
|
||||
self.view = ViewMessage(self.flags)
|
||||
|
||||
self.output: int = 0
|
||||
self.installed_packages: list = []
|
||||
|
@ -32,6 +33,7 @@ class RemovePackages(Configs):
|
|||
self.stderr = None
|
||||
self.stdout = None
|
||||
self.bold: str = self.color['bold']
|
||||
self.cyan: str = self.color['cyan']
|
||||
self.yellow: str = self.color['yellow']
|
||||
self.red: str = self.color['red']
|
||||
self.endc: str = self.color['endc']
|
||||
|
@ -39,14 +41,13 @@ class RemovePackages(Configs):
|
|||
self.bred: str = f'{self.bold}{self.red}'
|
||||
self.flag_resolve_off: list = ['-o', '--resolve-off']
|
||||
self.flag_no_silent: list = ['-n', '--no-silent']
|
||||
self.flag_yes: list = ['-y', '--yes']
|
||||
|
||||
def remove(self) -> None:
|
||||
""" Removes package with dependencies. """
|
||||
view = ViewMessage(self.flags)
|
||||
self.installed_packages, self.dependencies = self.view.remove_packages(self.packages)
|
||||
|
||||
self.installed_packages, self.dependencies = view.remove_packages(self.packages)
|
||||
|
||||
view.question()
|
||||
self.view.question()
|
||||
|
||||
start: float = time.time()
|
||||
self.remove_packages()
|
||||
|
@ -63,8 +64,43 @@ class RemovePackages(Configs):
|
|||
def remove_packages(self) -> None:
|
||||
""" Run Slackware command to remove the packages. """
|
||||
for package in self.installed_packages:
|
||||
command: str = f'{self.removepkg} {package}'
|
||||
self.multi_process(command, package)
|
||||
name: str = self.utils.split_binary_pkg(package)[0]
|
||||
|
||||
if self.check_in_logs_for_dependencies(name):
|
||||
command: str = f'{self.removepkg} {package}'
|
||||
self.multi_process(command, package)
|
||||
|
||||
def check_in_logs_for_dependencies(self, name):
|
||||
dependencies: list = []
|
||||
logs: dict = self.query_dependencies()
|
||||
|
||||
for package, requires in logs.items():
|
||||
if name in requires:
|
||||
dependencies.append(package)
|
||||
|
||||
if dependencies and not self.utils.is_option(self.flag_yes, self.flags) and self.ask_question:
|
||||
print(f"\n{self.bred}WARNING!{self.endc} The package '{self.cyan}{name}{self.endc}' "
|
||||
f"is a dependency for the packages: '{self.cyan}{', '.join(dependencies)}{self.endc}'.")
|
||||
answer: str = input('\nDo you want to remove? [y/N] ')
|
||||
|
||||
if answer not in ['Y', 'y']:
|
||||
return False
|
||||
print()
|
||||
|
||||
return True
|
||||
|
||||
def query_dependencies(self) -> dict:
|
||||
""" Returns a dictionary with the package name and the dependencies
|
||||
before they are saved with the command slpkg install. """
|
||||
logs_deps: dict = {}
|
||||
package_requires: tuple = self.session.query(
|
||||
LogsDependencies.name, LogsDependencies.requires).all()
|
||||
|
||||
for package in package_requires:
|
||||
if package[0] not in self.packages:
|
||||
logs_deps[package[0]] = package[1].split()
|
||||
|
||||
return logs_deps
|
||||
|
||||
def delete_main_logs(self) -> None:
|
||||
""" Deletes main packages from logs. """
|
||||
|
|
Loading…
Add table
Reference in a new issue