diff options
author | V3n3RiX <venerix@koprulu.sector> | 2023-04-08 19:37:02 +0100 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2023-04-08 19:37:02 +0100 |
commit | 4aaf46b25037684158755558b7ccd5e3c626040e (patch) | |
tree | c33d817d3e67380de160ccdba0b9b09d735d464f | |
parent | ef26ce410f8202ba69699ea7696058648887c71a (diff) |
install : implement --oneshot, bugfix : https://bugs.redcorelinux.org/show_bug.cgi?id=138
-rw-r--r-- | src/backend/install.py | 42 | ||||
-rwxr-xr-x | src/frontend/cli/sisyphus-cli.py | 21 |
2 files changed, 44 insertions, 19 deletions
diff --git a/src/backend/install.py b/src/backend/install.py index 16779c5..81dd3b4 100644 --- a/src/backend/install.py +++ b/src/backend/install.py @@ -16,7 +16,7 @@ import sisyphus.syncdb import sisyphus.update -def start(pkgname): +def start(pkgname, oneshot=False): if sisyphus.checkenv.root(): sisyphus.update.start(gfx_ui=False) sisyphus.solvedeps.start(pkgname) @@ -30,13 +30,16 @@ def start(pkgname): print("\n" + sisyphus.getcolor.green + "These are the binary packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.magenta + ", ".join( bin_list) + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str(len(bin_list)) + " " + "binary package(s)" + sisyphus.getcolor.reset + "\n") while True: - user_input = input(sisyphus.getcolor.bright_white + "Would you like to proceed?" + sisyphus.getcolor.reset + " " + - "[" + sisyphus.getcolor.bright_green + "Yes" + sisyphus.getcolor.reset + "/" + sisyphus.getcolor.bright_red + "No" + sisyphus.getcolor.reset + "]" + " ") + if oneshot: + user_input = 'yes' + else: + user_input = input(sisyphus.getcolor.bright_white + "Would you like to proceed?" + sisyphus.getcolor.reset + " " + + "[" + sisyphus.getcolor.bright_green + "Yes" + sisyphus.getcolor.reset + "/" + sisyphus.getcolor.bright_red + "No" + sisyphus.getcolor.reset + "]" + " ") if user_input.lower() in ['yes', 'y', '']: sisyphus.download.start( dl_world=False, gfx_ui=False) p_exe = subprocess.Popen(['emerge', '--quiet', '--verbose', '--usepkg', '--usepkgonly', '--rebuilt-binaries', - '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname)) + '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + (['--oneshot'] if oneshot else []) + list(pkgname)) p_exe.wait() sisyphus.syncdb.lcl_tbl() break @@ -70,7 +73,7 @@ def start(pkgname): sys.exit() -def estart(pkgname): +def estart(pkgname, oneshot=False): if sisyphus.checkenv.root(): sisyphus.update.start(gfx_ui=False) sisyphus.solvedeps.start(pkgname) @@ -84,13 +87,16 @@ def estart(pkgname): print("\n" + sisyphus.getcolor.green + "These are the binary packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.magenta + ", ".join( bin_list) + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str(len(bin_list)) + " " + "binary package(s)" + sisyphus.getcolor.reset + "\n") while True: - user_input = input(sisyphus.getcolor.bright_white + "Would you like to proceed?" + sisyphus.getcolor.reset + " " + - "[" + sisyphus.getcolor.bright_green + "Yes" + sisyphus.getcolor.reset + "/" + sisyphus.getcolor.bright_red + "No" + sisyphus.getcolor.reset + "]" + " ") + if oneshot: + user_input = 'yes' + else: + user_input = input(sisyphus.getcolor.bright_white + "Would you like to proceed?" + sisyphus.getcolor.reset + " " + + "[" + sisyphus.getcolor.bright_green + "Yes" + sisyphus.getcolor.reset + "/" + sisyphus.getcolor.bright_red + "No" + sisyphus.getcolor.reset + "]" + " ") if user_input.lower() in ['yes', 'y', '']: sisyphus.download.start( dl_world=False, gfx_ui=False) p_exe = subprocess.Popen(['emerge', '--quiet', '--verbose', '--usepkg', '--usepkgonly', '--rebuilt-binaries', - '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname)) + '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + (['--oneshot'] if oneshot else []) + list(pkgname)) p_exe.wait() sisyphus.syncdb.lcl_tbl() break @@ -113,13 +119,16 @@ def estart(pkgname): print("\n" + sisyphus.getcolor.green + "These are the source packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.green + ", ".join( src_list) + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str(len(src_list)) + " " + "source package(s)" + sisyphus.getcolor.reset + "\n") while True: - user_input = input(sisyphus.getcolor.bright_white + "Would you like to proceed?" + sisyphus.getcolor.reset + " " + - "[" + sisyphus.getcolor.bright_green + "Yes" + sisyphus.getcolor.reset + "/" + sisyphus.getcolor.bright_red + "No" + sisyphus.getcolor.reset + "]" + " ") + if oneshot: + user_input = 'yes' + else: + user_input = input(sisyphus.getcolor.bright_white + "Would you like to proceed?" + sisyphus.getcolor.reset + " " + + "[" + sisyphus.getcolor.bright_green + "Yes" + sisyphus.getcolor.reset + "/" + sisyphus.getcolor.bright_red + "No" + sisyphus.getcolor.reset + "]" + " ") if user_input.lower() in ['yes', 'y', '']: sisyphus.download.start( dl_world=False, gfx_ui=False) - p_exe = subprocess.Popen(['emerge', '--quiet', '--verbose', '--usepkg', '--rebuilt-binaries', - '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname)) + 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.wait() sisyphus.syncdb.lcl_tbl() break @@ -134,11 +143,14 @@ def estart(pkgname): print("\n" + sisyphus.getcolor.green + "These are the source packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.green + ", ".join( src_list) + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str(len(src_list)) + " " + "source package(s)" + sisyphus.getcolor.reset + "\n") while True: - user_input = input(sisyphus.getcolor.bright_white + "Would you like to proceed?" + sisyphus.getcolor.reset + " " + - "[" + sisyphus.getcolor.bright_green + "Yes" + sisyphus.getcolor.reset + "/" + sisyphus.getcolor.bright_red + "No" + sisyphus.getcolor.reset + "]" + " ") + if oneshot: + user_input = 'yes' + else: + user_input = input(sisyphus.getcolor.bright_white + "Would you like to proceed?" + sisyphus.getcolor.reset + " " + + "[" + sisyphus.getcolor.bright_green + "Yes" + sisyphus.getcolor.reset + "/" + sisyphus.getcolor.bright_red + "No" + sisyphus.getcolor.reset + "]" + " ") if user_input.lower() in ['yes', 'y', '']: p_exe = subprocess.Popen( - ['emerge', '--quiet', '--verbose', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname)) + ['emerge', '--quiet', '--verbose', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + (['--oneshot'] if oneshot else []) + list(pkgname)) p_exe.wait() sisyphus.syncdb.lcl_tbl() break diff --git a/src/frontend/cli/sisyphus-cli.py b/src/frontend/cli/sisyphus-cli.py index e4dd877..3dce38f 100755 --- a/src/frontend/cli/sisyphus-cli.py +++ b/src/frontend/cli/sisyphus-cli.py @@ -105,7 +105,9 @@ def search(package: List[str] = typer.Argument(...), sisyphus.search.estart(package) @app.command("install") -def install(pkgname: List[str], ebuild: bool = typer.Option(False, "--ebuild", "-e")): +def install(pkgname: List[str], + ebuild: bool = typer.Option(False, "--ebuild", "-e", help = 'Search in ebuilds (slower)'), + oneshot: bool = typer.Option(False, "--oneshot", "-1", help= 'Do not add package to world set')): """Install binary and/or ebuild(source) packages. By default, only binary packages will be installed. Use the --ebuild option to install ebuild(source) packages. @@ -122,11 +124,22 @@ def install(pkgname: List[str], ebuild: bool = typer.Option(False, "--ebuild", " The --ebuild option will preffer to reuse binary packages(if available) to satisfy the dependencies for the ebuild(source) package, speeding up the installation. You can use the --ebuild option even if you don't want to install any ebuild(source) packages; It will fall back to binary packages only. + + The --oneshot option will install the packages as described above, however it will not add them to the 'world' set, which means they will not be marked as + explicitly installed. As a result, they will be treated as orphans and they will be uninstalled with 'sisyphus autoremove' if no other package needs them as + a depencency, unless they are explicitly added to the 'world' set using 'emerge --noreplace pkgname'. The --oneshot option does not require any confirmation, + and packages will be installed straight away. """ - if not ebuild: - sisyphus.install.start(pkgname) + if not oneshot: + if not ebuild: + sisyphus.install.start(pkgname, oneshot=False) + else: + sisyphus.install.estart(pkgname, oneshot=False) else: - sisyphus.install.estart(pkgname) + if not ebuild: + sisyphus.install.start(pkgname, oneshot=True) + else: + sisyphus.install.estart(pkgname, oneshot=True) @app.command("uninstall") def uninstall(pkgname: List[str], force: bool = typer.Option(False, "--force", "-f")): |