Gentoo Archives: gentoo-portage-dev

From: Martin Vaeth <martin@×××××.de>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] [Patch] Minor revisions (beginning of implementation)
Date: Tue, 22 Jul 2014 19:45:22
Message-Id: slrnlstf6e.2f1.martin@epidot.math.uni-rostock.de
1 Please, find attached the patches I mentioned on dev-ml
2 concerning minor revisions.
3 As mentioned there, the patch is not yet finished.
4
5 Besides my lack of time the main reason is that any attempts
6 to modify self._phases (or also any other flag) in
7 EbuildExecuter do not work
8 (e.g. if the commented line self._phases = () in the patch
9 is uncommented, python reports an error that a read-only
10 attribute is changed).
11
12 I do not have enough python knowledge to see the reason for
13 this error.
14
15 Let me summarize once more what still needs to be done:
16
17 1. Of course, the above problem must be fixed so that
18 the main "build" phases are skipped. I am unable to do this
19 in a reasonable time, but it should be easy for a python
20 expert.
21
22 2. The "merge" phase must be patched to not modify CONTENTS
23 when some corresponding flag in EbuildExecuter.py was set.
24
25 3. The setting of the variables P, PR, etc. needs to be
26 modified to *not* include the minor revision.
27
28 4. The setting of _rev in versions.py must be treated
29 similar as in e.g. _cp. Unfortunately, _rev is already
30 used in the setting of _cp so that it seems that the
31 whole meachanism to set these variables must be rewritten.
32 I suggest to postpone this until 1-3 are properly tested
33 and if it seems reasonable that the change can be done.
34
35 5. Finally, .tbz2 files should be updated.
36 This is probably not so easy, but IMHO also not so urgent:
37 In the worst case, the user has to recompile the package
38 manually to get the *.tbz2 file. (It means that those
39 users will not profit from minor revisions, but it will
40 not do much harm to them, either).
41
42 In any case, do not expect that I will have the time to
43 continue on this patch - my job needs currently all of my
44 time, and this will not change very soon.
45
46
47 --- portage.bak/pym/_emerge/EbuildExecuter.py
48 +++ portage.bak/pym/_emerge/EbuildExecuter.py
49 @@ -7,7 +7,9 @@
50 import portage
51 from portage import os
52 from portage.eapi import eapi_has_src_prepare_and_src_configure, \
53 - eapi_exports_replace_vars
54 + eapi_exports_replace_vars, \
55 + eapi_supports_minor_revision
56 +from portage.versions import pkgcmp, pkgsplit
57 from portage.package.ebuild.doebuild import _prepare_fake_distdir
58
59 class EbuildExecuter(CompositeTask):
60 @@ -35,6 +37,14 @@
61 for match in vardb.match(pkg.slot_atom) + \
62 vardb.match('='+pkg.cpv)))
63
64 + if eapi_supports_minor_revision(settings['EAPI']):
65 + vardb = pkg.root_config.trees['vartree'].dbapi
66 + for match in vardb.match(pkg.slot_atom):
67 + if(pkgcmp(pkgsplit(pkg.cpv), pkgsplit(match), True) == 1):
68 + # This does not work, since attributes are readonly???
69 + #self._phases = ()
70 + break
71 +
72 setup_phase = EbuildPhase(background=self.background,
73 phase="setup", scheduler=scheduler,
74 settings=settings)
75 --- portage.bak/pym/portage/eapi.py
76 +++ portage.bak/pym/portage/eapi.py
77 @@ -68,6 +68,9 @@
78 def eapi_has_use_dep_defaults(eapi):
79 return eapi not in ("0", "1", "2", "3")
80
81 +def eapi_supports_minor_revision(eapi):
82 + return eapi not in ("0", "1", "2", "3", "4")
83 +
84 def eapi_has_repo_deps(eapi):
85 return eapi in ("4-python", "5-progress")
86
87 @@ -96,7 +99,7 @@
88 return eapi in ("5-hdepend",)
89
90 _eapi_attrs = collections.namedtuple('_eapi_attrs',
91 - 'dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC '
92 + 'minor_revision dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC '
93 'feature_flag_test feature_flag_targetroot '
94 'hdepend iuse_defaults iuse_effective '
95 'repo_deps required_use required_use_at_most_one_of slot_operator slot_deps '
96 @@ -121,6 +124,7 @@
97 eapi = None
98
99 eapi_attrs = _eapi_attrs(
100 + minor_revision = (eapi is None or eapi_supports_minor_revision(eapi)),
101 dots_in_PN = (eapi is None or eapi_allows_dots_in_PN(eapi)),
102 dots_in_use_flags = (eapi is None or eapi_allows_dots_in_use_flags(eapi)),
103 exports_EBUILD_PHASE_FUNC = (eapi is None or eapi_exports_EBUILD_PHASE_FUNC(eapi)),
104 --- portage.bak/pym/portage/versions.py
105 +++ portage.bak/pym/portage/versions.py
106 @@ -50,8 +50,10 @@
107 }
108
109 _v = r'(cvs\.)?(\d+)((\.\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\d*)*)'
110 -_rev = r'\d+'
111 -_vr = _v + '(-r(' + _rev + '))?'
112 +
113 +_rev = r'(\d+)(\.(\d+))?'
114 +
115 +_vr = _v + '(-r' + _rev + ')?'
116
117 _cp = {
118 "dots_disallowed_in_PN": '(' + _cat + '/' + _pkg['dots_disallowed_in_PN'] + '(-' + _vr + ')?)',
119 @@ -115,7 +117,7 @@
120 print(_("!!! syntax error in version: %s") % myver)
121 return False
122
123 -def vercmp(ver1, ver2, silent=1):
124 +def vercmp(ver1, ver2, minor=False, silent=1):
125 """
126 Compare two versions
127 Example usage:
128 @@ -131,12 +133,16 @@
129 @type pkg1: string (example: "2.1.2-r3")
130 @param pkg2: version to compare againts (see ver_regexp in portage.versions.py)
131 @type pkg2: string (example: "2.1.2_rc5")
132 + @param minor: whether to take minor revision into account
133 + @type minor: Boolean
134 @rtype: None or float
135 @return:
136 - 1. positive if ver1 is greater than ver2
137 - 2. negative if ver1 is less than ver2
138 - 3. 0 if ver1 equals ver2
139 - 4. None if ver1 or ver2 are invalid (see ver_regexp in portage.versions.py)
140 + 1. 2 if ver1 is greater than ver2
141 + 2. -2 if ver1 is less than ver2
142 + 3. 1 if ver1 is greater than ver2 only in minor revision and minor=True
143 + 4. -1 if ver1 is greater than ver2 only in minor revision and minor=True
144 + 5. 0 if ver1 equals ver2 (up to minor revision if minor=False)
145 + 6. None if ver1 or ver2 are invalid (see ver_regexp in portage.versions.py)
146 """
147
148 if ver1 == ver2:
149 @@ -157,9 +163,9 @@
150
151 # shortcut for cvs ebuilds (new style)
152 if match1.group(1) and not match2.group(1):
153 - return 1
154 + return 2
155 elif match2.group(1) and not match1.group(1):
156 - return -1
157 + return -2
158
159 # building lists of the version parts before the suffix
160 # first part is simple
161 @@ -212,13 +218,13 @@
162
163 for i in range(0, max(len(list1), len(list2))):
164 if len(list1) <= i:
165 - return -1
166 + return -2
167 elif len(list2) <= i:
168 - return 1
169 + return 2
170 elif list1[i] != list2[i]:
171 a = list1[i]
172 b = list2[i]
173 - rval = (a > b) - (a < b)
174 + rval = 2 * ((a > b) - (a < b))
175 return rval
176
177 # main version is equal, so now compare the _suffix part
178 @@ -238,7 +244,7 @@
179 if s1[0] != s2[0]:
180 a = suffix_value[s1[0]]
181 b = suffix_value[s2[0]]
182 - rval = (a > b) - (a < b)
183 + rval = 2 * ((a > b) - (a < b))
184 return rval
185 if s1[1] != s2[1]:
186 # it's possible that the s(1|2)[1] == ''
187 @@ -251,7 +257,7 @@
188 r2 = int(s2[1])
189 except ValueError:
190 r2 = 0
191 - rval = (r1 > r2) - (r1 < r2)
192 + rval = 2 * ((r1 > r2) - (r1 < r2))
193 if rval:
194 return rval
195
196 @@ -264,10 +270,23 @@
197 r2 = int(match2.group(10))
198 else:
199 r2 = 0
200 + rval = 2 * ((r1 > r2) - (r1 < r2))
201 + if not minor:
202 + return rval
203 +
204 +
205 + if match1.group(12):
206 + r1 = int(match1.group(12))
207 + else:
208 + r1 = 0
209 + if match2.group(12):
210 + r2 = int(match2.group(12))
211 + else:
212 + r2 = 0
213 rval = (r1 > r2) - (r1 < r2)
214 return rval
215 -
216 -def pkgcmp(pkg1, pkg2):
217 +
218 +def pkgcmp(pkg1, pkg2, minor=False):
219 """
220 Compare 2 package versions created in pkgsplit format.
221
222 @@ -285,13 +304,15 @@
223 @rtype: None or integer
224 @return:
225 1. None if package names are not the same
226 - 2. 1 if pkg1 is greater than pkg2
227 - 3. -1 if pkg1 is less than pkg2
228 - 4. 0 if pkg1 equals pkg2
229 + 2. 2 if pkg1 is greater than pkg2
230 + 3. -2 if pkg1 is less than pkg2
231 + 4. 1 if pkg1 is greater than pkg2 only in minor revision and minor=True
232 + 5. -1 if pkg1 is less than pkg2 only in minor revision and minor=True
233 + 6. 0 if pkg1 equals pkg2 (up to revision if minor=False)
234 """
235 if pkg1[0] != pkg2[0]:
236 return None
237 - return vercmp("-".join(pkg1[1:]), "-".join(pkg2[1:]))
238 + return vercmp("-".join(pkg1[1:]), "-".join(pkg2[1:]), minor)
239
240 def _pkgsplit(mypkg, eapi=None):
241 """
242 @@ -557,7 +578,7 @@
243 v1 = x.version
244 except AttributeError:
245 v1 = _pkg_str(x, eapi=eapi).version
246 - if vercmp(v1, v2) > 0:
247 + if vercmp(v1, v2, True) > 0:
248 bestmatch = x
249 v2 = v1
250 return bestmatch