public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Matt Turner <mattst88@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: Matt Turner <mattst88@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH gentoolkit 2/2] eclean: Add option to delete binpkgs with changed deps
Date: Thu, 20 Feb 2020 21:29:45 -0800	[thread overview]
Message-ID: <20200221052945.972092-2-mattst88@gentoo.org> (raw)
In-Reply-To: <20200221052945.972092-1-mattst88@gentoo.org>

Signed-off-by: Matt Turner <mattst88@gentoo.org>
---
 pym/gentoolkit/eclean/cli.py    |  7 ++++++-
 pym/gentoolkit/eclean/search.py | 30 +++++++++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/pym/gentoolkit/eclean/cli.py b/pym/gentoolkit/eclean/cli.py
index 1a99b3e..39aafd3 100644
--- a/pym/gentoolkit/eclean/cli.py
+++ b/pym/gentoolkit/eclean/cli.py
@@ -147,6 +147,8 @@ def printUsage(_error=None, help=None):
 	or help in ('all','packages'):
 		print( "Available", yellow("options"),"for the",
 				green("packages"),"action:", file=out)
+		print( yellow("     --changed-deps")+
+			"               - delete packages for which ebuild dependencies have changed", file=out)
 		print( yellow(" -i, --ignore-failure")+
 			"             - ignore failure to locate PKGDIR", file=out)
 		print( file=out)
@@ -263,6 +265,8 @@ def parseArgs(options={}):
 				options['size-limit'] = parseSize(a)
 			elif o in ("-v", "--verbose") and not options['quiet']:
 					options['verbose'] = True
+			elif o in ("--changed-deps"):
+				options['changed-deps'] = True
 			elif o in ("-i", "--ignore-failure"):
 				options['ignore-failure'] = True
 			else:
@@ -290,7 +294,7 @@ def parseArgs(options={}):
 	getopt_options['short']['distfiles'] = "fs:"
 	getopt_options['long']['distfiles'] = ["fetch-restricted", "size-limit="]
 	getopt_options['short']['packages'] = "i"
-	getopt_options['long']['packages'] = ["ignore-failure"]
+	getopt_options['long']['packages'] = ["ignore-failure", "changed-deps"]
 	# set default options, except 'nocolor', which is set in main()
 	options['interactive'] = False
 	options['pretend'] = False
@@ -303,6 +307,7 @@ def parseArgs(options={}):
 	options['fetch-restricted'] = False
 	options['size-limit'] = 0
 	options['verbose'] = False
+	options['changed-deps'] = False
 	options['ignore-failure'] = False
 	# if called by a well-named symlink, set the action accordingly:
 	action = None
diff --git a/pym/gentoolkit/eclean/search.py b/pym/gentoolkit/eclean/search.py
index 831ba39..da8c286 100644
--- a/pym/gentoolkit/eclean/search.py
+++ b/pym/gentoolkit/eclean/search.py
@@ -13,6 +13,8 @@ import sys
 from functools import partial
 
 import portage
+from portage.dep import Atom, use_reduce
+from portage.dep._slot_operator import strip_slots
 
 import gentoolkit.pprinter as pp
 from gentoolkit.eclean.exclude import (exclDictMatchCP, exclDictExpand,
@@ -488,6 +490,17 @@ class DistfilesSearch(object):
 		return clean_me, saved
 
 
+def _deps_equal(deps_a, deps_b, eapi, uselist=None):
+    """Compare two dependency lists given a set of USE flags"""
+    if deps_a == deps_b: return True
+
+    deps_a = use_reduce(deps_a, uselist=uselist, eapi=eapi, token_class=Atom)
+    deps_b = use_reduce(deps_b, uselist=uselist, eapi=eapi, token_class=Atom)
+    strip_slots(deps_a)
+    strip_slots(deps_b)
+    return deps_a == deps_b
+
+
 def findPackages(
         options,
         exclude=None,
@@ -564,7 +577,22 @@ def findPackages(
 
         # Exclude if binpkg exists in the porttree and not --deep
         if not destructive and port_dbapi.cpv_exists(cpv):
-            continue
+            if not options['changed-deps']:
+                continue
+
+            uselist = bin_dbapi.aux_get(cpv, ['USE'])[0].split()
+            all_equal = True
+
+            for k in ('RDEPEND', 'PDEPEND'):
+                binpkg_deps = bin_dbapi.aux_get(cpv, [k])
+                ebuild_deps = port_dbapi.aux_get(cpv, [k])
+
+                if not _deps_equal(binpkg_deps, ebuild_deps, cpv.eapi, uselist):
+                    all_equal = False
+                    break
+
+            if all_equal:
+                continue
 
         if destructive and var_dbapi.cpv_exists(cpv):
             # Exclude if an instance of the package is installed due to
-- 
2.24.1



  reply	other threads:[~2020-02-21  5:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-21  5:29 [gentoo-portage-dev] [PATCH gentoolkit 1/2] eclean: Rewrite findPackages() Matt Turner
2020-02-21  5:29 ` Matt Turner [this message]
2020-03-02  6:32   ` [gentoo-portage-dev] [PATCH gentoolkit 2/2] eclean: Add option to delete binpkgs with changed deps Zac Medico
2020-03-02 20:40     ` Matt Turner
2020-03-02 21:02       ` Matt Turner
2020-03-03  3:38         ` Zac Medico
2020-03-02  6:39   ` Zac Medico
2020-03-02 21:11     ` Matt Turner
2020-03-03  5:15       ` Zac Medico
2020-03-07  6:10         ` Matt Turner
2020-02-21  5:34 ` [gentoo-portage-dev] Re: [PATCH gentoolkit 1/2] eclean: Rewrite findPackages() Matt Turner
2020-02-21  5:36 ` [gentoo-portage-dev] " Michael 'veremitz' Everitt
2020-03-02  6:25   ` Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200221052945.972092-2-mattst88@gentoo.org \
    --to=mattst88@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox