diff options
Diffstat (limited to 'src/backend/uninstall.py')
-rw-r--r-- | src/backend/uninstall.py | 71 |
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() |