summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2020-06-10 00:12:21 +0100
committerV3n3RiX <venerix@redcorelinux.org>2020-06-10 00:12:21 +0100
commitdf5e80d63cff8acce2b510e1f2be07a7e1369415 (patch)
tree85f3127fb5f533719008edc98c97e2bfcb76ac9a /src/backend
parentc76a29a71d16e9ed512a22945d6e6b77b0d21fb6 (diff)
branchsetup : new generic module, drop old branchinject, branchmaster && branchnext modules; plug the new module into the new cli client -> works magic
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/__init__.py4
-rw-r--r--src/backend/branchinject.py41
-rw-r--r--src/backend/branchmaster.py70
-rw-r--r--src/backend/branchnext.py70
-rw-r--r--src/backend/branchsetup.py71
-rw-r--r--src/backend/check.py42
-rw-r--r--src/backend/filesystem.py4
-rw-r--r--src/backend/setprofile.py6
8 files changed, 100 insertions, 208 deletions
diff --git a/src/backend/__init__.py b/src/backend/__init__.py
index 5a1e703..cd50979 100644
--- a/src/backend/__init__.py
+++ b/src/backend/__init__.py
@@ -1,9 +1,7 @@
from .autoremove import *
from .binhost import *
-from .branchinject import *
-from .branchmaster import *
-from .branchnext import *
from .branchreset import *
+from .branchsetup import *
from .cache import *
from .check import *
from .csvfiles import *
diff --git a/src/backend/branchinject.py b/src/backend/branchinject.py
deleted file mode 100644
index 7c9a09f..0000000
--- a/src/backend/branchinject.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/python3
-
-import sisyphus.check
-import sisyphus.branchreset
-import sisyphus.branchmaster
-import sisyphus.branchnext
-import sisyphus.metadata
-import sisyphus.setjobs
-import sisyphus.setprofile
-
-def gitlabMaster():
- sisyphus.check.root()
- sisyphus.branchreset.start()
- sisyphus.branchmaster.startGitlab()
- sisyphus.setjobs.start()
- sisyphus.setprofile.start()
- sisyphus.metadata.regenAnimated()
-
-def PagureMaster():
- sisyphus.check.root()
- sisyphus.branchreset.start()
- sisyphus.branchmaster.startPagure()
- sisyphus.setjobs.start()
- sisyphus.setprofile.start()
- sisyphus.metadata.regenAnimated()
-
-def GitlabNext():
- sisyphus.check.root()
- sisyphus.branchreset.start()
- sisyphus.branchnext.startGitlab()
- sisyphus.setjobs.start()
- sisyphus.setprofile.start()
- sisyphus.metadata.regenAnimated()
-
-def PagureNext():
- sisyphus.check.root()
- sisyphus.branchreset.start()
- sisyphus.branchnext.startPagure()
- sisyphus.setjobs.start()
- sisyphus.setprofile.start()
- sisyphus.metadata.regenAnimated()
diff --git a/src/backend/branchmaster.py b/src/backend/branchmaster.py
deleted file mode 100644
index d9a2b09..0000000
--- a/src/backend/branchmaster.py
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/python3
-
-import animation
-import os
-import subprocess
-import sisyphus.filesystem
-
-@animation.wait('injecting gentoo linux portage tree - branch master')
-def setGitlabMasterStage1():
- if not os.path.isdir(os.path.join(sisyphus.filesystem.portageRepoDir, '.git')):
- os.chdir(sisyphus.filesystem.portageRepoDir)
- subprocess.call(['git', 'init', '-q'])
- subprocess.call(['git', 'remote', 'add', 'origin', 'https://gitlab.com/redcore/portage.git'])
- subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'master', '--quiet'])
- subprocess.call(['git', 'checkout', '-b', 'master', 'origin/master', '--quiet'])
-
-@animation.wait('injecting redcore linux ebuild tree - branch master')
-def setGitlabMasterStage2():
- if not os.path.isdir(os.path.join(sisyphus.filesystem.redcoreRepoDir, '.git')):
- os.chdir(sisyphus.filesystem.redcoreRepoDir)
- subprocess.call(['git', 'init', '-q'])
- subprocess.call(['git', 'remote', 'add', 'origin', 'https://gitlab.com/redcore/redcore-desktop.git'])
- subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'master', '--quiet'])
- subprocess.call(['git', 'checkout', '-b', 'master', 'origin/master', '--quiet'])
-
-@animation.wait('injecting redcore linux portage configuration - branch master')
-def setGitlabMasterStage3():
- if not os.path.isdir(os.path.join(sisyphus.filesystem.portageConfigDir, '.git')):
- os.chdir(sisyphus.filesystem.portageConfigDir)
- subprocess.call(['git', 'init', '-q'])
- subprocess.call(['git', 'remote', 'add', 'origin', 'https://gitlab.com/redcore/redcore-build.git'])
- subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'master', '--quiet'])
- subprocess.call(['git', 'checkout', '-b', 'master', 'origin/master', '--quiet'])
-
-def gitlabStart():
- setGitlabMasterStage1()
- setGitlabMasterStage2()
- setGitlabMasterStage3()
-
-@animation.wait('injecting gentoo linux portage tree - branch master')
-def setPagureMasterStage1():
- if not os.path.isdir(os.path.join(sisyphus.filesystem.portageRepoDir, '.git')):
- os.chdir(sisyphus.filesystem.portageRepoDir)
- subprocess.call(['git', 'init', '-q'])
- subprocess.call(['git', 'remote', 'add', 'origin', 'https://pagure.io/redcore/portage.git'])
- subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'master', '--quiet'])
- subprocess.call(['git', 'checkout', '-b', 'master', 'origin/master', '--quiet'])
-
-@animation.wait('injecting redcore linux ebuild tree - branch master')
-def setPagureMasterStage2():
- if not os.path.isdir(os.path.join(sisyphus.filesystem.redcoreRepoDir, '.git')):
- os.chdir(sisyphus.filesystem.redcoreRepoDir)
- subprocess.call(['git', 'init', '-q'])
- subprocess.call(['git', 'remote', 'add', 'origin', 'https://pagure.io/redcore/redcore-desktop.git'])
- subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'master', '--quiet'])
- subprocess.call(['git', 'checkout', '-b', 'master', 'origin/master', '--quiet'])
-
-@animation.wait('injecting redcore linux portage configuration - branch master')
-def setPagureMasterStage3():
- if not os.path.isdir(os.path.join(sisyphus.filesystem.portageConfigDir, '.git')):
- os.chdir(sisyphus.filesystem.portageConfigDir)
- subprocess.call(['git', 'init', '-q'])
- subprocess.call(['git', 'remote', 'add', 'origin', 'https://pagure.io/redcore/redcore-build.git'])
- subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'master', '--quiet'])
- subprocess.call(['git', 'checkout', '-b', 'master', 'origin/master', '--quiet'])
-
-def pagureStart():
- setPagureMasterStage1()
- setPagureMasterStage2()
- setPagureMasterStage3()
diff --git a/src/backend/branchnext.py b/src/backend/branchnext.py
deleted file mode 100644
index 858de86..0000000
--- a/src/backend/branchnext.py
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/python3
-
-import animation
-import os
-import subprocess
-import sisyphus.filesystem
-
-@animation.wait('injecting gentoo linux portage tree - branch next')
-def setGitlabNextStage1():
- if not os.path.isdir(os.path.join(sisyphus.filesystem.portageRepoDir, '.git')):
- os.chdir(sisyphus.filesystem.portageRepoDir)
- subprocess.call(['git', 'init', '-q'])
- subprocess.call(['git', 'remote', 'add', 'origin', 'https://gitlab.com/redcore/portage.git'])
- subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'next', '--quiet'])
- subprocess.call(['git', 'checkout', '-b', 'next', 'origin/next', '--quiet'])
-
-@animation.wait('injecting redcore linux ebuild tree - branch next')
-def setGitlabNextStage2():
- if not os.path.isdir(os.path.join(sisyphus.filesystem.redcoreRepoDir, '.git')):
- os.chdir(sisyphus.filesystem.redcoreRepoDir)
- subprocess.call(['git', 'init', '-q'])
- subprocess.call(['git', 'remote', 'add', 'origin', 'https://gitlab.com/redcore/redcore-desktop.git'])
- subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'next', '--quiet'])
- subprocess.call(['git', 'checkout', '-b', 'next', 'origin/next', '--quiet'])
-
-@animation.wait('injecting redcore linux portage configuration - branch next')
-def setGitlabNextStage3():
- if not os.path.isdir(os.path.join(sisyphus.filesystem.portageConfigDir, '.git')):
- os.chdir(sisyphus.filesystem.portageConfigDir)
- subprocess.call(['git', 'init', '-q'])
- subprocess.call(['git', 'remote', 'add', 'origin', 'https://gitlab.com/redcore/redcore-build.git'])
- subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'next', '--quiet'])
- subprocess.call(['git', 'checkout', '-b', 'next', 'origin/next', '--quiet'])
-
-def startGitlab():
- setGitlabNextStage1()
- setGitlabNextStage2()
- setGitlabNextStage3()
-
-@animation.wait('injecting gentoo linux portage tree - branch next')
-def setPagureNextStage1():
- if not os.path.isdir(os.path.join(sisyphus.filesystem.portageRepoDir, '.git')):
- os.chdir(sisyphus.filesystem.portageRepoDir)
- subprocess.call(['git', 'init', '-q'])
- subprocess.call(['git', 'remote', 'add', 'origin', 'https://pagure.io/redcore/portage.git'])
- subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'next', '--quiet'])
- subprocess.call(['git', 'checkout', '-b', 'next', 'origin/next', '--quiet'])
-
-@animation.wait('injecting redcore linux ebuild tree - branch next')
-def setPagureNextStage2():
- if not os.path.isdir(os.path.join(sisyphus.filesystem.redcoreRepoDir, '.git')):
- os.chdir(sisyphus.filesystem.redcoreRepoDir)
- subprocess.call(['git', 'init', '-q'])
- subprocess.call(['git', 'remote', 'add', 'origin', 'https://pagure.io/redcore/redcore-desktop.git'])
- subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'next', '--quiet'])
- subprocess.call(['git', 'checkout', '-b', 'next', 'origin/next', '--quiet'])
-
-@animation.wait('injecting redcore linux portage configuration - branch next')
-def setPagureNextStage3():
- if not os.path.isdir(os.path.join(sisyphus.filesystem.portageConfigDir, '.git')):
- os.chdir(sisyphus.filesystem.portageConfigDir)
- subprocess.call(['git', 'init', '-q'])
- subprocess.call(['git', 'remote', 'add', 'origin', 'https://pagure.io/redcore/redcore-build.git'])
- subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'next', '--quiet'])
- subprocess.call(['git', 'checkout', '-b', 'next', 'origin/next', '--quiet'])
-
-def startPagure():
- setPagureNextStage1()
- setPagureNextStage2()
- setPagureNextStage3()
diff --git a/src/backend/branchsetup.py b/src/backend/branchsetup.py
new file mode 100644
index 0000000..5e0976e
--- /dev/null
+++ b/src/backend/branchsetup.py
@@ -0,0 +1,71 @@
+#!/usr/bin/python3
+
+import os
+import subprocess
+import sisyphus.check
+import sisyphus.branchreset
+import sisyphus.filesystem
+import sys
+
+def start(branch,remote):
+ if "master" in branch:
+ if "gitlab" in remote:
+ remote = sisyphus.filesystem.remoteGitlab
+ elif "pagure" in remote:
+ remote = sisyphus.filesystem.remotePagure
+ else:
+ sys.exit("Usage: sisyphus-cli.py branch [OPTIONS] BRANCH" + "\n" +
+ "Try 'sisyphus-cli.py branch --help' for help." + "\n\n" +
+ "Error: Invalid remote" + " " + "'" + str(remote) + "'" + " " + "(options : gitlab, pagure)"
+ )
+ elif "next" in branch:
+ if "gitlab" in remote:
+ remote = sisyphus.filesystem.remoteGitlab
+ elif "pagure" in remote:
+ remote = sisyphus.filesystem.remotePagure
+ else:
+ sys.exit("Usage: sisyphus-cli.py branch [OPTIONS] BRANCH" + "\n" +
+ "Try 'sisyphus-cli.py branch --help' for help." + "\n\n" +
+ "Error: Invalid remote" + " " + "'" + str(remote) + "'" + " " + "(options : gitlab, pagure)"
+ )
+ else:
+ sys.exit("Usage: sisyphus-cli.py branch [OPTIONS] BRANCH" + "\n" +
+ "Try 'sisyphus-cli.py branch --help' for help." + "\n\n" +
+ "Error: Invalid branch" + " " + "'" + str(branch) + "'" +" " + "(options : master, next)"
+ )
+
+ portageRemote = [remote, sisyphus.filesystem.portageRepo]
+ redcoreRemote = [remote, sisyphus.filesystem.redcoreRepo]
+ portageConfigRemote = [remote, sisyphus.filesystem.portageConfigRepo]
+ remoteBranch = ['origin', branch]
+
+ sisyphus.check.root()
+ sisyphus.branchreset.start()
+
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.portageRepoDir, '.git')):
+ os.chdir(sisyphus.filesystem.portageRepoDir)
+ print("\nInjecting branch" + " " + "'" + branch + "'" + " " + "from" + " " + "/".join(portageRemote))
+ subprocess.call(['git', 'init', '-q'])
+ subprocess.call(['git', 'remote', 'add', 'origin'] + "/".join(portageRemote).split())
+ subprocess.call(['git', 'fetch', '--depth=1', 'origin'] + branch.split() + ['--quiet'])
+ subprocess.call(['git', 'checkout', '-b'] + branch.split() + "/".join(remoteBranch).split() + ['--quiet'])
+
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.redcoreRepoDir, '.git')):
+ os.chdir(sisyphus.filesystem.redcoreRepoDir)
+ print("\nInjecting branch" + " " + "'" + branch + "'" + " " + "from" + " " + "/".join(redcoreRemote) + "\n")
+ subprocess.call(['git', 'init', '-q'])
+ subprocess.call(['git', 'remote', 'add', 'origin'] + "/".join(redcoreRemote).split())
+ subprocess.call(['git', 'fetch', '--depth=1', 'origin'] + branch.split() + ['--quiet'])
+ subprocess.call(['git', 'checkout', '-b'] + branch.split() + "/".join(remoteBranch).split() + ['--quiet'])
+
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.portageConfigDir, '.git')):
+ os.chdir(sisyphus.filesystem.portageConfigDir)
+ print("Injecting branch" + " " + "'" + branch + "'" + " " + "from" + " " + "/".join(portageConfigRemote) + "\n")
+ subprocess.call(['git', 'init', '-q'])
+ subprocess.call(['git', 'remote', 'add', 'origin'] + "/".join(portageConfigRemote).split())
+ subprocess.call(['git', 'fetch', '--depth=1', 'origin'] + branch.split() + ['--quiet'])
+ subprocess.call(['git', 'checkout', '-b'] + branch.split() + "/".join(remoteBranch).split() + ['--quiet'])
+
+ sisyphus.setjobs.start()
+ sisyphus.setprofile.start()
+ sisyphus.metadata.regenAnimated()
diff --git a/src/backend/check.py b/src/backend/check.py
index 9c0a878..a129d36 100644
--- a/src/backend/check.py
+++ b/src/backend/check.py
@@ -10,36 +10,38 @@ def root():
sys.exit("\nYou need root permissions to do this, exiting!\n")
def portage():
- os.chdir(sisyphus.filesystem.portageRepoDir)
- needsPortageSync = int()
+ if os.path.isdir(os.path.join(sisyphus.filesystem.portageRepoDir, '.git')):
+ os.chdir(sisyphus.filesystem.portageRepoDir)
+ 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}'])
+ 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, stderr=subprocess.DEVNULL)
+ gitExec = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
- if not localHash.decode().strip() == remoteHash.decode().strip():
- needsPortageSync = int(1)
+ if not localHash.decode().strip() == remoteHash.decode().strip():
+ needsPortageSync = int(1)
- gitExec.wait()
- return needsPortageSync
+ gitExec.wait()
+ return needsPortageSync
def overlay():
- os.chdir(sisyphus.filesystem.redcoreRepoDir)
- needsOverlaySync = int()
+ if os.path.isdir(os.path.join(sisyphus.filesystem.redcoreRepoDir, '.git')):
+ os.chdir(sisyphus.filesystem.redcoreRepoDir)
+ 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}'])
+ 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, stderr=subprocess.DEVNULL)
+ gitExec = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
- if not localHash.decode().strip() == remoteHash.decode().strip():
- needsOverlaySync = int(1)
+ if not localHash.decode().strip() == remoteHash.decode().strip():
+ needsOverlaySync = int(1)
- gitExec.wait()
- return needsOverlaySync
+ gitExec.wait()
+ return needsOverlaySync
def update():
portage()
diff --git a/src/backend/filesystem.py b/src/backend/filesystem.py
index 9e1c3b1..cfbfa86 100644
--- a/src/backend/filesystem.py
+++ b/src/backend/filesystem.py
@@ -1,7 +1,7 @@
#!/usr/bin/python3
-remoteGitlab = 'https://gitlab.com/redcore/'
-remotePagure = 'https://pagure.io/redcore/'
+remoteGitlab = 'https://gitlab.com/redcore'
+remotePagure = 'https://pagure.io/redcore'
portageRepo = 'portage.git'
redcoreRepo = 'redcore-desktop.git'
diff --git a/src/backend/setprofile.py b/src/backend/setprofile.py
index c78269f..8329385 100644
--- a/src/backend/setprofile.py
+++ b/src/backend/setprofile.py
@@ -5,5 +5,7 @@ import subprocess
@animation.wait('setting up hardened profile')
def start():
- subprocess.call(['eselect', 'profile', 'set', 'default/linux/amd64/17.0/hardened'])
- subprocess.call(['env-update'])
+ eselectExec = subprocess.Popen(['eselect', 'profile', 'set', 'default/linux/amd64/17.0/hardened'])
+ eselectExec.wait()
+ envExec = subprocess.Popen(['env-update'], stdout=subprocess.DEVNULL)
+ envExec.wait()