diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2021-01-30 14:41:20 +0000 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2021-01-30 14:41:20 +0000 |
commit | 515171c670ed6ae373002196b8cd3dd1154cd5cc (patch) | |
tree | 24c23352ea23f85f95cb065d200621949fd986c7 /src/backend | |
parent | 1e64e01b293ecd775af05816cc3d299ebadb5960 (diff) |
ui : move package operations into the backend
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/__init__.py | 14 | ||||
-rw-r--r-- | src/backend/autoremove.py | 16 | ||||
-rw-r--r-- | src/backend/ebuildinstall.py (renamed from src/backend/installebuild.py) | 0 | ||||
-rw-r--r-- | src/backend/ebuildsearch.py (renamed from src/backend/searchebuild.py) | 0 | ||||
-rw-r--r-- | src/backend/ebuildupgrade.py (renamed from src/backend/upgradeebuild.py) | 0 | ||||
-rw-r--r-- | src/backend/forceuninstall.py (renamed from src/backend/uninstallforce.py) | 0 | ||||
-rw-r--r-- | src/backend/install.py (renamed from src/backend/installbinary.py) | 42 | ||||
-rw-r--r-- | src/backend/search.py (renamed from src/backend/searchbinary.py) | 0 | ||||
-rw-r--r-- | src/backend/uninstall.py | 16 | ||||
-rw-r--r-- | src/backend/upgrade.py (renamed from src/backend/upgradebinary.py) | 48 |
10 files changed, 125 insertions, 11 deletions
diff --git a/src/backend/__init__.py b/src/backend/__init__.py index 59c927c..d868abb 100644 --- a/src/backend/__init__.py +++ b/src/backend/__init__.py @@ -6,23 +6,23 @@ from .cache import * from .check import * from .csvfiles import * from .database import * +from .ebuildinstall import * +from .ebuildsearch import * +from .ebuildupgrade import * from .filesystem import * -from .installbinary import * -from .installebuild import * +from .forceuninstall import * +from .install import * from .killportage import * from .metadata import * from .mirror import * from .rescue import * -from .searchbinary import * -from .searchebuild import * +from .search import * from .setjobs import * from .setprofile import * from .solvedeps import * from .spmsync import * from .sync import * from .sysinfo import * -from .uninstallforce import * from .uninstall import * from .update import * -from .upgradebinary import * -from .upgradeebuild import * +from .upgrade import * diff --git a/src/backend/autoremove.py b/src/backend/autoremove.py index 497d8e5..5c2ee7a 100644 --- a/src/backend/autoremove.py +++ b/src/backend/autoremove.py @@ -1,9 +1,12 @@ #!/usr/bin/python3 +import atexit +import io import subprocess +import sys import sisyphus.check import sisyphus.database -import sys +import sisyphus.killportage def start(): if sisyphus.check.root(): @@ -12,3 +15,14 @@ def start(): sisyphus.database.syncLocal() else: sys.exit("\nYou need root permissions to do this, exiting!\n") + +def startqt(): + portageExec = subprocess.Popen(['emerge', '--depclean'], stdout=subprocess.PIPE) + # kill portage if the program dies or it's terminated by the user + atexit.register(sisyphus.killportage.start, portageExec) + + for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"): + print(portageOutput.rstrip()) + + portageExec.wait() + sisyphus.database.syncLocal() diff --git a/src/backend/installebuild.py b/src/backend/ebuildinstall.py index 27062bf..27062bf 100644 --- a/src/backend/installebuild.py +++ b/src/backend/ebuildinstall.py diff --git a/src/backend/searchebuild.py b/src/backend/ebuildsearch.py index c9b5862..c9b5862 100644 --- a/src/backend/searchebuild.py +++ b/src/backend/ebuildsearch.py diff --git a/src/backend/upgradeebuild.py b/src/backend/ebuildupgrade.py index 21add70..21add70 100644 --- a/src/backend/upgradeebuild.py +++ b/src/backend/ebuildupgrade.py diff --git a/src/backend/uninstallforce.py b/src/backend/forceuninstall.py index 11139f4..11139f4 100644 --- a/src/backend/uninstallforce.py +++ b/src/backend/forceuninstall.py diff --git a/src/backend/installbinary.py b/src/backend/install.py index d161a3c..cf6d55c 100644 --- a/src/backend/installbinary.py +++ b/src/backend/install.py @@ -1,15 +1,17 @@ #!/usr/bin/python3 +import atexit +import io import os import shutil import subprocess import sys -import io import wget import sisyphus.binhost import sisyphus.check import sisyphus.database import sisyphus.filesystem +import sisyphus.killportage import sisyphus.solvedeps import sisyphus.update @@ -66,3 +68,41 @@ def start(pkgname): sys.exit("\n" + "Invalid request;" " " + "Use" + " " + "'" + "sisyphus install" + " " + " ".join(pkgname) + " " + "--ebuild" + "'" + ";" + " " + "Quitting." + "\n") else: sys.exit("\nYou need root permissions to do this, exiting!\n") + +def startqt(pkgname): + binhostURL = sisyphus.binhost.getURL() + areBinaries,areSources,needsConfig = sisyphus.solvedeps.package.__wrapped__(pkgname) #undecorate + + os.chdir(sisyphus.filesystem.portageCacheDir) + print("\n" + "These are the binary packages that will be merged, in order:" + "\n\n" + " ".join(areBinaries) + "\n\n" + "Total:" + " " + str(len(areBinaries)) + " " + "binary package(s)" + "\n\n") + 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(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(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]) + + portageExec = subprocess.Popen(['emerge', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--misspell-suggestion=n', '--fuzzy-search=n'] + pkgname, stdout=subprocess.PIPE) + # kill portage if the program dies or it's terminated by the user + atexit.register(sisyphus.killportage.start, portageExec) + + 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() diff --git a/src/backend/searchbinary.py b/src/backend/search.py index b52c3c6..b52c3c6 100644 --- a/src/backend/searchbinary.py +++ b/src/backend/search.py diff --git a/src/backend/uninstall.py b/src/backend/uninstall.py index 8da7e79..9d76067 100644 --- a/src/backend/uninstall.py +++ b/src/backend/uninstall.py @@ -1,9 +1,12 @@ #!/usr/bin/python3 +import atexit +import io import subprocess +import sys import sisyphus.check import sisyphus.database -import sys +import sisyphus.killportage def start(pkgname): if sisyphus.check.root(): @@ -12,3 +15,14 @@ def start(pkgname): sisyphus.database.syncLocal() else: sys.exit("\nYou need root permissions to do this, exiting!\n") + +def startqt(pkgname): + portageExec = subprocess.Popen(['emerge', '--depclean'] + pkgname, stdout=subprocess.PIPE) + # kill portage if the program dies or it's terminated by the user + atexit.register(sisyphus.killportage.start, portageExec) + + for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"): + print(portageOutput.rstrip()) + + portageExec.wait() + sisyphus.database.syncLocal() diff --git a/src/backend/upgradebinary.py b/src/backend/upgrade.py index 9b14868..06839f6 100644 --- a/src/backend/upgradebinary.py +++ b/src/backend/upgrade.py @@ -1,15 +1,17 @@ #!/usr/bin/python3 +import atexit +import io import os import shutil import subprocess import sys -import io import wget import sisyphus.binhost import sisyphus.check import sisyphus.database import sisyphus.filesystem +import sisyphus.killportage import sisyphus.solvedeps import sisyphus.update @@ -66,3 +68,47 @@ def start(): sys.exit("\n" + "Invalid request;" " " + "Use" + " " + "'" + "sisyphus upgrade --ebuild" + "'" + ";" + " " + "Quitting." + "\n") else: sys.exit("\nYou need root permissions to do this, exiting!\n") + +def startqt() + binhostURL = sisyphus.binhost.getURL() + areBinaries,areSources,needsConfig = sisyphus.solvedeps.world.__wrapped__() #undecorate + + if not len(areSources) == 0: + print("\n" + "Source package(s) found in the mix;" + " " + "Use sisyphus CLI:" + " " + "'" + "sisyphus upgrade --ebuild" + "'" + " " + "to perform the upgrade;" + " " + "Aborting." + "\n") + else: + if not len(areBinaries) == 0: + os.chdir(sisyphus.filesystem.portageCacheDir) + print("\n" + "These are the binary packages that will be merged, in order:" + "\n\n" + " ".join(areBinaries) + "\n\n" + "Total:" + " " + str(len(areBinaries)) + " " + "binary package(s)" + "\n\n") + 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(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(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]) + + 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) + # kill portage if the program dies or it's terminated by the user + atexit.register(sisyphus.killportage.start, portageExec) + + 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: + print("\n" + "No package upgrades found; Quitting." + "\n") |