1 |
Author: grobian |
2 |
Date: 2010-02-27 20:02:45 +0000 (Sat, 27 Feb 2010) |
3 |
New Revision: 15484 |
4 |
|
5 |
Added: |
6 |
main/branches/prefix/pym/portage/_deprecated.py |
7 |
Modified: |
8 |
main/branches/prefix/pym/portage/__init__.py |
9 |
main/branches/prefix/pym/portage/dbapi/__init__.py |
10 |
main/branches/prefix/pym/portage/dbapi/vartree.py |
11 |
main/branches/prefix/pym/repoman/checks.py |
12 |
Log: |
13 |
Merged from trunk -r15465:15470 |
14 |
|
15 |
| 15466 | Splid deprecated functions into a _deprecated module. | |
16 |
| zmedico | | |
17 |
|
18 |
| 15467 | Fix broken dep_expand import from previous commit. | |
19 |
| zmedico | | |
20 |
|
21 |
| 15468 | Move merge and unmerge functions to the vartree module. | |
22 |
| zmedico | | |
23 |
|
24 |
| 15469 | Move getvirtuals to _deprecated module. | |
25 |
| zmedico | | |
26 |
|
27 |
| 15470 | Eliminate the PhaseCheck constructor and make | |
28 |
| zmedico | PhaseCheck.phases_re a class attribute. Thanks to Sebastian | |
29 |
| | Pipping <sping@g.o> for the initial patch. | |
30 |
|
31 |
|
32 |
Modified: main/branches/prefix/pym/portage/__init__.py |
33 |
=================================================================== |
34 |
--- main/branches/prefix/pym/portage/__init__.py 2010-02-27 19:32:48 UTC (rev 15483) |
35 |
+++ main/branches/prefix/pym/portage/__init__.py 2010-02-27 20:02:45 UTC (rev 15484) |
36 |
@@ -86,7 +86,7 @@ |
37 |
'portage.dbapi.dep_expand:dep_expand', |
38 |
'portage.dbapi.porttree:close_portdbapi_caches,FetchlistDict,' + \ |
39 |
'portagetree,portdbapi', |
40 |
- 'portage.dbapi.vartree:vardbapi,vartree,dblink', |
41 |
+ 'portage.dbapi.vartree:dblink,merge,unmerge,vardbapi,vartree', |
42 |
'portage.dbapi.virtual:fakedbapi', |
43 |
'portage.dep', |
44 |
'portage.dep:best_match_to_list,dep_getcpv,dep_getkey,' + \ |
45 |
@@ -136,6 +136,7 @@ |
46 |
'cpv_getkey@getCPFromCPV,endversion_keys,' + \ |
47 |
'suffix_value@endversion,pkgcmp,pkgsplit,vercmp,ververify', |
48 |
'portage.xpak', |
49 |
+ 'portage._deprecated:dep_virtual,digestParseFile,getvirtuals,pkgmerge', |
50 |
) |
51 |
|
52 |
import portage.const |
53 |
@@ -543,30 +544,6 @@ |
54 |
mylink=mydir+"/"+mylink |
55 |
return os.path.normpath(mylink) |
56 |
|
57 |
-def digestParseFile(myfilename, mysettings=None): |
58 |
- """(filename) -- Parses a given file for entries matching: |
59 |
- <checksumkey> <checksum_hex_string> <filename> <filesize> |
60 |
- Ignores lines that don't start with a valid checksum identifier |
61 |
- and returns a dict with the filenames as keys and {checksumkey:checksum} |
62 |
- as the values. |
63 |
- DEPRECATED: this function is now only a compability wrapper for |
64 |
- portage.manifest.Manifest().""" |
65 |
- |
66 |
- warnings.warn("portage.digestParseFile() is deprecated", |
67 |
- DeprecationWarning, stacklevel=2) |
68 |
- |
69 |
- mysplit = myfilename.split(os.sep) |
70 |
- if mysplit[-2] == "files" and mysplit[-1].startswith("digest-"): |
71 |
- pkgdir = os.sep + os.sep.join(mysplit[:-2]).strip(os.sep) |
72 |
- elif mysplit[-1] == "Manifest": |
73 |
- pkgdir = os.sep + os.sep.join(mysplit[:-1]).strip(os.sep) |
74 |
- |
75 |
- if mysettings is None: |
76 |
- global settings |
77 |
- mysettings = config(clone=settings) |
78 |
- |
79 |
- return Manifest(pkgdir, mysettings["DISTDIR"]).getDigests() |
80 |
- |
81 |
_testing_eapis = frozenset() |
82 |
_deprecated_eapis = frozenset(["3_pre2", "3_pre1", "2_pre3", "2_pre2", "2_pre1"]) |
83 |
|
84 |
@@ -638,66 +615,6 @@ |
85 |
raise portage.exception.PortageException( |
86 |
"mv '%s' '%s'" % (src, dest)) |
87 |
|
88 |
-def merge(mycat, mypkg, pkgloc, infloc, myroot, mysettings, myebuild=None, |
89 |
- mytree=None, mydbapi=None, vartree=None, prev_mtimes=None, blockers=None, |
90 |
- scheduler=None): |
91 |
- if not os.access(myroot + EPREFIX_LSTRIP, os.W_OK): |
92 |
- writemsg(_("Permission denied: access('%s', W_OK)\n") % |
93 |
- (myroot + EPREFIX_LSTRIP), noiselevel=-1) |
94 |
- return errno.EACCES |
95 |
- mylink = dblink(mycat, mypkg, myroot, mysettings, treetype=mytree, |
96 |
- vartree=vartree, blockers=blockers, scheduler=scheduler) |
97 |
- return mylink.merge(pkgloc, infloc, myroot, myebuild, |
98 |
- mydbapi=mydbapi, prev_mtimes=prev_mtimes) |
99 |
- |
100 |
-def unmerge(cat, pkg, myroot, mysettings, mytrimworld=1, vartree=None, |
101 |
- ldpath_mtimes=None, scheduler=None): |
102 |
- mylink = dblink(cat, pkg, myroot, mysettings, treetype="vartree", |
103 |
- vartree=vartree, scheduler=scheduler) |
104 |
- vartree = mylink.vartree |
105 |
- try: |
106 |
- mylink.lockdb() |
107 |
- if mylink.exists(): |
108 |
- vartree.dbapi.plib_registry.load() |
109 |
- vartree.dbapi.plib_registry.pruneNonExisting() |
110 |
- retval = mylink.unmerge(trimworld=mytrimworld, cleanup=1, |
111 |
- ldpath_mtimes=ldpath_mtimes) |
112 |
- if retval == os.EX_OK: |
113 |
- mylink.delete() |
114 |
- return retval |
115 |
- return os.EX_OK |
116 |
- finally: |
117 |
- vartree.dbapi.linkmap._clear_cache() |
118 |
- mylink.unlockdb() |
119 |
- |
120 |
-def dep_virtual(mysplit, mysettings): |
121 |
- "Does virtual dependency conversion" |
122 |
- warnings.warn("portage.dep_virtual() is deprecated", |
123 |
- DeprecationWarning, stacklevel=2) |
124 |
- newsplit=[] |
125 |
- myvirtuals = mysettings.getvirtuals() |
126 |
- for x in mysplit: |
127 |
- if isinstance(x, list): |
128 |
- newsplit.append(dep_virtual(x, mysettings)) |
129 |
- else: |
130 |
- mykey=dep_getkey(x) |
131 |
- mychoices = myvirtuals.get(mykey, None) |
132 |
- if mychoices: |
133 |
- if len(mychoices) == 1: |
134 |
- a = x.replace(mykey, dep_getkey(mychoices[0]), 1) |
135 |
- else: |
136 |
- if x[0]=="!": |
137 |
- # blocker needs "and" not "or(||)". |
138 |
- a=[] |
139 |
- else: |
140 |
- a=['||'] |
141 |
- for y in mychoices: |
142 |
- a.append(x.replace(mykey, dep_getkey(y), 1)) |
143 |
- newsplit.append(a) |
144 |
- else: |
145 |
- newsplit.append(x) |
146 |
- return newsplit |
147 |
- |
148 |
auxdbkeys = ( |
149 |
'DEPEND', 'RDEPEND', 'SLOT', 'SRC_URI', |
150 |
'RESTRICT', 'HOMEPAGE', 'LICENSE', 'DESCRIPTION', |
151 |
@@ -708,162 +625,6 @@ |
152 |
) |
153 |
auxdbkeylen=len(auxdbkeys) |
154 |
|
155 |
-def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None, |
156 |
- vartree=None, prev_mtimes=None, blockers=None): |
157 |
- """will merge a .tbz2 file, returning a list of runtime dependencies |
158 |
- that must be satisfied, or None if there was a merge error. This |
159 |
- code assumes the package exists.""" |
160 |
- |
161 |
- warnings.warn("portage.pkgmerge() is deprecated", |
162 |
- DeprecationWarning, stacklevel=2) |
163 |
- |
164 |
- global db |
165 |
- if mydbapi is None: |
166 |
- mydbapi = db[myroot]["bintree"].dbapi |
167 |
- if vartree is None: |
168 |
- vartree = db[myroot]["vartree"] |
169 |
- if mytbz2[-5:]!=".tbz2": |
170 |
- print(_("!!! Not a .tbz2 file")) |
171 |
- return 1 |
172 |
- |
173 |
- tbz2_lock = None |
174 |
- mycat = None |
175 |
- mypkg = None |
176 |
- did_merge_phase = False |
177 |
- success = False |
178 |
- try: |
179 |
- """ Don't lock the tbz2 file because the filesytem could be readonly or |
180 |
- shared by a cluster.""" |
181 |
- #tbz2_lock = portage.locks.lockfile(mytbz2, wantnewlockfile=1) |
182 |
- |
183 |
- mypkg = os.path.basename(mytbz2)[:-5] |
184 |
- xptbz2 = portage.xpak.tbz2(mytbz2) |
185 |
- mycat = xptbz2.getfile(_unicode_encode("CATEGORY", |
186 |
- encoding=_encodings['repo.content'])) |
187 |
- if not mycat: |
188 |
- writemsg(_("!!! CATEGORY info missing from info chunk, aborting...\n"), |
189 |
- noiselevel=-1) |
190 |
- return 1 |
191 |
- mycat = _unicode_decode(mycat, |
192 |
- encoding=_encodings['repo.content'], errors='replace') |
193 |
- mycat = mycat.strip() |
194 |
- |
195 |
- buildprefix = xptbz2.getfile("EPREFIX") |
196 |
- if not buildprefix: |
197 |
- writemsg("!!! EPREFIX info missing from info chunk, aborting...\n", |
198 |
- noiselevel=-1) |
199 |
- return 1 |
200 |
- buildprefix = buildprefix.strip() |
201 |
- |
202 |
- # These are the same directories that would be used at build time. |
203 |
- builddir = os.path.join( |
204 |
- mysettings["PORTAGE_TMPDIR"], "portage", mycat, mypkg) |
205 |
- catdir = os.path.dirname(builddir) |
206 |
- # if the prefix differs, we copy it to the image after extraction |
207 |
- if (buildprefix != EPREFIX): |
208 |
- pkgloc = os.path.join(builddir, "work") |
209 |
- else: |
210 |
- pkgloc = os.path.join(builddir, "image") |
211 |
- infloc = os.path.join(builddir, "build-info") |
212 |
- myebuild = os.path.join( |
213 |
- infloc, os.path.basename(mytbz2)[:-4] + "ebuild") |
214 |
- portage.util.ensure_dirs(os.path.dirname(catdir), |
215 |
- uid=portage_uid, gid=portage_gid, mode=0o70, mask=0) |
216 |
- catdir_lock = portage.locks.lockdir(catdir) |
217 |
- portage.util.ensure_dirs(catdir, |
218 |
- uid=portage_uid, gid=portage_gid, mode=0o70, mask=0) |
219 |
- try: |
220 |
- shutil.rmtree(builddir) |
221 |
- except (IOError, OSError) as e: |
222 |
- if e.errno != errno.ENOENT: |
223 |
- raise |
224 |
- del e |
225 |
- for mydir in (builddir, pkgloc, infloc): |
226 |
- portage.util.ensure_dirs(mydir, uid=portage_uid, |
227 |
- gid=portage_gid, mode=0o755) |
228 |
- writemsg_stdout(_(">>> Extracting info\n")) |
229 |
- xptbz2.unpackinfo(infloc) |
230 |
- mysettings.setcpv(mycat + "/" + mypkg, mydb=mydbapi) |
231 |
- # Store the md5sum in the vdb. |
232 |
- fp = open(_unicode_encode(os.path.join(infloc, 'BINPKGMD5')), 'w') |
233 |
- fp.write(str(portage.checksum.perform_md5(mytbz2))+"\n") |
234 |
- fp.close() |
235 |
- |
236 |
- # This gives bashrc users an opportunity to do various things |
237 |
- # such as remove binary packages after they're installed. |
238 |
- mysettings["PORTAGE_BINPKG_FILE"] = mytbz2 |
239 |
- mysettings.backup_changes("PORTAGE_BINPKG_FILE") |
240 |
- debug = mysettings.get("PORTAGE_DEBUG", "") == "1" |
241 |
- |
242 |
- # We want to install in "our" prefix, not the binary one |
243 |
- mysettings["EPREFIX"] = EPREFIX |
244 |
- # Store "our" prefix in the vdb. |
245 |
- fp = open(os.path.join(infloc, "EPREFIX"), "w") |
246 |
- fp.write(EPREFIX+"\n") |
247 |
- fp.close() |
248 |
- |
249 |
- # Eventually we'd like to pass in the saved ebuild env here. |
250 |
- retval = doebuild(myebuild, "setup", myroot, mysettings, debug=debug, |
251 |
- tree="bintree", mydbapi=mydbapi, vartree=vartree) |
252 |
- if retval != os.EX_OK: |
253 |
- writemsg(_("!!! Setup failed: %s\n") % retval, noiselevel=-1) |
254 |
- return retval |
255 |
- |
256 |
- writemsg_stdout(_(">>> Extracting %s\n") % mypkg) |
257 |
- retval = portage.process.spawn_bash( |
258 |
- "bzip2 -dqc -- '%s' | tar -xp -C '%s' -f -" % (mytbz2, pkgloc), |
259 |
- env=mysettings.environ()) |
260 |
- if retval != os.EX_OK: |
261 |
- writemsg(_("!!! Error Extracting '%s'\n") % mytbz2, noiselevel=-1) |
262 |
- return retval |
263 |
- #portage.locks.unlockfile(tbz2_lock) |
264 |
- #tbz2_lock = None |
265 |
- |
266 |
- # the extracted package put everything in buildprefix, so we |
267 |
- # just have to move it to the right EPREFIX |
268 |
- if buildprefix != EPREFIX: |
269 |
- writemsg_stdout(">>> Adjusting Prefix to %s\n" % EPREFIX) |
270 |
- b = os.path.join(pkgloc, buildprefix.lstrip(os.path.sep)) |
271 |
- i = os.path.join(builddir, "image", EPREFIX_LSTRIP) |
272 |
- # make sure the directory structure for EPREFIX is set up in |
273 |
- # the image, but avoid the last directory being there, |
274 |
- # otherwise chpathtool will complain |
275 |
- portage.util.ensure_dirs(i) |
276 |
- os.rmdir(i) |
277 |
- retval = portage.process.spawn_bash( |
278 |
- "chpathtool -q '%s' '%s' '%s' '%s'" % (b, i, buildprefix, EPREFIX), |
279 |
- env=mysettings.environ()) |
280 |
- if retval != os.EX_OK: |
281 |
- writemsg("!!! Adjusing to Prefix failed!\n", noiselevel=-1) |
282 |
- return retval |
283 |
- pkgloc = os.path.join(builddir, "image") |
284 |
- |
285 |
- mylink = dblink(mycat, mypkg, myroot, mysettings, vartree=vartree, |
286 |
- treetype="bintree", blockers=blockers) |
287 |
- retval = mylink.merge(pkgloc, infloc, myroot, myebuild, cleanup=0, |
288 |
- mydbapi=mydbapi, prev_mtimes=prev_mtimes) |
289 |
- did_merge_phase = True |
290 |
- success = retval == os.EX_OK |
291 |
- return retval |
292 |
- finally: |
293 |
- mysettings.pop("PORTAGE_BINPKG_FILE", None) |
294 |
- if tbz2_lock: |
295 |
- portage.locks.unlockfile(tbz2_lock) |
296 |
- if True: |
297 |
- if not did_merge_phase: |
298 |
- # The merge phase handles this already. Callers don't know how |
299 |
- # far this function got, so we have to call elog_process() here |
300 |
- # so that it's only called once. |
301 |
- from portage.elog import elog_process |
302 |
- elog_process(mycat + "/" + mypkg, mysettings) |
303 |
- try: |
304 |
- if success: |
305 |
- shutil.rmtree(builddir) |
306 |
- except (IOError, OSError) as e: |
307 |
- if e.errno != errno.ENOENT: |
308 |
- raise |
309 |
- del e |
310 |
- |
311 |
def deprecated_profile_check(settings=None): |
312 |
config_root = "/" |
313 |
if settings is not None: |
314 |
@@ -894,17 +655,6 @@ |
315 |
writemsg("\n\n", noiselevel=-1) |
316 |
return True |
317 |
|
318 |
-# gets virtual package settings |
319 |
-def getvirtuals(myroot): |
320 |
- """ |
321 |
- Calls portage.settings.getvirtuals(). |
322 |
- @deprecated: Use portage.settings.getvirtuals(). |
323 |
- """ |
324 |
- global settings |
325 |
- warnings.warn("portage.getvirtuals() is deprecated", |
326 |
- DeprecationWarning, stacklevel=2) |
327 |
- return settings.getvirtuals() |
328 |
- |
329 |
def commit_mtimedb(mydict=None, filename=None): |
330 |
if mydict is None: |
331 |
global mtimedb |
332 |
|
333 |
Copied: main/branches/prefix/pym/portage/_deprecated.py (from rev 15470, main/trunk/pym/portage/_deprecated.py) |
334 |
=================================================================== |
335 |
--- main/branches/prefix/pym/portage/_deprecated.py (rev 0) |
336 |
+++ main/branches/prefix/pym/portage/_deprecated.py 2010-02-27 20:02:45 UTC (rev 15484) |
337 |
@@ -0,0 +1,228 @@ |
338 |
+# Copyright 2010 Gentoo Foundation |
339 |
+# Distributed under the terms of the GNU General Public License v2 |
340 |
+# $Id$ |
341 |
+ |
342 |
+from __future__ import print_function |
343 |
+ |
344 |
+import errno |
345 |
+import shutil |
346 |
+import warnings |
347 |
+ |
348 |
+import portage |
349 |
+from portage import os, _encodings, _unicode_decode, _unicode_encode |
350 |
+from portage.data import portage_gid, portage_uid |
351 |
+from portage.dep import dep_getkey |
352 |
+from portage.localization import _ |
353 |
+from portage.manifest import Manifest |
354 |
+from portage.util import writemsg, writemsg_stdout |
355 |
+ |
356 |
+def digestParseFile(myfilename, mysettings=None): |
357 |
+ """(filename) -- Parses a given file for entries matching: |
358 |
+ <checksumkey> <checksum_hex_string> <filename> <filesize> |
359 |
+ Ignores lines that don't start with a valid checksum identifier |
360 |
+ and returns a dict with the filenames as keys and {checksumkey:checksum} |
361 |
+ as the values. |
362 |
+ DEPRECATED: this function is now only a compability wrapper for |
363 |
+ portage.manifest.Manifest().""" |
364 |
+ |
365 |
+ warnings.warn("portage.digestParseFile() is deprecated", |
366 |
+ DeprecationWarning, stacklevel=2) |
367 |
+ |
368 |
+ mysplit = myfilename.split(os.sep) |
369 |
+ if mysplit[-2] == "files" and mysplit[-1].startswith("digest-"): |
370 |
+ pkgdir = os.sep + os.sep.join(mysplit[:-2]).strip(os.sep) |
371 |
+ elif mysplit[-1] == "Manifest": |
372 |
+ pkgdir = os.sep + os.sep.join(mysplit[:-1]).strip(os.sep) |
373 |
+ |
374 |
+ return Manifest(pkgdir, None).getDigests() |
375 |
+ |
376 |
+def dep_virtual(mysplit, mysettings): |
377 |
+ "Does virtual dependency conversion" |
378 |
+ warnings.warn("portage.dep_virtual() is deprecated", |
379 |
+ DeprecationWarning, stacklevel=2) |
380 |
+ newsplit=[] |
381 |
+ myvirtuals = mysettings.getvirtuals() |
382 |
+ for x in mysplit: |
383 |
+ if isinstance(x, list): |
384 |
+ newsplit.append(dep_virtual(x, mysettings)) |
385 |
+ else: |
386 |
+ mykey=dep_getkey(x) |
387 |
+ mychoices = myvirtuals.get(mykey, None) |
388 |
+ if mychoices: |
389 |
+ if len(mychoices) == 1: |
390 |
+ a = x.replace(mykey, dep_getkey(mychoices[0]), 1) |
391 |
+ else: |
392 |
+ if x[0]=="!": |
393 |
+ # blocker needs "and" not "or(||)". |
394 |
+ a=[] |
395 |
+ else: |
396 |
+ a=['||'] |
397 |
+ for y in mychoices: |
398 |
+ a.append(x.replace(mykey, dep_getkey(y), 1)) |
399 |
+ newsplit.append(a) |
400 |
+ else: |
401 |
+ newsplit.append(x) |
402 |
+ return newsplit |
403 |
+ |
404 |
+def getvirtuals(myroot): |
405 |
+ """ |
406 |
+ Calls portage.settings.getvirtuals(). |
407 |
+ @deprecated: Use portage.settings.getvirtuals(). |
408 |
+ """ |
409 |
+ warnings.warn("portage.getvirtuals() is deprecated", |
410 |
+ DeprecationWarning, stacklevel=2) |
411 |
+ return portage.settings.getvirtuals() |
412 |
+ |
413 |
+def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None, |
414 |
+ vartree=None, prev_mtimes=None, blockers=None): |
415 |
+ """will merge a .tbz2 file, returning a list of runtime dependencies |
416 |
+ that must be satisfied, or None if there was a merge error. This |
417 |
+ code assumes the package exists.""" |
418 |
+ |
419 |
+ warnings.warn("portage.pkgmerge() is deprecated", |
420 |
+ DeprecationWarning, stacklevel=2) |
421 |
+ |
422 |
+ if mydbapi is None: |
423 |
+ mydbapi = portage.db[myroot]["bintree"].dbapi |
424 |
+ if vartree is None: |
425 |
+ vartree = portage.db[myroot]["vartree"] |
426 |
+ if mytbz2[-5:]!=".tbz2": |
427 |
+ print(_("!!! Not a .tbz2 file")) |
428 |
+ return 1 |
429 |
+ |
430 |
+ tbz2_lock = None |
431 |
+ mycat = None |
432 |
+ mypkg = None |
433 |
+ did_merge_phase = False |
434 |
+ success = False |
435 |
+ try: |
436 |
+ """ Don't lock the tbz2 file because the filesytem could be readonly or |
437 |
+ shared by a cluster.""" |
438 |
+ #tbz2_lock = portage.locks.lockfile(mytbz2, wantnewlockfile=1) |
439 |
+ |
440 |
+ mypkg = os.path.basename(mytbz2)[:-5] |
441 |
+ xptbz2 = portage.xpak.tbz2(mytbz2) |
442 |
+ mycat = xptbz2.getfile(_unicode_encode("CATEGORY", |
443 |
+ encoding=_encodings['repo.content'])) |
444 |
+ if not mycat: |
445 |
+ writemsg(_("!!! CATEGORY info missing from info chunk, aborting...\n"), |
446 |
+ noiselevel=-1) |
447 |
+ return 1 |
448 |
+ mycat = _unicode_decode(mycat, |
449 |
+ encoding=_encodings['repo.content'], errors='replace') |
450 |
+ mycat = mycat.strip() |
451 |
+ |
452 |
+ buildprefix = xptbz2.getfile("EPREFIX") |
453 |
+ if not buildprefix: |
454 |
+ writemsg("!!! EPREFIX info missing from info chunk, aborting...\n", |
455 |
+ noiselevel=-1) |
456 |
+ return 1 |
457 |
+ buildprefix = buildprefix.strip() |
458 |
+ |
459 |
+ # These are the same directories that would be used at build time. |
460 |
+ builddir = os.path.join( |
461 |
+ mysettings["PORTAGE_TMPDIR"], "portage", mycat, mypkg) |
462 |
+ catdir = os.path.dirname(builddir) |
463 |
+ # if the prefix differs, we copy it to the image after extraction |
464 |
+ if (buildprefix != EPREFIX): |
465 |
+ pkgloc = os.path.join(builddir, "work") |
466 |
+ else: |
467 |
+ pkgloc = os.path.join(builddir, "image") |
468 |
+ infloc = os.path.join(builddir, "build-info") |
469 |
+ myebuild = os.path.join( |
470 |
+ infloc, os.path.basename(mytbz2)[:-4] + "ebuild") |
471 |
+ portage.util.ensure_dirs(os.path.dirname(catdir), |
472 |
+ uid=portage_uid, gid=portage_gid, mode=0o70, mask=0) |
473 |
+ portage.util.ensure_dirs(catdir, |
474 |
+ uid=portage_uid, gid=portage_gid, mode=0o70, mask=0) |
475 |
+ try: |
476 |
+ shutil.rmtree(builddir) |
477 |
+ except (IOError, OSError) as e: |
478 |
+ if e.errno != errno.ENOENT: |
479 |
+ raise |
480 |
+ del e |
481 |
+ for mydir in (builddir, pkgloc, infloc): |
482 |
+ portage.util.ensure_dirs(mydir, uid=portage_uid, |
483 |
+ gid=portage_gid, mode=0o755) |
484 |
+ writemsg_stdout(_(">>> Extracting info\n")) |
485 |
+ xptbz2.unpackinfo(infloc) |
486 |
+ mysettings.setcpv(mycat + "/" + mypkg, mydb=mydbapi) |
487 |
+ # Store the md5sum in the vdb. |
488 |
+ fp = open(_unicode_encode(os.path.join(infloc, 'BINPKGMD5')), 'w') |
489 |
+ fp.write(str(portage.checksum.perform_md5(mytbz2))+"\n") |
490 |
+ fp.close() |
491 |
+ |
492 |
+ # This gives bashrc users an opportunity to do various things |
493 |
+ # such as remove binary packages after they're installed. |
494 |
+ mysettings["PORTAGE_BINPKG_FILE"] = mytbz2 |
495 |
+ mysettings.backup_changes("PORTAGE_BINPKG_FILE") |
496 |
+ debug = mysettings.get("PORTAGE_DEBUG", "") == "1" |
497 |
+ |
498 |
+ # We want to install in "our" prefix, not the binary one |
499 |
+ mysettings["EPREFIX"] = EPREFIX |
500 |
+ # Store "our" prefix in the vdb. |
501 |
+ fp = open(os.path.join(infloc, "EPREFIX"), "w") |
502 |
+ fp.write(EPREFIX+"\n") |
503 |
+ fp.close() |
504 |
+ |
505 |
+ # Eventually we'd like to pass in the saved ebuild env here. |
506 |
+ retval = portage.doebuild(myebuild, "setup", myroot, mysettings, debug=debug, |
507 |
+ tree="bintree", mydbapi=mydbapi, vartree=vartree) |
508 |
+ if retval != os.EX_OK: |
509 |
+ writemsg(_("!!! Setup failed: %s\n") % retval, noiselevel=-1) |
510 |
+ return retval |
511 |
+ |
512 |
+ writemsg_stdout(_(">>> Extracting %s\n") % mypkg) |
513 |
+ retval = portage.process.spawn_bash( |
514 |
+ "bzip2 -dqc -- '%s' | tar -xp -C '%s' -f -" % (mytbz2, pkgloc), |
515 |
+ env=mysettings.environ()) |
516 |
+ if retval != os.EX_OK: |
517 |
+ writemsg(_("!!! Error Extracting '%s'\n") % mytbz2, noiselevel=-1) |
518 |
+ return retval |
519 |
+ #portage.locks.unlockfile(tbz2_lock) |
520 |
+ #tbz2_lock = None |
521 |
+ |
522 |
+ # the extracted package put everything in buildprefix, so we |
523 |
+ # just have to move it to the right EPREFIX |
524 |
+ if buildprefix != EPREFIX: |
525 |
+ writemsg_stdout(">>> Adjusting Prefix to %s\n" % EPREFIX) |
526 |
+ b = os.path.join(pkgloc, buildprefix.lstrip(os.path.sep)) |
527 |
+ i = os.path.join(builddir, "image", EPREFIX_LSTRIP) |
528 |
+ # make sure the directory structure for EPREFIX is set up in |
529 |
+ # the image, but avoid the last directory being there, |
530 |
+ # otherwise chpathtool will complain |
531 |
+ portage.util.ensure_dirs(i) |
532 |
+ os.rmdir(i) |
533 |
+ retval = portage.process.spawn_bash( |
534 |
+ "chpathtool -q '%s' '%s' '%s' '%s'" % (b, i, buildprefix, EPREFIX), |
535 |
+ env=mysettings.environ()) |
536 |
+ if retval != os.EX_OK: |
537 |
+ writemsg("!!! Adjusing to Prefix failed!\n", noiselevel=-1) |
538 |
+ return retval |
539 |
+ pkgloc = os.path.join(builddir, "image") |
540 |
+ |
541 |
+ mylink = dblink(mycat, mypkg, myroot, mysettings, vartree=vartree, |
542 |
+ treetype="bintree", blockers=blockers) |
543 |
+ retval = mylink.merge(pkgloc, infloc, myroot, myebuild, cleanup=0, |
544 |
+ mydbapi=mydbapi, prev_mtimes=prev_mtimes) |
545 |
+ did_merge_phase = True |
546 |
+ success = retval == os.EX_OK |
547 |
+ return retval |
548 |
+ finally: |
549 |
+ mysettings.pop("PORTAGE_BINPKG_FILE", None) |
550 |
+ if tbz2_lock: |
551 |
+ portage.locks.unlockfile(tbz2_lock) |
552 |
+ if True: |
553 |
+ if not did_merge_phase: |
554 |
+ # The merge phase handles this already. Callers don't know how |
555 |
+ # far this function got, so we have to call elog_process() here |
556 |
+ # so that it's only called once. |
557 |
+ from portage.elog import elog_process |
558 |
+ elog_process(mycat + "/" + mypkg, mysettings) |
559 |
+ try: |
560 |
+ if success: |
561 |
+ shutil.rmtree(builddir) |
562 |
+ except (IOError, OSError) as e: |
563 |
+ if e.errno != errno.ENOENT: |
564 |
+ raise |
565 |
+ del e |
566 |
|
567 |
Modified: main/branches/prefix/pym/portage/dbapi/__init__.py |
568 |
=================================================================== |
569 |
--- main/branches/prefix/pym/portage/dbapi/__init__.py 2010-02-27 19:32:48 UTC (rev 15483) |
570 |
+++ main/branches/prefix/pym/portage/dbapi/__init__.py 2010-02-27 20:02:45 UTC (rev 15484) |
571 |
@@ -8,7 +8,7 @@ |
572 |
|
573 |
import portage |
574 |
portage.proxy.lazyimport.lazyimport(globals(), |
575 |
- 'portage.dbapi.dep_expand:_dep_expand', |
576 |
+ 'portage.dbapi.dep_expand:dep_expand@_dep_expand', |
577 |
'portage.dep:match_from_list', |
578 |
'portage.locks:unlockfile', |
579 |
'portage.output:colorize', |
580 |
|
581 |
Modified: main/branches/prefix/pym/portage/dbapi/vartree.py |
582 |
=================================================================== |
583 |
--- main/branches/prefix/pym/portage/dbapi/vartree.py 2010-02-27 19:32:48 UTC (rev 15483) |
584 |
+++ main/branches/prefix/pym/portage/dbapi/vartree.py 2010-02-27 20:02:45 UTC (rev 15484) |
585 |
@@ -5475,6 +5475,38 @@ |
586 |
"Is this a regular package (does it have a CATEGORY file? A dblink can be virtual *and* regular)" |
587 |
return os.path.exists(os.path.join(self.dbdir, "CATEGORY")) |
588 |
|
589 |
+def merge(mycat, mypkg, pkgloc, infloc, myroot, mysettings, myebuild=None, |
590 |
+ mytree=None, mydbapi=None, vartree=None, prev_mtimes=None, blockers=None, |
591 |
+ scheduler=None): |
592 |
+ if not os.access(myroot + EPREFIX_LSTRIP, os.W_OK): |
593 |
+ writemsg(_("Permission denied: access('%s', W_OK)\n") % myroot + EPREFIX_LSTRIP, |
594 |
+ noiselevel=-1) |
595 |
+ return errno.EACCES |
596 |
+ mylink = dblink(mycat, mypkg, myroot, mysettings, treetype=mytree, |
597 |
+ vartree=vartree, blockers=blockers, scheduler=scheduler) |
598 |
+ return mylink.merge(pkgloc, infloc, myroot, myebuild, |
599 |
+ mydbapi=mydbapi, prev_mtimes=prev_mtimes) |
600 |
+ |
601 |
+def unmerge(cat, pkg, myroot, mysettings, mytrimworld=1, vartree=None, |
602 |
+ ldpath_mtimes=None, scheduler=None): |
603 |
+ mylink = dblink(cat, pkg, myroot, mysettings, treetype="vartree", |
604 |
+ vartree=vartree, scheduler=scheduler) |
605 |
+ vartree = mylink.vartree |
606 |
+ try: |
607 |
+ mylink.lockdb() |
608 |
+ if mylink.exists(): |
609 |
+ vartree.dbapi.plib_registry.load() |
610 |
+ vartree.dbapi.plib_registry.pruneNonExisting() |
611 |
+ retval = mylink.unmerge(trimworld=mytrimworld, cleanup=1, |
612 |
+ ldpath_mtimes=ldpath_mtimes) |
613 |
+ if retval == os.EX_OK: |
614 |
+ mylink.delete() |
615 |
+ return retval |
616 |
+ return os.EX_OK |
617 |
+ finally: |
618 |
+ vartree.dbapi.linkmap._clear_cache() |
619 |
+ mylink.unlockdb() |
620 |
+ |
621 |
def write_contents(contents, root, f): |
622 |
""" |
623 |
Write contents to any file like object. The file will be left open. |
624 |
|
625 |
Modified: main/branches/prefix/pym/repoman/checks.py |
626 |
=================================================================== |
627 |
--- main/branches/prefix/pym/repoman/checks.py 2010-02-27 19:32:48 UTC (rev 15483) |
628 |
+++ main/branches/prefix/pym/repoman/checks.py 2010-02-27 20:02:45 UTC (rev 15484) |
629 |
@@ -35,17 +35,13 @@ |
630 |
|
631 |
ignore_line = re.compile(r'(^\s*#)') |
632 |
func_end_re = re.compile(r'^\}$') |
633 |
+ phases_re = re.compile('(%s)' % '|'.join(( |
634 |
+ 'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare', |
635 |
+ 'src_configure', 'src_compile', 'src_test', 'src_install', |
636 |
+ 'pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm', |
637 |
+ 'pkg_config'))) |
638 |
in_phase = '' |
639 |
|
640 |
- def __init__(self): |
641 |
- self.phases = ('pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare', 'src_configure', 'src_compile', |
642 |
- 'src_test', 'src_install', 'pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm', 'pkg_config') |
643 |
- phase_re = '(' |
644 |
- for phase in self.phases: |
645 |
- phase_re += phase + '|' |
646 |
- phase_re = phase_re[:-1] + ')' |
647 |
- self.phases_re = re.compile(phase_re) |
648 |
- |
649 |
def check(self, num, line): |
650 |
m = self.phases_re.match(line) |
651 |
if m is not None: |