From 6ff384e5716dc9392475c35bb381a2872e9f2e6b Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Fri, 1 Mar 2024 22:42:04 +0000 Subject: * expose the --nodeps option from Portage in Sisyphus CLI * use it to install packages without retreiving their dependencies * rewrite and update the CLI help menu to reflect the new option * some minor cosmetic fixes --- src/backend/instpkgsrc.py | 42 +++++++++++++++++++++++++----------------- src/backend/rmpkgsrc.py | 2 +- src/backend/solvedeps.py | 6 +++--- src/backend/sysupgrade.py | 27 +++++++++++++++------------ 4 files changed, 44 insertions(+), 33 deletions(-) (limited to 'src/backend') diff --git a/src/backend/instpkgsrc.py b/src/backend/instpkgsrc.py index 68f10b3..091502b 100644 --- a/src/backend/instpkgsrc.py +++ b/src/backend/instpkgsrc.py @@ -47,23 +47,31 @@ def sigint_handler(signal, frame): signal.signal(signal.SIGINT, sigint_handler) -def start(pkgname, ebuild=False, gfx_ui=False, oneshot=False): +def start(pkgname, ebuild=False, gfx_ui=False, oneshot=False, nodeps=False): + go_args = ['--quiet', '--verbose', + '--misspell-suggestion=n', '--fuzzy-search=n'] + nogo_args = ['--quiet', '--pretend', '--getbinpkg', + '--rebuilt-binaries', '--misspell-suggestion=n', '--fuzzy-search=n'] if not sisyphus.checkenv.root(): print(f"{sisyphus.getclr.bright_red}\nRoot permissions are required for this operation.\n{sisyphus.getclr.reset}") sys.exit() else: if gfx_ui: - sisyphus.solvedeps.start.__wrapped__(pkgname) # undecorate + sisyphus.solvedeps.start.__wrapped__( + pkgname, nodeps=False) # undecorate else: sisyphus.syncall.start(gfx_ui=False) - sisyphus.solvedeps.start(pkgname) + if nodeps: + sisyphus.solvedeps.start(pkgname, nodeps=True) + else: + sisyphus.solvedeps.start(pkgname, nodeps=False) bin_list, src_list, is_vague, need_cfg = pickle.load( open(os.path.join(sisyphus.getfs.p_mtd_dir, "sisyphus_pkgdeps.pickle"), "rb")) if is_vague != 0: # catch ambiguous packages - p_exe = subprocess.Popen(['emerge', '--quiet', '--pretend', '--getbinpkg', '--rebuilt-binaries', - '--with-bdeps=y', '--misspell-suggestion=y', '--fuzzy-search=y'] + list(pkgname)) + p_exe = subprocess.Popen( + ['emerge'] + nogo_args + (['--nodeps'] if nodeps else ['--with-bdeps=y']) + list(pkgname)) try: p_exe.wait() except KeyboardInterrupt: @@ -79,8 +87,8 @@ def start(pkgname, ebuild=False, gfx_ui=False, oneshot=False): sys.exit() elif need_cfg != 0: # catch aliens - p_exe = subprocess.Popen(['emerge', '--quiet', '--pretend', '--getbinpkg', '--rebuilt-binaries', - '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname)) + p_exe = subprocess.Popen( + ['emerge'] + nogo_args + (['--nodeps'] if nodeps else ['--with-bdeps=y']) + list(pkgname)) try: p_exe.wait() except KeyboardInterrupt: @@ -115,8 +123,8 @@ def start(pkgname, ebuild=False, gfx_ui=False, oneshot=False): user_input = input( f"{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', '--quiet', '--verbose', '--with-bdeps=y', '--misspell-suggestion=n', - '--fuzzy-search=n'] + (['--oneshot'] if oneshot else []) + list(pkgname)) + p_exe = subprocess.Popen(['emerge'] + go_args + (['--nodeps'] if nodeps else [ + '--with-bdeps=y']) + (['--oneshot'] if oneshot else []) + list(pkgname)) try: set_nonblocking(sys.stdout.fileno()) spinner_animation() @@ -170,8 +178,8 @@ def start(pkgname, ebuild=False, gfx_ui=False, oneshot=False): if user_input.lower() in ['yes', 'y', '']: sisyphus.dlbinpkg.start(dl_world=False, gfx_ui=False) os.chdir(sisyphus.getfs.p_cch_dir) - p_exe = subprocess.Popen(['emerge', '--quiet', '--verbose', '--usepkg', '--rebuilt-binaries', '--with-bdeps=y', - '--misspell-suggestion=n', '--fuzzy-search=n'] + (['--oneshot'] if oneshot else []) + list(pkgname)) + p_exe = subprocess.Popen(['emerge'] + go_args + ['--usepkg', '--rebuilt-binaries'] + ( + ['--nodeps'] if nodeps else ['--with-bdeps=y']) + (['--oneshot'] if oneshot else []) + list(pkgname)) try: set_nonblocking(sys.stdout.fileno()) spinner_animation() @@ -218,8 +226,8 @@ def start(pkgname, ebuild=False, gfx_ui=False, oneshot=False): if user_input.lower() in ['yes', 'y', '']: sisyphus.dlbinpkg.start(dl_world=False, gfx_ui=False) os.chdir(sisyphus.getfs.p_cch_dir) - p_exe = subprocess.Popen(['emerge', '--quiet', '--verbose', '--usepkg', '--usepkgonly', '--rebuilt-binaries', - '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + (['--oneshot'] if oneshot else []) + list(pkgname)) + p_exe = subprocess.Popen(['emerge'] + go_args + ['--usepkg', '--usepkgonly', '--rebuilt-binaries'] + ( + ['--nodeps'] if nodeps else ['--with-bdeps=y']) + (['--oneshot'] if oneshot else []) + list(pkgname)) try: set_nonblocking(sys.stdout.fileno()) spinner_animation() @@ -294,8 +302,8 @@ def start(pkgname, ebuild=False, gfx_ui=False, oneshot=False): str(len(bin_list)) + " binary package(s)\n\n") sisyphus.dlbinpkg.start(dl_world=False, gfx_ui=True) os.chdir(sisyphus.getfs.p_cch_dir) - p_exe = subprocess.Popen(['emerge', '--quiet', '--verbose', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--with-bdeps=y', - '--misspell-suggestion=n', '--fuzzy-search=n'] + pkgname, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p_exe = subprocess.Popen(['emerge'] + go_args + ['--usepkg', '--usepkgonly', '--rebuilt-binaries'] + ( + ['--nodeps'] if nodeps else ['--with-bdeps=y']) + (['--oneshot'] if oneshot else []) + pkgname, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # --nodeps && --oneshot are set to False in the graphical client # kill portage if the program dies or it's terminated by the user atexit.register(sisyphus.killemerge.start, p_exe) @@ -318,8 +326,8 @@ def start(pkgname, ebuild=False, gfx_ui=False, oneshot=False): sisyphus.dlbinpkg.start( dl_world=False, gfx_ui=False) os.chdir(sisyphus.getfs.p_cch_dir) - p_exe = subprocess.Popen(['emerge', '--quiet', '--verbose', '--usepkg', '--usepkgonly', '--rebuilt-binaries', - '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + (['--oneshot'] if oneshot else []) + list(pkgname)) + p_exe = subprocess.Popen(['emerge'] + go_args + ['--usepkg', '--usepkgonly', '--rebuilt-binaries'] + ( + ['--nodeps'] if nodeps else ['--with-bdeps=y']) + (['--oneshot'] if oneshot else []) + list(pkgname)) try: set_nonblocking(sys.stdout.fileno()) spinner_animation() diff --git a/src/backend/rmpkgsrc.py b/src/backend/rmpkgsrc.py index ec5a097..b039f96 100644 --- a/src/backend/rmpkgsrc.py +++ b/src/backend/rmpkgsrc.py @@ -83,7 +83,7 @@ def start(pkgname, depclean=False, gfx_ui=False, unmerge=False): pass # GUI always calls /, no ambiguity else: p_exe = subprocess.Popen( - ['emerge', '--depclean', '--quiet', '--pretend', '--verbose'] + list(pkgname)) + ['emerge'] + args + ['--pretend', '--verbose'] + list(pkgname)) try: p_exe.wait() except KeyboardInterrupt: diff --git a/src/backend/solvedeps.py b/src/backend/solvedeps.py index d3e8a3b..34d70b8 100644 --- a/src/backend/solvedeps.py +++ b/src/backend/solvedeps.py @@ -17,15 +17,15 @@ signal.signal(signal.SIGINT, sigint_handler) @animation.wait('resolving dependencies') -def start(pkgname=None): +def start(pkgname=None, nodeps=False): bin_list = [] src_list = [] is_vague = int() need_cfg = int() if pkgname: - args = ['--quiet', '--pretend', '--getbinpkg', '--rebuilt-binaries', - '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname) + args = ['--quiet', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--misspell-suggestion=n', + '--fuzzy-search=n'] + (['--nodeps'] if nodeps else ['--with-bdeps=y']) + list(pkgname) else: args = ['--quiet', '--update', '--deep', '--newuse', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'] diff --git a/src/backend/sysupgrade.py b/src/backend/sysupgrade.py index f6415f3..f8b01d2 100644 --- a/src/backend/sysupgrade.py +++ b/src/backend/sysupgrade.py @@ -48,6 +48,10 @@ signal.signal(signal.SIGINT, sigint_handler) def start(ebuild=False, gfx_ui=False): + go_args = ['--quiet', '--verbose', '--update', '--deep', '--newuse', + '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + nogo_args = ['--quiet', '--update', '--deep', '--newuse', '--pretend', '--getbinpkg', + '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n',] if not sisyphus.checkenv.root(): print(f"{sisyphus.getclr.bright_red}\nRoot permissions are required for this operation.\n{sisyphus.getclr.reset}") sys.exit() @@ -62,8 +66,7 @@ def start(ebuild=False, gfx_ui=False): open(os.path.join(sisyphus.getfs.p_mtd_dir, "sisyphus_worlddeps.pickle"), "rb")) if need_cfg != 0: # catch aliens - p_exe = subprocess.Popen(['emerge', '--quiet', '--update', '--deep', '--newuse', '--pretend', '--getbinpkg', - '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world']) + p_exe = subprocess.Popen(['emerge'] + nogo_args + ['@world']) try: p_exe.wait() except KeyboardInterrupt: @@ -104,8 +107,8 @@ def start(ebuild=False, gfx_ui=False): user_input = input( f"{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', '--quiet', '--verbose', '--update', '--deep', '--newuse', - '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world']) + p_exe = subprocess.Popen( + ['emerge'] + go_args + ['@world']) try: set_nonblocking(sys.stdout.fileno()) spinner_animation() @@ -159,8 +162,8 @@ def start(ebuild=False, gfx_ui=False): if user_input.lower() in ['yes', 'y', '']: sisyphus.dlbinpkg.start(dl_world=True, gfx_ui=False) os.chdir(sisyphus.getfs.p_cch_dir) - p_exe = subprocess.Popen(['emerge', '--quiet', '--verbose', '--update', '--deep', '--newuse', '--usepkg', - '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world']) + p_exe = subprocess.Popen( + ['emerge'] + go_args + ['--usepkg', '--rebuilt-binaries', '@world']) try: set_nonblocking(sys.stdout.fileno()) spinner_animation() @@ -207,8 +210,8 @@ def start(ebuild=False, gfx_ui=False): if user_input.lower() in ['yes', 'y', '']: sisyphus.dlbinpkg.start(dl_world=True, gfx_ui=False) os.chdir(sisyphus.getfs.p_cch_dir) - p_exe = subprocess.Popen(['emerge', '--quiet', '--verbose', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', - '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world']) + p_exe = subprocess.Popen( + ['emerge'] + go_args + ['--usepkg', '--usepkgonly', '--rebuilt-binaries', '@world']) try: set_nonblocking(sys.stdout.fileno()) spinner_animation() @@ -285,8 +288,8 @@ def start(ebuild=False, gfx_ui=False): f"\n\nTotal: {len(bin_list)} binary package(s)\n") sisyphus.dlbinpkg.start(dl_world=True, gfx_ui=True) os.chdir(sisyphus.getfs.p_cch_dir) - p_exe = subprocess.Popen(['emerge', '--quiet', '--verbose', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', '--rebuilt-binaries', - '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p_exe = subprocess.Popen(['emerge'] + go_args + ['--usepkg', '--usepkgonly', + '--rebuilt-binaries', '@world'], 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) @@ -309,8 +312,8 @@ def start(ebuild=False, gfx_ui=False): sisyphus.dlbinpkg.start( dl_world=True, gfx_ui=False) os.chdir(sisyphus.getfs.p_cch_dir) - p_exe = subprocess.Popen(['emerge', '--quiet', '--verbose', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', - '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world']) + p_exe = subprocess.Popen( + ['emerge'] + go_args + ['--usepkg', '--usepkgonly', '--rebuilt-binaries', '@world']) try: set_nonblocking(sys.stdout.fileno()) spinner_animation() -- cgit v1.2.3