summaryrefslogtreecommitdiff
path: root/src/backend/sync.py
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2020-06-06 16:22:04 +0100
committerV3n3RiX <venerix@redcorelinux.org>2020-06-06 16:22:04 +0100
commitac0efd1bd6c703147bd8d3caedf489fab87d6131 (patch)
treee6af981b6e90be35447dbb88dd276a4d8ff2d47e /src/backend/sync.py
parent49e6ab19aa461151132dfb4f1cf962d4ef403c66 (diff)
big rewrite : split the backend in smaller pieces, rework the cli frontend to work with the new backend ... gui frontend wip
Diffstat (limited to 'src/backend/sync.py')
-rw-r--r--src/backend/sync.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/backend/sync.py b/src/backend/sync.py
new file mode 100644
index 0000000..b8fd91c
--- /dev/null
+++ b/src/backend/sync.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python3
+
+import os
+import subprocess
+
+gentooEbuildDir = '/usr/ports/gentoo'
+redcoreEbuildDir = '/usr/ports/redcore'
+portageConfigDir = '/opt/redcore-build'
+
+def portage():
+ os.chdir(gentooEbuildDir)
+ localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
+ remoteBranch = subprocess.check_output(['git', 'rev-parse', '--symbolic-full-name', '@{u}'])
+
+ gitExecStage1 = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE)
+ gitExecStage1.wait()
+ gitExecStage2 = subprocess.Popen(['git', 'reset', '--hard'] + remoteBranch.decode().strip().replace('refs/remotes/','').split() + ['--quiet'], stdout=subprocess.PIPE)
+ gitExecStage2.wait()
+
+def overlay():
+ os.chdir(redcoreEbuildDir)
+ localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
+ remoteBranch = subprocess.check_output(['git', 'rev-parse', '--symbolic-full-name', '@{u}'])
+
+ gitExecStage1 = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE)
+ gitExecStage1.wait()
+ gitExecStage2 = subprocess.Popen(['git', 'reset', '--hard'] + remoteBranch.decode().strip().replace('refs/remotes/','').split() + ['--quiet'], stdout=subprocess.PIPE)
+ gitExecStage2.wait()
+
+def portageCfg():
+ os.chdir(portageConfigDir)
+ localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
+ remoteBranch = subprocess.check_output(['git', 'rev-parse', '--symbolic-full-name', '@{u}'])
+
+ gitExecStage1 = subprocess.Popen(['git', 'stash'], stdout=subprocess.PIPE)
+ gitExecStage1.wait()
+ gitExecStage2 = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE)
+ gitExecStage2.wait()
+ gitExecStage3 = subprocess.Popen(['git', 'reset', '--hard'] + remoteBranch.decode().strip().replace('refs/remotes/','').split() + ['--quiet'], stdout=subprocess.PIPE)
+ gitExecStage3.wait()
+ gitExecStage4 = subprocess.Popen(['git', 'stash', 'apply'], stdout=subprocess.PIPE)
+ gitExecStage4.wait()
+ gitExecStage5 = subprocess.Popen(['git', 'stash', 'clear'], stdout=subprocess.PIPE)
+ gitExecStage5.wait()
+ gitExecStage6 = subprocess.Popen(['git', 'gc', '--prune=now', '--quiet'], stdout=subprocess.PIPE)
+ gitExecStage6.wait()