diff options
-rw-r--r-- | src/backend/check.py | 38 | ||||
-rw-r--r-- | src/backend/update.py | 18 |
2 files changed, 35 insertions, 21 deletions
diff --git a/src/backend/check.py b/src/backend/check.py index a159a27..7f23338 100644 --- a/src/backend/check.py +++ b/src/backend/check.py @@ -9,22 +9,34 @@ def root(): return True if os.getuid() == 0 else False def branch(): + activeBranch = None + if os.path.isdir(os.path.join(sisyphus.filesystem.portageRepoDir, '.git')): os.chdir(sisyphus.filesystem.portageRepoDir) - needsMatch = int() - - isBinhost = sisyphus.binhost.start() localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) - if "packages-next" in isBinhost: - if localBranch.decode().strip() == "next": - needsMatch = int(0) - else: - needsMatch = int(1) + if localBranch.decode().strip() == 'master': + activeBranch = str('master') + + if localBranch.decode().strip() == 'next': + activeBranch = str('next') + + return activeBranch + +def sanity(): + activeBranch = branch() + isBinhost = sisyphus.binhost.start() + isSane = int() + + if "packages-next" in isBinhost: + if activeBranch == "next": + isSane = int(1) + else: + isSane = int(0) + else: + if activeBranch == "master": + isSane = int(1) else: - if localBranch.decode().strip() == "master": - needsMatch = int(0) - else: - needsMatch = int(1) + isSane = int(0) - return needsMatch,localBranch + return isSane diff --git a/src/backend/update.py b/src/backend/update.py index 0253118..0fe1fde 100644 --- a/src/backend/update.py +++ b/src/backend/update.py @@ -18,29 +18,31 @@ def syncAll(): @animation.wait('fetching updates') def start(): + activeBranch = sisyphus.check.branch() isBinhost = sisyphus.binhost.start() - needsMatch,localBranch = sisyphus.check.branch() + isSane = sisyphus.check.sanity() - if needsMatch == 0: + if isSane == 1: syncAll() else: if "packages-next" in isBinhost: - print("\nCurrent branch: '" + localBranch.decode().strip() + "' (stable)" + "\nCurrent binhost: '" + isBinhost + "' (testing)") + print("\nCurrent branch: '" + activeBranch + "' (stable)" + "\nCurrent binhost: '" + isBinhost + "' (testing)") else: - print("\nCurrent branch: '" + localBranch.decode().strip() + "' (testing)" + "\nCurrent binhost: '" + isBinhost + "' (stable)") + print("\nCurrent branch: '" + activeBranch + "' (testing)" + "\nCurrent binhost: '" + isBinhost + "' (stable)") sys.exit("\nInvalid branch - binhost pairing; Use 'sisyphus branch --help' for help; Quitting.") def startqt(): + activeBranch = sisyphus.check.branch() isBinhost = sisyphus.binhost.start() - needsMatch,localBranch = sisyphus.check.branch() + isSane = sisyphus.check.sanity() - if needsMatch == 0: + if isSane == 1: syncAll() else: if "packages-next" in isBinhost: - print("\nCurrent branch: '" + localBranch.decode().strip() + "' (stable)" + "\nCurrent binhost: '" + isBinhost + "' (testing)") + print("\nCurrent branch: '" + activeBranch + "' (stable)" + "\nCurrent binhost: '" + isBinhost + "' (testing)") else: - print("\nCurrent branch: '" + localBranch.decode().strip() + "' (testing)" + "\nCurrent binhost: '" + isBinhost + "' (stable)") + print("\nCurrent branch: '" + activeBranch + "' (testing)" + "\nCurrent binhost: '" + isBinhost + "' (stable)") print("\nInvalid branch - binhost pairing; Use 'sisyphus branch --help' for help; Quitting in 10 seconds.\n") t = int(10) while t: |