From e1562a71d6483021d332bccbfc5a3086688bc58c Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sat, 17 Sep 2022 19:12:53 +0100 Subject: rearrange the backend --- src/backend/checkEnvironment.py | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/backend/checkEnvironment.py (limited to 'src/backend/checkEnvironment.py') diff --git a/src/backend/checkEnvironment.py b/src/backend/checkEnvironment.py new file mode 100644 index 0000000..5a43780 --- /dev/null +++ b/src/backend/checkEnvironment.py @@ -0,0 +1,42 @@ +#!/usr/bin/python3 + +import os +import subprocess +import sisyphus.getBinhost +import sisyphus.getFilesystem + +def root(): + return True if os.getuid() == 0 else False + +def branch(): + activeBranch = None + + if os.path.isdir(os.path.join(sisyphus.getFilesystem.portageRepoDir, '.git')): + os.chdir(sisyphus.getFilesystem.portageRepoDir) + 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() + isBinhost = sisyphus.getBinhost.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: + isSane = int(0) + + return isSane -- cgit v1.2.3