summaryrefslogtreecommitdiff
path: root/src/backend/solverevdeps.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/solverevdeps.py')
-rw-r--r--src/backend/solverevdeps.py42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/backend/solverevdeps.py b/src/backend/solverevdeps.py
index 0400be9..12b4eb4 100644
--- a/src/backend/solverevdeps.py
+++ b/src/backend/solverevdeps.py
@@ -18,10 +18,33 @@ signal.signal(signal.SIGINT, sigint_handler)
@animation.wait('resolving reverse dependencies')
def start(pkgname=None, depclean=False, unmerge=False):
+ is_installed = int(1)
is_needed = int(0)
+ is_vague = int(0)
if unmerge:
- pass # behave like portage and ignore reverse dependencies
+ is_needed = int(0)
+ try:
+ p_exe = subprocess.Popen(['emerge', '--unmerge', '--quiet', '--pretend', '--verbose'] + list(
+ pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+ stdout, stderr = p_exe.communicate()
+
+ for p_out in stderr.decode('utf-8').splitlines():
+ if any(key in p_out for key in ["Couldn't find",
+ "to depclean."]):
+ is_installed = int(0)
+
+ if any(key in p_out for key in ["short ebuild name",
+ "is ambiguous"]):
+ is_vague = int(1)
+ except KeyboardInterrupt:
+ p_exe.terminate()
+ try:
+ p_exe.wait(1)
+ except subprocess.TimeoutExpired:
+ p_exe.kill()
+ sys.exit()
else:
try:
p_exe = subprocess.Popen(['emerge', '--depclean', '--quiet', '--pretend',
@@ -30,11 +53,19 @@ def start(pkgname=None, depclean=False, unmerge=False):
stdout, stderr = p_exe.communicate()
for p_out in stdout.decode('utf-8').splitlines():
- if any(key in p_out for key in ["pulled in by:", "required"]):
+ if any(key in p_out for key in ["pulled in by:",
+ "required"]):
is_needed = int(1)
- pickle.dump(is_needed, open(os.path.join(
- sisyphus.getfs.p_mtd_dir, "sisyphus_pkgrevdeps.pickle"), "wb"))
+ for p_out in stderr.decode('utf-8').splitlines():
+ if any(key in p_out for key in ["Couldn't find",
+ "to depclean."]):
+ is_installed = int(0)
+
+ if any(key in p_out for key in ["short ebuild name",
+ "is ambiguous"]):
+ is_vague = int(1)
+
except KeyboardInterrupt:
p_exe.terminate()
try:
@@ -42,3 +73,6 @@ def start(pkgname=None, depclean=False, unmerge=False):
except subprocess.TimeoutExpired:
p_exe.kill()
sys.exit()
+
+ pickle.dump([is_installed, is_needed, is_vague], open(os.path.join(
+ sisyphus.getfs.p_mtd_dir, "sisyphus_pkgrevdeps.pickle"), "wb"))