1 |
Author: zmedico |
2 |
Date: 2010-02-25 22:16:32 +0000 (Thu, 25 Feb 2010) |
3 |
New Revision: 15466 |
4 |
|
5 |
Added: |
6 |
main/trunk/pym/portage/_deprecated.py |
7 |
Modified: |
8 |
main/trunk/pym/portage/__init__.py |
9 |
Log: |
10 |
Splid deprecated functions into a _deprecated module. |
11 |
|
12 |
|
13 |
Modified: main/trunk/pym/portage/__init__.py |
14 |
=================================================================== |
15 |
--- main/trunk/pym/portage/__init__.py 2010-02-25 22:02:52 UTC (rev 15465) |
16 |
+++ main/trunk/pym/portage/__init__.py 2010-02-25 22:16:32 UTC (rev 15466) |
17 |
@@ -136,6 +136,7 @@ |
18 |
'cpv_getkey@getCPFromCPV,endversion_keys,' + \ |
19 |
'suffix_value@endversion,pkgcmp,pkgsplit,vercmp,ververify', |
20 |
'portage.xpak', |
21 |
+ 'portage._deprecated:dep_virtual,digestParseFile,pkgmerge', |
22 |
) |
23 |
|
24 |
import portage.const |
25 |
@@ -544,30 +545,6 @@ |
26 |
|
27 |
_doebuild_manifest_exempt_depend = 0 |
28 |
|
29 |
-def digestParseFile(myfilename, mysettings=None): |
30 |
- """(filename) -- Parses a given file for entries matching: |
31 |
- <checksumkey> <checksum_hex_string> <filename> <filesize> |
32 |
- Ignores lines that don't start with a valid checksum identifier |
33 |
- and returns a dict with the filenames as keys and {checksumkey:checksum} |
34 |
- as the values. |
35 |
- DEPRECATED: this function is now only a compability wrapper for |
36 |
- portage.manifest.Manifest().""" |
37 |
- |
38 |
- warnings.warn("portage.digestParseFile() is deprecated", |
39 |
- DeprecationWarning, stacklevel=2) |
40 |
- |
41 |
- mysplit = myfilename.split(os.sep) |
42 |
- if mysplit[-2] == "files" and mysplit[-1].startswith("digest-"): |
43 |
- pkgdir = os.sep + os.sep.join(mysplit[:-2]).strip(os.sep) |
44 |
- elif mysplit[-1] == "Manifest": |
45 |
- pkgdir = os.sep + os.sep.join(mysplit[:-1]).strip(os.sep) |
46 |
- |
47 |
- if mysettings is None: |
48 |
- global settings |
49 |
- mysettings = config(clone=settings) |
50 |
- |
51 |
- return Manifest(pkgdir, mysettings["DISTDIR"]).getDigests() |
52 |
- |
53 |
_testing_eapis = frozenset() |
54 |
_deprecated_eapis = frozenset(["3_pre2", "3_pre1", "2_pre3", "2_pre2", "2_pre1"]) |
55 |
|
56 |
@@ -671,34 +648,6 @@ |
57 |
vartree.dbapi.linkmap._clear_cache() |
58 |
mylink.unlockdb() |
59 |
|
60 |
-def dep_virtual(mysplit, mysettings): |
61 |
- "Does virtual dependency conversion" |
62 |
- warnings.warn("portage.dep_virtual() is deprecated", |
63 |
- DeprecationWarning, stacklevel=2) |
64 |
- newsplit=[] |
65 |
- myvirtuals = mysettings.getvirtuals() |
66 |
- for x in mysplit: |
67 |
- if isinstance(x, list): |
68 |
- newsplit.append(dep_virtual(x, mysettings)) |
69 |
- else: |
70 |
- mykey=dep_getkey(x) |
71 |
- mychoices = myvirtuals.get(mykey, None) |
72 |
- if mychoices: |
73 |
- if len(mychoices) == 1: |
74 |
- a = x.replace(mykey, dep_getkey(mychoices[0]), 1) |
75 |
- else: |
76 |
- if x[0]=="!": |
77 |
- # blocker needs "and" not "or(||)". |
78 |
- a=[] |
79 |
- else: |
80 |
- a=['||'] |
81 |
- for y in mychoices: |
82 |
- a.append(x.replace(mykey, dep_getkey(y), 1)) |
83 |
- newsplit.append(a) |
84 |
- else: |
85 |
- newsplit.append(x) |
86 |
- return newsplit |
87 |
- |
88 |
auxdbkeys = ( |
89 |
'DEPEND', 'RDEPEND', 'SLOT', 'SRC_URI', |
90 |
'RESTRICT', 'HOMEPAGE', 'LICENSE', 'DESCRIPTION', |
91 |
@@ -709,125 +658,6 @@ |
92 |
) |
93 |
auxdbkeylen=len(auxdbkeys) |
94 |
|
95 |
-def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None, |
96 |
- vartree=None, prev_mtimes=None, blockers=None): |
97 |
- """will merge a .tbz2 file, returning a list of runtime dependencies |
98 |
- that must be satisfied, or None if there was a merge error. This |
99 |
- code assumes the package exists.""" |
100 |
- |
101 |
- warnings.warn("portage.pkgmerge() is deprecated", |
102 |
- DeprecationWarning, stacklevel=2) |
103 |
- |
104 |
- global db |
105 |
- if mydbapi is None: |
106 |
- mydbapi = db[myroot]["bintree"].dbapi |
107 |
- if vartree is None: |
108 |
- vartree = db[myroot]["vartree"] |
109 |
- if mytbz2[-5:]!=".tbz2": |
110 |
- print(_("!!! Not a .tbz2 file")) |
111 |
- return 1 |
112 |
- |
113 |
- tbz2_lock = None |
114 |
- mycat = None |
115 |
- mypkg = None |
116 |
- did_merge_phase = False |
117 |
- success = False |
118 |
- try: |
119 |
- """ Don't lock the tbz2 file because the filesytem could be readonly or |
120 |
- shared by a cluster.""" |
121 |
- #tbz2_lock = portage.locks.lockfile(mytbz2, wantnewlockfile=1) |
122 |
- |
123 |
- mypkg = os.path.basename(mytbz2)[:-5] |
124 |
- xptbz2 = portage.xpak.tbz2(mytbz2) |
125 |
- mycat = xptbz2.getfile(_unicode_encode("CATEGORY", |
126 |
- encoding=_encodings['repo.content'])) |
127 |
- if not mycat: |
128 |
- writemsg(_("!!! CATEGORY info missing from info chunk, aborting...\n"), |
129 |
- noiselevel=-1) |
130 |
- return 1 |
131 |
- mycat = _unicode_decode(mycat, |
132 |
- encoding=_encodings['repo.content'], errors='replace') |
133 |
- mycat = mycat.strip() |
134 |
- |
135 |
- # These are the same directories that would be used at build time. |
136 |
- builddir = os.path.join( |
137 |
- mysettings["PORTAGE_TMPDIR"], "portage", mycat, mypkg) |
138 |
- catdir = os.path.dirname(builddir) |
139 |
- pkgloc = os.path.join(builddir, "image") |
140 |
- infloc = os.path.join(builddir, "build-info") |
141 |
- myebuild = os.path.join( |
142 |
- infloc, os.path.basename(mytbz2)[:-4] + "ebuild") |
143 |
- portage.util.ensure_dirs(os.path.dirname(catdir), |
144 |
- uid=portage_uid, gid=portage_gid, mode=0o70, mask=0) |
145 |
- catdir_lock = portage.locks.lockdir(catdir) |
146 |
- portage.util.ensure_dirs(catdir, |
147 |
- uid=portage_uid, gid=portage_gid, mode=0o70, mask=0) |
148 |
- try: |
149 |
- shutil.rmtree(builddir) |
150 |
- except (IOError, OSError) as e: |
151 |
- if e.errno != errno.ENOENT: |
152 |
- raise |
153 |
- del e |
154 |
- for mydir in (builddir, pkgloc, infloc): |
155 |
- portage.util.ensure_dirs(mydir, uid=portage_uid, |
156 |
- gid=portage_gid, mode=0o755) |
157 |
- writemsg_stdout(_(">>> Extracting info\n")) |
158 |
- xptbz2.unpackinfo(infloc) |
159 |
- mysettings.setcpv(mycat + "/" + mypkg, mydb=mydbapi) |
160 |
- # Store the md5sum in the vdb. |
161 |
- fp = open(_unicode_encode(os.path.join(infloc, 'BINPKGMD5')), 'w') |
162 |
- fp.write(str(portage.checksum.perform_md5(mytbz2))+"\n") |
163 |
- fp.close() |
164 |
- |
165 |
- # This gives bashrc users an opportunity to do various things |
166 |
- # such as remove binary packages after they're installed. |
167 |
- mysettings["PORTAGE_BINPKG_FILE"] = mytbz2 |
168 |
- mysettings.backup_changes("PORTAGE_BINPKG_FILE") |
169 |
- debug = mysettings.get("PORTAGE_DEBUG", "") == "1" |
170 |
- |
171 |
- # Eventually we'd like to pass in the saved ebuild env here. |
172 |
- retval = doebuild(myebuild, "setup", myroot, mysettings, debug=debug, |
173 |
- tree="bintree", mydbapi=mydbapi, vartree=vartree) |
174 |
- if retval != os.EX_OK: |
175 |
- writemsg(_("!!! Setup failed: %s\n") % retval, noiselevel=-1) |
176 |
- return retval |
177 |
- |
178 |
- writemsg_stdout(_(">>> Extracting %s\n") % mypkg) |
179 |
- retval = portage.process.spawn_bash( |
180 |
- "bzip2 -dqc -- '%s' | tar -xp -C '%s' -f -" % (mytbz2, pkgloc), |
181 |
- env=mysettings.environ()) |
182 |
- if retval != os.EX_OK: |
183 |
- writemsg(_("!!! Error Extracting '%s'\n") % mytbz2, noiselevel=-1) |
184 |
- return retval |
185 |
- #portage.locks.unlockfile(tbz2_lock) |
186 |
- #tbz2_lock = None |
187 |
- |
188 |
- mylink = dblink(mycat, mypkg, myroot, mysettings, vartree=vartree, |
189 |
- treetype="bintree", blockers=blockers) |
190 |
- retval = mylink.merge(pkgloc, infloc, myroot, myebuild, cleanup=0, |
191 |
- mydbapi=mydbapi, prev_mtimes=prev_mtimes) |
192 |
- did_merge_phase = True |
193 |
- success = retval == os.EX_OK |
194 |
- return retval |
195 |
- finally: |
196 |
- mysettings.pop("PORTAGE_BINPKG_FILE", None) |
197 |
- if tbz2_lock: |
198 |
- portage.locks.unlockfile(tbz2_lock) |
199 |
- if True: |
200 |
- if not did_merge_phase: |
201 |
- # The merge phase handles this already. Callers don't know how |
202 |
- # far this function got, so we have to call elog_process() here |
203 |
- # so that it's only called once. |
204 |
- from portage.elog import elog_process |
205 |
- elog_process(mycat + "/" + mypkg, mysettings) |
206 |
- try: |
207 |
- if success: |
208 |
- shutil.rmtree(builddir) |
209 |
- except (IOError, OSError) as e: |
210 |
- if e.errno != errno.ENOENT: |
211 |
- raise |
212 |
- del e |
213 |
- |
214 |
def deprecated_profile_check(settings=None): |
215 |
config_root = "/" |
216 |
if settings is not None: |
217 |
|
218 |
Added: main/trunk/pym/portage/_deprecated.py |
219 |
=================================================================== |
220 |
--- main/trunk/pym/portage/_deprecated.py (rev 0) |
221 |
+++ main/trunk/pym/portage/_deprecated.py 2010-02-25 22:16:32 UTC (rev 15466) |
222 |
@@ -0,0 +1,182 @@ |
223 |
+# Copyright 2010 Gentoo Foundation |
224 |
+# Distributed under the terms of the GNU General Public License v2 |
225 |
+# $Id$ |
226 |
+ |
227 |
+from __future__ import print_function |
228 |
+ |
229 |
+import errno |
230 |
+import shutil |
231 |
+import warnings |
232 |
+ |
233 |
+import portage |
234 |
+from portage import os, _encodings, _unicode_decode, _unicode_encode |
235 |
+from portage.data import portage_gid, portage_uid |
236 |
+from portage.dep import dep_getkey |
237 |
+from portage.localization import _ |
238 |
+from portage.manifest import Manifest |
239 |
+from portage.util import writemsg, writemsg_stdout |
240 |
+ |
241 |
+def digestParseFile(myfilename, mysettings=None): |
242 |
+ """(filename) -- Parses a given file for entries matching: |
243 |
+ <checksumkey> <checksum_hex_string> <filename> <filesize> |
244 |
+ Ignores lines that don't start with a valid checksum identifier |
245 |
+ and returns a dict with the filenames as keys and {checksumkey:checksum} |
246 |
+ as the values. |
247 |
+ DEPRECATED: this function is now only a compability wrapper for |
248 |
+ portage.manifest.Manifest().""" |
249 |
+ |
250 |
+ warnings.warn("portage.digestParseFile() is deprecated", |
251 |
+ DeprecationWarning, stacklevel=2) |
252 |
+ |
253 |
+ mysplit = myfilename.split(os.sep) |
254 |
+ if mysplit[-2] == "files" and mysplit[-1].startswith("digest-"): |
255 |
+ pkgdir = os.sep + os.sep.join(mysplit[:-2]).strip(os.sep) |
256 |
+ elif mysplit[-1] == "Manifest": |
257 |
+ pkgdir = os.sep + os.sep.join(mysplit[:-1]).strip(os.sep) |
258 |
+ |
259 |
+ return Manifest(pkgdir, None).getDigests() |
260 |
+ |
261 |
+def dep_virtual(mysplit, mysettings): |
262 |
+ "Does virtual dependency conversion" |
263 |
+ warnings.warn("portage.dep_virtual() is deprecated", |
264 |
+ DeprecationWarning, stacklevel=2) |
265 |
+ newsplit=[] |
266 |
+ myvirtuals = mysettings.getvirtuals() |
267 |
+ for x in mysplit: |
268 |
+ if isinstance(x, list): |
269 |
+ newsplit.append(dep_virtual(x, mysettings)) |
270 |
+ else: |
271 |
+ mykey=dep_getkey(x) |
272 |
+ mychoices = myvirtuals.get(mykey, None) |
273 |
+ if mychoices: |
274 |
+ if len(mychoices) == 1: |
275 |
+ a = x.replace(mykey, dep_getkey(mychoices[0]), 1) |
276 |
+ else: |
277 |
+ if x[0]=="!": |
278 |
+ # blocker needs "and" not "or(||)". |
279 |
+ a=[] |
280 |
+ else: |
281 |
+ a=['||'] |
282 |
+ for y in mychoices: |
283 |
+ a.append(x.replace(mykey, dep_getkey(y), 1)) |
284 |
+ newsplit.append(a) |
285 |
+ else: |
286 |
+ newsplit.append(x) |
287 |
+ return newsplit |
288 |
+ |
289 |
+def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None, |
290 |
+ vartree=None, prev_mtimes=None, blockers=None): |
291 |
+ """will merge a .tbz2 file, returning a list of runtime dependencies |
292 |
+ that must be satisfied, or None if there was a merge error. This |
293 |
+ code assumes the package exists.""" |
294 |
+ |
295 |
+ warnings.warn("portage.pkgmerge() is deprecated", |
296 |
+ DeprecationWarning, stacklevel=2) |
297 |
+ |
298 |
+ if mydbapi is None: |
299 |
+ mydbapi = portage.db[myroot]["bintree"].dbapi |
300 |
+ if vartree is None: |
301 |
+ vartree = portage.db[myroot]["vartree"] |
302 |
+ if mytbz2[-5:]!=".tbz2": |
303 |
+ print(_("!!! Not a .tbz2 file")) |
304 |
+ return 1 |
305 |
+ |
306 |
+ tbz2_lock = None |
307 |
+ mycat = None |
308 |
+ mypkg = None |
309 |
+ did_merge_phase = False |
310 |
+ success = False |
311 |
+ try: |
312 |
+ """ Don't lock the tbz2 file because the filesytem could be readonly or |
313 |
+ shared by a cluster.""" |
314 |
+ #tbz2_lock = portage.locks.lockfile(mytbz2, wantnewlockfile=1) |
315 |
+ |
316 |
+ mypkg = os.path.basename(mytbz2)[:-5] |
317 |
+ xptbz2 = portage.xpak.tbz2(mytbz2) |
318 |
+ mycat = xptbz2.getfile(_unicode_encode("CATEGORY", |
319 |
+ encoding=_encodings['repo.content'])) |
320 |
+ if not mycat: |
321 |
+ writemsg(_("!!! CATEGORY info missing from info chunk, aborting...\n"), |
322 |
+ noiselevel=-1) |
323 |
+ return 1 |
324 |
+ mycat = _unicode_decode(mycat, |
325 |
+ encoding=_encodings['repo.content'], errors='replace') |
326 |
+ mycat = mycat.strip() |
327 |
+ |
328 |
+ # These are the same directories that would be used at build time. |
329 |
+ builddir = os.path.join( |
330 |
+ mysettings["PORTAGE_TMPDIR"], "portage", mycat, mypkg) |
331 |
+ catdir = os.path.dirname(builddir) |
332 |
+ pkgloc = os.path.join(builddir, "image") |
333 |
+ infloc = os.path.join(builddir, "build-info") |
334 |
+ myebuild = os.path.join( |
335 |
+ infloc, os.path.basename(mytbz2)[:-4] + "ebuild") |
336 |
+ portage.util.ensure_dirs(os.path.dirname(catdir), |
337 |
+ uid=portage_uid, gid=portage_gid, mode=0o70, mask=0) |
338 |
+ portage.util.ensure_dirs(catdir, |
339 |
+ uid=portage_uid, gid=portage_gid, mode=0o70, mask=0) |
340 |
+ try: |
341 |
+ shutil.rmtree(builddir) |
342 |
+ except (IOError, OSError) as e: |
343 |
+ if e.errno != errno.ENOENT: |
344 |
+ raise |
345 |
+ del e |
346 |
+ for mydir in (builddir, pkgloc, infloc): |
347 |
+ portage.util.ensure_dirs(mydir, uid=portage_uid, |
348 |
+ gid=portage_gid, mode=0o755) |
349 |
+ writemsg_stdout(_(">>> Extracting info\n")) |
350 |
+ xptbz2.unpackinfo(infloc) |
351 |
+ mysettings.setcpv(mycat + "/" + mypkg, mydb=mydbapi) |
352 |
+ # Store the md5sum in the vdb. |
353 |
+ fp = open(_unicode_encode(os.path.join(infloc, 'BINPKGMD5')), 'w') |
354 |
+ fp.write(str(portage.checksum.perform_md5(mytbz2))+"\n") |
355 |
+ fp.close() |
356 |
+ |
357 |
+ # This gives bashrc users an opportunity to do various things |
358 |
+ # such as remove binary packages after they're installed. |
359 |
+ mysettings["PORTAGE_BINPKG_FILE"] = mytbz2 |
360 |
+ mysettings.backup_changes("PORTAGE_BINPKG_FILE") |
361 |
+ debug = mysettings.get("PORTAGE_DEBUG", "") == "1" |
362 |
+ |
363 |
+ # Eventually we'd like to pass in the saved ebuild env here. |
364 |
+ retval = portage.doebuild(myebuild, "setup", myroot, mysettings, debug=debug, |
365 |
+ tree="bintree", mydbapi=mydbapi, vartree=vartree) |
366 |
+ if retval != os.EX_OK: |
367 |
+ writemsg(_("!!! Setup failed: %s\n") % retval, noiselevel=-1) |
368 |
+ return retval |
369 |
+ |
370 |
+ writemsg_stdout(_(">>> Extracting %s\n") % mypkg) |
371 |
+ retval = portage.process.spawn_bash( |
372 |
+ "bzip2 -dqc -- '%s' | tar -xp -C '%s' -f -" % (mytbz2, pkgloc), |
373 |
+ env=mysettings.environ()) |
374 |
+ if retval != os.EX_OK: |
375 |
+ writemsg(_("!!! Error Extracting '%s'\n") % mytbz2, noiselevel=-1) |
376 |
+ return retval |
377 |
+ #portage.locks.unlockfile(tbz2_lock) |
378 |
+ #tbz2_lock = None |
379 |
+ |
380 |
+ mylink = portage.dblink(mycat, mypkg, myroot, mysettings, vartree=vartree, |
381 |
+ treetype="bintree", blockers=blockers) |
382 |
+ retval = mylink.merge(pkgloc, infloc, myroot, myebuild, cleanup=0, |
383 |
+ mydbapi=mydbapi, prev_mtimes=prev_mtimes) |
384 |
+ did_merge_phase = True |
385 |
+ success = retval == os.EX_OK |
386 |
+ return retval |
387 |
+ finally: |
388 |
+ mysettings.pop("PORTAGE_BINPKG_FILE", None) |
389 |
+ if tbz2_lock: |
390 |
+ portage.locks.unlockfile(tbz2_lock) |
391 |
+ if True: |
392 |
+ if not did_merge_phase: |
393 |
+ # The merge phase handles this already. Callers don't know how |
394 |
+ # far this function got, so we have to call elog_process() here |
395 |
+ # so that it's only called once. |
396 |
+ from portage.elog import elog_process |
397 |
+ elog_process(mycat + "/" + mypkg, mysettings) |
398 |
+ try: |
399 |
+ if success: |
400 |
+ shutil.rmtree(builddir) |
401 |
+ except (IOError, OSError) as e: |
402 |
+ if e.errno != errno.ENOENT: |
403 |
+ raise |
404 |
+ del e |
405 |
|
406 |
|
407 |
Property changes on: main/trunk/pym/portage/_deprecated.py |
408 |
___________________________________________________________________ |
409 |
Added: svn:keywords |
410 |
+ Id |