summaryrefslogtreecommitdiff
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
parent49e6ab19aa461151132dfb4f1cf962d4ef403c66 (diff)
big rewrite : split the backend in smaller pieces, rework the cli frontend to work with the new backend ... gui frontend wip
-rw-r--r--src/backend/__init__.py0
-rw-r--r--src/backend/binhost.py15
-rw-r--r--src/backend/branchinject.py41
-rw-r--r--src/backend/branchmaster.py73
-rw-r--r--src/backend/branchnext.py73
-rw-r--r--src/backend/branchreset.py38
-rw-r--r--src/backend/check.py49
-rw-r--r--src/backend/clean.py13
-rw-r--r--src/backend/csvfiles.py21
-rw-r--r--src/backend/database.py61
-rw-r--r--src/backend/help.py61
-rw-r--r--src/backend/install.py122
-rw-r--r--src/backend/killportage.py4
-rw-r--r--src/backend/libsisyphus.py865
-rw-r--r--src/backend/metadata.py35
-rw-r--r--src/backend/mirror.py60
-rw-r--r--src/backend/removeorphans.py11
-rw-r--r--src/backend/rescue.py24
-rw-r--r--src/backend/search.py6
-rw-r--r--src/backend/setjobs.py8
-rw-r--r--src/backend/setprofile.py9
-rw-r--r--src/backend/solvedeps.py69
-rw-r--r--src/backend/sync.py46
-rw-r--r--src/backend/sysinfo.py7
-rw-r--r--src/backend/uninstall.py11
-rw-r--r--src/backend/uninstallforce.py11
-rw-r--r--src/backend/update.py39
-rw-r--r--src/backend/upgrade.py123
-rwxr-xr-xsrc/frontend/cli/sisyphus-cli.py67
29 files changed, 1069 insertions, 893 deletions
diff --git a/src/backend/__init__.py b/src/backend/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/backend/__init__.py
diff --git a/src/backend/binhost.py b/src/backend/binhost.py
new file mode 100644
index 0000000..5bcf20c
--- /dev/null
+++ b/src/backend/binhost.py
@@ -0,0 +1,15 @@
+#!/usr/bin/python3
+
+import subprocess
+import io
+
+def getURL():
+ binhostURL = []
+ portageExec = subprocess.Popen(['emerge', '--info', '--verbose'], stdout=subprocess.PIPE)
+
+ for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
+ if "PORTAGE_BINHOST" in portageOutput.rstrip():
+ binhostURL = str(portageOutput.rstrip().split("=")[1].strip('\"'))
+
+ portageExec.wait()
+ return binhostURL
diff --git a/src/backend/branchinject.py b/src/backend/branchinject.py
new file mode 100644
index 0000000..7c9a09f
--- /dev/null
+++ b/src/backend/branchinject.py
@@ -0,0 +1,41 @@
+#!/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
new file mode 100644
index 0000000..6229511
--- /dev/null
+++ b/src/backend/branchmaster.py
@@ -0,0 +1,73 @@
+#!/usr/bin/python3
+
+import animation
+import os
+import subprocess
+
+gentooEbuildDir = '/usr/ports/gentoo'
+redcoreEbuildDir = '/usr/ports/redcore'
+portageConfigDir = '/opt/redcore-build'
+
+@animation.wait('injecting gentoo linux portage tree - branch master')
+def setGitlabMasterStage1():
+ if not os.path.isdir(os.path.join(gentooEbuildDir, '.git')):
+ os.chdir(gentooEbuildDir)
+ 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(redcoreEbuildDir, '.git')):
+ os.chdir(redcoreEbuildDir)
+ 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(portageConfigDir, '.git')):
+ os.chdir(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(gentooEbuildDir, '.git')):
+ os.chdir(gentooEbuildDir)
+ 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(redcoreEbuildDir, '.git')):
+ os.chdir(redcoreEbuildDir)
+ 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(portageConfigDir, '.git')):
+ os.chdir(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
new file mode 100644
index 0000000..bb29b04
--- /dev/null
+++ b/src/backend/branchnext.py
@@ -0,0 +1,73 @@
+#!/usr/bin/python3
+
+import animation
+import os
+import subprocess
+
+gentooEbuildDir = '/usr/ports/gentoo'
+redcoreEbuildDir = '/usr/ports/redcore'
+portageConfigDir = '/opt/redcore-build'
+
+@animation.wait('injecting gentoo linux portage tree - branch next')
+def setGitlabNextStage1():
+ if not os.path.isdir(os.path.join(gentooEbuildDir, '.git')):
+ os.chdir(gentooEbuildDir)
+ 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(redcoreEbuildDir, '.git')):
+ os.chdir(redcoreEbuildDir)
+ 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(portageConfigDir, '.git')):
+ os.chdir(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(gentooEbuildDir, '.git')):
+ os.chdir(gentooEbuildDir)
+ 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(redcoreEbuildDir, '.git')):
+ os.chdir(redcoreEbuildDir)
+ 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(portageConfigDir, '.git')):
+ os.chdir(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/branchreset.py b/src/backend/branchreset.py
new file mode 100644
index 0000000..6168a25
--- /dev/null
+++ b/src/backend/branchreset.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python3
+
+import animation
+import os
+import shutil
+
+gentooEbuildDir = '/usr/ports/gentoo'
+redcoreEbuildDir = '/usr/ports/redcore'
+portageConfigDir = '/opt/redcore-build'
+
+@animation.wait('resetting branch configuration')
+def start():
+ 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)
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()
+
diff --git a/src/backend/clean.py b/src/backend/clean.py
new file mode 100644
index 0000000..2460d9e
--- /dev/null
+++ b/src/backend/clean.py
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+
+import os
+
+portageCacheDir = '/var/cache/packages'
+
+def cache():
+ if os.path.isdir(portageCacheDir):
+ for files in os.listdir(portageCacheDir):
+ if os.path.isfile(os.path.join(portageCacheDir, files)):
+ os.remove(os.path.join(portageCacheDir, files))
+ else:
+ shutil.rmtree(os.path.join(portageCacheDir, files))
diff --git a/src/backend/csvfiles.py b/src/backend/csvfiles.py
new file mode 100644
index 0000000..67daec4
--- /dev/null
+++ b/src/backend/csvfiles.py
@@ -0,0 +1,21 @@
+#!/usr/bin/python3
+
+import subprocess
+import io
+
+def getURL():
+ remotePkgCsv = []
+ remoteDescCsv = []
+ portageExec = subprocess.Popen(['emerge', '--info', '--verbose'], stdout=subprocess.PIPE)
+
+ for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
+ if "PORTAGE_BINHOST" in portageOutput.rstrip():
+ if "packages-next" in portageOutput.rstrip():
+ remotePkgCsv = str(portageOutput.rstrip().split("=")[1].strip('\"').replace('packages-next', 'csv-next') + 'remotePackagesPre.csv')
+ remoteDescCsv = str(portageOutput.rstrip().split("=")[1].strip('\"').replace('packages-next', 'csv-next') + 'remoteDescriptionsPre.csv')
+ else:
+ remotePkgCsv = str(portageOutput.rstrip().split("=")[1].strip('\"').replace('packages', 'csv') + 'remotePackagesPre.csv')
+ remoteDescCsv = str(portageOutput.rstrip().split("=")[1].strip('\"').replace('packages', 'csv') + 'remoteDescriptionsPre.csv')
+
+ portageExec.wait()
+ return remotePkgCsv,remoteDescCsv
diff --git a/src/backend/database.py b/src/backend/database.py
new file mode 100644
index 0000000..277a265
--- /dev/null
+++ b/src/backend/database.py
@@ -0,0 +1,61 @@
+#!/usr/bin/python3
+
+import csv
+import shutil
+import urllib3
+import sqlite3
+import subprocess
+import sisyphus.csvfiles
+
+remotePkgsDB = '/var/lib/sisyphus/csv/remotePackagesPre.csv'
+remoteDscsDB = '/var/lib/sisyphus/csv/remoteDescriptionsPre.csv'
+localPkgsDB = '/var/lib/sisyphus/csv/localPackagesPre.csv'
+sisyphusDB = '/var/lib/sisyphus/db/sisyphus.db'
+
+def getRemote():
+ remotePkgCsv,remoteDescCsv = sisyphus.csvfiles.getURL()
+ http = urllib3.PoolManager()
+
+ with http.request('GET', remotePkgCsv, preload_content=False) as tmp_buffer, open(remotePkgsDB, 'wb') as output_file:
+ shutil.copyfileobj(tmp_buffer, output_file)
+
+ with http.request('GET', remoteDescCsv, preload_content=False) as tmp_buffer, open(remoteDscsDB, 'wb') as output_file:
+ shutil.copyfileobj(tmp_buffer, output_file)
+
+def makeLocal():
+ subprocess.call(['/usr/share/sisyphus/helpers/make_local_csv'])
+
+def syncRemote():
+ getRemote()
+
+ sisyphusdb = sqlite3.connect(sisyphusDB)
+ sisyphusdb.cursor().execute('''drop table if exists remote_packages''')
+ sisyphusdb.cursor().execute('''drop table if exists remote_descriptions''')
+ sisyphusdb.cursor().execute('''create table remote_packages (category TEXT,name TEXT,version TEXT,slot TEXT)''')
+ sisyphusdb.cursor().execute('''create table remote_descriptions (category TEXT,name TEXT,description TEXT)''')
+
+ with open(remotePkgsDB) as rmtCsv:
+ for row in csv.reader(rmtCsv):
+ sisyphusdb.cursor().execute("insert into remote_packages (category, name, version, slot) values (?, ?, ?, ?);", row)
+
+ with open(remoteDscsDB) as rmtCsv:
+ for row in csv.reader(rmtCsv):
+ sisyphusdb.cursor().execute("insert into remote_descriptions (category, name, description) values (?, ?, ?);", row)
+
+ sisyphusdb.commit()
+ sisyphusdb.close()
+
+def syncLocal():
+ makeLocal()
+
+ sisyphusdb = sqlite3.connect(sisyphusDB)
+ sisyphusdb.cursor().execute('''drop table if exists local_packages''')
+ sisyphusdb.cursor().execute('''create table local_packages (category TEXT,name TEXT,version TEXT,slot TEXT)''')
+
+ with open(localPkgsDB) as lclCsv:
+ for row in csv.reader(lclCsv):
+ sisyphusdb.cursor().execute("insert into local_packages (category, name, version, slot) values (?, ?, ?, ?);", row)
+
+ sisyphusdb.commit()
+ sisyphusdb.close()
+
diff --git a/src/backend/help.py b/src/backend/help.py
new file mode 100644
index 0000000..d62e212
--- /dev/null
+++ b/src/backend/help.py
@@ -0,0 +1,61 @@
+#!/usr/bin/python3
+
+def show():
+ 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")
+ print("an apt-get/yum-alike interface to these commands, to assist newcomer people transitioning from")
+ print("Debian/RedHat-based systems to Gentoo." + "\n")
+ print("Commands :" + "\n")
+ print("--install")
+ print("* Install binary and/or ebuild (source) packages" + "\n")
+ print("--uninstall")
+ print("* Uninstall packages *SAFELY* by checking for reverse dependencies")
+ print("* If reverse dependencies exist, the package(s) will NOT be uninstalled to prevent the possible breakage of the system")
+ print("* If you really want to uninstall the package, make sure you uninstall all reverse dependencies as well")
+ print("* This will not allways be possible, as the reverse dependency chain may be way to long and require you to uninstall critical system packages" + "\n")
+ print("--force-uninstall")
+ print("* Uninstall packages *UNSAFELY* by ignoring reverse dependencies")
+ print("* This may break your system if you uninstall critical system packages")
+ print("* It will try the best it can to preserve the libraries required by other packages to prevent such a breakage")
+ print("* Upgrading the system may pull the packages back in, to fix the reverse dependency chain" + "\n")
+ print("--remove-orphans")
+ print("* Uninstall packages that are no longer needed")
+ print("* When you uninstall a package without it's reverse dependencies, those dependencies will become orphans if nothing else requires them")
+ print("* In addition, a package may no longer depend on another one, so that other package becomes orphan as well if nothing else requires it")
+ print("* Use this option to check the whole dependency chain for such packages, and uninstall them" + "\n")
+ print("--update")
+ print("* Update the Portage tree, the Redcore Overlay(s), Portage configs && Sisyphus's package database" + "\n")
+ print("--upgrade")
+ print("* Upgrade the system using binary and/or ebuild (source) packages" + "\n")
+ print("--search")
+ print("* Search for binary and/or ebuild (source) packages" + "\n")
+ print("--spmsync")
+ print("* Sync Sisyphus's package database with Portage's package database")
+ print("* When you install something with Portage directly (emerge), Sisyphus is not aware of that package, and it doesn't track it in it's database")
+ print("* Use this option to synchronize Sisyphus's package database with Portage's package database" + "\n")
+ print("--rescue")
+ print("* Resurrect Sisyphus's package database if lost or corrupted")
+ print("* If for some reason Sisyphus's package database is lost or corrupted, it can be resurrected using Portage's package database")
+ print("* If Portage's package database is corrupted (in this case you're screwed anyway :D), only a partial resurrection will be possible")
+ print("* If Portage's package database is intact, full resurrection will be possible" + "\n")
+ print("--mirror --list")
+ print("* List available binary package repository mirrors (the active one is marked with *)" + "\n")
+ print("--mirror --set 'INDEX'")
+ print("* Change the binary package repository to the selected mirror" + "\n")
+ print("--branch='BRANCH' --remote='REMOTE'")
+ print("* Pull the branch 'BRANCH' of the Portage tree, Redcore overlay && Portage configs. Use 'REMOTE' git repositories.")
+ print("* 'BRANCH' can be one of the following : master, next")
+ print("* 'REMOTE' can be one of the following : gitlab, pagure")
+ print("*")
+ print("* Examples: ")
+ print("* '--branch=master --remote=gitlab' will pull the branch 'master' from gitlab.com")
+ print("* '--branch=next --remote=pagure' will pull the branch 'next' from pagure.io")
+ print("*")
+ print("* !!! WARNING !!!")
+ print("* Once you changed the branch, you must pair the branch 'BRANCH' with the correct binary repository")
+ print("* Branch 'master' must be paired with the stable binary repository (odd numbers in 'sisyphus --mirror --list'). Examples : 'sisyphus --mirror --set 1' or 'sisyphus --mirror --set 5' ")
+ print("* Branch 'next' must be paired with the testing binary repository (even numbers in 'sisyphus --mirror --list'). Examples : 'sisyphus --mirror --set 2' or 'sisyphus --mirror --set 8'" + "\n")
+ print("--sysinfo")
+ print("* Display information about installed core packages and portage configuration" + "\n")
+ print("--help")
+ print("* Display this help information" + "\n")
diff --git a/src/backend/install.py b/src/backend/install.py
new file mode 100644
index 0000000..ba1cfa0
--- /dev/null
+++ b/src/backend/install.py
@@ -0,0 +1,122 @@
+#!/usr/bin/python3
+
+import os
+import shutil
+import subprocess
+import sys
+import io
+import wget
+import sisyphus.binhost
+import sisyphus.database
+import sisyphus.solvedeps
+import sisyphus.update
+
+portageCacheDir = '/var/cache/packages'
+
+def start(pkgList):
+ sisyphus.update.start()
+
+ binhostURL = sisyphus.binhost.getURL()
+ areBinaries,areSources,needsConfig = sisyphus.solvedeps.package(pkgList)
+
+ if needsConfig == 0:
+ if len(areSources) == 0:
+ if not len(areBinaries) == 0:
+ os.chdir(portageCacheDir)
+ print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + str(areBinaries) + "\n\n" + "Total:" + " " + str(len(areBinaries)) + " " + "binary package(s)" + "\n")
+ if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
+ for index, binary in enumerate([package + '.tbz2' for package in areBinaries]):
+ print(">>> Fetching" + " " + binhostURL + binary)
+ wget.download(binhostURL + binary)
+ print("\n")
+
+ subprocess.call(['qtbz2', '-x'] + binary.rstrip().split("/")[1].split())
+ CATEGORY = subprocess.check_output(['qxpak', '-x', '-O'] + binary.rstrip().split("/")[1].replace('tbz2', 'xpak').split() + ['CATEGORY'])
+
+ if os.path.exists(binary.rstrip().split("/")[1].replace('tbz2', 'xpak')):
+ os.remove(binary.rstrip().split("/")[1].replace('tbz2', 'xpak'))
+
+ if os.path.isdir(os.path.join(portageCacheDir, CATEGORY.decode().strip())):
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
+ else:
+ os.makedirs(os.path.join(portageCacheDir, CATEGORY.decode().strip()))
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
+
+ if os.path.exists(binary.rstrip().split("/")[1]):
+ os.remove(binary.rstrip().split("/")[1])
+
+ portageExec = subprocess.Popen(['emerge', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--misspell-suggestion=n', '--fuzzy-search=n'] + pkgList, stdout=subprocess.PIPE)
+
+ for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
+ if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
+ if not "Calculating dependencies" in portageOutput.rstrip():
+ print(portageOutput.rstrip())
+
+ portageExec.wait()
+ sisyphus.database.syncLocal()
+ else:
+ sys.exit("\n" + "Ok; Quitting." + "\n")
+ else:
+ sys.exit("\n" + "No package found; Quitting." + "\n")
+ else:
+ if not len(areBinaries) == 0:
+ os.chdir(portageCacheDir)
+ print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + str(areBinaries) + "\n\n" + "Total:" + " " + str(len(areBinaries)) + " " + "binary package(s)" + "\n")
+ print("\n" + "These are the source packages that would be merged, in order:" + "\n\n" + str(areSources) + "\n\n" + "Total:" + " " + str(len(areSources)) + " " + "source package(s)" + "\n")
+ if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
+ for index, binary in enumerate([package + '.tbz2' for package in areBinaries]):
+ print(">>> Fetching" + " " + binhostURL + binary)
+ wget.download(binhostURL + binary)
+ print("\n")
+
+ subprocess.call(['qtbz2', '-x'] + binary.rstrip().split("/")[1].split())
+ CATEGORY = subprocess.check_output(['qxpak', '-x', '-O'] + binary.rstrip().split("/")[1].replace('tbz2', 'xpak').split() + ['CATEGORY'])
+
+ if os.path.exists(binary.rstrip().split("/")[1].replace('tbz2', 'xpak')):
+ os.remove(binary.rstrip().split("/")[1].replace('tbz2', 'xpak'))
+
+ if os.path.isdir(os.path.join(portageCacheDir, CATEGORY.decode().strip())):
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
+ else:
+ os.makedirs(os.path.join(portageCacheDir, CATEGORY.decode().strip()))
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
+
+ if os.path.exists(binary.rstrip().split("/")[1]):
+ os.remove(binary.rstrip().split("/")[1])
+
+ portageExec = subprocess.Popen(['emerge', '--usepkg', '--rebuilt-binaries', '--misspell-suggestion=n', '--fuzzy-search=n'] + pkgList, stdout=subprocess.PIPE)
+
+ for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
+ if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
+ if not "Calculating dependencies" in portageOutput.rstrip():
+ print(portageOutput.rstrip())
+
+ portageExec.wait()
+ sisyphus.database.syncLocal()
+ else:
+ sys.exit("\n" + "Ok; Quitting." + "\n")
+ else:
+ print("\n" + "These are the source packages that would be merged, in order:" + "\n\n" + str(areSources) + "\n\n" + "Total:" + " " + str(len(areSources)) + " " + "source package(s)" + "\n")
+ if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
+ portageExec = subprocess.Popen(['emerge', '--misspell-suggestion=n', '--fuzzy-search=n'] + pkgList, stdout=subprocess.PIPE)
+
+ for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
+ if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
+ if not "Calculating dependencies" in portageOutput.rstrip():
+ print(portageOutput.rstrip())
+
+ portageExec.wait()
+ sisyphus.database.syncLocal()
+ else:
+ sys.exit("\n" + "Ok; Quitting." + "\n")
+ else:
+ portageExec = subprocess.Popen(['emerge', '--quiet', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--misspell-suggestion=n', '--fuzzy-search=n'] + pkgList, stdout=subprocess.PIPE)
+
+ for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
+ if not "Local copy of remote index is up-to-date and will be used." in portageOutput.rstrip():
+ if not "ebuild" in portageOutput.rstrip():
+ if not "binary" in portageOutput.rstrip():
+ print(portageOutput.rstrip())
+
+ portageExec.wait()
+ sys.exit("\n" + "Cannot proceed; Apply the above changes to your portage configuration files and try again; Quitting." + "\n")
diff --git a/src/backend/killportage.py b/src/backend/killportage.py
new file mode 100644
index 0000000..f01af6b
--- /dev/null
+++ b/src/backend/killportage.py
@@ -0,0 +1,4 @@
+#!/usr/bin/python3
+
+def start(portageCmd):
+ portageCmd.terminate()
diff --git a/src/backend/libsisyphus.py b/src/backend/libsisyphus.py
deleted file mode 100644
index 1a54fe7..0000000
--- a/src/backend/libsisyphus.py
+++ /dev/null
@@ -1,865 +0,0 @@
-#!/usr/bin/python3
-
-import animation
-import csv
-import os
-import shutil
-import sqlite3
-import subprocess
-import sys
-import urllib3
-import io
-import wget
-
-gentooEbuildDir = '/usr/ports/gentoo'
-redcoreEbuildDir = '/usr/ports/redcore'
-portageConfigDir = '/opt/redcore-build'
-portageCacheDir = '/var/cache/packages'
-portageMetadataDir = '/var/cache/edb'
-remotePkgsDB = '/var/lib/sisyphus/csv/remotePackagesPre.csv'
-remoteDscsDB = '/var/lib/sisyphus/csv/remoteDescriptionsPre.csv'
-localPkgsDB = '/var/lib/sisyphus/csv/localPackagesPre.csv'
-sisyphusDB = '/var/lib/sisyphus/db/sisyphus.db'
-mirrorCfg = '/etc/sisyphus/mirrors.conf'
-
-def checkRoot():
- if not os.getuid() == 0:
- sys.exit("\nYou need root permissions to do this, exiting!\n")
-
-def getMirrorList():
- mirrorList = []
-
- with open(mirrorCfg) as mirrorFile:
- for line in mirrorFile.readlines():
- if 'PORTAGE_BINHOST=' in line:
- url = line.split("=")[1].replace('"', '').rstrip()
- mirror = {'isActive': True, 'Url': url}
- if line.startswith('#'):
- mirror['isActive'] = False
- mirrorList.append(mirror)
- mirrorFile.close()
-
- return mirrorList
-
-def getBinhostURL():
- binhostURL = []
- portageExec = subprocess.Popen(['emerge', '--info', '--verbose'], stdout=subprocess.PIPE)
-
- for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
- if "PORTAGE_BINHOST" in portageOutput.rstrip():
- binhostURL = str(portageOutput.rstrip().split("=")[1].strip('\"'))
-
- portageExec.wait()
- return binhostURL
-
-def getCsvUrl():
- remotePkgCsv = []
- remoteDescCsv = []
- portageExec = subprocess.Popen(['emerge', '--info', '--verbose'], stdout=subprocess.PIPE)
-
- for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
- if "PORTAGE_BINHOST" in portageOutput.rstrip():
- if "packages-next" in portageOutput.rstrip():
- remotePkgCsv = str(portageOutput.rstrip().split("=")[1].strip('\"').replace('packages-next', 'csv-next') + 'remotePackagesPre.csv')
- remoteDescCsv = str(portageOutput.rstrip().split("=")[1].strip('\"').replace('packages-next', 'csv-next') + 'remoteDescriptionsPre.csv')
- else:
- remotePkgCsv = str(portageOutput.rstrip().split("=")[1].strip('\"').replace('packages', 'csv') + 'remotePackagesPre.csv')
- remoteDescCsv = str(portageOutput.rstrip().split("=")[1].strip('\"').replace('packages', 'csv') + 'remoteDescriptionsPre.csv')
-
- portageExec.wait()
- return remotePkgCsv,remoteDescCsv
-
-@animation.wait('resolving dependencies')
-def getPackageDeps(pkgList):
- areBinaries = []
- areSources = []
- needsConfig = int()
- portageExec = subprocess.Popen(['emerge', '--quiet', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--misspell-suggestion=n', '--fuzzy-search=n'] + pkgList, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-
- for portageOutput in io.TextIOWrapper(portageExec.stderr, encoding="utf-8"):
- if "The following keyword changes are necessary to proceed:" in portageOutput.rstrip():
- needsConfig = int(1)
-
- if "The following mask changes are necessary to proceed:" in portageOutput.rstrip():
- needsConfig = int(1)
-
- if "The following USE changes are necessary to proceed:" in portageOutput.rstrip():
- needsConfig = int(1)
-
- if "The following REQUIRED_USE flag constraints are unsatisfied:" in portageOutput.rstrip():
- needsConfig = int(1)
-
- for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
- if "[binary" in portageOutput.rstrip():
- isBinary = str(portageOutput.rstrip().split("]")[1].split("[")[0].strip("\ "))
- areBinaries.append(isBinary)
-
- if "[ebuild" in portageOutput.rstrip():
- isSource = str(portageOutput.rstrip().split("]")[1].split("[")[0].strip("\ "))
- areSources.append(isSource)
-
- portageExec.wait()
- return areBinaries,areSources,needsConfig
-
-@animation.wait('resolving dependencies')
-def getWorldDeps():
- areBinaries = []
- areSources = []
- needsConfig = int()
- portageExec = subprocess.Popen(['emerge', '--quiet', '--update', '--deep', '--newuse', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-
- for portageOutput in io.TextIOWrapper(portageExec.stderr, encoding="utf-8"):
- if "The following keyword changes are necessary to proceed:" in portageOutput.rstrip():
- needsConfig = int(1)
-
- if "The following mask changes are necessary to proceed:" in portageOutput.rstrip():
- needsConfig = int(1)
-
- if "The following USE changes are necessary to proceed:" in portageOutput.rstrip():
- needsConfig = int(1)
-
- if "The following REQUIRED_USE flag constraints are unsatisfied:" in portageOutput.rstrip():
- needsConfig = int(1)
-
- for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
- if "[binary" in portageOutput.rstrip():
- isBinary = str(portageOutput.rstrip().split("]")[1].split("[")[0].strip("\ "))
- areBinaries.append(isBinary)
-
- if "[ebuild" in portageOutput.rstrip():
- isSource = str(portageOutput.rstrip().split("]")[1].split("[")[0].strip("\ "))
- areSources.append(isSource)
-
- portageExec.wait()
- return areBinaries,areSources,needsConfig
-
-def fetchRemoteDatabase():
- remotePkgCsv,remoteDescCsv = getCsvUrl()
- http = urllib3.PoolManager()
-
- with http.request('GET', remotePkgCsv, preload_content=False) as tmp_buffer, open(remotePkgsDB, 'wb') as output_file:
- shutil.copyfileobj(tmp_buffer, output_file)
-
- with http.request('GET', remoteDescCsv, preload_content=False) as tmp_buffer, open(remoteDscsDB, 'wb') as output_file:
- shutil.copyfileobj(tmp_buffer, output_file)
-
-def makeLocalDatabase():
- subprocess.call(['/usr/share/sisyphus/helpers/make_local_csv'])
-
-def syncRemoteDatabase():
- fetchRemoteDatabase()
-
- sisyphusdb = sqlite3.connect(sisyphusDB)
- sisyphusdb.cursor().execute('''drop table if exists remote_packages''')
- sisyphusdb.cursor().execute('''drop table if exists remote_descriptions''')
- sisyphusdb.cursor().execute('''create table remote_packages (category TEXT,name TEXT,version TEXT,slot TEXT)''')
- sisyphusdb.cursor().execute('''create table remote_descriptions (category TEXT,name TEXT,description TEXT)''')
-
- with open(remotePkgsDB) as rmtCsv:
- for row in csv.reader(rmtCsv):
- sisyphusdb.cursor().execute("insert into remote_packages (category, name, version, slot) values (?, ?, ?, ?);", row)
-
- with open(remoteDscsDB) as rmtCsv:
- for row in csv.reader(rmtCsv):
- sisyphusdb.cursor().execute("insert into remote_descriptions (category, name, description) values (?, ?, ?);", row)
-
- sisyphusdb.commit()
- sisyphusdb.close()
-
-def syncLocalDatabase():
- makeLocalDatabase()
-
- sisyphusdb = sqlite3.connect(sisyphusDB)
- sisyphusdb.cursor().execute('''drop table if exists local_packages''')
- sisyphusdb.cursor().execute('''create table local_packages (category TEXT,name TEXT,version TEXT,slot TEXT)''')
-
- with open(localPkgsDB) as lclCsv:
- for row in csv.reader(lclCsv):
- sisyphusdb.cursor().execute("insert into local_packages (category, name, version, slot) values (?, ?, ?, ?);", row)
-
- sisyphusdb.commit()
- sisyphusdb.close()
-
-def checkPortageTree():
- os.chdir(gentooEbuildDir)
- needsPortageTreeSync = 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():
- needsPortageTreeSync = int(1)
-
- gitExec.wait()
- return needsPortageTreeSync
-
-def checkOverlayTree():
- os.chdir(redcoreEbuildDir)
- needsOverlayTreeSync = 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():
- needsOverlayTreeSync = int(1)
-
- gitExec.wait()
- return needsOverlayTreeSync
-
-def syncPortageTree():
- 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 syncOverlayTree():
- 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 syncPortageConfig():
- 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()
-
-def refreshPortageMetadata():
- if os.path.isdir(portageMetadataDir):
- for files in os.listdir(portageMetadataDir):
- if os.path.isfile(os.path.join(portageMetadataDir, files)):
- os.remove(os.path.join(portageMetadataDir, files))
- else:
- shutil.rmtree(os.path.join(portageMetadataDir, files))
-
- portageExecStage1 = subprocess.Popen(['emerge', '--quiet', '--regen'], stdout=subprocess.PIPE)
- portageExecStage1.wait()
- portageExecStage2 = subprocess.Popen(['emerge', '--quiet', '--metadata'], stdout=subprocess.PIPE)
- portageExecStage2.wait()
-
-def cleanCacheDir():
- if os.path.isdir(portageCacheDir):
- for files in os.listdir(portageCacheDir):
- if os.path.isfile(os.path.join(portageCacheDir, files)):
- os.remove(os.path.join(portageCacheDir, files))
- else:
- shutil.rmtree(os.path.join(portageCacheDir, files))
-
-def checkUpdate():
- checkPortageTree()
- checkOverlayTree()
-
-@animation.wait('fetching updates')
-def startUpdate():
- checkRoot()
- cleanCacheDir()
-
- needsPortageTreeSync = checkPortageTree()
- needsOverlayTreeSync = checkOverlayTree()
-
- if needsPortageTreeSync == 1:
- if needsOverlayTreeSync == 1:
- syncPortageTree()
- syncOverlayTree()
- syncPortageConfig()
- syncRemoteDatabase()
- refreshPortageMetadata()
- elif not needsOverlayTreeSync == 1:
- syncPortageTree()
- syncOverlayTree()
- syncPortageConfig()
- syncRemoteDatabase()
- refreshPortageMetadata()
- elif not needsPortageTreeSync == 1:
- if needsOverlayTreeSync == 1:
- syncPortageTree()
- syncOverlayTree()
- syncPortageConfig()
- syncRemoteDatabase()
- refreshPortageMetadata()
- elif not needsOverlayTreeSync == 1:
- syncPortageConfig()
-
-@animation.wait('syncing spm changes')
-def startSyncSPM():
- syncLocalDatabase()
-
-@animation.wait('recovering databases')
-def rescueDB():
- if os.path.exists(remotePkgsDB):
- os.remove(remotePkgsDB)
- if os.path.exists(remoteDscsDB):
- os.remove(remoteDscsDB)
- if os.path.exists(localPkgsDB):
- os.remove(localPkgsDB)
- if os.path.exists(sisyphusDB):
- os.remove(sisyphusDB)
-
- syncRemoteDatabase()
- syncLocalDatabase()
-
-def startSearch(pkgList):
- subprocess.call(['emerge', '--search', '--getbinpkg'] + pkgList)
-
-def startInstall(pkgList):
- startUpdate()
-
- binhostURL = getBinhostURL()
- areBinaries,areSources,needsConfig = getPackageDeps(pkgList)
-
- if needsConfig == 0:
- if len(areSources) == 0:
- if not len(areBinaries) == 0:
- os.chdir(portageCacheDir)
- print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + str(areBinaries) + "\n\n" + "Total:" + " " + str(len(areBinaries)) + " " + "binary package(s)" + "\n")
- if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
- for index, binary in enumerate([package + '.tbz2' for package in areBinaries]):
- print(">>> Fetching" + " " + binhostURL + binary)
- wget.download(binhostURL + binary)
- print("\n")
-
- subprocess.call(['qtbz2', '-x'] + binary.rstrip().split("/")[1].split())
- CATEGORY = subprocess.check_output(['qxpak', '-x', '-O'] + binary.rstrip().split("/")[1].replace('tbz2', 'xpak').split() + ['CATEGORY'])
-
- if os.path.exists(binary.rstrip().split("/")[1].replace('tbz2', 'xpak')):
- os.remove(binary.rstrip().split("/")[1].replace('tbz2', 'xpak'))
-
- if os.path.isdir(os.path.join(portageCacheDir, CATEGORY.decode().strip())):
- shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
- else:
- os.makedirs(os.path.join(portageCacheDir, CATEGORY.decode().strip()))
- shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
-
- if os.path.exists(binary.rstrip().split("/")[1]):
- os.remove(binary.rstrip().split("/")[1])
-
- portageExec = subprocess.Popen(['emerge', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--misspell-suggestion=n', '--fuzzy-search=n'] + pkgList, stdout=subprocess.PIPE)
-
- for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
- if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
- if not "Calculating dependencies" in portageOutput.rstrip():
- print(portageOutput.rstrip())
-
- portageExec.wait()
- syncLocalDatabase()
- else:
- sys.exit("\n" + "Ok; Quitting." + "\n")
- else:
- sys.exit("\n" + "No package found; Quitting." + "\n")
- else:
- if not len(areBinaries) == 0:
- os.chdir(portageCacheDir)
- print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + str(areBinaries) + "\n\n" + "Total:" + " " + str(len(areBinaries)) + " " + "binary package(s)" + "\n")
- print("\n" + "These are the source packages that would be merged, in order:" + "\n\n" + str(areSources) + "\n\n" + "Total:" + " " + str(len(areSources)) + " " + "source package(s)" + "\n")
- if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
- for index, binary in enumerate([package + '.tbz2' for package in areBinaries]):
- print(">>> Fetching" + " " + binhostURL + binary)
- wget.download(binhostURL + binary)
- print("\n")
-
- subprocess.call(['qtbz2', '-x'] + binary.rstrip().split("/")[1].split())
- CATEGORY = subprocess.check_output(['qxpak', '-x', '-O'] + binary.rstrip().split("/")[1].replace('tbz2', 'xpak').split() + ['CATEGORY'])
-
- if os.path.exists(binary.rstrip().split("/")[1].replace('tbz2', 'xpak')):
- os.remove(binary.rstrip().split("/")[1].replace('tbz2', 'xpak'))
-
- if os.path.isdir(os.path.join(portageCacheDir, CATEGORY.decode().strip())):
- shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
- else:
- os.makedirs(os.path.join(portageCacheDir, CATEGORY.decode().strip()))
- shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
-
- if os.path.exists(binary.rstrip().split("/")[1]):
- os.remove(binary.rstrip().split("/")[1])
-
- portageExec = subprocess.Popen(['emerge', '--usepkg', '--rebuilt-binaries', '--misspell-suggestion=n', '--fuzzy-search=n'] + pkgList, stdout=subprocess.PIPE)
-
- for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
- if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
- if not "Calculating dependencies" in portageOutput.rstrip():
- print(portageOutput.rstrip())
-
- portageExec.wait()
- syncLocalDatabase()
- else:
- sys.exit("\n" + "Ok; Quitting." + "\n")
- else:
- print("\n" + "These are the source packages that would be merged, in order:" + "\n\n" + str(areSources) + "\n\n" + "Total:" + " " + str(len(areSources)) + " " + "source package(s)" + "\n")
- if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
- portageExec = subprocess.Popen(['emerge', '--misspell-suggestion=n', '--fuzzy-search=n'] + pkgList, stdout=subprocess.PIPE)
-
- for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
- if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
- if not "Calculating dependencies" in portageOutput.rstrip():
- print(portageOutput.rstrip())
-
- portageExec.wait()
- syncLocalDatabase()
- else:
- sys.exit("\n" + "Ok; Quitting." + "\n")
- else:
- portageExec = subprocess.Popen(['emerge', '--quiet', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--misspell-suggestion=n', '--fuzzy-search=n'] + pkgList, stdout=subprocess.PIPE)
-
- for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
- if not "Local copy of remote index is up-to-date and will be used." in portageOutput.rstrip():
- if not "ebuild" in portageOutput.rstrip():
- if not "binary" in portageOutput.rstrip():
- print(portageOutput.rstrip())
-
- portageExec.wait()
- sys.exit("\n" + "Cannot proceed; Apply the above changes to your portage configuration files and try again; Quitting." + "\n")
-
-def startUpgrade():
- startUpdate()
-
- binhostURL = getBinhostURL()
- areBinaries,areSources,needsConfig = getWorldDeps()
-
- if needsConfig == 0:
- if len(areSources) == 0:
- if not len(areBinaries) == 0:
- os.chdir(portageCacheDir)
- print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + str(areBinaries) + "\n\n" + "Total:" + " " + str(len(areBinaries)) + " " + "binary package(s)" + "\n")
- if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
- for index, binary in enumerate([package + '.tbz2' for package in areBinaries]):
- print(">>> Fetching" + " " + binhostURL + binary)
- wget.download(binhostURL + binary)
- print("\n")
-
- subprocess.call(['qtbz2', '-x'] + binary.rstrip().split("/")[1].split())
- CATEGORY = subprocess.check_output(['qxpak', '-x', '-O'] + binary.rstrip().split("/")[1].replace('tbz2', 'xpak').split() + ['CATEGORY'])
-
- if os.path.exists(binary.rstrip().split("/")[1].replace('tbz2', 'xpak')):
- os.remove(binary.rstrip().split("/")[1].replace('tbz2', 'xpak'))
-
- if os.path.isdir(os.path.join(portageCacheDir, CATEGORY.decode().strip())):
- shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
- else:
- os.makedirs(os.path.join(portageCacheDir, CATEGORY.decode().strip()))
- shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
-
- if os.path.exists(binary.rstrip().split("/")[1]):
- os.remove(binary.rstrip().split("/")[1])
-
- portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE)
-
- for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
- if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
- if not "Calculating dependencies" in portageOutput.rstrip():
- print(portageOutput.rstrip())
-
- portageExec.wait()
- syncLocalDatabase()
- else:
- sys.exit("\n" + "Ok; Quitting." + "\n")
- else:
- sys.exit("\n" + "No package upgrades found; Quitting." + "\n")
- else:
- if not len(areBinaries) == 0:
- os.chdir(portageCacheDir)
- print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + str(areBinaries) + "\n\n" + "Total:" + " " + str(len(areBinaries)) + " " + "binary package(s)" + "\n")
- print("\n" + "These are the source packages that would be merged, in order:" + "\n\n" + str(areSources) + "\n\n" + "Total:" + " " + str(len(areSources)) + " " + "source package(s)" + "\n")
- if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
- for index, binary in enumerate([package + '.tbz2' for package in areBinaries]):
- print(">>> Fetching" + " " + binhostURL + binary)
- wget.download(binhostURL + binary)
- print("\n")
-
- subprocess.call(['qtbz2', '-x'] + binary.rstrip().split("/")[1].split())
- CATEGORY = subprocess.check_output(['qxpak', '-x', '-O'] + binary.rstrip().split("/")[1].replace('tbz2', 'xpak').split() + ['CATEGORY'])
-
- if os.path.exists(binary.rstrip().split("/")[1].replace('tbz2', 'xpak')):
- os.remove(binary.rstrip().split("/")[1].replace('tbz2', 'xpak'))
-
- if os.path.isdir(os.path.join(portageCacheDir, CATEGORY.decode().strip())):
- shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
- else:
- os.makedirs(os.path.join(portageCacheDir, CATEGORY.decode().strip()))
- shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
-
- if os.path.exists(binary.rstrip().split("/")[1]):
- os.remove(binary.rstrip().split("/")[1])
-
- portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--usepkg', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE)
-
- for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
- if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
- if not "Calculating dependencies" in portageOutput.rstrip():
- print(portageOutput.rstrip())
-
- portageExec.wait()
- syncLocalDatabase()
- else:
- sys.exit("\n" + "Ok; Quitting." + "\n")
- else:
- print("\n" + "These are the source packages that would be merged, in order:" + "\n\n" + str(areSources) + "\n\n" + "Total:" + " " + str(len(areSources)) + " " + "source package(s)" + "\n")
- if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
- portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE)
-
- for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
- if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
- if not "Calculating dependencies" in portageOutput.rstrip():
- print(portageOutput.rstrip())
-
- portageExec.wait()
- syncLocalDatabase()
- else:
- sys.exit("\n" + "Ok; Quitting." + "\n")
- else:
- portageExec = subprocess.Popen(['emerge', '--quiet', '--update', '--deep', '--newuse', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE)
-
- for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
- if not "Local copy of remote index is up-to-date and will be used." in portageOutput.rstrip():
- if not "ebuild" in portageOutput.rstrip():
- if not "binary" in portageOutput.rstrip():
- print(portageOutput.rstrip())
-
- portageExec.wait()
- sys.exit("\n" + "Cannot proceed; Apply the above changes to your portage configuration files and try again; Quitting." + "\n")
-
-def startUninstall(pkgList):
- portageExec = subprocess.Popen(['emerge', '--quiet', '--depclean', '--ask'] + pkgList)
- portageExec.wait()
- syncLocalDatabase()
-
-def startUninstallForce(pkgList):
- portageExec = subprocess.Popen(['emerge', '--quiet', '--unmerge', '--ask'] + pkgList)
- portageExec.wait()
- syncLocalDatabase()
-
-def removeOrphans():
- portageExec = subprocess.Popen(['emerge', '--quiet', '--depclean', '--ask'])
- portageExec.wait()
- syncLocalDatabase()
-
-def sysInfo():
- subprocess.call(['emerge', '--info'])
-
-def portageKill(portageCmd):
- portageCmd.terminate()
-
-def printMirrorList():
- mirrorList = getMirrorList()
-
- for i, line in enumerate(mirrorList):
- if line['isActive']:
- print(i + 1, '*', line['Url'])
- else:
- print(i + 1, ' ', line['Url'])
-
-def writeMirrorCfg(mirrorList):
- with open(mirrorCfg, 'w+') as mirrorFile:
- mirrorFile.write("#######################################################\n")
- mirrorFile.write("# Support for multiple mirrors is somewhat incomplete #\n")
- mirrorFile.write("#######################################################\n")
- mirrorFile.write("# Please avoid using the Main Repository #\n")
- mirrorFile.write("# http://mirrors.redcorelinux.org/redcorelinux #\n")
- mirrorFile.write("# as the bandwidth is limited, use mirrors instead #\n")
- mirrorFile.write("#######################################################\n")
- mirrorFile.write("# Uncomment only one mirror from the list bellow #\n")
- mirrorFile.write("#######################################################\n")
- mirrorFile.write("\n")
- for line in mirrorList:
- mirror = 'PORTAGE_BINHOST=' + '"' + line['Url'] + '"'
- if not line['isActive']:
- mirror = '# ' + mirror
- mirrorFile.write(mirror + "\n")
- mirrorFile.write("\n")
-
-def setActiveMirror(mirror):
- mirror = int(mirror[0])
- mirrorList = getMirrorList()
- if mirror not in range(1, len(mirrorList) + 1):
- print("\n" + "Mirror index is wrong, please check with sisyphus --mirror --list" + "\n")
- else:
- for i in range(0, len(mirrorList)):
- indx = i + 1
- if indx == mirror:
- mirrorList[i]['isActive'] = True
- else:
- mirrorList[i]['isActive'] = False
- writeMirrorCfg(mirrorList)
-
-@animation.wait('resetting branch configuration')
-def resetBranch():
- 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)
-
-@animation.wait('injecting gentoo linux portage tree - branch master')
-def setGitlabMasterStage1():
- if not os.path.isdir(os.path.join(gentooEbuildDir, '.git')):
- os.chdir(gentooEbuildDir)
- 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(redcoreEbuildDir, '.git')):
- os.chdir(redcoreEbuildDir)
- 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(portageConfigDir, '.git')):
- os.chdir(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 setGitlabMaster():
- setGitlabMasterStage1()
- setGitlabMasterStage2()
- setGitlabMasterStage3()
-
-@animation.wait('injecting gentoo linux portage tree - branch master')
-def setPagureMasterStage1():
- if not os.path.isdir(os.path.join(gentooEbuildDir, '.git')):
- os.chdir(gentooEbuildDir)
- 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(redcoreEbuildDir, '.git')):
- os.chdir(redcoreEbuildDir)
- 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(portageConfigDir, '.git')):
- os.chdir(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 setPagureMaster():
- setPagureMasterStage1()
- setPagureMasterStage2()
- setPagureMasterStage3()
-
-@animation.wait('injecting gentoo linux portage tree - branch next')
-def setGitlabNextStage1():
- if not os.path.isdir(os.path.join(gentooEbuildDir, '.git')):
- os.chdir(gentooEbuildDir)
- 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(redcoreEbuildDir, '.git')):
- os.chdir(redcoreEbuildDir)
- 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(portageConfigDir, '.git')):
- os.chdir(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 setGitlabNext():
- setGitlabNextStage1()
- setGitlabNextStage2()
- setGitlabNextStage3()
-
-@animation.wait('injecting gentoo linux portage tree - branch next')
-def setPagureNextStage1():
- if not os.path.isdir(os.path.join(gentooEbuildDir, '.git')):
- os.chdir(gentooEbuildDir)
- 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(redcoreEbuildDir, '.git')):
- os.chdir(redcoreEbuildDir)
- 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(portageConfigDir, '.git')):
- os.chdir(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 setPagureNext():
- setPagureNextStage1()
- setPagureNextStage2()
- setPagureNextStage3()
-
-@animation.wait('setting up hardened profile')
-def setHardenedProfile():
- subprocess.call(['eselect', 'profile', 'set', 'default/linux/amd64/17.0/hardened'])
- subprocess.call(['env-update'])
-
-@animation.wait('adjusting MAKEOPTS')
-def setJobs():
- subprocess.call(['/usr/share/sisyphus/helpers/set_jobs'])
-
-def injectGitlabMaster():
- checkRoot()
- resetBranch()
- setGitlabMaster()
- setHardenedProfile()
- setJobs()
- refreshPortageMetadata()
-
-def injectPagureMaster():
- checkRoot()
- resetBranch()
- setPagureMaster()
- setHardenedProfile()
- setJobs()
- refreshPortageMetadata()
-
-def injectGitlabNext():
- checkRoot()
- resetBranch()
- setGitlabNext()
- setHardenedProfile()
- setJobs()
- refreshPortageMetadata()
-
-def injectPagureNext():
- checkRoot()
- resetBranch()
- setPagureNext()
- setHardenedProfile()
- setJobs()
- refreshPortageMetadata()
-
-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")
- print("an apt-get/yum-alike interface to these commands, to assist newcomer people transitioning from")
- print("Debian/RedHat-based systems to Gentoo." + "\n")
- print("Commands :" + "\n")
- print("--install")
- print("* Install binary and/or ebuild (source) packages" + "\n")
- print("--uninstall")
- print("* Uninstall packages *SAFELY* by checking for reverse dependencies")
- print("* If reverse dependencies exist, the package(s) will NOT be uninstalled to prevent the possible breakage of the system")
- print("* If you really want to uninstall the package, make sure you uninstall all reverse dependencies as well")
- print("* This will not allways be possible, as the reverse dependency chain may be way to long and require you to uninstall critical system packages" + "\n")
- print("--force-uninstall")
- print("* Uninstall packages *UNSAFELY* by ignoring reverse dependencies")
- print("* This may break your system if you uninstall critical system packages")
- print("* It will try the best it can to preserve the libraries required by other packages to prevent such a breakage")
- print("* Upgrading the system may pull the packages back in, to fix the reverse dependency chain" + "\n")
- print("--remove-orphans")
- print("* Uninstall packages that are no longer needed")
- print("* When you uninstall a package without it's reverse dependencies, those dependencies will become orphans if nothing else requires them")
- print("* In addition, a package may no longer depend on another one, so that other package becomes orphan as well if nothing else requires it")
- print("* Use this option to check the whole dependency chain for such packages, and uninstall them" + "\n")
- print("--update")
- print("* Update the Portage tree, the Redcore Overlay(s), Portage configs && Sisyphus's package database" + "\n")
- print("--upgrade")
- print("* Upgrade the system using binary and/or ebuild (source) packages" + "\n")
- print("--search")
- print("* Search for binary and/or ebuild (source) packages" + "\n")
- print("--spmsync")
- print("* Sync Sisyphus's package database with Portage's package database")
- print("* When you install something with Portage directly (emerge), Sisyphus is not aware of that package, and it doesn't track it in it's database")
- print("* Use this option to synchronize Sisyphus's package database with Portage's package database" + "\n")
- print("--rescue")
- print("* Resurrect Sisyphus's package database if lost or corrupted")
- print("* If for some reason Sisyphus's package database is lost or corrupted, it can be resurrected using Portage's package database")
- print("* If Portage's package database is corrupted (in this case you're screwed anyway :D), only a partial resurrection will be possible")
- print("* If Portage's package database is intact, full resurrection will be possible" + "\n")
- print("--mirror --list")
- print("* List available binary package repository mirrors (the active one is marked with *)" + "\n")
- print("--mirror --set 'INDEX'")
- print("* Change the binary package repository to the selected mirror" + "\n")
- print("--branch='BRANCH' --remote='REMOTE'")
- print("* Pull the branch 'BRANCH' of the Portage tree, Redcore overlay && Portage configs. Use 'REMOTE' git repositories.")
- print("* 'BRANCH' can be one of the following : master, next")
- print("* 'REMOTE' can be one of the following : gitlab, pagure")
- print("*")
- print("* Examples: ")
- print("* '--branch=master --remote=gitlab' will pull the branch 'master' from gitlab.com")
- print("* '--branch=next --remote=pagure' will pull the branch 'next' from pagure.io")
- print("*")
- print("* !!! WARNING !!!")
- print("* Once you changed the branch, you must pair the branch 'BRANCH' with the correct binary repository")
- print("* Branch 'master' must be paired with the stable binary repository (odd numbers in 'sisyphus --mirror --list'). Examples : 'sisyphus --mirror --set 1' or 'sisyphus --mirror --set 5' ")
- print("* Branch 'next' must be paired with the testing binary repository (even numbers in 'sisyphus --mirror --list'). Examples : 'sisyphus --mirror --set 2' or 'sisyphus --mirror --set 8'" + "\n")
- print("--sysinfo")
- print("* Display information about installed core packages and portage configuration" + "\n")
- print("--help")
- print("* Display this help information" + "\n")
diff --git a/src/backend/metadata.py b/src/backend/metadata.py
new file mode 100644
index 0000000..fc30b15
--- /dev/null
+++ b/src/backend/metadata.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python3
+
+import animation
+import os
+import shutil
+import subprocess
+
+portageMetadataDir = '/var/cache/edb'
+
+def regenSilent():
+ if os.path.isdir(portageMetadataDir):
+ for files in os.listdir(portageMetadataDir):
+ if os.path.isfile(os.path.join(portageMetadataDir, files)):
+ os.remove(os.path.join(portageMetadataDir, files))
+ else:
+ shutil.rmtree(os.path.join(portageMetadataDir, files))
+
+ portageExecStage1 = subprocess.Popen(['emerge', '--quiet', '--regen'], stdout=subprocess.PIPE)
+ portageExecStage1.wait()
+ portageExecStage2 = subprocess.Popen(['emerge', '--quiet', '--metadata'], stdout=subprocess.PIPE)
+ portageExecStage2.wait()
+
+@animation.wait("refreshing metadata")
+def regenAnimated():
+ if os.path.isdir(portageMetadataDir):
+ for files in os.listdir(portageMetadataDir):
+ if os.path.isfile(os.path.join(portageMetadataDir, files)):
+ os.remove(os.path.join(portageMetadataDir, files))
+ else:
+ shutil.rmtree(os.path.join(portageMetadataDir, files))
+
+ portageExecStage1 = subprocess.Popen(['emerge', '--quiet', '--regen'], stdout=subprocess.PIPE)
+ portageExecStage1.wait()
+ portageExecStage2 = subprocess.Popen(['emerge', '--quiet', '--metadata'], stdout=subprocess.PIPE)
+ portageExecStage2.wait()
diff --git a/src/backend/mirror.py b/src/backend/mirror.py
new file mode 100644
index 0000000..7d041cf
--- /dev/null
+++ b/src/backend/mirror.py
@@ -0,0 +1,60 @@
+#!/usr/bin/python3
+
+mirrorCfg = '/etc/sisyphus/mirrors.conf'
+
+def getList():
+ mirrorList = []
+
+ with open(mirrorCfg) as mirrorFile:
+ for line in mirrorFile.readlines():
+ if 'PORTAGE_BINHOST=' in line:
+ url = line.split("=")[1].replace('"', '').rstrip()
+ mirror = {'isActive': True, 'Url': url}
+ if line.startswith('#'):
+ mirror['isActive'] = False
+ mirrorList.append(mirror)
+ mirrorFile.close()
+
+ return mirrorList
+
+def printList():
+ mirrorList = getList()
+
+ for i, line in enumerate(mirrorList):
+ if line['isActive']:
+ print(i + 1, '*', line['Url'])
+ else:
+ print(i + 1, ' ', line['Url'])
+
+def writeList(mirrorList):
+ with open(mirrorCfg, 'w+') as mirrorFile:
+ mirrorFile.write("#######################################################\n")
+ mirrorFile.write("# Support for multiple mirrors is somewhat incomplete #\n")
+ mirrorFile.write("#######################################################\n")
+ mirrorFile.write("# Please avoid using the Main Repository #\n")
+ mirrorFile.write("# http://mirrors.redcorelinux.org/redcorelinux #\n")
+ mirrorFile.write("# as the bandwidth is limited, use mirrors instead #\n")
+ mirrorFile.write("#######################################################\n")
+ mirrorFile.write("# Uncomment only one mirror from the list bellow #\n")
+ mirrorFile.write("#######################################################\n")
+ mirrorFile.write("\n")
+ for line in mirrorList:
+ mirror = 'PORTAGE_BINHOST=' + '"' + line['Url'] + '"'
+ if not line['isActive']:
+ mirror = '# ' + mirror
+ mirrorFile.write(mirror + "\n")
+ mirrorFile.write("\n")
+
+def setActive(mirror):
+ mirror = int(mirror[0])
+ mirrorList = getList()
+ if mirror not in range(1, len(mirrorList) + 1):
+ print("\n" + "Mirror index is wrong, please check with sisyphus --mirror --list" + "\n")
+ else:
+ for i in range(0, len(mirrorList)):
+ indx = i + 1
+ if indx == mirror:
+ mirrorList[i]['isActive'] = True
+ else:
+ mirrorList[i]['isActive'] = False
+ writeList(mirrorList)
diff --git a/src/backend/removeorphans.py b/src/backend/removeorphans.py
new file mode 100644
index 0000000..a0b4f30
--- /dev/null
+++ b/src/backend/removeorphans.py
@@ -0,0 +1,11 @@
+#!/usr/bin/python3
+
+import subprocess
+import sisyphus.check
+import sisyphus.sync
+
+def start():
+ sisyphus.check.root()
+ portageExec = subprocess.Popen(['emerge', '--quiet', '--depclean', '--ask'])
+ portageExec.wait()
+ sisyphus.database.syncLocal()
diff --git a/src/backend/rescue.py b/src/backend/rescue.py
new file mode 100644
index 0000000..18523d4
--- /dev/null
+++ b/src/backend/rescue.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python3
+
+import animation
+import os
+import sisyphus.database
+
+remotePkgsDB = '/var/lib/sisyphus/csv/remotePackagesPre.csv'
+remoteDscsDB = '/var/lib/sisyphus/csv/remoteDescriptionsPre.csv'
+localPkgsDB = '/var/lib/sisyphus/csv/localPackagesPre.csv'
+sisyphusDB = '/var/lib/sisyphus/db/sisyphus.db'
+
+@animation.wait('recovering databases')
+def start():
+ if os.path.exists(remotePkgsDB):
+ os.remove(remotePkgsDB)
+ if os.path.exists(remoteDscsDB):
+ os.remove(remoteDscsDB)
+ if os.path.exists(localPkgsDB):
+ os.remove(localPkgsDB)
+ if os.path.exists(sisyphusDB):
+ os.remove(sisyphusDB)
+
+ sisyphus.database.syncRemote()
+ sisyphus.database.syncLocal()
diff --git a/src/backend/search.py b/src/backend/search.py
new file mode 100644
index 0000000..7e5ab2f
--- /dev/null
+++ b/src/backend/search.py
@@ -0,0 +1,6 @@
+#!/usr/bin/python3
+
+import subprocess
+
+def start(pkgList):
+ subprocess.call(['emerge', '--search', '--getbinpkg'] + pkgList)
diff --git a/src/backend/setjobs.py b/src/backend/setjobs.py
new file mode 100644
index 0000000..1047913
--- /dev/null
+++ b/src/backend/setjobs.py
@@ -0,0 +1,8 @@
+#!/usr/bin/python3
+
+import animation
+import subprocess
+
+@animation.wait('adjusting MAKEOPTS')
+def start():
+ subprocess.call(['/usr/share/sisyphus/helpers/set_jobs'])
diff --git a/src/backend/setprofile.py b/src/backend/setprofile.py
new file mode 100644
index 0000000..c78269f
--- /dev/null
+++ b/src/backend/setprofile.py
@@ -0,0 +1,9 @@
+#!/usr/bin/python3
+
+import animation
+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'])
diff --git a/src/backend/solvedeps.py b/src/backend/solvedeps.py
new file mode 100644
index 0000000..256d588
--- /dev/null
+++ b/src/backend/solvedeps.py
@@ -0,0 +1,69 @@
+#!/usr/bin/python3
+
+import animation
+import subprocess
+import io
+
+@animation.wait('resolving dependencies')
+def package(pkgList):
+ areBinaries = []
+ areSources = []
+ needsConfig = int()
+ portageExec = subprocess.Popen(['emerge', '--quiet', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--misspell-suggestion=n', '--fuzzy-search=n'] + pkgList, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+ for portageOutput in io.TextIOWrapper(portageExec.stderr, encoding="utf-8"):
+ if "The following keyword changes are necessary to proceed:" in portageOutput.rstrip():
+ needsConfig = int(1)
+
+ if "The following mask changes are necessary to proceed:" in portageOutput.rstrip():
+ needsConfig = int(1)
+
+ if "The following USE changes are necessary to proceed:" in portageOutput.rstrip():
+ needsConfig = int(1)
+
+ if "The following REQUIRED_USE flag constraints are unsatisfied:" in portageOutput.rstrip():
+ needsConfig = int(1)
+
+ for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
+ if "[binary" in portageOutput.rstrip():
+ isBinary = str(portageOutput.rstrip().split("]")[1].split("[")[0].strip("\ "))
+ areBinaries.append(isBinary)
+
+ if "[ebuild" in portageOutput.rstrip():
+ isSource = str(portageOutput.rstrip().split("]")[1].split("[")[0].strip("\ "))
+ areSources.append(isSource)
+
+ portageExec.wait()
+ return areBinaries,areSources,needsConfig
+
+@animation.wait('resolving dependencies')
+def world():
+ areBinaries = []
+ areSources = []
+ needsConfig = int()
+ portageExec = subprocess.Popen(['emerge', '--quiet', '--update', '--deep', '--newuse', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+ for portageOutput in io.TextIOWrapper(portageExec.stderr, encoding="utf-8"):
+ if "The following keyword changes are necessary to proceed:" in portageOutput.rstrip():
+ needsConfig = int(1)
+
+ if "The following mask changes are necessary to proceed:" in portageOutput.rstrip():
+ needsConfig = int(1)
+
+ if "The following USE changes are necessary to proceed:" in portageOutput.rstrip():
+ needsConfig = int(1)
+
+ if "The following REQUIRED_USE flag constraints are unsatisfied:" in portageOutput.rstrip():
+ needsConfig = int(1)
+
+ for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
+ if "[binary" in portageOutput.rstrip():
+ isBinary = str(portageOutput.rstrip().split("]")[1].split("[")[0].strip("\ "))
+ areBinaries.append(isBinary)
+
+ if "[ebuild" in portageOutput.rstrip():
+ isSource = str(portageOutput.rstrip().split("]")[1].split("[")[0].strip("\ "))
+ areSources.append(isSource)
+
+ portageExec.wait()
+ return areBinaries,areSources,needsConfig
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()
diff --git a/src/backend/sysinfo.py b/src/backend/sysinfo.py
new file mode 100644
index 0000000..5ae29c2
--- /dev/null
+++ b/src/backend/sysinfo.py
@@ -0,0 +1,7 @@
+#!/usr/bin/python3
+
+import subprocess
+
+def show():
+ subprocess.call(['emerge', '--info'])
+
diff --git a/src/backend/uninstall.py b/src/backend/uninstall.py
new file mode 100644
index 0000000..8dc9e34
--- /dev/null
+++ b/src/backend/uninstall.py
@@ -0,0 +1,11 @@
+#!/usr/bin/python3
+
+import subprocess
+import sisyphus.check
+import sisyphus.sync
+
+def start(pkgList):
+ sisyphus.check.root()
+ portageExec = subprocess.Popen(['emerge', '--quiet', '--depclean', '--ask'] + pkgList)
+ portageExec.wait()
+ sisyphus.database.syncLocal()
diff --git a/src/backend/uninstallforce.py b/src/backend/uninstallforce.py
new file mode 100644
index 0000000..e3f4144
--- /dev/null
+++ b/src/backend/uninstallforce.py
@@ -0,0 +1,11 @@
+#!/usr/bin/python3
+
+import subprocess
+import sisyphus.check
+import sisyphus.sync
+
+def start(pkgList):
+ sisyphus.check.root()
+ portageExec = subprocess.Popen(['emerge', '--quiet', '--unmerge', '--ask'] + pkgList)
+ portageExec.wait()
+ sisyphus.database.syncLocal()
diff --git a/src/backend/update.py b/src/backend/update.py
new file mode 100644
index 0000000..dd184d2
--- /dev/null
+++ b/src/backend/update.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python3
+
+import animation
+import sisyphus.check
+import sisyphus.clean
+import sisyphus.database
+import sisyphus.metadata
+import sisyphus.sync
+
+@animation.wait('fetching updates')
+def start():
+ sisyphus.check.root()
+ sisyphus.clean.cache()
+
+ needsPortage = sisyphus.check.portage()
+ needsOverlay = sisyphus.check.overlay()
+
+ if needsPortage == 1:
+ if needsOverlay == 1:
+ sisyphus.sync.portage()
+ sisyphus.sync.overlay()
+ sisyphus.sync.portageCfg()
+ sisyphus.database.syncRemote()
+ sisyphus.metadata.regenSilent()
+ elif not needsOverlay == 1:
+ sisyphus.sync.portage()
+ sisyphus.sync.overlay()
+ sisyphus.sync.portageCfg()
+ sisyphus.database.syncRemote()
+ sisyphus.metadata.regenSilent()
+ elif not needsPortage == 1:
+ if needsOverlay == 1:
+ sisyphus.sync.portage()
+ sisyphus.sync.overlay()
+ sisyphus.sync.portageCfg()
+ sisyphus.database.syncRemote()
+ sisyphus.metadata.regenSilent()
+ elif not needsOverlay == 1:
+ sisyphus.sync.portageCfg()
diff --git a/src/backend/upgrade.py b/src/backend/upgrade.py
new file mode 100644
index 0000000..0a3762d
--- /dev/null
+++ b/src/backend/upgrade.py
@@ -0,0 +1,123 @@
+#!/usr/bin/python3
+
+import os
+import shutil
+import subprocess
+import sys
+import io
+import wget
+import sisyphus.binhost
+import sisyphus.database
+import sisyphus.solvedeps
+import sisyphus.update
+
+portageCacheDir = '/var/cache/packages'
+
+def start():
+ sisyphus.update.start()
+
+ binhostURL = sisyphus.binhost.getURL()
+ areBinaries,areSources,needsConfig = sisyphus.solvedeps.world()
+
+ if needsConfig == 0:
+ if len(areSources) == 0:
+ if not len(areBinaries) == 0:
+ os.chdir(portageCacheDir)
+ print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + str(areBinaries) + "\n\n" + "Total:" + " " + str(len(areBinaries)) + " " + "binary package(s)" + "\n")
+ if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
+ for index, binary in enumerate([package + '.tbz2' for package in areBinaries]):
+ print(">>> Fetching" + " " + binhostURL + binary)
+ wget.download(binhostURL + binary)
+ print("\n")
+
+ subprocess.call(['qtbz2', '-x'] + binary.rstrip().split("/")[1].split())
+ CATEGORY = subprocess.check_output(['qxpak', '-x', '-O'] + binary.rstrip().split("/")[1].replace('tbz2', 'xpak').split() + ['CATEGORY'])
+
+ if os.path.exists(binary.rstrip().split("/")[1].replace('tbz2', 'xpak')):
+ os.remove(binary.rstrip().split("/")[1].replace('tbz2', 'xpak'))
+
+ if os.path.isdir(os.path.join(portageCacheDir, CATEGORY.decode().strip())):
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
+ else:
+ os.makedirs(os.path.join(portageCacheDir, CATEGORY.decode().strip()))
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
+
+ if os.path.exists(binary.rstrip().split("/")[1]):
+ os.remove(binary.rstrip().split("/")[1])
+
+ portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE)
+
+ for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
+ if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
+ if not "Calculating dependencies" in portageOutput.rstrip():
+ print(portageOutput.rstrip())
+
+ portageExec.wait()
+ sisyphus.database.syncLocal()
+ else:
+ sys.exit("\n" + "Ok; Quitting." + "\n")
+ else:
+ sys.exit("\n" + "No package upgrades found; Quitting." + "\n")
+ else:
+ if not len(areBinaries) == 0:
+ os.chdir(portageCacheDir)
+ print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + str(areBinaries) + "\n\n" + "Total:" + " " + str(len(areBinaries)) + " " + "binary package(s)" + "\n")
+ print("\n" + "These are the source packages that would be merged, in order:" + "\n\n" + str(areSources) + "\n\n" + "Total:" + " " + str(len(areSources)) + " " + "source package(s)" + "\n")
+ if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
+ for index, binary in enumerate([package + '.tbz2' for package in areBinaries]):
+ print(">>> Fetching" + " " + binhostURL + binary)
+ wget.download(binhostURL + binary)
+ print("\n")
+
+ subprocess.call(['qtbz2', '-x'] + binary.rstrip().split("/")[1].split())
+ CATEGORY = subprocess.check_output(['qxpak', '-x', '-O'] + binary.rstrip().split("/")[1].replace('tbz2', 'xpak').split() + ['CATEGORY'])
+
+ if os.path.exists(binary.rstrip().split("/")[1].replace('tbz2', 'xpak')):
+ os.remove(binary.rstrip().split("/")[1].replace('tbz2', 'xpak'))
+
+ if os.path.isdir(os.path.join(portageCacheDir, CATEGORY.decode().strip())):
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
+ else:
+ os.makedirs(os.path.join(portageCacheDir, CATEGORY.decode().strip()))
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(portageCacheDir, CATEGORY.decode().strip()), os.path.basename(binary.rstrip().split("/")[1])))
+
+ if os.path.exists(binary.rstrip().split("/")[1]):
+ os.remove(binary.rstrip().split("/")[1])
+
+ portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--usepkg', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE)
+
+ for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
+ if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
+ if not "Calculating dependencies" in portageOutput.rstrip():
+ print(portageOutput.rstrip())
+
+ portageExec.wait()
+ sisyphus.database.syncLocal()
+ else:
+ sys.exit("\n" + "Ok; Quitting." + "\n")
+ else:
+ print("\n" + "These are the source packages that would be merged, in order:" + "\n\n" + str(areSources) + "\n\n" + "Total:" + " " + str(len(areSources)) + " " + "source package(s)" + "\n")
+ if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
+ portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE)
+
+ for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
+ if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
+ if not "Calculating dependencies" in portageOutput.rstrip():
+ print(portageOutput.rstrip())
+
+ portageExec.wait()
+ sisyphus.database.syncLocal()
+ else:
+ sys.exit("\n" + "Ok; Quitting." + "\n")
+ else:
+ portageExec = subprocess.Popen(['emerge', '--quiet', '--update', '--deep', '--newuse', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE)
+
+ for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
+ if not "Local copy of remote index is up-to-date and will be used." in portageOutput.rstrip():
+ if not "ebuild" in portageOutput.rstrip():
+ if not "binary" in portageOutput.rstrip():
+ print(portageOutput.rstrip())
+
+ portageExec.wait()
+ sys.exit("\n" + "Cannot proceed; Apply the above changes to your portage configuration files and try again; Quitting." + "\n")
+
diff --git a/src/frontend/cli/sisyphus-cli.py b/src/frontend/cli/sisyphus-cli.py
index c78f939..1393cae 100755
--- a/src/frontend/cli/sisyphus-cli.py
+++ b/src/frontend/cli/sisyphus-cli.py
@@ -1,10 +1,23 @@
#!/usr/bin/python3
+import sisyphus.branchinject
+import sisyphus.check
+import sisyphus.help
+import sisyphus.install
+import sisyphus.mirror
+import sisyphus.removeorphans
+import sisyphus.rescue
+import sisyphus.search
+import sisyphus.setjobs
+import sisyphus.sysinfo
+import sisyphus.uninstall
+import sisyphus.uninstallforce
+import sisyphus.update
+import sisyphus.upgrade
import sys
-from libsisyphus import *
-checkUpdate()
-setJobs.__wrapped__() #undecorate
+sisyphus.check.update()
+sisyphus.setjobs.start.__wrapped__() # undecorate
pkgList = sys.argv[2:]
if "__main__" == __name__:
@@ -13,59 +26,57 @@ if "__main__" == __name__:
if not pkgList:
sys.exit("\n" + "Nothing to install, please provide at least one package name; quitting" + "\n")
else:
- startInstall(pkgList)
+ sisyphus.install.start(pkgList)
elif "--uninstall" in sys.argv[1:]:
if not pkgList:
sys.exit("\n" + "Nothing to uninstall, please provide at least one package name; quitting" + "\n")
else:
- startUninstall(pkgList)
+ sisyphus.uninstall.start(pkgList)
elif "--force-uninstall" in sys.argv[1:]:
if not pkgList:
sys.exit("\n" + "Nothing to force uninstall, please provide at least one package name; quitting" + "\n")
else:
- startUninstallForce(pkgList)
+ sisyphus.uninstallforce.start(pkgList)
elif "--remove-orphans" in sys.argv[1:]:
- removeOrphans()
- elif "--update" in sys.argv[1:]:
- startUpdate()
- elif "--upgrade" in sys.argv[1:]:
- startUpgrade()
+ sisyphus.removeorphans.start()
elif "--search" in sys.argv[1:]:
if not pkgList:
sys.exit("\n" + "Nothing to search, please provide at least one package name; quitting" + "\n")
else:
- startSearch(pkgList)
- elif "--spmsync" in sys.argv[1:]:
- startSyncSPM()
+ sisyphus.search.start(pkgList)
+ elif "--update" in sys.argv[1:]:
+ sisyphus.update.start()
+ elif "--upgrade" in sys.argv[1:]:
+ sisyphus.upgrade.start()
elif "--rescue" in sys.argv[1:]:
- rescueDB()
+ sisyphus.rescue.start()
elif "--sysinfo" in sys.argv[1:]:
- sysInfo()
+ sisyphus.sysinfo.show()
elif "--mirror" in sys.argv[1:]:
if "--list" in sys.argv[2:]:
- printMirrorList()
+ sisyphus.mirror.printList()
elif "--set" in sys.argv[2:]:
if sys.argv[3:]:
- setActiveMirror(sys.argv[3:])
+ sisyphus.mirror.setActive(sys.argv[3:])
else:
- showHelp()
+ sisyphus.help.show()
else:
- showHelp()
+ sisyphus.help.show()
elif "--branch=master" in sys.argv[1:]:
if "--remote=gitlab" in sys.argv[2:]:
- injectGitlabMaster()
+ sisyphus.branchinject.gitlabMaster()
elif "--remote=pagure" in sys.argv[2:]:
- injectPagureMaster()
+ sisyphus.branchinject.pagureMaster()
else:
- showHelp()
+ sisyphus.help.show()
elif "--branch=next" in sys.argv[1:]:
if "--remote=gitlab" in sys.argv[2:]:
- injectGitlabNext()
+ sisyphus.branchinject.gitlabNext()
elif "--remote=pagure" in sys.argv[2:]:
- injectPagureNext()
+ sisyphus.branchinject.pagureNext()
else:
- showHelp()
+ sisyphus.help.show()
elif "--help" in sys.argv[1:]:
- showHelp()
+ sisyphus.help.show()
else:
- showHelp()
+ sisyphus.help.show()