summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/libsisyphus.py111
-rwxr-xr-xsrc/frontend/cli/sisyphus-cli.py7
-rwxr-xr-xsrc/helpers/set_jobs12
3 files changed, 126 insertions, 4 deletions
diff --git a/src/backend/libsisyphus.py b/src/backend/libsisyphus.py
index 5b58c37..c5773c2 100644
--- a/src/backend/libsisyphus.py
+++ b/src/backend/libsisyphus.py
@@ -10,6 +10,7 @@ import sys
import urllib3
import io
import wget
+import shutil
gentooEbuildDir = '/usr/ports/gentoo'
redcoreEbuildDir = '/usr/ports/redcore'
@@ -134,7 +135,7 @@ def fetchRemoteDatabase():
shutil.copyfileobj(tmp_buffer, output_file)
def makeLocalDatabase():
- subprocess.check_call(['/usr/share/sisyphus/helpers/make_local_csv'])
+ subprocess.call(['/usr/share/sisyphus/helpers/make_local_csv'])
def syncRemoteDatabase():
fetchRemoteDatabase()
@@ -216,7 +217,7 @@ def rescueDB():
syncLocalDatabase()
def startSearch(pkgList):
- subprocess.check_call(['emerge', '--search', '--getbinpkg'] + pkgList)
+ subprocess.call(['emerge', '--search', '--getbinpkg'] + pkgList)
def startInstall(pkgList):
startUpdate()
@@ -464,12 +465,11 @@ def removeOrphans():
syncLocalDatabase()
def sysInfo():
- subprocess.check_call(['emerge', '--info'])
+ subprocess.call(['emerge', '--info'])
def portageKill(portageCmd):
portageCmd.terminate()
-
def printMirrorList():
mirrorList = getMirrorList()
@@ -512,6 +512,109 @@ def setActiveMirror(mirror):
mirrorList[i]['isActive'] = False
writeMirrorCfg(mirrorList)
+@animation.wait('I am resetting portage environment')
+def resetPortageEnv():
+ if os.path.isdir(gentooEbuildDir):
+ for files in os.listdir(gentooEbuildDir):
+ if os.path.isfile(os.path.join(gentooEbuildDir, files)):
+ os.remove(os.path.join(gentooEbuildDir, files))
+ else:
+ shutil.rmtree(os.path.join(gentooEbuildDir, files))
+ else:
+ os.makedirs(gentooEbuildDir)
+
+ if os.path.isdir(redcoreEbuildDir):
+ for files in os.listdir(redcoreEbuildDir):
+ if os.path.isfile(os.path.join(redcoreEbuildDir, files)):
+ os.remove(os.path.join(redcoreEbuildDir, files))
+ else:
+ shutil.rmtree(os.path.join(redcoreEbuildDir, files))
+ else:
+ os.makedirs(redcoreEbuildDir)
+
+ if os.path.isdir(portageConfigDir):
+ for files in os.listdir(portageConfigDir):
+ if os.path.isfile(os.path.join(portageConfigDir, files)):
+ os.remove(os.path.join(portageConfigDir, files))
+ else:
+ shutil.rmtree(os.path.join(portageConfigDir, files))
+ else:
+ os.makedirs(portageConfigDir)
+
+def setPortageEnvStable():
+ if not os.path.isdir(os.path.join(gentooEbuildDir, '.git')):
+ print("\nI am injecting Gentoo Linux portage tree (master)\n")
+ os.chdir(gentooEbuildDir)
+ subprocess.call(['git', 'init', '-q'])
+ subprocess.call(['git', 'remote', 'add', 'origin', 'https://pagure.io/redcore/portage.git'])
+ subprocess.call(['git', 'pull', '--depth=1', 'origin', 'master'])
+ subprocess.call(['git', 'branch', '-u', 'origin/master', 'master'])
+
+ if not os.path.isdir(os.path.join(redcoreEbuildDir, '.git')):
+ print("\nI am injecting Redcore Linux overlay (master)\n")
+ os.chdir(redcoreEbuildDir)
+ subprocess.call(['git', 'init', '-q'])
+ subprocess.call(['git', 'remote', 'add', 'origin', 'https://pagure.io/redcore/redcore-desktop.git'])
+ subprocess.call(['git', 'pull', '--depth=1', 'origin', 'master'])
+ subprocess.call(['git', 'branch', '-u', 'origin/master', 'master'])
+
+ if not os.path.isdir(os.path.join(portageConfigDir, '.git')):
+ print("\nI am injecting Redcore Linux portage configuration (master)\n")
+ os.chdir(portageConfigDir)
+ subprocess.call(['git', 'init', '-q'])
+ subprocess.call(['git', 'remote', 'add', 'origin', 'https://pagure.io/redcore/redcore-build.git'])
+ subprocess.call(['git', 'pull', '--depth=1', 'origin', 'master'])
+ subprocess.call(['git', 'branch', '-u', 'origin/master', 'master'])
+
+def setPortageEnvTesting():
+ if not os.path.isdir(os.path.join(gentooEbuildDir, '.git')):
+ print("\nI am injecting Gentoo Linux portage tree (next)\n")
+ os.chdir(gentooEbuildDir)
+ subprocess.call(['git', 'init', '-q'])
+ subprocess.call(['git', 'remote', 'add', 'origin', 'https://pagure.io/redcore/portage.git'])
+ subprocess.call(['git', 'pull', '--depth=1', 'origin', 'next'])
+ subprocess.call(['git', 'checkout', '-b', 'next', 'origin/next'])
+
+ if not os.path.isdir(os.path.join(redcoreEbuildDir, '.git')):
+ print("\nI am injecting Redcore Linux overlay (next)\n")
+ os.chdir(redcoreEbuildDir)
+ subprocess.call(['git', 'init', '-q'])
+ subprocess.call(['git', 'remote', 'add', 'origin', 'https://pagure.io/redcore/redcore-desktop.git'])
+ subprocess.call(['git', 'pull', '--depth=1', 'origin', 'next'])
+ subprocess.call(['git', 'checkout', '-b', 'next', 'origin/next'])
+
+ if not os.path.isdir(os.path.join(portageConfigDir, '.git')):
+ print("\nI am injecting Redcore Linux portage configuration (next)\n")
+ os.chdir(portageConfigDir)
+ subprocess.call(['git', 'init', '-q'])
+ subprocess.call(['git', 'remote', 'add', 'origin', 'https://pagure.io/redcore/redcore-build.git'])
+ subprocess.call(['git', 'pull', '--depth=1', 'origin', 'next'])
+ subprocess.call(['git', 'checkout', '-b', 'next', 'origin/next'])
+
+def setHardenedProfile():
+ subprocess.call(['eselect', 'profile', 'set', 'default/linux/amd64/17.0/hardened'])
+ subprocess.call(['env-update'])
+
+def resetPortage():
+ resetPortageEnv()
+
+def setJobs():
+ subprocess.call(['/usr/share/sisyphus/helpers/set_jobs'])
+
+def setupStable():
+ checkRoot()
+ resetPortageEnv()
+ setPortageEnvStable()
+ setHardenedProfile()
+ setJobs()
+
+def setupTesting():
+ checkRoot()
+ resetPortageEnv()
+ setPortageEnvTesting()
+ setHardenedProfile()
+ setJobs()
+
def showHelp():
print("\n" + "Usage : sisyphus command [package(s)] || [file(s)]" + "\n")
print("Sisyphus is a simple python wrapper around portage, gentoolkit, and portage-utils which provides")
diff --git a/src/frontend/cli/sisyphus-cli.py b/src/frontend/cli/sisyphus-cli.py
index 5ec0504..13c84f2 100755
--- a/src/frontend/cli/sisyphus-cli.py
+++ b/src/frontend/cli/sisyphus-cli.py
@@ -49,6 +49,13 @@ if "__main__" == __name__:
showHelp()
else:
showHelp()
+ elif "--branch" in sys.argv[1:]:
+ if "--master" in sys.argv[2:]:
+ setupStable()
+ elif "--next" in sys.argv[2:]:
+ setupTesting()
+ else:
+ showHelp()
elif "--help" in sys.argv[1:]:
showHelp()
else:
diff --git a/src/helpers/set_jobs b/src/helpers/set_jobs
new file mode 100755
index 0000000..0d42a1d
--- /dev/null
+++ b/src/helpers/set_jobs
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+portageConfigDir="/opt/redcore-build/conf/intel/portage"
+
+setjobs () {
+ # default MAKEOPTS value is -j64, but that's overkill for lower spec machines
+ # this will adjust MAKEOPTS to a value detected by $(getconf _NPROCESSORS_ONLN)
+ sed -i "s/\-j\([0-9]\+\)/\-j$(getconf _NPROCESSORS_ONLN)/g" "$portageConfigDir"/make.conf/00-makeopts.conf # global makeopts (exclude kernel)
+ sed -i "s/\-j\([0-9]\+\)/\-j$(getconf _NPROCESSORS_ONLN)/g" "$portageConfigDir"/env/makenoise.conf # kernel makeopts
+}
+
+setjobs