diff options
-rw-r--r-- | src/backend/__init__.py | 4 | ||||
-rw-r--r-- | src/backend/branchinject.py | 41 | ||||
-rw-r--r-- | src/backend/branchmaster.py | 70 | ||||
-rw-r--r-- | src/backend/branchnext.py | 70 | ||||
-rw-r--r-- | src/backend/branchsetup.py | 71 | ||||
-rw-r--r-- | src/backend/check.py | 42 | ||||
-rw-r--r-- | src/backend/filesystem.py | 4 | ||||
-rw-r--r-- | src/backend/setprofile.py | 6 | ||||
-rwxr-xr-x | src/frontend/cli/sisyphus-cli.py | 13 |
9 files changed, 108 insertions, 213 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() diff --git a/src/frontend/cli/sisyphus-cli.py b/src/frontend/cli/sisyphus-cli.py index 7488922..ee9bd9f 100755 --- a/src/frontend/cli/sisyphus-cli.py +++ b/src/frontend/cli/sisyphus-cli.py @@ -4,6 +4,9 @@ import sisyphus import typer from typing import List +sisyphus.check.update() +sisyphus.setjobs.start.__wrapped__() # undecorate + app = typer.Typer() mirrorSetup = typer.Typer() app.add_typer(mirrorSetup, name="mirror", help='List/Set the active binary repository mirror.') @@ -86,15 +89,15 @@ def branch(branch: str = typer.Argument(...), remote: str = typer.Option(...)): """Pull the branch 'BRANCH' of the Portage tree, Redcore overlay and Portage configs, using 'REMOTE' git repositories. - 'BRANCH' can be one of the following : master, next (default is master) + 'BRANCH' can be one of the following : master, next - 'REMOTE' can be one of the following : gitlab, pagure (default is pagure) + 'REMOTE' can be one of the following : gitlab, pagure * Examples: - 'branch master --remote gitlab' will pull the branch 'master' from gitlab.com + 'branch master --remote=gitlab' will pull the branch 'master' from gitlab.com - 'branch next --remote pagure' will pull the branch 'next' from pagure.io + 'branch next --remote=pagure' will pull the branch 'next' from pagure.io !!! WARNING !!! @@ -108,7 +111,7 @@ def branch(branch: str = typer.Argument(...), remote: str = typer.Option(...)): * Examples : 'sisyphus mirror set 2' or 'sisyphus mirror set 8' """ - typer.echo(f"Injecting {branch} branch from {remote} repository") + sisyphus.branchsetup.start(branch, remote) @app.command("sysinfo") def sysinfo(): |