summaryrefslogtreecommitdiff
path: root/src/backend/uninstall.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/uninstall.py
parenta513187d4842758e63fda6abd90c86d4f9d19928 (diff)
don't silently fail while attempting to uninstall a package with reverse dependenciesv6.2401.0
Diffstat (limited to 'src/backend/uninstall.py')
-rw-r--r--src/backend/uninstall.py71
1 files changed, 53 insertions, 18 deletions
diff --git a/src/backend/uninstall.py b/src/backend/uninstall.py
index 70150f9..ede3947 100644
--- a/src/backend/uninstall.py
+++ b/src/backend/uninstall.py
@@ -8,6 +8,7 @@ import sys
import sisyphus.checkenv
import sisyphus.getcolor
import sisyphus.killemerge
+import sisyphus.solverdeps
import sisyphus.syncdb
@@ -25,24 +26,16 @@ def start(pkgname, depclean=False, gfx_ui=False, unmerge=False):
print(sisyphus.getcolor.bright_red +
"\nYou need root permissions to do this!\n" + sisyphus.getcolor.reset)
sys.exit()
+ else:
+ if gfx_ui:
+ is_needed = sisyphus.solverdeps.start.__wrapped__(pkgname)
+ else:
+ is_needed = sisyphus.solverdeps.start(pkgname)
- if unmerge:
- p_exe = subprocess.Popen(
- ['emerge', '--quiet', '--unmerge', '--ask'] + list(pkgname))
- try:
- p_exe.wait()
- sisyphus.syncdb.lcl_tbl()
- except KeyboardInterrupt:
- p_exe.terminate()
- try:
- p_exe.wait(1)
- except subprocess.TimeoutExpired:
- p_exe.kill()
- sys.exit()
- elif depclean:
+ if is_needed != 0:
if gfx_ui:
- p_exe = subprocess.Popen(
- ['emerge'] + args + pkgname, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ p_exe = subprocess.Popen(['emerge'] + args + ['--pretend', '--verbose'] + list(
+ pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# kill portage if the program dies or it's terminated by the user
atexit.register(sisyphus.killemerge.start, p_exe)
@@ -50,10 +43,27 @@ def start(pkgname, depclean=False, gfx_ui=False, unmerge=False):
print(p_out.rstrip())
p_exe.wait()
- sisyphus.syncdb.lcl_tbl()
+ print("\nWon't uninstall! Other packages depend on " + str(pkgname))
else:
p_exe = subprocess.Popen(
- ['emerge'] + args + ['--ask'] + list(pkgname))
+ ['emerge'] + args + ['--pretend', '--verbose'] + list(pkgname))
+ try:
+ p_exe.wait()
+ except KeyboardInterrupt:
+ p_exe.terminate()
+ try:
+ p_exe.wait(1)
+ except subprocess.TimeoutExpired:
+ p_exe.kill()
+ sys.exit()
+ print(sisyphus.getcolor.bright_red +
+ "\nWon't uninstall! Other packages depend on " + sisyphus.getcolor.reset + str(pkgname))
+ print(sisyphus.getcolor.bright_red + "Use the " + sisyphus.getcolor.reset + sisyphus.getcolor.green + "'--force'" +
+ sisyphus.getcolor.reset + sisyphus.getcolor.bright_red + " option to override at your own risk!\n" + sisyphus.getcolor.reset)
+ else:
+ if unmerge:
+ p_exe = subprocess.Popen(
+ ['emerge', '--quiet', '--unmerge', '--ask'] + list(pkgname))
try:
p_exe.wait()
sisyphus.syncdb.lcl_tbl()
@@ -64,3 +74,28 @@ def start(pkgname, depclean=False, gfx_ui=False, unmerge=False):
except subprocess.TimeoutExpired:
p_exe.kill()
sys.exit()
+ elif depclean:
+ if gfx_ui:
+ p_exe = subprocess.Popen(
+ ['emerge'] + args + pkgname, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ # kill portage if the program dies or it's terminated by the user
+ atexit.register(sisyphus.killemerge.start, p_exe)
+
+ for p_out in io.TextIOWrapper(p_exe.stdout, encoding="utf-8"):
+ print(p_out.rstrip())
+
+ p_exe.wait()
+ sisyphus.syncdb.lcl_tbl()
+ else:
+ p_exe = subprocess.Popen(
+ ['emerge'] + args + ['--ask'] + list(pkgname))
+ try:
+ p_exe.wait()
+ sisyphus.syncdb.lcl_tbl()
+ except KeyboardInterrupt:
+ p_exe.terminate()
+ try:
+ p_exe.wait(1)
+ except subprocess.TimeoutExpired:
+ p_exe.kill()
+ sys.exit()