Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: man/, pym/portage/dbapi/, bin/, pym/_emerge/
Date: Wed, 01 May 2013 23:47:00
Message-Id: 1367451858.22b8c3bbe79a9fe23752375dadcf42b09c24b20c.zmedico@gentoo
1 commit: 22b8c3bbe79a9fe23752375dadcf42b09c24b20c
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Wed May 1 23:44:18 2013 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Wed May 1 23:44:18 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=22b8c3bb
7
8 Support RESTRICT=preserve-libs, bug #364427
9
10 Note than when a package is merged, RESTRICT=preserve-libs applies if
11 *either* the new instance or the old instance sets
12 RESTRICT=preserve-libs.
13
14 Also note that when the user has preserve-libs enabled, the
15 --depclean-lib-check option may now kick in if one of the packages
16 selected for unmerge sets RESTRICT=preserve-libs.
17
18 ---
19 bin/repoman | 2 +-
20 man/ebuild.5 | 5 +++
21 man/emerge.1 | 9 +++--
22 pym/_emerge/actions.py | 24 +++++++++++++--
23 pym/portage/dbapi/vartree.py | 64 ++++++++++++++++++++++++++++--------------
24 5 files changed, 74 insertions(+), 30 deletions(-)
25
26 diff --git a/bin/repoman b/bin/repoman
27 index a829334..a7bcbe1 100755
28 --- a/bin/repoman
29 +++ b/bin/repoman
30 @@ -450,7 +450,7 @@ for x in missingvars:
31 qawarnings.add(x)
32
33 valid_restrict = frozenset(["binchecks", "bindist",
34 - "fetch", "installsources", "mirror",
35 + "fetch", "installsources", "mirror", "preserve-libs",
36 "primaryuri", "splitdebug", "strip", "test", "userpriv"])
37
38 live_eclasses = frozenset([
39
40 diff --git a/man/ebuild.5 b/man/ebuild.5
41 index 7ecb672..20e7b4b 100644
42 --- a/man/ebuild.5
43 +++ b/man/ebuild.5
44 @@ -673,6 +673,11 @@ binaries that are not compatible with debugedit.
45 .I mirror
46 files in \fBSRC_URI\fR will not be downloaded from the \fBGENTOO_MIRRORS\fR.
47 .TP
48 +.I preserve\-libs
49 +Disables preserve\-libs for specific packages. Note than when a package is
50 +merged, RESTRICT=preserve\-libs applies if either the new instance or the
51 +old instance sets RESTRICT=preserve\-libs.
52 +.TP
53 .I primaryuri
54 fetch from URIs in \fBSRC_URI\fR before \fBGENTOO_MIRRORS\fR.
55 .TP
56
57 diff --git a/man/emerge.1 b/man/emerge.1
58 index 874d333..15e8185 100644
59 --- a/man/emerge.1
60 +++ b/man/emerge.1
61 @@ -429,10 +429,11 @@ required.
62 .BR "\-\-depclean\-lib\-check [ y | n ]"
63 Account for library link-level dependencies during
64 \fB\-\-depclean\fR and \fB\-\-prune\fR actions.
65 -This option is enabled by default. This option is ignored
66 -when FEATURES="preserve\-libs" is enabled in
67 -\fBmake.conf\fR(5), since any libraries that have
68 -consumers will simply be preserved.
69 +This option is enabled by default. If FEATURES="preserve\-libs" is
70 +enabled in \fBmake.conf\fR(5), and preserve\-libs is not restricted
71 +for any of the packages selected for removal, then this option is
72 +ignored because any libraries that have consumers will simply be
73 +preserved.
74 .TP
75 .BR \-\-digest
76 Prevent corruption from being noticed. The `repoman manifest` command is the
77
78 diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
79 index 2c5a1b3..3982eb3 100644
80 --- a/pym/_emerge/actions.py
81 +++ b/pym/_emerge/actions.py
82 @@ -987,10 +987,19 @@ def calc_depclean(settings, trees, ldpath_mtimes,
83 cleanlist = create_cleanlist()
84 clean_set = set(cleanlist)
85
86 - if cleanlist and \
87 - real_vardb._linkmap is not None and \
88 - myopts.get("--depclean-lib-check", _DEPCLEAN_LIB_CHECK_DEFAULT) != "n" and \
89 - "preserve-libs" not in settings.features:
90 + depclean_lib_check = cleanlist and real_vardb._linkmap is not None and \
91 + myopts.get("--depclean-lib-check", _DEPCLEAN_LIB_CHECK_DEFAULT) != "n"
92 + preserve_libs = "preserve-libs" in settings.features
93 + preserve_libs_restrict = False
94 +
95 + if depclean_lib_check and preserve_libs:
96 + for pkg in cleanlist:
97 + if "preserve-libs" in pkg.restrict:
98 + preserve_libs_restrict = True
99 + break
100 +
101 + if depclean_lib_check and \
102 + (preserve_libs_restrict or not preserve_libs):
103
104 # Check if any of these packages are the sole providers of libraries
105 # with consumers that have not been selected for removal. If so, these
106 @@ -1003,6 +1012,13 @@ def calc_depclean(settings, trees, ldpath_mtimes,
107 writemsg_level(">>> Checking for lib consumers...\n")
108
109 for pkg in cleanlist:
110 +
111 + if preserve_libs and "preserve-libs" not in pkg.restrict:
112 + # Any needed libraries will be preserved
113 + # when this package is unmerged, so there's
114 + # no need to account for it here.
115 + continue
116 +
117 pkg_dblink = real_vardb._dblink(pkg.cpv)
118 consumers = {}
119
120
121 diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
122 index 0d4a756..c6eaabf 100644
123 --- a/pym/portage/dbapi/vartree.py
124 +++ b/pym/portage/dbapi/vartree.py
125 @@ -1519,6 +1519,10 @@ class dblink(object):
126 self._protect_obj = None
127 self._pipe = pipe
128
129 + # When necessary, this attribute is modified for
130 + # compliance with RESTRICT=preserve-libs.
131 + self._preserve_libs = "preserve-libs" in mysettings.features
132 +
133 def __hash__(self):
134 return hash(self._hash_key)
135
136 @@ -1895,6 +1899,10 @@ class dblink(object):
137 except UnsupportedAPIException as e:
138 eapi_unsupported = e
139
140 + if self._preserve_libs and "preserve-libs" in \
141 + self.settings["PORTAGE_RESTRICT"].split():
142 + self._preserve_libs = False
143 +
144 builddir_lock = None
145 scheduler = self._scheduler
146 retval = os.EX_OK
147 @@ -2879,7 +2887,7 @@ class dblink(object):
148 self.vartree.dbapi._linkmap is None or \
149 self.vartree.dbapi._plib_registry is None or \
150 (not unmerge and self._installed_instance is None) or \
151 - "preserve-libs" not in self.settings.features:
152 + not self._preserve_libs:
153 return set()
154
155 os = _os_merge
156 @@ -3598,26 +3606,40 @@ class dblink(object):
157 cp = self.mysplit[0]
158 slot_atom = "%s:%s" % (cp, slot)
159
160 - # filter any old-style virtual matches
161 - slot_matches = [cpv for cpv in self.vartree.dbapi.match(slot_atom) \
162 - if cpv_getkey(cpv) == cp]
163 -
164 - if self.mycpv not in slot_matches and \
165 - self.vartree.dbapi.cpv_exists(self.mycpv):
166 - # handle multislot or unapplied slotmove
167 - slot_matches.append(self.mycpv)
168 -
169 - others_in_slot = []
170 - for cur_cpv in slot_matches:
171 - # Clone the config in case one of these has to be unmerged since
172 - # we need it to have private ${T} etc... for things like elog.
173 - settings_clone = portage.config(clone=self.settings)
174 - settings_clone.pop("PORTAGE_BUILDDIR_LOCKED", None)
175 - settings_clone.reset()
176 - others_in_slot.append(dblink(self.cat, catsplit(cur_cpv)[1],
177 - settings=settings_clone,
178 - vartree=self.vartree, treetype="vartree",
179 - scheduler=self._scheduler, pipe=self._pipe))
180 + self.lockdb()
181 + try:
182 + # filter any old-style virtual matches
183 + slot_matches = [cpv for cpv in self.vartree.dbapi.match(slot_atom)
184 + if cpv_getkey(cpv) == cp]
185 +
186 + if self.mycpv not in slot_matches and \
187 + self.vartree.dbapi.cpv_exists(self.mycpv):
188 + # handle multislot or unapplied slotmove
189 + slot_matches.append(self.mycpv)
190 +
191 + others_in_slot = []
192 + for cur_cpv in slot_matches:
193 + # Clone the config in case one of these has to be unmerged,
194 + # since we need it to have private ${T} etc... for things
195 + # like elog.
196 + settings_clone = portage.config(clone=self.settings)
197 + settings_clone.pop("PORTAGE_BUILDDIR_LOCKED", None)
198 + settings_clone.setcpv(cur_cpv, mydb=self.vartree.dbapi)
199 + if self._preserve_libs and "preserve-libs" in \
200 + settings_clone["PORTAGE_RESTRICT"].split():
201 + self._preserve_libs = False
202 + others_in_slot.append(dblink(self.cat, catsplit(cur_cpv)[1],
203 + settings=settings_clone,
204 + vartree=self.vartree, treetype="vartree",
205 + scheduler=self._scheduler, pipe=self._pipe))
206 + finally:
207 + self.unlockdb()
208 +
209 + # If any instance has RESTRICT=preserve-libs, then
210 + # restrict it for all instances.
211 + if not self._preserve_libs:
212 + for dblnk in others_in_slot:
213 + dblnk._preserve_libs = False
214
215 retval = self._security_check(others_in_slot)
216 if retval: