summaryrefslogtreecommitdiff
path: root/src/backend/solverdeps.py
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2024-01-20 22:52:36 +0000
committerV3n3RiX <venerix@koprulu.sector>2024-01-20 22:52:36 +0000
commit5cf564d3b5109c2a9e4b5917eb7d834f8b911d3b (patch)
tree1a237d98fdd45a123b1175c35bf068ec6c42ed54 /src/backend/solverdeps.py
parenta513187d4842758e63fda6abd90c86d4f9d19928 (diff)
don't silently fail while attempting to uninstall a package with reverse dependenciesv6.2401.0
Diffstat (limited to 'src/backend/solverdeps.py')
-rw-r--r--src/backend/solverdeps.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/backend/solverdeps.py b/src/backend/solverdeps.py
new file mode 100644
index 0000000..b866cc8
--- /dev/null
+++ b/src/backend/solverdeps.py
@@ -0,0 +1,37 @@
+#!/usr/bin/python3
+
+import animation
+import signal
+import subprocess
+import sys
+
+
+def sigint_handler(signal, frame):
+ sys.exit(0)
+
+
+signal.signal(signal.SIGINT, sigint_handler)
+
+
+@animation.wait('resolving reverse dependencies')
+def start(pkgname=None):
+ is_needed = int(0)
+
+ p_exe = subprocess.Popen(
+ ['emerge', '--depclean', '--quiet', '--pretend', '--verbose'] + list(pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+ try:
+ stdout, stderr = p_exe.communicate()
+
+ for p_out in stdout.decode('utf-8').splitlines():
+ if any(key in p_out for key in ["pulled in by:", "required"]):
+ is_needed = int(1)
+
+ except KeyboardInterrupt:
+ p_exe.terminate()
+ try:
+ p_exe.wait(1)
+ except subprocess.TimeoutExpired:
+ p_exe.kill()
+ sys.exit()
+ return is_needed