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

import os
import subprocess
import sisyphus.getenv
import sisyphus.getfs


def root():
    return True if os.getuid() == 0 else False


def branch():
    activeBranch = None

    if os.path.isdir(os.path.join(sisyphus.getfs.gentooRepoDir, '.git')):
        os.chdir(sisyphus.getfs.gentooRepoDir)
        localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])

        if localBranch.decode().strip() == 'master':
            activeBranch = str('master')

        if localBranch.decode().strip() == 'next':
           activeBranch = str('next')

    return activeBranch


def sanity():
    activeBranch = branch()
    binhostURL = sisyphus.getenv.binhostURL()
    isSane = int()

    if "packages-next" in binhostURL:
        if activeBranch == "next":
            isSane = int(1)
        else:
            isSane = int(0)
    else:
        if activeBranch == "master":
            isSane = int(1)
        else:
            isSane = int(0)

    return isSane