Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 276813 | Differences between
and this patch

Collapse All | Expand All

(-)a/pym/portage/cache/flat_hash.py (-10 / +6 lines)
Lines 9-14 from portage.cache import cache_errors Link Here
9
import errno
9
import errno
10
import stat
10
import stat
11
import sys
11
import sys
12
import os as _os
12
from portage import os
13
from portage import os
13
from portage import _encodings
14
from portage import _encodings
14
from portage import _unicode_encode
15
from portage import _unicode_encode
Lines 32-64 class database(fs_template.FsBased): Link Here
32
			self._ensure_dirs()
33
			self._ensure_dirs()
33
34
34
	def _getitem(self, cpv):
35
	def _getitem(self, cpv):
35
		fp = os.path.join(self.location, cpv)
36
		fp = self.location + _os.sep + cpv
36
		try:
37
		try:
37
			myf = codecs.open(_unicode_encode(fp,
38
			myf = codecs.open(_unicode_encode(fp,
38
				encoding=_encodings['fs'], errors='strict'),
39
				encoding=_encodings['fs'], errors='strict'),
39
				mode='r', encoding=_encodings['repo.content'],
40
				mode='r', encoding=_encodings['repo.content'],
40
				errors='replace')
41
				errors='replace')
41
			try:
42
			try:
42
				d = self._parse_data(myf.readlines(), cpv)
43
				d = self._parse_data(myf.read().split("\n"), cpv)
43
				if '_mtime_' not in d:
44
				if '_mtime_' not in d:
44
					# Backward compatibility with old cache
45
					# Backward compatibility with old cache
45
					# that uses mtime mangling.
46
					# that uses mtime mangling.
46
					d['_mtime_'] = long(os.fstat(myf.fileno()).st_mtime)
47
					d['_mtime_'] = long(_os.fstat(myf.fileno()).st_mtime)
47
				return d
48
				return d
48
			finally:
49
			finally:
49
				myf.close()
50
				myf.close()
50
		except (IOError, OSError) as e:
51
		except (IOError, OSError) as e:
51
			if e.errno != errno.ENOENT:
52
			if e.errno != errno.ENOENT:
52
				raise cache_errors.CacheCorruption(cpv, e)
53
				raise cache_errors.CacheCorruption(cpv, e)
53
			raise KeyError(cpv)
54
			raise KeyError(cpv, e)
54
55
55
	def _parse_data(self, data, cpv):
56
	def _parse_data(self, data, cpv):
56
		try:
57
		try:
57
			d = dict(map(lambda x:x.rstrip("\n").split("=", 1), data))
58
			return dict( x.split("=", 1) for x in data )
58
		except ValueError as e:
59
		except ValueError as e:
59
			# If a line is missing an "=", the split length is 1 instead of 2.
60
			# If a line is missing an "=", the split length is 1 instead of 2.
60
			raise cache_errors.CacheCorruption(cpv, e)
61
			raise cache_errors.CacheCorruption(cpv, e)
61
		return d
62
62
63
	def _setitem(self, cpv, values):
63
	def _setitem(self, cpv, values):
64
#		import pdb;pdb.set_trace()
64
#		import pdb;pdb.set_trace()
Lines 101-107 class database(fs_template.FsBased): Link Here
101
			os.remove(fp)
101
			os.remove(fp)
102
			raise cache_errors.CacheCorruption(cpv, e)
102
			raise cache_errors.CacheCorruption(cpv, e)
103
103
104
105
	def _delitem(self, cpv):
104
	def _delitem(self, cpv):
106
#		import pdb;pdb.set_trace()
105
#		import pdb;pdb.set_trace()
107
		try:
106
		try:
Lines 112-122 class database(fs_template.FsBased): Link Here
112
			else:
111
			else:
113
				raise cache_errors.CacheCorruption(cpv, e)
112
				raise cache_errors.CacheCorruption(cpv, e)
114
113
115
116
	def __contains__(self, cpv):
114
	def __contains__(self, cpv):
117
		return os.path.exists(os.path.join(self.location, cpv))
115
		return os.path.exists(os.path.join(self.location, cpv))
118
116
119
120
	def __iter__(self):
117
	def __iter__(self):
121
		"""generator for walking the dir struct"""
118
		"""generator for walking the dir struct"""
122
		dirs = [self.location]
119
		dirs = [self.location]
Lines 140-143 class database(fs_template.FsBased): Link Here
140
					continue
137
					continue
141
				yield p[len_base+1:]
138
				yield p[len_base+1:]
142
			dirs.pop(0)
139
			dirs.pop(0)
143
(-)a/pym/portage/cache/metadata.py (-1 / +1 lines)
Lines 52-58 class database(flat_hash.database): Link Here
52
				d.clear()
52
				d.clear()
53
				try:
53
				try:
54
					for i, key in enumerate(self.auxdbkey_order):
54
					for i, key in enumerate(self.auxdbkey_order):
55
						d[key] = data[i].rstrip("\n")
55
						d[key] = data[i]
56
				except IndexError:
56
				except IndexError:
57
					pass
57
					pass
58
				break
58
				break
(-)a/pym/portage/dbapi/porttree.py (-10 / +3 lines)
Lines 379-387 class portdbapi(dbapi): Link Here
379
			"PDEPEND", "PROPERTIES", "PROVIDE", "RDEPEND", "repository",
379
			"PDEPEND", "PROPERTIES", "PROVIDE", "RDEPEND", "repository",
380
			"RESTRICT", "SLOT"])
380
			"RESTRICT", "SLOT"])
381
381
382
		# Repoman modifies _aux_cache_keys, so delay _aux_cache_slot_dict
383
		# initialization until the first aux_get call.
384
		self._aux_cache_slot_dict = None
385
		self._aux_cache = {}
382
		self._aux_cache = {}
386
		self._broken_ebuilds = set()
383
		self._broken_ebuilds = set()
387
384
Lines 548-554 class portdbapi(dbapi): Link Here
548
	def _pull_valid_cache(self, cpv, ebuild_path, repo_path):
545
	def _pull_valid_cache(self, cpv, ebuild_path, repo_path):
549
546
550
		try:
547
		try:
551
			st = os.stat(ebuild_path)
548
			st = _os.stat(_unicode_encode(ebuild_path, encoding=portage._encodings['fs']))
552
			emtime = st[stat.ST_MTIME]
549
			emtime = st[stat.ST_MTIME]
553
		except OSError:
550
		except OSError:
554
			writemsg(_("!!! aux_get(): ebuild for " \
551
			writemsg(_("!!! aux_get(): ebuild for " \
Lines 668-675 class portdbapi(dbapi): Link Here
668
				mydata["_eclasses_"] = {}
665
				mydata["_eclasses_"] = {}
669
666
670
		# do we have a origin repository name for the current package
667
		# do we have a origin repository name for the current package
671
		mydata["repository"] = self._repository_map.get(
668
		mydata["repository"] = self._repository_map.get(mylocation, "")
672
			os.path.sep.join(myebuild.split(os.path.sep)[:-3]), "")
673
669
674
		mydata["INHERITED"] = ' '.join(mydata.get("_eclasses_", []))
670
		mydata["INHERITED"] = ' '.join(mydata.get("_eclasses_", []))
675
		mydata["_mtime_"] = long(st.st_mtime)
671
		mydata["_mtime_"] = long(st.st_mtime)
Lines 687-696 class portdbapi(dbapi): Link Here
687
		returnme = [mydata.get(x, "") for x in mylist]
683
		returnme = [mydata.get(x, "") for x in mylist]
688
684
689
		if cache_me:
685
		if cache_me:
690
			if self._aux_cache_slot_dict is None:
686
			aux_cache = {}
691
				self._aux_cache_slot_dict = \
692
					slot_dict_class(self._aux_cache_keys)
693
			aux_cache = self._aux_cache_slot_dict()
694
			for x in self._aux_cache_keys:
687
			for x in self._aux_cache_keys:
695
				aux_cache[x] = mydata.get(x, "")
688
				aux_cache[x] = mydata.get(x, "")
696
			self._aux_cache[mycpv] = aux_cache
689
			self._aux_cache[mycpv] = aux_cache

Return to bug 276813