diff options
author | V3n3RiX <venerix@koprulu.sector> | 2024-02-29 03:48:08 +0000 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2024-03-01 07:33:34 +0000 |
commit | 5a8384b21bb066ca44f6823871ad1d0aa1aa2c28 (patch) | |
tree | 23af9daff7b1810281c8a61ce51cfc2e33fd5150 /src/backend/rmpkgsrc.py | |
parent | 1c1b0f57b0adf71a216e74e0fb718ed0b218c39d (diff) |
bugfix : https://bugs.redcorelinux.org/show_bug.cgi?id=156
Diffstat (limited to 'src/backend/rmpkgsrc.py')
-rw-r--r-- | src/backend/rmpkgsrc.py | 242 |
1 files changed, 141 insertions, 101 deletions
diff --git a/src/backend/rmpkgsrc.py b/src/backend/rmpkgsrc.py index 5502bc8..63343fc 100644 --- a/src/backend/rmpkgsrc.py +++ b/src/backend/rmpkgsrc.py @@ -63,64 +63,42 @@ def start(pkgname, depclean=False, gfx_ui=False, unmerge=False): sisyphus.solverevdeps.start( pkgname, depclean=True, unmerge=False) - is_needed = pickle.load( - open(os.path.join(sisyphus.getfs.p_mtd_dir, "sisyphus_pkgrevdeps.pickle"), "rb")) - - if unmerge: - print("\n" + sisyphus.getclr.bright_white + "Selected packages are slated for" + sisyphus.getclr.reset + " " + sisyphus.getclr.green + - "'forced'" + sisyphus.getclr.reset + " " + sisyphus.getclr.bright_white + "removal." + sisyphus.getclr.reset + "\n") - while True: - user_input = input(sisyphus.getclr.bright_white + "Would you like to proceed?" + sisyphus.getclr.reset + " " + - "[" + sisyphus.getclr.bright_green + "Yes" + sisyphus.getclr.reset + "/" + sisyphus.getclr.bright_red + "No" + sisyphus.getclr.reset + "]" + " ") - if user_input.lower() in ['yes', 'y', '']: - while True: - confirmation_input = input(sisyphus.getclr.bright_white + "Are you sure you would like to proceed?" + sisyphus.getclr.reset + " " + - "[" + sisyphus.getclr.bright_green + "Yes" + sisyphus.getclr.reset + "/" + sisyphus.getclr.bright_red + "No" + sisyphus.getclr.reset + "]" + " ") - if confirmation_input.lower() in ['yes', 'y', '']: - p_exe = subprocess.Popen( - ['emerge', '--quiet', '--unmerge'] + list(pkgname)) - try: - set_nonblocking(sys.stdout.fileno()) - spinner_animation() - - sel = selectors.DefaultSelector() - sel.register(sys.stdin, selectors.EVENT_READ) - - while True: - events = sel.select(timeout=0.1) - for key, mask in events: - if key.fileobj == sys.stdin: - line = sys.stdin.readline().strip() - if line.lower() == 'q': - sys.exit() - if p_exe.poll() is not None: - break - except KeyboardInterrupt: - p_exe.terminate() - try: - p_exe.wait(1) - except subprocess.TimeoutExpired: - p_exe.kill() - sys.exit() - finally: - p_exe.wait() - sisyphus.syncdb.lcl_tbl() - break - elif confirmation_input.lower() in ['no', 'n']: - break - else: - print("\nSorry, response" + " " + "'" + - confirmation_input + "'" + " " + "not understood.\n") - continue - break - elif user_input.lower() in ['no', 'n']: - break + is_installed, is_needed, is_vague = pickle.load(open(os.path.join( + sisyphus.getfs.p_mtd_dir, "sisyphus_pkgrevdeps.pickle"), "rb")) + + if is_vague != 0: # catch ambiguous packages + if unmerge: + p_exe = subprocess.Popen( + ['emerge', '--unmerge', '--quiet', '--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() + else: + if gfx_ui: + pass # GUI always calls <category>/<pkgname>, no ambiguity else: - print("\nSorry, response" + " " + "'" + - user_input + "'" + " " + "not understood.\n") - continue - else: - if is_needed != 0: + p_exe = subprocess.Popen( + ['emerge', '--depclean', '--quiet', '--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() + + elif is_needed != 0: + if unmerge: + pass + else: if gfx_ui: p_exe = subprocess.Popen(['emerge'] + args + ['--pretend', '--verbose'] + list( pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -131,7 +109,8 @@ def start(pkgname, depclean=False, gfx_ui=False, unmerge=False): print(p_out.rstrip()) p_exe.wait() - print("\nWon't uninstall! Other packages depend on " + str(pkgname)) + print( + "\nUnable to proceed! There are other packages with dependencies that prevent removal.") else: p_exe = subprocess.Popen( ['emerge'] + args + ['--pretend', '--verbose'] + list(pkgname)) @@ -160,57 +139,64 @@ def start(pkgname, depclean=False, gfx_ui=False, unmerge=False): sys.exit() finally: p_exe.wait() - print(sisyphus.getclr.bright_red + "\nWon't uninstall! Other packages depend on " + - sisyphus.getclr.reset + str(pkgname)) + print(sisyphus.getclr.bright_red + + "\nUnable to proceed! There are other packages with dependencies that prevent removal." + sisyphus.getclr.reset) print(sisyphus.getclr.bright_white + "Use the " + sisyphus.getclr.reset + sisyphus.getclr.green + "'--force'" + sisyphus.getclr.reset + sisyphus.getclr.bright_white + " option to override at your own risk!\n" + sisyphus.getclr.reset) - else: - 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: + else: + if is_installed == 0: + print(sisyphus.getclr.bright_red + + "\nUnable to proceed! One or more selected packages could not be located for removal.\n" + sisyphus.getclr.reset) + sys.exit() + else: + if unmerge: print("\n" + sisyphus.getclr.bright_white + "Selected packages are slated for" + sisyphus.getclr.reset + " " + sisyphus.getclr.green + - "'safe'" + sisyphus.getclr.reset + " " + sisyphus.getclr.bright_white + "removal." + sisyphus.getclr.reset + "\n") + "'forced'" + sisyphus.getclr.reset + " " + sisyphus.getclr.bright_white + "removal." + sisyphus.getclr.reset + "\n") while True: user_input = input(sisyphus.getclr.bright_white + "Would you like to proceed?" + sisyphus.getclr.reset + " " + "[" + sisyphus.getclr.bright_green + "Yes" + sisyphus.getclr.reset + "/" + sisyphus.getclr.bright_red + "No" + sisyphus.getclr.reset + "]" + " ") if user_input.lower() in ['yes', 'y', '']: - p_exe = subprocess.Popen( - ['emerge'] + args + list(pkgname)) - try: - set_nonblocking(sys.stdout.fileno()) - spinner_animation() - - sel = selectors.DefaultSelector() - sel.register(sys.stdin, selectors.EVENT_READ) - - while True: - events = sel.select(timeout=0.1) - for key, mask in events: - if key.fileobj == sys.stdin: - line = sys.stdin.readline().strip() - if line.lower() == 'q': - sys.exit() - if p_exe.poll() is not None: - break - except KeyboardInterrupt: - p_exe.terminate() - try: - p_exe.wait(1) - except subprocess.TimeoutExpired: - p_exe.kill() - sys.exit() - finally: - p_exe.wait() - sisyphus.syncdb.lcl_tbl() + while True: + confirmation_input = input(sisyphus.getclr.bright_white + "Are you sure you would like to proceed?" + sisyphus.getclr.reset + " " + + "[" + sisyphus.getclr.bright_green + "Yes" + sisyphus.getclr.reset + "/" + sisyphus.getclr.bright_red + "No" + sisyphus.getclr.reset + "]" + " ") + if confirmation_input.lower() in ['yes', 'y', '']: + p_exe = subprocess.Popen( + ['emerge', '--quiet', '--unmerge'] + list(pkgname)) + try: + set_nonblocking(sys.stdout.fileno()) + spinner_animation() + + sel = selectors.DefaultSelector() + sel.register( + sys.stdin, selectors.EVENT_READ) + + while True: + events = sel.select(timeout=0.1) + for key, mask in events: + if key.fileobj == sys.stdin: + line = sys.stdin.readline().strip() + if line.lower() == 'q': + sys.exit() + if p_exe.poll() is not None: + break + except KeyboardInterrupt: + p_exe.terminate() + try: + p_exe.wait(1) + except subprocess.TimeoutExpired: + p_exe.kill() + sys.exit() + finally: + p_exe.wait() + sisyphus.syncdb.lcl_tbl() + break + elif confirmation_input.lower() in ['no', 'n']: + break + else: + print("\nSorry, response" + " " + "'" + + confirmation_input + "'" + " " + "not understood.\n") + continue break elif user_input.lower() in ['no', 'n']: break @@ -218,3 +204,57 @@ def start(pkgname, depclean=False, gfx_ui=False, unmerge=False): print("\nSorry, response" + " " + "'" + user_input + "'" + " " + "not understood.\n") continue + else: + 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: + print("\n" + sisyphus.getclr.bright_white + "Selected packages are slated for" + sisyphus.getclr.reset + " " + sisyphus.getclr.green + + "'safe'" + sisyphus.getclr.reset + " " + sisyphus.getclr.bright_white + "removal." + sisyphus.getclr.reset + "\n") + while True: + user_input = input(sisyphus.getclr.bright_white + "Would you like to proceed?" + sisyphus.getclr.reset + " " + + "[" + sisyphus.getclr.bright_green + "Yes" + sisyphus.getclr.reset + "/" + sisyphus.getclr.bright_red + "No" + sisyphus.getclr.reset + "]" + " ") + if user_input.lower() in ['yes', 'y', '']: + p_exe = subprocess.Popen( + ['emerge'] + args + list(pkgname)) + try: + set_nonblocking(sys.stdout.fileno()) + spinner_animation() + + sel = selectors.DefaultSelector() + sel.register(sys.stdin, selectors.EVENT_READ) + + while True: + events = sel.select(timeout=0.1) + for key, mask in events: + if key.fileobj == sys.stdin: + line = sys.stdin.readline().strip() + if line.lower() == 'q': + sys.exit() + if p_exe.poll() is not None: + break + except KeyboardInterrupt: + p_exe.terminate() + try: + p_exe.wait(1) + except subprocess.TimeoutExpired: + p_exe.kill() + sys.exit() + finally: + p_exe.wait() + sisyphus.syncdb.lcl_tbl() + break + elif user_input.lower() in ['no', 'n']: + break + else: + print("\nSorry, response" + " " + "'" + + user_input + "'" + " " + "not understood.\n") + continue |