From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH] sets: introduce @changed-deps to update packages which need dep changes.
Date: Fri, 25 Jul 2014 00:26:05 +0200 [thread overview]
Message-ID: <1406240765-4626-1-git-send-email-mgorny@gentoo.org> (raw)
The @changed-deps set tries to compare RDEPEND and PDEPEND entries of
installed packages with ebuild counterparts, and pulls the ebuild
whenever the two are not in sync. This could be used, for example, to
clean up the system after disabling --dynamic-deps.
---
cnf/sets/portage.conf | 5 +++++
pym/portage/_sets/dbapi.py | 53 ++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/cnf/sets/portage.conf b/cnf/sets/portage.conf
index b73afb1..fd2c387 100644
--- a/cnf/sets/portage.conf
+++ b/cnf/sets/portage.conf
@@ -84,3 +84,8 @@ class = portage.sets.dbapi.UnavailableSet
# are not available.
[unavailable-binaries]
class = portage.sets.dbapi.UnavailableBinaries
+
+# Installed packages for which vdb *DEPEND entries are outdated compared
+# to the matching portdb entry.
+[changed-deps]
+class = portage.sets.dbapi.ChangedDepsSet
diff --git a/pym/portage/_sets/dbapi.py b/pym/portage/_sets/dbapi.py
index 384fb3a..9b2cb8b 100644
--- a/pym/portage/_sets/dbapi.py
+++ b/pym/portage/_sets/dbapi.py
@@ -1,17 +1,18 @@
# Copyright 2007-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+import re
import time
from portage import os
from portage.versions import best, catsplit, vercmp
-from portage.dep import Atom
+from portage.dep import Atom, use_reduce
from portage.localization import _
from portage._sets.base import PackageSet
from portage._sets import SetConfigError, get_boolean
import portage
-__all__ = ["CategorySet", "DowngradeSet",
+__all__ = ["CategorySet", "ChangedDepsSet", "DowngradeSet",
"EverythingSet", "OwnerSet", "VariableSet"]
class EverythingSet(PackageSet):
@@ -456,3 +457,51 @@ class RebuiltBinaries(EverythingSet):
bindb=trees["bintree"].dbapi)
singleBuilder = classmethod(singleBuilder)
+
+class ChangedDepsSet(PackageSet):
+
+ _operations = ["merge", "unmerge"]
+
+ description = "Package set which contains all installed " + \
+ "packages for which the vdb *DEPEND entries are outdated " + \
+ "compared to corresponding portdb entries."
+
+ def __init__(self, portdb=None, vardb=None):
+ super(ChangedDepsSet, self).__init__()
+ self._portdb = portdb
+ self._vardb = vardb
+
+ def load(self):
+ depvars = ('RDEPEND', 'PDEPEND')
+
+ subslot_repl_re = re.compile(r':[^[]*=')
+
+ atoms = []
+ for cpv in self._vardb.cpv_all():
+ # no ebuild, no dynamic-deps to break it :)
+ if not self._portdb.cpv_exists(cpv):
+ continue
+
+ use, eapi = self._vardb.aux_get(cpv, ('USE', 'EAPI'))
+
+ def clean_subslots(depatom):
+ if isinstance(depatom, list):
+ return [clean_subslots(x) for x in depatom]
+ else:
+ return subslot_repl_re.sub(':=', depatom)
+
+ vdbvars = [clean_subslots(use_reduce(x, uselist=use, eapi=eapi))
+ for x in self._vardb.aux_get(cpv, depvars)]
+ pdbvars = [clean_subslots(use_reduce(x, uselist=use, eapi=eapi))
+ for x in self._portdb.aux_get(cpv, depvars)]
+
+ if vdbvars != pdbvars:
+ atoms.append('=%s' % cpv)
+
+ self._setAtoms(atoms)
+
+ def singleBuilder(cls, options, settings, trees):
+ return cls(portdb=trees["porttree"].dbapi,
+ vardb=trees["vartree"].dbapi)
+
+ singleBuilder = classmethod(singleBuilder)
--
2.0.2
next reply other threads:[~2014-07-24 22:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-24 22:26 Michał Górny [this message]
2014-07-30 16:14 ` [gentoo-portage-dev] [PATCH] sets: introduce @changed-deps to update packages which need dep changes Michał Górny
2014-07-30 16:36 ` [gentoo-portage-dev] [PATCH v2] " Michał Górny
2014-08-07 8:22 ` Michał Górny
2014-08-03 3:11 ` [gentoo-portage-dev] [PATCH] " Mike Gilbert
2014-08-13 19:39 ` Michał Górny
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=1406240765-4626-1-git-send-email-mgorny@gentoo.org \
--to=mgorny@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