summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2020-06-06 20:37:56 +0100
committerV3n3RiX <venerix@redcorelinux.org>2020-06-06 20:37:56 +0100
commited88746cd33c0f861e9c45bf05bf9e44d86089ba (patch)
treee6656f3d54bd738383d048c744d330dca2c15e4c /src/backend
parent2d86cd9ddc5d9442e4a8e8fb50d72480a8293a4a (diff)
filesystem module : gather all the folder and file paths used by sisyphus under one module, and expose them to other modules from there
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/__init__.py2
-rw-r--r--src/backend/branchmaster.py29
-rw-r--r--src/backend/branchnext.py29
-rw-r--r--src/backend/branchreset.py41
-rw-r--r--src/backend/cache.py13
-rw-r--r--src/backend/check.py8
-rw-r--r--src/backend/database.py20
-rw-r--r--src/backend/filesystem.py12
-rw-r--r--src/backend/install.py23
-rw-r--r--src/backend/metadata.py23
-rw-r--r--src/backend/mirror.py6
-rw-r--r--src/backend/rescue.py22
-rw-r--r--src/backend/sync.py11
-rw-r--r--src/backend/upgrade.py23
14 files changed, 124 insertions, 138 deletions
diff --git a/src/backend/__init__.py b/src/backend/__init__.py
index c5f8f58..d9fdc29 100644
--- a/src/backend/__init__.py
+++ b/src/backend/__init__.py
@@ -7,6 +7,7 @@ from .cache import *
from .check import *
from .csvfiles import *
from .database import *
+from .filesystem import *
from .help import *
from .install import *
from .killportage import *
@@ -24,4 +25,3 @@ from .uninstallforce import *
from .uninstall import *
from .update import *
from .upgrade import *
-
diff --git a/src/backend/branchmaster.py b/src/backend/branchmaster.py
index 6229511..6a114c5 100644
--- a/src/backend/branchmaster.py
+++ b/src/backend/branchmaster.py
@@ -3,15 +3,12 @@
import animation
import os
import subprocess
-
-gentooEbuildDir = '/usr/ports/gentoo'
-redcoreEbuildDir = '/usr/ports/redcore'
-portageConfigDir = '/opt/redcore-build'
+import sisyphus.filesystem
@animation.wait('injecting gentoo linux portage tree - branch master')
def setGitlabMasterStage1():
- if not os.path.isdir(os.path.join(gentooEbuildDir, '.git')):
- os.chdir(gentooEbuildDir)
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.gentooEbuildDir, '.git')):
+ os.chdir(sisyphus.filesystem.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'])
@@ -19,8 +16,8 @@ def setGitlabMasterStage1():
@animation.wait('injecting redcore linux ebuild tree - branch master')
def setGitlabMasterStage2():
- if not os.path.isdir(os.path.join(redcoreEbuildDir, '.git')):
- os.chdir(redcoreEbuildDir)
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.redcoreEbuildDir, '.git')):
+ os.chdir(sisyphus.filesystem.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'])
@@ -28,8 +25,8 @@ def setGitlabMasterStage2():
@animation.wait('injecting redcore linux portage configuration - branch master')
def setGitlabMasterStage3():
- if not os.path.isdir(os.path.join(portageConfigDir, '.git')):
- os.chdir(portageConfigDir)
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.portageConfigDir, '.git')):
+ os.chdir(sisyphus.filesystem.portageConfigDir)
subprocess.call(['git', 'init', '-q'])
subprocess.call(['git', 'remote', 'add', 'origin', 'https://gitlab.com/redcore/redcore-build.git'])
subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'master', '--quiet'])
@@ -42,8 +39,8 @@ def gitlabStart():
@animation.wait('injecting gentoo linux portage tree - branch master')
def setPagureMasterStage1():
- if not os.path.isdir(os.path.join(gentooEbuildDir, '.git')):
- os.chdir(gentooEbuildDir)
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.gentooEbuildDir, '.git')):
+ os.chdir(sisyphus.filesystem.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'])
@@ -51,8 +48,8 @@ def setPagureMasterStage1():
@animation.wait('injecting redcore linux ebuild tree - branch master')
def setPagureMasterStage2():
- if not os.path.isdir(os.path.join(redcoreEbuildDir, '.git')):
- os.chdir(redcoreEbuildDir)
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.redcoreEbuildDir, '.git')):
+ os.chdir(sisyphus.filesystem.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'])
@@ -60,8 +57,8 @@ def setPagureMasterStage2():
@animation.wait('injecting redcore linux portage configuration - branch master')
def setPagureMasterStage3():
- if not os.path.isdir(os.path.join(portageConfigDir, '.git')):
- os.chdir(portageConfigDir)
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.portageConfigDir, '.git')):
+ os.chdir(sisyphus.filesystem.portageConfigDir)
subprocess.call(['git', 'init', '-q'])
subprocess.call(['git', 'remote', 'add', 'origin', 'https://pagure.io/redcore/redcore-build.git'])
subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'master', '--quiet'])
diff --git a/src/backend/branchnext.py b/src/backend/branchnext.py
index bb29b04..5c9e390 100644
--- a/src/backend/branchnext.py
+++ b/src/backend/branchnext.py
@@ -3,15 +3,12 @@
import animation
import os
import subprocess
-
-gentooEbuildDir = '/usr/ports/gentoo'
-redcoreEbuildDir = '/usr/ports/redcore'
-portageConfigDir = '/opt/redcore-build'
+import sisyphus.filesystem
@animation.wait('injecting gentoo linux portage tree - branch next')
def setGitlabNextStage1():
- if not os.path.isdir(os.path.join(gentooEbuildDir, '.git')):
- os.chdir(gentooEbuildDir)
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.gentooEbuildDir, '.git')):
+ os.chdir(sisyphus.filesystem.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'])
@@ -19,8 +16,8 @@ def setGitlabNextStage1():
@animation.wait('injecting redcore linux ebuild tree - branch next')
def setGitlabNextStage2():
- if not os.path.isdir(os.path.join(redcoreEbuildDir, '.git')):
- os.chdir(redcoreEbuildDir)
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.redcoreEbuildDir, '.git')):
+ os.chdir(sisyphus.filesystem.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'])
@@ -28,8 +25,8 @@ def setGitlabNextStage2():
@animation.wait('injecting redcore linux portage configuration - branch next')
def setGitlabNextStage3():
- if not os.path.isdir(os.path.join(portageConfigDir, '.git')):
- os.chdir(portageConfigDir)
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.portageConfigDir, '.git')):
+ os.chdir(sisyphus.filesystem.portageConfigDir)
subprocess.call(['git', 'init', '-q'])
subprocess.call(['git', 'remote', 'add', 'origin', 'https://gitlab.com/redcore/redcore-build.git'])
subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'next', '--quiet'])
@@ -42,8 +39,8 @@ def startGitlab():
@animation.wait('injecting gentoo linux portage tree - branch next')
def setPagureNextStage1():
- if not os.path.isdir(os.path.join(gentooEbuildDir, '.git')):
- os.chdir(gentooEbuildDir)
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.gentooEbuildDir, '.git')):
+ os.chdir(sisyphus.filesystem.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'])
@@ -51,8 +48,8 @@ def setPagureNextStage1():
@animation.wait('injecting redcore linux ebuild tree - branch next')
def setPagureNextStage2():
- if not os.path.isdir(os.path.join(redcoreEbuildDir, '.git')):
- os.chdir(redcoreEbuildDir)
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.redcoreEbuildDir, '.git')):
+ os.chdir(sisyphus.filesystem.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'])
@@ -60,8 +57,8 @@ def setPagureNextStage2():
@animation.wait('injecting redcore linux portage configuration - branch next')
def setPagureNextStage3():
- if not os.path.isdir(os.path.join(portageConfigDir, '.git')):
- os.chdir(portageConfigDir)
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.portageConfigDir, '.git')):
+ os.chdir(sisyphus.filesystem.portageConfigDir)
subprocess.call(['git', 'init', '-q'])
subprocess.call(['git', 'remote', 'add', 'origin', 'https://pagure.io/redcore/redcore-build.git'])
subprocess.call(['git', 'fetch', '--depth=1', 'origin', 'next', '--quiet'])
diff --git a/src/backend/branchreset.py b/src/backend/branchreset.py
index 6168a25..def225a 100644
--- a/src/backend/branchreset.py
+++ b/src/backend/branchreset.py
@@ -3,36 +3,33 @@
import animation
import os
import shutil
-
-gentooEbuildDir = '/usr/ports/gentoo'
-redcoreEbuildDir = '/usr/ports/redcore'
-portageConfigDir = '/opt/redcore-build'
+import sisyphus.filesystem
@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))
+ if os.path.isdir(sisyphus.filesystem.gentooEbuildDir):
+ for files in os.listdir(sisyphus.filesystem.gentooEbuildDir):
+ if os.path.isfile(os.path.join(sisyphus.filesystem.gentooEbuildDir, files)):
+ os.remove(os.path.join(sisyphus.filesystem.gentooEbuildDir, files))
else:
- shutil.rmtree(os.path.join(gentooEbuildDir, files))
+ shutil.rmtree(os.path.join(sisyphus.filesystem.gentooEbuildDir, files))
else:
- os.makedirs(gentooEbuildDir)
+ os.makedirs(sisyphus.filesystem.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))
+ if os.path.isdir(sisyphus.filesystem.redcoreEbuildDir):
+ for files in os.listdir(sisyphus.filesystem.redcoreEbuildDir):
+ if os.path.isfile(os.path.join(sisyphus.filesystem.redcoreEbuildDir, files)):
+ os.remove(os.path.join(sisyphus.filesystem.redcoreEbuildDir, files))
else:
- shutil.rmtree(os.path.join(redcoreEbuildDir, files))
+ shutil.rmtree(os.path.join(sisyphus.filesystem.redcoreEbuildDir, files))
else:
- os.makedirs(redcoreEbuildDir)
+ os.makedirs(sisyphus.filesystem.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))
+ if os.path.isdir(sisyphus.filesystem.portageConfigDir):
+ for files in os.listdir(sisyphus.filesystem.portageConfigDir):
+ if os.path.isfile(os.path.join(sisyphus.filesystem.portageConfigDir, files)):
+ os.remove(os.path.join(sisyphus.filesystem.portageConfigDir, files))
else:
- shutil.rmtree(os.path.join(portageConfigDir, files))
+ shutil.rmtree(os.path.join(sisyphus.filesystem.portageConfigDir, files))
else:
- os.makedirs(portageConfigDir)
+ os.makedirs(sisyphus.filesystem.portageConfigDir)
diff --git a/src/backend/cache.py b/src/backend/cache.py
index aaa0a32..b040323 100644
--- a/src/backend/cache.py
+++ b/src/backend/cache.py
@@ -2,13 +2,12 @@
import os
import shutil
-
-portageCacheDir = '/var/cache/packages'
+import sisyphus.filesystem
def clean():
- 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))
+ if os.path.isdir(sisyphus.filesystem.portageCacheDir):
+ for files in os.listdir(sisyphus.filesystem.portageCacheDir):
+ if os.path.isfile(os.path.join(sisyphus.filesystem.portageCacheDir, files)):
+ os.remove(os.path.join(sisyphus.filesystem.portageCacheDir, files))
else:
- shutil.rmtree(os.path.join(portageCacheDir, files))
+ shutil.rmtree(os.path.join(sisyphus.filesystem.portageCacheDir, files))
diff --git a/src/backend/check.py b/src/backend/check.py
index 2f46357..ee580a2 100644
--- a/src/backend/check.py
+++ b/src/backend/check.py
@@ -3,16 +3,14 @@
import os
import sys
import subprocess
-
-gentooEbuildDir = '/usr/ports/gentoo'
-redcoreEbuildDir = '/usr/ports/redcore'
+import sisyphus.filesystem
def root():
if not os.getuid() == 0:
sys.exit("\nYou need root permissions to do this, exiting!\n")
def portage():
- os.chdir(gentooEbuildDir)
+ os.chdir(sisyphus.filesystem.gentooEbuildDir)
needsPortageSync = int()
localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
@@ -28,7 +26,7 @@ def portage():
return needsPortageSync
def overlay():
- os.chdir(redcoreEbuildDir)
+ os.chdir(sisyphus.filesystem.redcoreEbuildDir)
needsOverlaySync = int()
localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
diff --git a/src/backend/database.py b/src/backend/database.py
index 277a265..21db17e 100644
--- a/src/backend/database.py
+++ b/src/backend/database.py
@@ -6,20 +6,16 @@ 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'
+import sisyphus.filesystem
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:
+ with http.request('GET', remotePkgCsv, preload_content=False) as tmp_buffer, open(sisyphus.filesystem.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:
+ with http.request('GET', remoteDescCsv, preload_content=False) as tmp_buffer, open(sisyphus.filesystem.remoteDscsDB, 'wb') as output_file:
shutil.copyfileobj(tmp_buffer, output_file)
def makeLocal():
@@ -28,17 +24,17 @@ def makeLocal():
def syncRemote():
getRemote()
- sisyphusdb = sqlite3.connect(sisyphusDB)
+ sisyphusdb = sqlite3.connect(sisyphus.filesystem.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:
+ with open(sisyphus.filesystem.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:
+ with open(sisyphus.filesystem.remoteDscsDB) as rmtCsv:
for row in csv.reader(rmtCsv):
sisyphusdb.cursor().execute("insert into remote_descriptions (category, name, description) values (?, ?, ?);", row)
@@ -48,11 +44,11 @@ def syncRemote():
def syncLocal():
makeLocal()
- sisyphusdb = sqlite3.connect(sisyphusDB)
+ sisyphusdb = sqlite3.connect(sisyphus.filesystem.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:
+ with open(sisyphus.filesystem.localPkgsDB) as lclCsv:
for row in csv.reader(lclCsv):
sisyphusdb.cursor().execute("insert into local_packages (category, name, version, slot) values (?, ?, ?, ?);", row)
diff --git a/src/backend/filesystem.py b/src/backend/filesystem.py
new file mode 100644
index 0000000..4338a2a
--- /dev/null
+++ b/src/backend/filesystem.py
@@ -0,0 +1,12 @@
+#!/usr/bin/python3
+
+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'
diff --git a/src/backend/install.py b/src/backend/install.py
index ba1cfa0..cb13849 100644
--- a/src/backend/install.py
+++ b/src/backend/install.py
@@ -8,11 +8,10 @@ import io
import wget
import sisyphus.binhost
import sisyphus.database
+import sisyphus.filesystem
import sisyphus.solvedeps
import sisyphus.update
-portageCacheDir = '/var/cache/packages'
-
def start(pkgList):
sisyphus.update.start()
@@ -22,7 +21,7 @@ def start(pkgList):
if needsConfig == 0:
if len(areSources) == 0:
if not len(areBinaries) == 0:
- os.chdir(portageCacheDir)
+ os.chdir(sisyphus.filesystem.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]):
@@ -36,11 +35,11 @@ def start(pkgList):
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])))
+ if os.path.isdir(os.path.join(sisyphus.filesystem.portageCacheDir, CATEGORY.decode().strip())):
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(sisyphus.filesystem.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])))
+ os.makedirs(os.path.join(sisyphus.filesystem.portageCacheDir, CATEGORY.decode().strip()))
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(sisyphus.filesystem.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])
@@ -60,7 +59,7 @@ def start(pkgList):
sys.exit("\n" + "No package found; Quitting." + "\n")
else:
if not len(areBinaries) == 0:
- os.chdir(portageCacheDir)
+ os.chdir(sisyphus.filesystem.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":
@@ -75,11 +74,11 @@ def start(pkgList):
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])))
+ if os.path.isdir(os.path.join(sisyphus.filesystem.portageCacheDir, CATEGORY.decode().strip())):
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(sisyphus.filesystem.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])))
+ os.makedirs(os.path.join(sisyphus.filesystem.portageCacheDir, CATEGORY.decode().strip()))
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(sisyphus.filesystem.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])
diff --git a/src/backend/metadata.py b/src/backend/metadata.py
index fc30b15..a27e06a 100644
--- a/src/backend/metadata.py
+++ b/src/backend/metadata.py
@@ -4,16 +4,15 @@ import animation
import os
import shutil
import subprocess
-
-portageMetadataDir = '/var/cache/edb'
+import sisyphus.filesystem
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))
+ if os.path.isdir(sisyphus.filesystem.portageMetadataDir):
+ for files in os.listdir(sisyphus.filesystem.portageMetadataDir):
+ if os.path.isfile(os.path.join(sisyphus.filesystem.portageMetadataDir, files)):
+ os.remove(os.path.join(sisyphus.filesystem.portageMetadataDir, files))
else:
- shutil.rmtree(os.path.join(portageMetadataDir, files))
+ shutil.rmtree(os.path.join(sisyphus.filesystem.portageMetadataDir, files))
portageExecStage1 = subprocess.Popen(['emerge', '--quiet', '--regen'], stdout=subprocess.PIPE)
portageExecStage1.wait()
@@ -22,12 +21,12 @@ def regenSilent():
@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))
+ if os.path.isdir(sisyphus.filesystem.portageMetadataDir):
+ for files in os.listdir(sisyphus.filesystem.portageMetadataDir):
+ if os.path.isfile(os.path.join(sisyphus.filesystem.portageMetadataDir, files)):
+ os.remove(os.path.join(sisyphus.filesystem.portageMetadataDir, files))
else:
- shutil.rmtree(os.path.join(portageMetadataDir, files))
+ shutil.rmtree(os.path.join(sisyphus.filesystem.portageMetadataDir, files))
portageExecStage1 = subprocess.Popen(['emerge', '--quiet', '--regen'], stdout=subprocess.PIPE)
portageExecStage1.wait()
diff --git a/src/backend/mirror.py b/src/backend/mirror.py
index 7d041cf..6843e59 100644
--- a/src/backend/mirror.py
+++ b/src/backend/mirror.py
@@ -1,11 +1,11 @@
#!/usr/bin/python3
-mirrorCfg = '/etc/sisyphus/mirrors.conf'
+import sisyphus.filesystem
def getList():
mirrorList = []
- with open(mirrorCfg) as mirrorFile:
+ with open(sisyphus.filesystem.mirrorCfg) as mirrorFile:
for line in mirrorFile.readlines():
if 'PORTAGE_BINHOST=' in line:
url = line.split("=")[1].replace('"', '').rstrip()
@@ -27,7 +27,7 @@ def printList():
print(i + 1, ' ', line['Url'])
def writeList(mirrorList):
- with open(mirrorCfg, 'w+') as mirrorFile:
+ with open(sisyphus.filesystem.mirrorCfg, 'w+') as mirrorFile:
mirrorFile.write("#######################################################\n")
mirrorFile.write("# Support for multiple mirrors is somewhat incomplete #\n")
mirrorFile.write("#######################################################\n")
diff --git a/src/backend/rescue.py b/src/backend/rescue.py
index 18523d4..96d347f 100644
--- a/src/backend/rescue.py
+++ b/src/backend/rescue.py
@@ -3,22 +3,18 @@
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'
+import sisyphus.filesystem
@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)
+ if os.path.exists(sisyphus.filesystem.remotePkgsDB):
+ os.remove(sisyphus.filesystem.remotePkgsDB)
+ if os.path.exists(sisyphus.filesystem.remoteDscsDB):
+ os.remove(sisyphus.filesystem.remoteDscsDB)
+ if os.path.exists(sisyphus.filesystem.localPkgsDB):
+ os.remove(sisyphus.filesystem.localPkgsDB)
+ if os.path.exists(sisyphus.filesystem.sisyphusDB):
+ os.remove(sisyphus.filesystem.sisyphusDB)
sisyphus.database.syncRemote()
sisyphus.database.syncLocal()
diff --git a/src/backend/sync.py b/src/backend/sync.py
index b8fd91c..65afd2f 100644
--- a/src/backend/sync.py
+++ b/src/backend/sync.py
@@ -2,13 +2,10 @@
import os
import subprocess
-
-gentooEbuildDir = '/usr/ports/gentoo'
-redcoreEbuildDir = '/usr/ports/redcore'
-portageConfigDir = '/opt/redcore-build'
+import sisyphus.filesystem
def portage():
- os.chdir(gentooEbuildDir)
+ os.chdir(sisyphus.filesystem.gentooEbuildDir)
localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
remoteBranch = subprocess.check_output(['git', 'rev-parse', '--symbolic-full-name', '@{u}'])
@@ -18,7 +15,7 @@ def portage():
gitExecStage2.wait()
def overlay():
- os.chdir(redcoreEbuildDir)
+ os.chdir(sisyphus.filesystem.redcoreEbuildDir)
localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
remoteBranch = subprocess.check_output(['git', 'rev-parse', '--symbolic-full-name', '@{u}'])
@@ -28,7 +25,7 @@ def overlay():
gitExecStage2.wait()
def portageCfg():
- os.chdir(portageConfigDir)
+ os.chdir(sisyphus.filesystem.portageConfigDir)
localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
remoteBranch = subprocess.check_output(['git', 'rev-parse', '--symbolic-full-name', '@{u}'])
diff --git a/src/backend/upgrade.py b/src/backend/upgrade.py
index 0a3762d..d2961d6 100644
--- a/src/backend/upgrade.py
+++ b/src/backend/upgrade.py
@@ -8,11 +8,10 @@ import io
import wget
import sisyphus.binhost
import sisyphus.database
+import sisyphus.filesystem
import sisyphus.solvedeps
import sisyphus.update
-portageCacheDir = '/var/cache/packages'
-
def start():
sisyphus.update.start()
@@ -22,7 +21,7 @@ def start():
if needsConfig == 0:
if len(areSources) == 0:
if not len(areBinaries) == 0:
- os.chdir(portageCacheDir)
+ os.chdir(sisyphus.filesystem.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]):
@@ -36,11 +35,11 @@ def start():
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])))
+ if os.path.isdir(os.path.join(sisyphus.filesystem.portageCacheDir, CATEGORY.decode().strip())):
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(sisyphus.filesystem.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])))
+ os.makedirs(os.path.join(sisyphus.filesystem.portageCacheDir, CATEGORY.decode().strip()))
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(sisyphus.filesystem.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])
@@ -60,7 +59,7 @@ def start():
sys.exit("\n" + "No package upgrades found; Quitting." + "\n")
else:
if not len(areBinaries) == 0:
- os.chdir(portageCacheDir)
+ os.chdir(sisyphus.filesystem.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":
@@ -75,11 +74,11 @@ def start():
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])))
+ if os.path.isdir(os.path.join(sisyphus.filesystem.portageCacheDir, CATEGORY.decode().strip())):
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(sisyphus.filesystem.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])))
+ os.makedirs(os.path.join(sisyphus.filesystem.portageCacheDir, CATEGORY.decode().strip()))
+ shutil.move(binary.rstrip().split("/")[1], os.path.join(os.path.join(sisyphus.filesystem.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])