/[gentoo-src]/portage/pym/eclass_cache.py
Gentoo

Contents of /portage/pym/eclass_cache.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download) (as text)
Tue Mar 8 10:02:20 2005 UTC (9 years, 6 months ago) by ferringb
Branch: MAIN
CVS Tags: HEAD
Branch point for: portage_2_1
Changes since 1.1: +45 -82 lines
File MIME type: text/x-python
Cache refactoring is now in use.  Eclass_cache is now just
a dict of stacked eclasses, but doesn't track per pkg eclasses.
That is left up to the cache.  The cache now ignores/drops INHERITED- this
is replaced by _eclasses_, which is a serialized dict of
{eclass name: (on disk location, long(mtime))}.  Note the tuple- returns from the
cache subsystem *should* be tuples, just the same as mtime should be a long.
aux_get *should* return INHERITED, but it should do it dynamically.
Basically, INHERITED is determined on the fly from the cache's _eclasses_ setting.
Beyond that, a sql cache template was added, along with a sqlite example.
flat_list, along with a metadata/cache specific backend, and cache.util.mirror_cache,
for metadata transfers.
Note all existing cache modules/implementations are now invalidated.  Sorry.  Upgrade em.
Existing cache's on disk are invalidated also, with the exemption of portdir/metadata/cache.

1 from portage_util import writemsg
2 import portage_file
3 import os, sys
4 from portage_data import portage_gid
5
6 class cache:
7 """
8 Maintains the cache information about eclasses used in ebuild.
9 """
10 def __init__(self,porttree_root,overlays=[]):
11 self.porttree_root = porttree_root
12
13 self.eclasses = {} # {"Name": ("location","_mtime_")}
14
15 # screw with the porttree ordering, w/out having bash inherit match it, and I'll hurt you.
16 # ~harring
17 self.porttrees = [self.porttree_root]+overlays
18 self.porttrees = tuple(map(portage_file.normpath, self.porttrees))
19 self._master_eclass_root = os.path.join(self.porttrees[0],"eclass")
20 self.update_eclasses()
21
22 def close_caches(self):
23 import traceback
24 traceback.print_stack()
25 print "%s close_cache is deprecated" % self.__class__
26 self.eclasses.clear()
27
28 def flush_cache(self):
29 import traceback
30 traceback.print_stack()
31 print "%s flush_cache is deprecated" % self.__class__
32
33 self.update_eclasses()
34
35 def update_eclasses(self):
36 self.eclasses = {}
37 eclass_len = len(".eclass")
38 for x in [portage_file.normpath(os.path.join(y,"eclass")) for y in self.porttrees]:
39 if not os.path.isdir(x):
40 continue
41 for y in [y for y in os.listdir(x) if y.endswith(".eclass")]:
42 try:
43 mtime=os.stat(x+"/"+y).st_mtime
44 except OSError:
45 continue
46 ys=y[:-eclass_len]
47 self.eclasses[ys] = (x, long(mtime))
48
49 def is_eclass_data_valid(self, ec_dict):
50 # print "checking", ec_dict
51 if not isinstance(ec_dict, dict):
52 return False
53 for eclass, tup in ec_dict.iteritems():
54 if eclass not in self.eclasses or tuple(tup) != self.eclasses[eclass]:
55 # print "failed"
56 return False
57
58 return True
59
60 def get_eclass_data(self, inherits, from_master_only=False):
61 ec_dict = {}
62 for x in inherits:
63 try:
64 ec_dict[x] = self.eclasses[x]
65 except:
66 print "ec=",ec_dict
67 print "inherits=",inherits
68 raise
69 if from_master_only and self.eclasses[x][0] != self._master_eclass_root:
70 return None
71
72 return ec_dict

  ViewVC Help
Powered by ViewVC 1.1.20