Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r12735 - in main/trunk/pym/portage: cache dbapi
Date: Sun, 01 Mar 2009 06:25:09
Message-Id: E1Ldf6p-0003Zl-O7@stork.gentoo.org
1 Author: zmedico
2 Date: 2009-03-01 06:25:07 +0000 (Sun, 01 Mar 2009)
3 New Revision: 12735
4
5 Modified:
6 main/trunk/pym/portage/cache/sqlite.py
7 main/trunk/pym/portage/cache/template.py
8 main/trunk/pym/portage/cache/util.py
9 main/trunk/pym/portage/dbapi/porttree.py
10 Log:
11 * Fix portage.cache.template.database.__getitem__() to validate the _mtime_
12 field and raise a CacheCorruption exception if necessary.
13 * Make _mtime_ and _eclasses_ validation code in portdbapi and mirror_cache()
14 assume that these fields are the correct type (otherwise a CacheCorruption
15 exeception should be raised earlier).
16 * Fix the sqlite module to implement _getitem() so that it properly inherits
17 __getitem__() _mtime_ and _eclasses_ handling.
18
19
20 Modified: main/trunk/pym/portage/cache/sqlite.py
21 ===================================================================
22 --- main/trunk/pym/portage/cache/sqlite.py 2009-03-01 00:05:41 UTC (rev 12734)
23 +++ main/trunk/pym/portage/cache/sqlite.py 2009-03-01 06:25:07 UTC (rev 12735)
24 @@ -143,7 +143,7 @@
25 if actual_synchronous!=synchronous:
26 raise cache_errors.InitializationError(self.__class__,"actual synchronous = "+actual_synchronous+" does does not match requested value of "+synchronous)
27
28 - def __getitem__(self, cpv):
29 + def _getitem(self, cpv):
30 cursor = self._db_cursor
31 cursor.execute("select * from %s where %s=%s" % \
32 (self._db_table["packages"]["table_name"],
33 @@ -169,10 +169,6 @@
34 d[k]=str(d[k]) # convert unicode strings to normal
35 except UnicodeEncodeError, e:
36 pass #writemsg("%s: %s\n" % (cpv, str(e)))
37 - if "_eclasses_" in d:
38 - d["_eclasses_"] = reconstruct_eclasses(cpv, d["_eclasses_"])
39 - else:
40 - d["_eclasses_"] = {}
41 for x in self._known_keys:
42 d.setdefault(x,'')
43 return d
44
45 Modified: main/trunk/pym/portage/cache/template.py
46 ===================================================================
47 --- main/trunk/pym/portage/cache/template.py 2009-03-01 00:05:41 UTC (rev 12734)
48 +++ main/trunk/pym/portage/cache/template.py 2009-03-01 06:25:07 UTC (rev 12735)
49 @@ -40,6 +40,16 @@
50 d["_eclasses_"] = reconstruct_eclasses(cpv, d["_eclasses_"])
51 elif "_eclasses_" not in d:
52 d["_eclasses_"] = {}
53 + mtime = d.get('_mtime_')
54 + if mtime is None:
55 + raise cache_errors.CacheCorruption(cpv,
56 + '_mtime_ field is missing')
57 + try:
58 + mtime = long(mtime)
59 + except ValueError:
60 + raise cache_errors.CacheCorruption(cpv,
61 + '_mtime_ conversion to long failed: %s' % (mtime,))
62 + d['_mtime_'] = mtime
63 return d
64
65 def _getitem(self, cpv):
66
67 Modified: main/trunk/pym/portage/cache/util.py
68 ===================================================================
69 --- main/trunk/pym/portage/cache/util.py 2009-03-01 00:05:41 UTC (rev 12734)
70 +++ main/trunk/pym/portage/cache/util.py 2009-03-01 06:25:07 UTC (rev 12735)
71 @@ -45,13 +45,10 @@
72 except (KeyError, cache_errors.CacheError):
73 pass
74 else:
75 - try:
76 - if long(trg["_mtime_"]) == long(entry["_mtime_"]) and \
77 - eclass_cache.is_eclass_data_valid(trg["_eclasses_"]) and \
78 - set(trg["_eclasses_"]) == set(entry["_eclasses_"]):
79 - write_it = False
80 - except cache_errors.CacheError:
81 - pass
82 + if trg['_mtime_'] == entry['_mtime_'] and \
83 + eclass_cache.is_eclass_data_valid(trg['_eclasses_']) and \
84 + set(trg['_eclasses_']) == set(entry['_eclasses_']):
85 + write_it = False
86
87 for d in (entry, trg):
88 if d is not None and d.get('EAPI') in ('', '0'):
89
90 Modified: main/trunk/pym/portage/dbapi/porttree.py
91 ===================================================================
92 --- main/trunk/pym/portage/dbapi/porttree.py 2009-03-01 00:05:41 UTC (rev 12734)
93 +++ main/trunk/pym/portage/dbapi/porttree.py 2009-03-01 06:25:07 UTC (rev 12735)
94 @@ -346,19 +346,6 @@
95 for auxdb in auxdbs:
96 try:
97 metadata = auxdb[cpv]
98 - eapi = metadata.get("EAPI","").strip()
99 - if not eapi:
100 - eapi = "0"
101 - if eapi.startswith("-") and eapi_is_supported(eapi[1:]):
102 - pass
103 - elif emtime != int(metadata.get("_mtime_", 0)):
104 - pass
105 - elif len(metadata.get("_eclasses_", [])) > 0:
106 - if self.eclassdb.is_eclass_data_valid(
107 - metadata["_eclasses_"]):
108 - doregen = False
109 - else:
110 - doregen = False
111 except KeyError:
112 pass
113 except CacheError:
114 @@ -367,6 +354,15 @@
115 del auxdb[cpv]
116 except KeyError:
117 pass
118 + else:
119 + eapi = metadata.get('EAPI', '').strip()
120 + if not eapi:
121 + eapi = '0'
122 + if not (eapi[:1] == '-' and eapi_is_supported(eapi[1:])) and \
123 + emtime == metadata['_mtime_'] and \
124 + self.eclassdb.is_eclass_data_valid(metadata['_eclasses_']):
125 + doregen = False
126 +
127 if not doregen:
128 break