summaryrefslogtreecommitdiff
path: root/src/backend/update.py
blob: 57b05b6ddf3e71f3837f1a0cc4bd0a342717fa18 (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
#!/usr/bin/python3

import animation
import sys
import time
import sisyphus.checkenv
import sisyphus.getcolor
import sisyphus.getenv
import sisyphus.purgeenv
import sisyphus.syncdb
import sisyphus.syncenv


def syncAll():
    sisyphus.syncenv.gentooRepo()
    sisyphus.syncenv.redcoreRepo()
    sisyphus.syncenv.portageConfigRepo()
    sisyphus.syncdb.remoteTable()


@animation.wait('fetching updates')
def start():
    act_brch = sisyphus.getenv.sys_brch()
    bh_addr = sisyphus.getenv.bh_addr()
    isSane = sisyphus.checkenv.sanity()

    if isSane == 1:
        syncAll()
    else:
        if "packages-next" in bh_addr:
            print(sisyphus.getcolor.green + "\n\nActive branch:" + " " + sisyphus.getcolor.reset + "'" + act_brch + "'" + " " + "(stable)" +
                  " " + sisyphus.getcolor.green + "\nActive binhost:" + " " + sisyphus.getcolor.reset + "'" + bh_addr + "'" + " " + "(testing)")
        else:
            print(sisyphus.getcolor.green + "\n\nActive branch:" + " " + sisyphus.getcolor.reset + "'" + act_brch + "'" + " " + "(testing)" +
                  " " + sisyphus.getcolor.green + "\nActive binhost:" + " " + sisyphus.getcolor.reset + "'" + bh_addr + "'" + " " + "(stable)")
        sys.exit(sisyphus.getcolor.bright_red + "\n\nInvalid configuration!" + sisyphus.getcolor.reset + sisyphus.getcolor.bright_yellow +
                 "\nUse" + sisyphus.getcolor.reset + " " + "'" + "sisyphus branch --help" + "'" + " " + sisyphus.getcolor.bright_yellow + "for help" + sisyphus.getcolor.reset)


def xstart():
    act_brch = sisyphus.getenv.sys_brch()
    bh_addr = sisyphus.getenv.bh_addr()
    isSane = sisyphus.checkenv.sanity()

    if isSane == 1:
        syncAll()
    else:
        if "packages-next" in bh_addr:
            print("\n\nActive branch:" + " " + "'" + act_brch + "'" + " " + "(stable)" +
                  "\nActive binhost:" + " " + "'" + bh_addr + "'" + " " + "(testing)")
        else:
            print("\n\nActive branch:" + " " + "'" + act_brch + "'" + " " + "(testing)" +
                  "\nActive binhost:" + " " + "'" + bh_addr + "'" + " " + "(stable)")
        print("\n\nInvalid configuration!" +
              "\nUse 'sisyphus branch --help' for help\n")
        t = int(10)
        while t:
            mins, secs = divmod(t, 60)
            timer = '{:02d}:{:02d}'.format(mins, secs)
            print(timer, end="\r")
            time.sleep(1)
            t -= 1
        sys.exit()