summaryrefslogtreecommitdiff
path: root/src/frontend/cli/sisyphus-cli.py
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2020-06-09 13:57:07 +0100
committerV3n3RiX <venerix@redcorelinux.org>2020-06-09 13:57:07 +0100
commitdc646ecd9650eadf65fb5d6f019b5d555289cc66 (patch)
tree4bcde67170710e55399f2b46d30e3bdab98215c7 /src/frontend/cli/sisyphus-cli.py
parent4a2deff282a0a353ad85d43f3cc0095cdc9cfd83 (diff)
cli-frontend : make the new client the default clinet
Diffstat (limited to 'src/frontend/cli/sisyphus-cli.py')
-rwxr-xr-xsrc/frontend/cli/sisyphus-cli.py194
1 files changed, 126 insertions, 68 deletions
diff --git a/src/frontend/cli/sisyphus-cli.py b/src/frontend/cli/sisyphus-cli.py
index 5b7e3b2..a0ca430 100755
--- a/src/frontend/cli/sisyphus-cli.py
+++ b/src/frontend/cli/sisyphus-cli.py
@@ -1,71 +1,129 @@
#!/usr/bin/python3
-import sisyphus
-import sys
-
-sisyphus.check.update()
-sisyphus.setjobs.start.__wrapped__() # undecorate
-pkgList = sys.argv[2:]
-
-if "__main__" == __name__:
- if sys.argv[1:]:
- if "--install" in sys.argv[1:]:
- if not pkgList:
- sys.exit("\n" + "Nothing to install, please provide at least one package name; quitting" + "\n")
- else:
- sisyphus.install.start(pkgList)
- elif "--uninstall" in sys.argv[1:]:
- if not pkgList:
- sys.exit("\n" + "Nothing to uninstall, please provide at least one package name; quitting" + "\n")
- else:
- sisyphus.uninstall.start(pkgList)
- elif "--force-uninstall" in sys.argv[1:]:
- if not pkgList:
- sys.exit("\n" + "Nothing to force uninstall, please provide at least one package name; quitting" + "\n")
- else:
- sisyphus.uninstallforce.start(pkgList)
- elif "--remove-orphans" in sys.argv[1:]:
- sisyphus.removeorphans.start()
- elif "--search" in sys.argv[1:]:
- if not pkgList:
- sys.exit("\n" + "Nothing to search, please provide at least one package name; quitting" + "\n")
- else:
- sisyphus.search.start(pkgList)
- elif "--update" in sys.argv[1:]:
- sisyphus.update.start()
- elif "--upgrade" in sys.argv[1:]:
- sisyphus.upgrade.start()
- elif "--rescue" in sys.argv[1:]:
- sisyphus.rescue.start()
- elif "--spmsync" in sys.argv[1:]:
- sisyphus.spmsync.start()
- elif "--sysinfo" in sys.argv[1:]:
- sisyphus.sysinfo.show()
- elif "--mirror" in sys.argv[1:]:
- if "--list" in sys.argv[2:]:
- sisyphus.mirror.printList()
- elif "--set" in sys.argv[2:]:
- if sys.argv[3:]:
- sisyphus.mirror.setActive(sys.argv[3:])
- else:
- sisyphus.help.show()
- else:
- sisyphus.help.show()
- elif "--branch=master" in sys.argv[1:]:
- if "--remote=gitlab" in sys.argv[2:]:
- sisyphus.branchinject.gitlabMaster()
- elif "--remote=pagure" in sys.argv[2:]:
- sisyphus.branchinject.pagureMaster()
- else:
- sisyphus.help.show()
- elif "--branch=next" in sys.argv[1:]:
- if "--remote=gitlab" in sys.argv[2:]:
- sisyphus.branchinject.gitlabNext()
- elif "--remote=pagure" in sys.argv[2:]:
- sisyphus.branchinject.pagureNext()
- else:
- sisyphus.help.show()
- elif "--help" in sys.argv[1:]:
- sisyphus.help.show()
+import typer
+from typing import List
+
+app = typer.Typer()
+mirror_cmd = typer.Typer()
+app.add_typer(mirror_cmd, name="mirror", help='List/set the active binary repository mirror.')
+
+@app.callback()
+def app_callback():
+ """Sisyphus is a simple python wrapper around portage, gentoolkit, and portage-utils
+ which provides an apt-get/yum-alike interface to these commands,
+ to assist newcomer people transitioning from Debian/RedHat-based systems to Gentoo.
+
+ Use 'sisyphus COMMAND --help' for detailed usage.
+ """
+ pass
+
+@app.command("update")
+def update():
+ """Update the Portage tree, the Redcore Overlay(s), Portage configs and Sisyphus's package database."""
+ typer.echo("Updating system ...")
+
+@app.command("upgrade")
+def upgrade():
+ """Upgrade the system using binary and/or ebuild (source) packages."""
+ typer.echo("Upgrading all packages ...")
+
+@app.command("install")
+def install(pkglist: List[str]):
+ """Install binary and/or ebuild (source) packages."""
+ [typer.echo(f"Installing {pkg}") for pkg in pkglist]
+
+@app.command("uninstall")
+def uninstall(pkglist: List[str], force: bool = False):
+ """Uninstall packages *SAFELY* by checking for reverse dependencies.
+ If reverse dependencies exist, the package(s) will NOT be uninstalled to prevent the possible breakage of the system.
+ If you really want to uninstall the package, make sure you uninstall all reverse dependencies as well.
+ This will not allways be possible, as the reverse dependency chain may be way to long and require you to uninstall critical system packages.
+
+ Using the --force option, packages are uninstalled *UNSAFELY* by ignoring reverse dependencies.
+ This may break your system if you uninstall critical system packages.
+ It will try the best it can to preserve the libraries required by other packages to prevent such a breakage.
+ Upgrading the system may pull the packages back in, to fix the reverse dependency chain.
+ """
+ if not force:
+ [typer.echo(f"Safely removing {pkg}") for pkg in pkglist]
else:
- sisyphus.help.show()
+ [typer.echo(f"Force removing {pkg}") for pkg in pkglist]
+
+@app.command("autoremove")
+def autoremove():
+ """Uninstall packages that are no longer needed.
+ When you uninstall a package without it's reverse dependencies, those dependencies will become orphans if nothing else requires them.
+ In addition, a package may no longer depend on another one, so that other package becomes orphan as well if nothing else requires it.
+ Use this option to check the whole dependency chain for such packages, and uninstall them.
+ """
+ typer.echo("Performing cleanup ... ")
+
+@app.command("search")
+def install(pkglist: List[str]):
+ """Search for binary and/or ebuild (source) packages."""
+ [typer.echo(f"Searching for {pkg}") for pkg in pkglist]
+
+@app.command("spmsync")
+def spmsync():
+ """Sync Sisyphus's package database with Portage's package database.
+ When you install something with Portage directly (emerge), Sisyphus is not aware of that package, and it doesn't track it in it's database.
+ Use this command to synchronize Sisyphus's package database with Portage's package database.
+ """
+ typer.echo("Syncing sisyphus database ...")
+
+@app.command("rescue")
+def rescue():
+ """Resurrect Sisyphus's package database if lost or corrupted.
+ If for some reason Sisyphus's package database is lost or corrupted, it can be resurrected using Portage's package database.
+ If Portage's package database is corrupted (in this case you're screwed anyway :D), only a partial resurrection will be possible.
+ If Portage's package database is intact, full resurrection will be possible.
+ """
+ typer.echo("Syncing sisyphus database ...")
+
+@app.command("branch")
+def branch(branch: str = typer.Argument('master'), remote: str = typer.Option('pagure')):
+ """Pull the branch 'BRANCH' of the Portage tree, Redcore overlay and Portage configs,
+ using 'REMOTE' git repositories.
+
+ 'BRANCH' can be one of the following : master, next (default is master)
+
+ 'REMOTE' can be one of the following : gitlab, pagure (default is pagure)
+
+ * Examples:
+
+ 'branch master --remote gitlab' will pull the branch 'master' from gitlab.com
+
+ 'branch next --remote pagure' will pull the branch 'next' from pagure.io
+
+ !!! WARNING !!!
+
+ Once you changed the branch, you must pair the branch 'BRANCH' with the correct binary repository.
+
+ Branch 'master' must be paired with the stable binary repository (odd numbers in 'sisyphus mirror list').
+
+ * Examples : 'sisyphus mirror set 1' or 'sisyphus mirror set 5'
+
+ Branch 'next' must be paired with the testing binary repository (even numbers in 'sisyphus mirror list').
+
+ * Examples : 'sisyphus mirror set 2' or 'sisyphus mirror set 8'
+ """
+ typer.echo(f"Injecting {branch} branch from {remote} repository")
+
+@app.command("sysinfo")
+def sysinfo():
+ """Display information about installed core packages and portage configuration."""
+ typer.echo("Syncing sisyphus database ...")
+
+@mirror_cmd.command("list")
+def mirror_list():
+ """List available binary package repository mirrors
+ (the active one is marked with *)"""
+ typer.echo("Listing available mirrors ...")
+
+@mirror_cmd.command("set")
+def mirror_set(index: int):
+ """Change the binary package repository to the selected mirror."""
+ typer.echo(f"Setting mirror to: {index}")
+
+if __name__ == "__main__":
+ app()