Gentoo Archives: gentoo-portage-dev

From: Matt Turner <mattst88@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Matt Turner <mattst88@g.o>
Subject: [gentoo-portage-dev] [PATCH] Add @changed-subslot package set
Date: Sat, 16 Jan 2021 02:47:16
Message-Id: 20210116024709.248222-1-mattst88@gentoo.org
1 This set is the upgradable packages for which the highest visible
2 version has a different subslot than the currently installed version.
3
4 The primary purpose of this feature is for use in catalyst builds. We
5 update the "seed" stage3 before using it to build a new stage1.
6
7 Updating the entire stage is expensive and unnecessary (since we're
8 going to build the latest packages in stage1 and then rebuild everything
9 in stage3).
10
11 What we definitely do need to update in the original stage3 however, is
12 any package that would trigger a subslot rebuild.
13
14 For example: gcc links with libmpfr.so from dev-libs/mpfr. mpfr's SONAME
15 changes from libmpfr.so.4 (SLOT="0/4") to libmpfr.so.6 (SLOT="0/6"). If
16 the seed stage's dev-libs/mpfr is not updated before emerging gcc, gcc
17 will link with libmpfr.so.4, but the latest version of dev-libs/mpfr
18 will be built and libmpfr.so.6 included into the stage1. Since the old
19 libmpfr.so.4 is not included in the stage1, gcc will not work, breaking
20 subsequent stage builds.
21
22 Our current options to update the seed are too large a hammer (e.g.,
23 "--update --deep --newuse @world" or "--update --deep --newuse
24 --complete-graph --rebuild-if-new-ver gcc") and spend too much time
25 updating seed stages for no gain beyond updating only packages for whom
26 the subslot has changed.
27
28 With this set, catalyst will likely use
29
30 emerge @changed-subslot --ignore-built-slot-operator-deps y
31
32 to update the seed stage.
33
34 Thank you to Zac Medico for showing me how to do this.
35
36 Bug: https://bugs.gentoo.org/739004
37 Signed-off-by: Matt Turner <mattst88@g.o>
38 ---
39 cnf/sets/portage.conf | 5 +++++
40 lib/portage/_sets/dbapi.py | 39 +++++++++++++++++++++++++++++++++++++-
41 2 files changed, 43 insertions(+), 1 deletion(-)
42
43 diff --git a/cnf/sets/portage.conf b/cnf/sets/portage.conf
44 index 22f0fa3a5..5651a9c53 100644
45 --- a/cnf/sets/portage.conf
46 +++ b/cnf/sets/portage.conf
47 @@ -84,6 +84,11 @@ exclude-files = /usr/bin/Xorg
48 [rebuilt-binaries]
49 class = portage.sets.dbapi.RebuiltBinaries
50
51 +# Installed packages for which the subslot of the highest visible ebuild
52 +# version is different than the currently installed version.
53 +[changed-subslot]
54 +class = portage.sets.dbapi.SubslotChangedSet
55 +
56 # Installed packages for which the highest visible ebuild
57 # version is lower than the currently installed version.
58 [downgrade]
59 diff --git a/lib/portage/_sets/dbapi.py b/lib/portage/_sets/dbapi.py
60 index 52367c4a6..46ba5c17d 100644
61 --- a/lib/portage/_sets/dbapi.py
62 +++ b/lib/portage/_sets/dbapi.py
63 @@ -15,7 +15,7 @@ from portage._sets import SetConfigError, get_boolean
64 import portage
65
66 __all__ = ["CategorySet", "ChangedDepsSet", "DowngradeSet",
67 - "EverythingSet", "OwnerSet", "VariableSet"]
68 + "EverythingSet", "OwnerSet", "SubslotChangedSet", "VariableSet"]
69
70 class EverythingSet(PackageSet):
71 _operations = ["merge"]
72 @@ -167,6 +167,43 @@ class VariableSet(EverythingSet):
73
74 singleBuilder = classmethod(singleBuilder)
75
76 +class SubslotChangedSet(PackageSet):
77 +
78 + _operations = ["merge", "unmerge"]
79 +
80 + description = "Package set which contains all packages " + \
81 + "for which the subslot of the highest visible ebuild is " + \
82 + "different than the currently installed version."
83 +
84 + def __init__(self, portdb=None, vardb=None):
85 + super(SubslotChangedSet, self).__init__()
86 + self._portdb = portdb
87 + self._vardb = vardb
88 +
89 + def load(self):
90 + atoms = []
91 + xmatch = self._portdb.xmatch
92 + xmatch_level = "bestmatch-visible"
93 + cp_list = self._vardb.cp_list
94 + pkg_str = self._vardb._pkg_str
95 + for cp in self._vardb.cp_all():
96 + for cpv in cp_list(cp):
97 + pkg = pkg_str(cpv, None)
98 + slot_atom = "%s:%s" % (pkg.cp, pkg.slot)
99 + ebuild = xmatch(xmatch_level, slot_atom)
100 + if not ebuild:
101 + continue
102 + if pkg.sub_slot != ebuild.sub_slot:
103 + atoms.append(slot_atom)
104 +
105 + self._setAtoms(atoms)
106 +
107 + def singleBuilder(cls, options, settings, trees):
108 + return cls(portdb=trees["porttree"].dbapi,
109 + vardb=trees["vartree"].dbapi)
110 +
111 + singleBuilder = classmethod(singleBuilder)
112 +
113 class DowngradeSet(PackageSet):
114
115 _operations = ["merge", "unmerge"]
116 --
117 2.26.2

Replies