summaryrefslogtreecommitdiff
path: root/src/backend/check.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/check.py')
-rw-r--r--src/backend/check.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/backend/check.py b/src/backend/check.py
new file mode 100644
index 0000000..eb786aa
--- /dev/null
+++ b/src/backend/check.py
@@ -0,0 +1,49 @@
+#!/usr/bin/python3
+
+import os
+import sys
+import subprocess
+
+gentooEbuildDir = '/usr/ports/gentoo'
+redcoreEbuildDir = '/usr/ports/redcore'
+
+def root():
+ if not os.getuid() == 0:
+ sys.exit("\nYou need root permissions to do this, exiting!\n")
+
+def portage():
+ os.chdir(gentooEbuildDir)
+ needsPortageSync = int()
+
+ localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
+ localHash = subprocess.check_output(['git', 'rev-parse', '@'])
+ remoteHash = subprocess.check_output(['git', 'rev-parse', '@{u}'])
+
+ gitExec = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE)
+
+ if not localHash.decode().strip() == remoteHash.decode().strip():
+ needsPortageSync = int(1)
+
+ gitExec.wait()
+ return needsPortageSync
+
+def overlay():
+ os.chdir(redcoreEbuildDir)
+ needsOverlaySync = int()
+
+ localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
+ localHash = subprocess.check_output(['git', 'rev-parse', '@'])
+ remoteHash = subprocess.check_output(['git', 'rev-parse', '@{u}'])
+
+ gitExec = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE)
+
+ if not localHash.decode().strip() == remoteHash.decode().strip():
+ needsOverlaySync = int(1)
+
+ gitExec.wait()
+ return needsOverlaySync
+
+def update():
+ portage()
+ overlay()
+