* [gentoo-portage-dev] [PATCH] sets: introduce @changed-deps to update packages which need dep changes.
@ 2014-07-24 22:26 Michał Górny
2014-07-30 16:14 ` Michał Górny
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Michał Górny @ 2014-07-24 22:26 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Michał Górny
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] sets: introduce @changed-deps to update packages which need dep changes.
2014-07-24 22:26 [gentoo-portage-dev] [PATCH] sets: introduce @changed-deps to update packages which need dep changes Michał Górny
@ 2014-07-30 16:14 ` Michał Górny
2014-07-30 16:36 ` [gentoo-portage-dev] [PATCH v2] " Michał Górny
2014-08-03 3:11 ` [gentoo-portage-dev] [PATCH] " Mike Gilbert
2014-08-13 19:39 ` Michał Górny
2 siblings, 1 reply; 6+ messages in thread
From: Michał Górny @ 2014-07-30 16:14 UTC (permalink / raw
To: gentoo-portage-dev
[-- Attachment #1: Type: text/plain, Size: 459 bytes --]
Dnia 2014-07-25, o godz. 00:26:05
Michał Górny <mgorny@gentoo.org> napisał(a):
> 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.
I have found a few bugs and will be sending an updated version :).
--
Best regards,
Michał Górny
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 949 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gentoo-portage-dev] [PATCH v2] sets: introduce @changed-deps to update packages which need dep changes.
2014-07-30 16:14 ` Michał Górny
@ 2014-07-30 16:36 ` Michał Górny
2014-08-07 8:22 ` Michał Górny
0 siblings, 1 reply; 6+ messages in thread
From: Michał Górny @ 2014-07-30 16:36 UTC (permalink / raw
To: gentoo-portage-dev
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 | 81 ++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 84 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..364f2fc 100644
--- a/pym/portage/_sets/dbapi.py
+++ b/pym/portage/_sets/dbapi.py
@@ -1,17 +1,19 @@
# 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.exception import InvalidAtom
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 +458,78 @@ 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')
+
+ # regexp used to match atoms using subslot operator :=
+ subslot_repl_re = re.compile(r':[^[]*=')
+
+ atoms = []
+ for cpv in self._vardb.cpv_all():
+ # no ebuild, no update :).
+ if not self._portdb.cpv_exists(cpv):
+ continue
+
+ # USE flags used to build the ebuild and EAPI
+ # (needed for Atom & use_reduce())
+ use, eapi = self._vardb.aux_get(cpv, ('USE', 'EAPI'))
+ usel = use.split()
+
+ # function used to recursively process atoms in nested lists.
+ def clean_subslots(depatom, usel=None):
+ if isinstance(depatom, list):
+ # process the nested list.
+ return [clean_subslots(x, usel) for x in depatom]
+ else:
+ try:
+ # this can be either an atom or some special operator.
+ # in the latter case, we get InvalidAtom and pass it as-is.
+ a = Atom(depatom)
+ except InvalidAtom:
+ return depatom
+ else:
+ # if we're processing portdb, we need to evaluate USE flag
+ # dependency conditionals to make them match vdb. this
+ # requires passing the list of USE flags, so we reuse it
+ # as conditional for the operation as well.
+ if usel is not None:
+ a = a.evaluate_conditionals(usel)
+
+ # replace slot operator := dependencies with plain :=
+ # since we can't properly compare expanded slots
+ # in vardb to abstract slots in portdb.
+ return subslot_repl_re.sub(':=', a)
+
+ # get all *DEPEND variables from vdb & portdb and compare them.
+ # we need to do some cleaning up & expansion to make matching
+ # meaningful since vdb dependencies are conditional-free.
+ vdbvars = [clean_subslots(use_reduce(x, uselist=usel, eapi=eapi))
+ for x in self._vardb.aux_get(cpv, depvars)]
+ pdbvars = [clean_subslots(use_reduce(x, uselist=usel, eapi=eapi), usel)
+ for x in self._portdb.aux_get(cpv, depvars)]
+
+ # if dependencies don't match, trigger the rebuild.
+ 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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] sets: introduce @changed-deps to update packages which need dep changes.
2014-07-24 22:26 [gentoo-portage-dev] [PATCH] sets: introduce @changed-deps to update packages which need dep changes Michał Górny
2014-07-30 16:14 ` Michał Górny
@ 2014-08-03 3:11 ` Mike Gilbert
2014-08-13 19:39 ` Michał Górny
2 siblings, 0 replies; 6+ messages in thread
From: Mike Gilbert @ 2014-08-03 3:11 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Michał Górny
On Thu, Jul 24, 2014 at 6:26 PM, Michał Górny <mgorny@gentoo.org> wrote:
> 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.
Nice idea.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-portage-dev] [PATCH v2] sets: introduce @changed-deps to update packages which need dep changes.
2014-07-30 16:36 ` [gentoo-portage-dev] [PATCH v2] " Michał Górny
@ 2014-08-07 8:22 ` Michał Górny
0 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2014-08-07 8:22 UTC (permalink / raw
To: gentoo-portage-dev
[-- Attachment #1: Type: text/plain, Size: 576 bytes --]
Dnia 2014-07-30, o godz. 18:36:49
Michał Górny <mgorny@gentoo.org> napisał(a):
> 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.
As suggested by dol-sen, I've looked into paludis' source code and it
seems that it is using exactly the same method of comparing
dependencies (incl. the :X/Y= -> := normalization).
--
Best regards,
Michał Górny
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 949 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] sets: introduce @changed-deps to update packages which need dep changes.
2014-07-24 22:26 [gentoo-portage-dev] [PATCH] sets: introduce @changed-deps to update packages which need dep changes Michał Górny
2014-07-30 16:14 ` Michał Górny
2014-08-03 3:11 ` [gentoo-portage-dev] [PATCH] " Mike Gilbert
@ 2014-08-13 19:39 ` Michał Górny
2 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2014-08-13 19:39 UTC (permalink / raw
To: gentoo-portage-dev
[-- Attachment #1: Type: text/plain, Size: 508 bytes --]
Dnia 2014-07-25, o godz. 00:26:05
Michał Górny <mgorny@gentoo.org> napisał(a):
> 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.
The patch has been resent in a new thread [1].
[1]:http://thread.gmane.org/gmane.linux.gentoo.portage.devel/4411
--
Best regards,
Michał Górny
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 949 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-08-13 19:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-24 22:26 [gentoo-portage-dev] [PATCH] sets: introduce @changed-deps to update packages which need dep changes Michał Górny
2014-07-30 16:14 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox