From 515171c670ed6ae373002196b8cd3dd1154cd5cc Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sat, 30 Jan 2021 14:41:20 +0000 Subject: ui : move package operations into the backend --- src/backend/__init__.py | 14 ++--- src/backend/autoremove.py | 16 ++++- src/backend/ebuildinstall.py | 125 ++++++++++++++++++++++++++++++++++++ src/backend/ebuildsearch.py | 6 ++ src/backend/ebuildupgrade.py | 126 +++++++++++++++++++++++++++++++++++++ src/backend/forceuninstall.py | 14 +++++ src/backend/install.py | 108 +++++++++++++++++++++++++++++++ src/backend/installbinary.py | 68 -------------------- src/backend/installebuild.py | 125 ------------------------------------ src/backend/search.py | 133 +++++++++++++++++++++++++++++++++++++++ src/backend/searchbinary.py | 133 --------------------------------------- src/backend/searchebuild.py | 6 -- src/backend/uninstall.py | 16 ++++- src/backend/uninstallforce.py | 14 ----- src/backend/upgrade.py | 114 +++++++++++++++++++++++++++++++++ src/backend/upgradebinary.py | 68 -------------------- src/backend/upgradeebuild.py | 126 ------------------------------------- src/frontend/cli/sisyphus-cli.py | 14 ++--- src/frontend/gui/sisyphus-gui.py | 113 ++------------------------------- 19 files changed, 674 insertions(+), 665 deletions(-) create mode 100644 src/backend/ebuildinstall.py create mode 100644 src/backend/ebuildsearch.py create mode 100644 src/backend/ebuildupgrade.py create mode 100644 src/backend/forceuninstall.py create mode 100644 src/backend/install.py delete mode 100644 src/backend/installbinary.py delete mode 100644 src/backend/installebuild.py create mode 100644 src/backend/search.py delete mode 100644 src/backend/searchbinary.py delete mode 100644 src/backend/searchebuild.py delete mode 100644 src/backend/uninstallforce.py create mode 100644 src/backend/upgrade.py delete mode 100644 src/backend/upgradebinary.py delete mode 100644 src/backend/upgradeebuild.py 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/ebuildinstall.py b/src/backend/ebuildinstall.py new file mode 100644 index 0000000..27062bf --- /dev/null +++ b/src/backend/ebuildinstall.py @@ -0,0 +1,125 @@ +#!/usr/bin/python3 + +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.solvedeps +import sisyphus.update + +def start(pkgname): + if sisyphus.check.root(): + sisyphus.update.start() + + binhostURL = sisyphus.binhost.getURL() + areBinaries,areSources,needsConfig = sisyphus.solvedeps.package(pkgname) + + if needsConfig == 0: + if len(areSources) == 0: + if not len(areBinaries) == 0: + os.chdir(sisyphus.filesystem.portageCacheDir) + print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + " ".join(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(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'] + list(pkgname), 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(sisyphus.filesystem.portageCacheDir) + print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + " ".join(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" + " ".join(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(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', '--rebuilt-binaries', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), 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" + " ".join(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'] + list(pkgname), 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'] + list(pkgname), 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") + else: + sys.exit("\nYou need root permissions to do this, exiting!\n") diff --git a/src/backend/ebuildsearch.py b/src/backend/ebuildsearch.py new file mode 100644 index 0000000..c9b5862 --- /dev/null +++ b/src/backend/ebuildsearch.py @@ -0,0 +1,6 @@ +#!/usr/bin/python3 + +import subprocess + +def start(pkgname): + subprocess.call(['emerge', '--search', '--getbinpkg'] + list(pkgname)) diff --git a/src/backend/ebuildupgrade.py b/src/backend/ebuildupgrade.py new file mode 100644 index 0000000..21add70 --- /dev/null +++ b/src/backend/ebuildupgrade.py @@ -0,0 +1,126 @@ +#!/usr/bin/python3 + +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.solvedeps +import sisyphus.update + +def start(): + if sisyphus.check.root(): + 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(sisyphus.filesystem.portageCacheDir) + print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + " ".join(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(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) + + 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(sisyphus.filesystem.portageCacheDir) + print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + " ".join(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" + " ".join(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(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', '--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" + " ".join(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") + else: + sys.exit("\nYou need root permissions to do this, exiting!\n") + diff --git a/src/backend/forceuninstall.py b/src/backend/forceuninstall.py new file mode 100644 index 0000000..11139f4 --- /dev/null +++ b/src/backend/forceuninstall.py @@ -0,0 +1,14 @@ +#!/usr/bin/python3 + +import subprocess +import sisyphus.check +import sisyphus.database +import sys + +def start(pkgname): + if sisyphus.check.root(): + portageExec = subprocess.Popen(['emerge', '--quiet', '--unmerge', '--ask'] + list(pkgname)) + portageExec.wait() + sisyphus.database.syncLocal() + else: + sys.exit("\nYou need root permissions to do this, exiting!\n") diff --git a/src/backend/install.py b/src/backend/install.py new file mode 100644 index 0000000..cf6d55c --- /dev/null +++ b/src/backend/install.py @@ -0,0 +1,108 @@ +#!/usr/bin/python3 + +import atexit +import io +import os +import shutil +import subprocess +import sys +import wget +import sisyphus.binhost +import sisyphus.check +import sisyphus.database +import sisyphus.filesystem +import sisyphus.killportage +import sisyphus.solvedeps +import sisyphus.update + +def start(pkgname): + if sisyphus.check.root(): + sisyphus.update.start() + + binhostURL = sisyphus.binhost.getURL() + areBinaries,areSources,needsConfig = sisyphus.solvedeps.package(pkgname) + + if needsConfig == 0: + if len(areSources) == 0: + if not len(areBinaries) == 0: + os.chdir(sisyphus.filesystem.portageCacheDir) + print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + " ".join(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(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'] + list(pkgname), 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: + sys.exit("\n" + "Source package(s) found in the mix;" + " " + "Use" + " " + "'" + "sisyphus install" + " " + " ".join(pkgname) + " " + "--ebuild" + "'" + ";" + " " + "Quitting." + "\n") + else: + # don't silently fail if a source package requested without the --ebuild option needs a keyword, mask, REQUIRED_USE or USE change + 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/installbinary.py b/src/backend/installbinary.py deleted file mode 100644 index d161a3c..0000000 --- a/src/backend/installbinary.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/python3 - -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.solvedeps -import sisyphus.update - -def start(pkgname): - if sisyphus.check.root(): - sisyphus.update.start() - - binhostURL = sisyphus.binhost.getURL() - areBinaries,areSources,needsConfig = sisyphus.solvedeps.package(pkgname) - - if needsConfig == 0: - if len(areSources) == 0: - if not len(areBinaries) == 0: - os.chdir(sisyphus.filesystem.portageCacheDir) - print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + " ".join(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(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'] + list(pkgname), 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: - sys.exit("\n" + "Source package(s) found in the mix;" + " " + "Use" + " " + "'" + "sisyphus install" + " " + " ".join(pkgname) + " " + "--ebuild" + "'" + ";" + " " + "Quitting." + "\n") - else: - # don't silently fail if a source package requested without the --ebuild option needs a keyword, mask, REQUIRED_USE or USE change - 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") diff --git a/src/backend/installebuild.py b/src/backend/installebuild.py deleted file mode 100644 index 27062bf..0000000 --- a/src/backend/installebuild.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/python3 - -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.solvedeps -import sisyphus.update - -def start(pkgname): - if sisyphus.check.root(): - sisyphus.update.start() - - binhostURL = sisyphus.binhost.getURL() - areBinaries,areSources,needsConfig = sisyphus.solvedeps.package(pkgname) - - if needsConfig == 0: - if len(areSources) == 0: - if not len(areBinaries) == 0: - os.chdir(sisyphus.filesystem.portageCacheDir) - print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + " ".join(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(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'] + list(pkgname), 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(sisyphus.filesystem.portageCacheDir) - print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + " ".join(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" + " ".join(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(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', '--rebuilt-binaries', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), 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" + " ".join(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'] + list(pkgname), 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'] + list(pkgname), 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") - else: - sys.exit("\nYou need root permissions to do this, exiting!\n") diff --git a/src/backend/search.py b/src/backend/search.py new file mode 100644 index 0000000..b52c3c6 --- /dev/null +++ b/src/backend/search.py @@ -0,0 +1,133 @@ +#!/usr/bin/python3 + +import sisyphus.check +import sisyphus.filesystem +import sisyphus.update +import sqlite3 + +def searchDB(filter, cat = '', pn = '', desc = ''): + NOVIRT = "AND cat NOT LIKE 'virtual'" + SELECTS = { + 'all': f'''SELECT + i.category AS cat, + i.name as pn, + i.version as iv, + IFNULL(a.version, 'alien') AS av, + d.description AS desc + FROM local_packages AS i LEFT OUTER JOIN remote_packages as a + ON i.category = a.category + AND i.name = a.name + AND i.slot = a.slot + LEFT JOIN remote_descriptions AS d ON i.name = d.name AND i.category = d.category + WHERE cat LIKE '%{cat}%' AND pn LIKE '%{pn}%' AND desc LIKE '%{desc}%' {NOVIRT} + UNION + SELECT + a.category AS cat, + a.name as pn, + IFNULL(i.version, 'None') AS iv, + a.version as av, + d.description AS desc + FROM remote_packages AS a LEFT OUTER JOIN local_packages AS i + ON a.category = i.category + AND a.name = i.name + AND a.slot = i.slot + LEFT JOIN remote_descriptions AS d ON a.name = d.name AND a.category = d.category + WHERE cat LIKE '%{cat}%' AND pn LIKE '%{pn}%' AND desc LIKE '%{desc}%' {NOVIRT}''', + 'installed': f'''SELECT + i.category AS cat, + i.name AS pn, + i.version AS iv, + a.version as av, + d.description AS desc + FROM local_packages AS i + LEFT JOIN remote_packages AS a + ON i.category = a.category + AND i.name = a.name + AND i.slot = a.slot + LEFT JOIN remote_descriptions AS d ON i.name = d.name AND i.category = d.category + WHERE cat LIKE '%{cat}%' AND pn LIKE '%{pn}%' AND desc LIKE '%{desc}%' {NOVIRT}''', + 'alien': f'''SELECT + i.category AS cat, + i.name AS pn, + i.version as iv, + IFNULL(a.version, 'alien') AS av, + d.description AS desc + FROM local_packages AS i + LEFT JOIN remote_packages AS a + ON a.category = i.category + AND a.name = i.name + AND a.slot = i.slot + LEFT JOIN remote_descriptions AS d ON i.name = d.name AND i.category = d.category + WHERE cat LIKE '%{cat}%' AND pn LIKE '%{pn}%' AND desc LIKE '%{desc}%' {NOVIRT} + AND av IS 'alien' ''', + 'available': f'''SELECT + a.category AS cat, + a.name AS pn, + i.version as iv, + a.version AS av, + d.description AS desc + FROM remote_packages AS a + LEFT JOIN local_packages AS i + ON a.category = i.category + AND a.name = i.name + AND a.slot = i.slot + LEFT JOIN remote_descriptions AS d ON a.name = d.name AND a.category = d.category + WHERE cat LIKE '%{cat}%' AND pn LIKE '%{pn}%' AND desc LIKE '%{desc}%' {NOVIRT} + AND iv IS NULL''', + 'upgradeable': f'''SELECT + i.category AS cat, + i.name AS pn, + i.version as iv, + a.version AS av, + d.description AS desc + FROM local_packages AS i + INNER JOIN remote_packages AS a + ON i.category = a.category + AND i.name = a.name + AND i.slot = a.slot + LEFT JOIN remote_descriptions AS d ON i.name = d.name AND i.category = d.category + WHERE cat LIKE '%{cat}%' AND pn LIKE '%{pn}%' AND desc LIKE '%{desc}%' {NOVIRT} + AND iv <> av''' + } + + with sqlite3.connect(sisyphus.filesystem.localDatabase) as db: + db.row_factory = sqlite3.Row + cursor = db.cursor() + cursor.execute(SELECTS[filter]) + rows = cursor.fetchall() + + return rows + +def tosql(string): + return '%%' if string == '' else string.replace('*', '%').replace('?', '_') + +def showSearch(filter, cat, pn, desc, single): + print(f"Searching {filter} packages ... \n") + pkglist = searchDB(filter, tosql(cat), tosql(pn), tosql(desc)) + + if len(pkglist) == 0: + print("No package found!\nUse the '--ebuild' option to search for source packages!") + else: + if single: + print(f"{'Package':45} {'Installed':20} Available") + for pkg in pkglist: + if not single: + print(f"* {pkg['cat']}/{pkg['pn']}") + print(f"\tInstalled version: {pkg['iv']}") + if pkg['av'] != 'alien': + print(f"\tLatest available version: {pkg['av']}") + else: + print(f"\tAlien package: Use `sisyphus search --ebuild {pkg['pn']}` for available version!") + print(f"\tDescription: {pkg['desc']}\n") + else: + cpn = f"{pkg['cat']}/{pkg['pn']}" + print(f"{cpn:45} {str(pkg['iv']):20} {str(pkg['av'])}") + print(f"\nFound {len(pkglist)} matching package(s) ...") + +def start(filter, cat, pn, desc, single): + if sisyphus.check.root(): + sisyphus.update.start() + else: + print("\nYou are not root, cannot fetch updates.\nSearch result may be inaccurate!\n") + + showSearch(filter, cat, pn, desc, single) diff --git a/src/backend/searchbinary.py b/src/backend/searchbinary.py deleted file mode 100644 index b52c3c6..0000000 --- a/src/backend/searchbinary.py +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/python3 - -import sisyphus.check -import sisyphus.filesystem -import sisyphus.update -import sqlite3 - -def searchDB(filter, cat = '', pn = '', desc = ''): - NOVIRT = "AND cat NOT LIKE 'virtual'" - SELECTS = { - 'all': f'''SELECT - i.category AS cat, - i.name as pn, - i.version as iv, - IFNULL(a.version, 'alien') AS av, - d.description AS desc - FROM local_packages AS i LEFT OUTER JOIN remote_packages as a - ON i.category = a.category - AND i.name = a.name - AND i.slot = a.slot - LEFT JOIN remote_descriptions AS d ON i.name = d.name AND i.category = d.category - WHERE cat LIKE '%{cat}%' AND pn LIKE '%{pn}%' AND desc LIKE '%{desc}%' {NOVIRT} - UNION - SELECT - a.category AS cat, - a.name as pn, - IFNULL(i.version, 'None') AS iv, - a.version as av, - d.description AS desc - FROM remote_packages AS a LEFT OUTER JOIN local_packages AS i - ON a.category = i.category - AND a.name = i.name - AND a.slot = i.slot - LEFT JOIN remote_descriptions AS d ON a.name = d.name AND a.category = d.category - WHERE cat LIKE '%{cat}%' AND pn LIKE '%{pn}%' AND desc LIKE '%{desc}%' {NOVIRT}''', - 'installed': f'''SELECT - i.category AS cat, - i.name AS pn, - i.version AS iv, - a.version as av, - d.description AS desc - FROM local_packages AS i - LEFT JOIN remote_packages AS a - ON i.category = a.category - AND i.name = a.name - AND i.slot = a.slot - LEFT JOIN remote_descriptions AS d ON i.name = d.name AND i.category = d.category - WHERE cat LIKE '%{cat}%' AND pn LIKE '%{pn}%' AND desc LIKE '%{desc}%' {NOVIRT}''', - 'alien': f'''SELECT - i.category AS cat, - i.name AS pn, - i.version as iv, - IFNULL(a.version, 'alien') AS av, - d.description AS desc - FROM local_packages AS i - LEFT JOIN remote_packages AS a - ON a.category = i.category - AND a.name = i.name - AND a.slot = i.slot - LEFT JOIN remote_descriptions AS d ON i.name = d.name AND i.category = d.category - WHERE cat LIKE '%{cat}%' AND pn LIKE '%{pn}%' AND desc LIKE '%{desc}%' {NOVIRT} - AND av IS 'alien' ''', - 'available': f'''SELECT - a.category AS cat, - a.name AS pn, - i.version as iv, - a.version AS av, - d.description AS desc - FROM remote_packages AS a - LEFT JOIN local_packages AS i - ON a.category = i.category - AND a.name = i.name - AND a.slot = i.slot - LEFT JOIN remote_descriptions AS d ON a.name = d.name AND a.category = d.category - WHERE cat LIKE '%{cat}%' AND pn LIKE '%{pn}%' AND desc LIKE '%{desc}%' {NOVIRT} - AND iv IS NULL''', - 'upgradeable': f'''SELECT - i.category AS cat, - i.name AS pn, - i.version as iv, - a.version AS av, - d.description AS desc - FROM local_packages AS i - INNER JOIN remote_packages AS a - ON i.category = a.category - AND i.name = a.name - AND i.slot = a.slot - LEFT JOIN remote_descriptions AS d ON i.name = d.name AND i.category = d.category - WHERE cat LIKE '%{cat}%' AND pn LIKE '%{pn}%' AND desc LIKE '%{desc}%' {NOVIRT} - AND iv <> av''' - } - - with sqlite3.connect(sisyphus.filesystem.localDatabase) as db: - db.row_factory = sqlite3.Row - cursor = db.cursor() - cursor.execute(SELECTS[filter]) - rows = cursor.fetchall() - - return rows - -def tosql(string): - return '%%' if string == '' else string.replace('*', '%').replace('?', '_') - -def showSearch(filter, cat, pn, desc, single): - print(f"Searching {filter} packages ... \n") - pkglist = searchDB(filter, tosql(cat), tosql(pn), tosql(desc)) - - if len(pkglist) == 0: - print("No package found!\nUse the '--ebuild' option to search for source packages!") - else: - if single: - print(f"{'Package':45} {'Installed':20} Available") - for pkg in pkglist: - if not single: - print(f"* {pkg['cat']}/{pkg['pn']}") - print(f"\tInstalled version: {pkg['iv']}") - if pkg['av'] != 'alien': - print(f"\tLatest available version: {pkg['av']}") - else: - print(f"\tAlien package: Use `sisyphus search --ebuild {pkg['pn']}` for available version!") - print(f"\tDescription: {pkg['desc']}\n") - else: - cpn = f"{pkg['cat']}/{pkg['pn']}" - print(f"{cpn:45} {str(pkg['iv']):20} {str(pkg['av'])}") - print(f"\nFound {len(pkglist)} matching package(s) ...") - -def start(filter, cat, pn, desc, single): - if sisyphus.check.root(): - sisyphus.update.start() - else: - print("\nYou are not root, cannot fetch updates.\nSearch result may be inaccurate!\n") - - showSearch(filter, cat, pn, desc, single) diff --git a/src/backend/searchebuild.py b/src/backend/searchebuild.py deleted file mode 100644 index c9b5862..0000000 --- a/src/backend/searchebuild.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/python3 - -import subprocess - -def start(pkgname): - subprocess.call(['emerge', '--search', '--getbinpkg'] + list(pkgname)) 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/uninstallforce.py b/src/backend/uninstallforce.py deleted file mode 100644 index 11139f4..0000000 --- a/src/backend/uninstallforce.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/python3 - -import subprocess -import sisyphus.check -import sisyphus.database -import sys - -def start(pkgname): - if sisyphus.check.root(): - portageExec = subprocess.Popen(['emerge', '--quiet', '--unmerge', '--ask'] + list(pkgname)) - portageExec.wait() - sisyphus.database.syncLocal() - else: - sys.exit("\nYou need root permissions to do this, exiting!\n") diff --git a/src/backend/upgrade.py b/src/backend/upgrade.py new file mode 100644 index 0000000..06839f6 --- /dev/null +++ b/src/backend/upgrade.py @@ -0,0 +1,114 @@ +#!/usr/bin/python3 + +import atexit +import io +import os +import shutil +import subprocess +import sys +import wget +import sisyphus.binhost +import sisyphus.check +import sisyphus.database +import sisyphus.filesystem +import sisyphus.killportage +import sisyphus.solvedeps +import sisyphus.update + +def start(): + if sisyphus.check.root(): + 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(sisyphus.filesystem.portageCacheDir) + print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + " ".join(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(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) + + 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: + sys.exit("\n" + "Source package(s) found in the mix;" + " " + "Use" + " " + "'" + "sisyphus upgrade --ebuild" + "'" + ";" + " " + "Quitting." + "\n") + else: + # don't silently fail if a source package requested without the --ebuild option needs a keyword, mask, REQUIRED_USE or USE change + 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") diff --git a/src/backend/upgradebinary.py b/src/backend/upgradebinary.py deleted file mode 100644 index 9b14868..0000000 --- a/src/backend/upgradebinary.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/python3 - -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.solvedeps -import sisyphus.update - -def start(): - if sisyphus.check.root(): - 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(sisyphus.filesystem.portageCacheDir) - print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + " ".join(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(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) - - 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: - sys.exit("\n" + "Source package(s) found in the mix;" + " " + "Use" + " " + "'" + "sisyphus upgrade --ebuild" + "'" + ";" + " " + "Quitting." + "\n") - else: - # don't silently fail if a source package requested without the --ebuild option needs a keyword, mask, REQUIRED_USE or USE change - sys.exit("\n" + "Invalid request;" " " + "Use" + " " + "'" + "sisyphus upgrade --ebuild" + "'" + ";" + " " + "Quitting." + "\n") - else: - sys.exit("\nYou need root permissions to do this, exiting!\n") diff --git a/src/backend/upgradeebuild.py b/src/backend/upgradeebuild.py deleted file mode 100644 index 21add70..0000000 --- a/src/backend/upgradeebuild.py +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/python3 - -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.solvedeps -import sisyphus.update - -def start(): - if sisyphus.check.root(): - 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(sisyphus.filesystem.portageCacheDir) - print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + " ".join(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(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) - - 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(sisyphus.filesystem.portageCacheDir) - print("\n" + "These are the binary packages that would be merged, in order:" + "\n\n" + " ".join(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" + " ".join(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(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', '--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" + " ".join(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") - else: - sys.exit("\nYou need root permissions to do this, exiting!\n") - diff --git a/src/frontend/cli/sisyphus-cli.py b/src/frontend/cli/sisyphus-cli.py index e69a547..5c87698 100755 --- a/src/frontend/cli/sisyphus-cli.py +++ b/src/frontend/cli/sisyphus-cli.py @@ -97,12 +97,12 @@ def search(package: List[str] = typer.Argument(...), cat, pn = package[0].split('/') else: cat, pn = '', package[0] - sisyphus.searchbinary.start(filter.value, cat, pn, desc, quiet) + sisyphus.search.start(filter.value, cat, pn, desc, quiet) else: if not package: raise typer.Exit('No search term provided, try: sisyphus search --help') else: - sisyphus.searchebuild.start(package) + sisyphus.ebuildsearch.start(package) @app.command("install") def install(pkgname: List[str], ebuild: bool = typer.Option(False, "--ebuild", "-e")): @@ -124,9 +124,9 @@ def install(pkgname: List[str], ebuild: bool = typer.Option(False, "--ebuild", " You can use the --ebuild option even if you don't want to install any ebuild(source) packages; It will fall back to binary packages only. """ if not ebuild: - sisyphus.installbinary.start(pkgname) + sisyphus.install.start(pkgname) else: - sisyphus.installebuild.start(pkgname) + sisyphus.ebuildinstall.start(pkgname) @app.command("uninstall") def uninstall(pkgname: List[str], force: bool = typer.Option(False, "--force", "-f")): @@ -163,7 +163,7 @@ def uninstall(pkgname: List[str], force: bool = typer.Option(False, "--force", " if not force: sisyphus.uninstall.start(pkgname) else: - sisyphus.uninstallforce.start(pkgname) + sisyphus.forceuninstall.start(pkgname) @app.command("autoremove") def autoremove(): @@ -203,9 +203,9 @@ def upgrade(ebuild: bool = typer.Option(False, "--ebuild", "-e")): You can use the --ebuild option even if you don't have any ebuild(source) packages installed; It will fall back to binary packages only. """ if not ebuild: - sisyphus.upgradebinary.start() + sisyphus.upgrade.start() else: - sisyphus.upgradeebuild.start() + sisyphus.ebuildupgrade.start() @app.command("spmsync") def spmsync(): diff --git a/src/frontend/gui/sisyphus-gui.py b/src/frontend/gui/sisyphus-gui.py index fa2b057..8930f6c 100644 --- a/src/frontend/gui/sisyphus-gui.py +++ b/src/frontend/gui/sisyphus-gui.py @@ -1,13 +1,7 @@ #!/usr/bin/python3 -import os import sys -import subprocess import sqlite3 -import io -import atexit -import wget -import shutil import sisyphus from collections import OrderedDict from PyQt5 import QtCore, QtGui, QtWidgets, uic @@ -398,125 +392,26 @@ class MainWorker(QtCore.QObject): def startInstall(self): self.started.emit() pkgname = Sisyphus.pkgname - - binhostURL = sisyphus.binhost.getURL() - areBinaries,areSources,needsConfig = sisyphus.solvedeps.package.__wrapped__(pkgname) #undecorate - - os.chdir(sisyphus.filesystem.portageCacheDir) - self.workerOutput.emit("\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]): - self.workerOutput.emit(">>> Fetching" + " " + binhostURL + binary) - wget.download(binhostURL + binary) - self.workerOutput.emit("\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(): - self.workerOutput.emit(portageOutput.rstrip() + "\n") - - portageExec.wait() - sisyphus.database.syncLocal() + sisyphus.install.startqt(pkgname) self.finished.emit() @QtCore.pyqtSlot() def startUninstall(self): self.started.emit() pkgname = Sisyphus.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"): - self.workerOutput.emit(portageOutput.rstrip() + "\n") - - portageExec.wait() - sisyphus.database.syncLocal() + sisyphus.uninstall.startqt(pkgname) self.finished.emit() @QtCore.pyqtSlot() def startUpgrade(self): self.started.emit() - - binhostURL = sisyphus.binhost.getURL() - areBinaries,areSources,needsConfig = sisyphus.solvedeps.world.__wrapped__() #undecorate - - if not len(areSources) == 0: - self.workerOutput.emit("\n" + "Source package upgrades detected; Use sisyphus CLI to perform the upgrade; Aborting." + "\n") - else: - if not len(areBinaries) == 0: - self.workerOutput.emit("\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") - os.chdir(sisyphus.filesystem.portageCacheDir) - for index, binary in enumerate([package + '.tbz2' for package in areBinaries]): - self.workerOutput.emit(">>> Fetching" + " " + binhostURL + binary) - wget.download(binhostURL + binary) - self.workerOutput.emit("\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(): - self.workerOutput.emit(portageOutput.rstrip() + "\n") - - portageExec.wait() - sisyphus.database.syncLocal() - else: - self.workerOutput.emit("\n" + "No package upgrades found; Quitting." + "\n") - + sisyphus.upgrade.startqt() self.finished.emit() @QtCore.pyqtSlot() def startAutoremove(self): self.started.emit() - 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"): - self.workerOutput.emit(portageOutput.rstrip() + "\n") - - portageExec.wait() - sisyphus.database.syncLocal() + sisyphus.autoremove.startqt() self.finished.emit() -- cgit v1.2.3