summaryrefslogtreecommitdiff
path: root/src/frontend/cli/sisyphus-cli.py
blob: ee9bd9f7b39986cf514a3494af5f571dda8bad43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/python3

import sisyphus
import typer
from typing import List

sisyphus.check.update()
sisyphus.setjobs.start.__wrapped__() # undecorate

app = typer.Typer()
mirrorSetup = typer.Typer()
app.add_typer(mirrorSetup, 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("search")
def search(pkgname: List[str]):
    """Search for binary and/or ebuild (source) packages."""
    sisyphus.search.start(pkgname)

@app.command("install")
def install(pkgname: List[str]):
    """Install binary and/or ebuild (source) packages."""
    sisyphus.install.start(pkgname)

@app.command("uninstall")
def uninstall(pkgname: 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:
        sisyphus.uninstall.start(pkgname)
    else:
        sisyphus.uninstallforce.start(pkgname)

@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.
    """
    sisyphus.autoremove.start()

@app.command("update")
def update():
    """Update the Portage tree, the Redcore Overlay(s), Portage configs and Sisyphus's package database."""
    sisyphus.update.start()

@app.command("upgrade")
def upgrade():
    """Upgrade the system using binary and/or ebuild (source) packages."""
    sisyphus.upgrade.start()

@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.
    """
    sisyphus.spmsync.start()

@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.
    """
    sisyphus.rescue.start()

@app.command("branch")
def branch(branch: str = typer.Argument(...), remote: str = typer.Option(...)):
    """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

    'REMOTE' can be one of the following : gitlab, 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'
    """
    sisyphus.branchsetup.start(branch, remote)

@app.command("sysinfo")
def sysinfo():
    """Display information about installed core packages and portage configuration."""
    typer.echo("Syncing sisyphus database ...")

@mirrorSetup.command("list")
def mirrorlist():
    """List available binary package repository mirrors (the active one is marked with *)."""
    sisyphus.mirror.printList()

@mirrorSetup.command("set")
def mirrorset(index: int):
    """Change the binary package repository to the selected mirror."""
    sisyphus.mirror.setActive(index)

if __name__ == "__main__":
    app()