summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2018-11-11 15:21:08 +0000
committerV3n3RiX <venerix@redcorelinux.org>2018-11-11 15:21:08 +0000
commite123b0d877493e5b8f7c2c5028f832bb6ab585df (patch)
treecb1a6a888e6334006952ce3907fe5123470461b5
parentd4aac801bf44fbad975fbadf1807d73291b09dde (diff)
libsisyphus :
* implement first part of hybrid install and hybrid upgrade * for now they'll fallback to binary mode only, even if source dependencies will be found sisyphus-cly : * expose the new functions via sisyphus hybrid-install and sisyphus hybrid-upgrade
-rw-r--r--src/backend/libsisyphus.py98
-rwxr-xr-xsrc/frontend/cli/sisyphus-cli.py7
2 files changed, 102 insertions, 3 deletions
diff --git a/src/backend/libsisyphus.py b/src/backend/libsisyphus.py
index 51d61c5..f7893cc 100644
--- a/src/backend/libsisyphus.py
+++ b/src/backend/libsisyphus.py
@@ -227,7 +227,7 @@ def startInstall(pkgList):
if not len(binaryDeps) == 0:
os.chdir(portageCache)
- print("\n" + "These are the packages that would be merged, in order:" + "\n\n" + str(binaryDeps) + "\n\n" + "Total:" + " " + str(len(binaryDeps)) + " " + "package(s)" + "\n")
+ print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + str(binaryDeps) + "\n\n" + "Total:" + " " + str(len(binaryDeps)) + " " + "package(s)" + "\n")
if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
for index, url in enumerate([binhostURL + package + '.tbz2' for package in binaryDeps]):
print(">>> Fetching" + " " + url)
@@ -258,7 +258,53 @@ def startInstall(pkgList):
portageExec.wait()
syncLocalDatabase()
else:
- sys.exit("\n" + "No such package; quitting." + "\n")
+ sys.exit("\n" + "No such binary package; quitting." + "\n")
+
+def startHybridInstall(pkgList):
+ syncAll()
+
+ binhostURL = getBinhostURL()
+ binaryDeps = getPkgBinaryDeps(pkgList)
+ sourceDeps = getPkgSourceDeps(pkgList)
+ binaryPkgs = []
+
+ if len(sourceDeps) == 0:
+ if not len(binaryDeps) == 0:
+ os.chdir(portageCache)
+ print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + str(binaryDeps) + "\n\n" + "Total:" + " " + str(len(binaryDeps)) + " " + "package(s)" + "\n")
+ if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
+ for index, url in enumerate([binhostURL + package + '.tbz2' for package in binaryDeps]):
+ print(">>> Fetching" + " " + url)
+ wget.download(url)
+ print("\n")
+ else:
+ sys.exit("\n" + "Quitting!")
+
+ for index, binpkg in enumerate(binaryDeps):
+ binaryPkg = str(binpkg.rstrip().split("/")[1])
+ binaryPkgs.append(binaryPkg)
+
+ for index, binpkg in enumerate(binaryPkgs):
+ subprocess.call(['qtbz2', '-x'] + str(binpkg + '.tbz2').split())
+ CATEGORY = subprocess.check_output(['qxpak', '-x', '-O'] + str(binpkg + '.xpak').split() + ['CATEGORY'])
+ os.remove(str(binpkg + '.xpak'))
+
+ if os.path.isdir(portageCache + CATEGORY.decode().strip()):
+ shutil.move(str(binpkg + '.tbz2'), os.path.join(portageCache + CATEGORY.decode().strip(), os.path.basename(str(binpkg + '.tbz2'))))
+ else:
+ os.makedirs(portageCache + CATEGORY.decode().strip())
+ shutil.move(str(binpkg + '.tbz2'), os.path.join(portageCache + CATEGORY.decode().strip(), os.path.basename(str(binpkg + '.tbz2'))))
+
+ if os.path.exists(str(binpkg + '.tbz2')):
+ os.remove(str(binpkg + '.tbz2'))
+
+ portageExec = subprocess.Popen(['emerge', '--quiet', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--misspell-suggestion=n', '--fuzzy-search=n'] + pkgList)
+ portageExec.wait()
+ syncLocalDatabase()
+ else:
+ sys.exit("\n" + "No such binary package; quitting." + "\n")
+ else:
+ sys.exit("\n" + "This part is not yet implemented; quitting." + "\n")
def startUpgrade():
syncAll()
@@ -269,7 +315,7 @@ def startUpgrade():
if not len(binaryDeps) == 0:
os.chdir(portageCache)
- print("\n" + "These are the packages that would be merged, in order:" + "\n\n" + str(binaryDeps) + "\n\n" + "Total:" + " " + str(len(binaryDeps)) + " " + "package(s)" + "\n")
+ print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + str(binaryDeps) + "\n\n" + "Total:" + " " + str(len(binaryDeps)) + " " + "package(s)" + "\n")
if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
for index, url in enumerate([binhostURL + package + '.tbz2' for package in binaryDeps]):
print(">>> Fetching" + " " + url)
@@ -302,6 +348,52 @@ def startUpgrade():
else:
sys.exit("\n" + "Nothing to upgrade; quitting." + "\n")
+def startHybridUpgrade():
+ syncAll()
+
+ binhostURL = getBinhostURL()
+ binaryDeps = getWorldBinaryDeps()
+ sourceDeps = getWorldSourceDeps()
+ binaryPkgs = []
+
+ if len(sourceDeps) == 0:
+ if not len(binaryDeps) == 0:
+ os.chdir(portageCache)
+ print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + str(binaryDeps) + "\n\n" + "Total:" + " " + str(len(binaryDeps)) + " " + "package(s)" + "\n")
+ if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
+ for index, url in enumerate([binhostURL + package + '.tbz2' for package in binaryDeps]):
+ print(">>> Fetching" + " " + url)
+ wget.download(url)
+ print("\n")
+ else:
+ sys.exit("\n" + "Quitting!")
+
+ for index, worldpkg in enumerate(binaryDeps):
+ binaryPkg = str(worldpkg.rstrip().split("/")[1])
+ binaryPkgs.append(binaryPkg)
+
+ for index, worldpkg in enumerate(binaryPkgs):
+ subprocess.call(['qtbz2', '-x'] + str(worldpkg + '.tbz2').split())
+ CATEGORY = subprocess.check_output(['qxpak', '-x', '-O'] + str(worldpkg + '.xpak').split() + ['CATEGORY'])
+ os.remove(str(worldpkg + '.xpak'))
+
+ if os.path.isdir(portageCache + CATEGORY.decode().strip()):
+ shutil.move(str(worldpkg + '.tbz2'), os.path.join(portageCache + CATEGORY.decode().strip(), os.path.basename(str(worldpkg + '.tbz2'))))
+ else:
+ os.makedirs(portageCache + CATEGORY.decode().strip())
+ shutil.move(str(worldpkg + '.tbz2'), os.path.join(portageCache + CATEGORY.decode().strip(), os.path.basename(str(worldpkg + '.tbz2'))))
+
+ if os.path.exists(str(worldpkg + '.tbz2')):
+ os.remove(str(worldpkg + '.tbz2'))
+
+ portageExec = subprocess.Popen(['emerge', '--quiet', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'])
+ portageExec.wait()
+ syncLocalDatabase()
+ else:
+ sys.exit("\n" + "Nothing to upgrade; quitting." + "\n")
+ else:
+ sys.exit("\n" + "This part is not yet implemented; quitting." + "\n")
+
def startUninstall(pkgList):
portageExec = subprocess.Popen(['emerge', '--quiet', '--depclean', '--ask'] + pkgList)
portageExec.wait()
diff --git a/src/frontend/cli/sisyphus-cli.py b/src/frontend/cli/sisyphus-cli.py
index ff68593..3a1623e 100755
--- a/src/frontend/cli/sisyphus-cli.py
+++ b/src/frontend/cli/sisyphus-cli.py
@@ -12,6 +12,11 @@ if "__main__" == __name__:
sys.exit("\n" + "Nothing to install, please give at least one package name; quitting" + "\n")
else:
startInstall(pkgList)
+ elif "hybrid-install" in sys.argv[1:]:
+ if not pkgList:
+ sys.exit("\n" + "Nothing to install, please give at least one package name; quitting" + "\n")
+ else:
+ startHybridInstall(pkgList)
elif "uninstall" in sys.argv[1:]:
if not pkgList:
sys.exit("\n" + "Nothing to uninstall, please give at least one package name; quitting" + "\n")
@@ -28,6 +33,8 @@ if "__main__" == __name__:
startSync()
elif "upgrade" in sys.argv[1:]:
startUpgrade()
+ elif "hybrid-upgrade" in sys.argv[1:]:
+ startHybridUpgrade()
elif "search" in sys.argv[1:]:
if not pkgList:
sys.exit("\n" + "Nothing to search, please give at least one package name; quitting" + "\n")