From 2b1a995b3b86c8efcca3af4ec760b6b45a564120 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 11 Nov 2018 21:35:34 +0000 Subject: prevent false positives when system is set to srcmode, and install/upgrade is used instead of hybrid-install/hybrid-upgrade --- src/backend/libsisyphus.py | 148 ++++++++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 70 deletions(-) (limited to 'src') diff --git a/src/backend/libsisyphus.py b/src/backend/libsisyphus.py index 541aec8..32b96dc 100644 --- a/src/backend/libsisyphus.py +++ b/src/backend/libsisyphus.py @@ -223,42 +223,46 @@ def startInstall(pkgList): binhostURL = getBinhostURL() binaryDeps = getPkgBinaryDeps(pkgList) + sourceDeps = getPkgSourceDeps(pkgList) binaryPkgs = [] - 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)) + " " + "binary 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") - - 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() + 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)) + " " + "binary 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") + + 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" + "Ok; Quitting.") else: - sys.exit("\n" + "Ok; quitting.") + sys.exit("\n" + "No package found; Quitting." + "\n") else: - sys.exit("\n" + "No such binary package; quitting." + "\n") + sys.exit("\n" + "No binary package found; Source package found; Use sisyphus hybrid-install; Quitting." + "\n") def startHybridInstall(pkgList): syncAll() @@ -300,9 +304,9 @@ def startHybridInstall(pkgList): portageExec.wait() syncLocalDatabase() else: - sys.exit("\n" + "Ok; quitting.") + sys.exit("\n" + "Ok; Quitting.") else: - sys.exit("\n" + "No such binary package; quitting." + "\n") + sys.exit("\n" + "No package found; Quitting." + "\n") else: if not len(binaryDeps) == 0: os.chdir(portageCache) @@ -336,7 +340,7 @@ def startHybridInstall(pkgList): portageExec.wait() syncLocalDatabase() else: - sys.exit("\n" + "Ok; quitting.") + sys.exit("\n" + "Ok; Quitting.") else: sys.exit("\n" + "This part is not yet implemented; quitting." + "\n") @@ -345,42 +349,46 @@ def startUpgrade(): binhostURL = getBinhostURL() binaryDeps = getWorldBinaryDeps() + sourceDeps = getWorldSourceDeps() binaryPkgs = [] - 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)) + " " + "binary 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") - - 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() + 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)) + " " + "binary 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") + + 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" + "Ok; Quitting.") else: - sys.exit("\n" + "Ok; quitting.") + sys.exit("\n" + "No package upgrades found; Quitting." + "\n") else: - sys.exit("\n" + "Nothing to upgrade; quitting." + "\n") + sys.exit("\n" + "No binary package upgrades found; Source package upgrades found; Use sisyphus hybrid-upgrade; Quitting." + "\n") def startHybridUpgrade(): syncAll() @@ -422,9 +430,9 @@ def startHybridUpgrade(): portageExec.wait() syncLocalDatabase() else: - sys.exit("\n" + "Ok; quitting.") + sys.exit("\n" + "Ok; Quitting.") else: - sys.exit("\n" + "Nothing to upgrade; quitting." + "\n") + sys.exit("\n" + "No package upgrades found; Quitting." + "\n") else: if not len(binaryDeps) == 0: os.chdir(portageCache) @@ -458,7 +466,7 @@ def startHybridUpgrade(): portageExec.wait() syncLocalDatabase() else: - sys.exit("\n" + "Ok; quitting.") + sys.exit("\n" + "Ok; Quitting.") else: sys.exit("\n" + "This part is not yet implemented; quitting." + "\n") -- cgit v1.2.3