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

Collapse All | Expand All

(-)a/catalyst/hash_utils.py (-1 / +50 lines)
Lines 102-106 class HashMap(object): Link Here
102
			print header+" (%s) = %s" % (short_file, result)
102
			print header+" (%s) = %s" % (short_file, result)
103
		return result
103
		return result
104
104
105
105
	def gen_chksumfile(self, file_, filename, storedir, hash_type, exit_on_error=True):
106
		filename = filename
107
		modtime = os.path.getmtime(file_)
108
		chksum = self.calc_hash2(file_, hash_type)
109
		chksum = chksum[:-1] + " " +str(modtime)
110
		try:
111
			with open(os.path.join(storedir,filename), 'w') as chksumfile:
112
				chksumfile.write(chksum)
113
		except IOError:
114
			if exit_on_error:
115
				raise CatalystError("Could not generate checksum for " + file_, print_traceback=True)
116
			return False
117
		return True
118
119
	def evaluate_spec(self, spec, filename, storedir, hash_type):
120
		chksumfile = os.path.join(storedir,filename)
121
		with open(chksumfile, 'r') as specfile:
122
			lines = specfile.readlines()
123
			hash_value = lines[0].split()
124
			hash_value = hash_value[1]
125
			chksum, filename, modtime = lines[1].split()
126
			modtime_n = os.path.getmtime(spec)
127
			# First check the modification time to save
128
			# resources, if it hasn't been modified, 
129
			# don't bother generating a second checksum.
130
			if not modtime == modtime_n:
131
				hash_value_n = self.calc_hash2(spec, hash_type.lower()).split()
132
				hash_value_n = hash_value_n[1]
133
				chksum_n = self.calc_hash2(spec, hash_type).split()
134
				chksum_n = chksum_n[3]
135
				# Check the hash value in the file against
136
				# the current hash value from the config.
137
				if not hash_value == hash_value_n:
138
					chksum_n = self.calc_hash2(spec, hash_value.lower()).split()
139
					chksum_n = chksum_n[3]
140
				
141
				if not chksum == chksum_n:
142
					return False
143
			
144
				self.gen_chksumfile(spec, filename, storedir, hash_value_n.lower())
145
			return True
146
147
	def check_chksum(self, spec, filename, storedir, hash_type):
148
		file_location=os.path.join(storedir,filename)
149
		if os.path.exists(file_location):
150
			return self.evaluate_spec(spec, filename, storedir, hash_type)
151
		else:
152
			# If the checksum doesn't exist, this is the first time
153
			# using this spec file, so no need to check against it.
154
			return self.gen_chksumfile(spec, filename, storedir, hash_type)
106
155
(-)a/catalyst/main.py (-1 / +9 lines)
Lines 330-335 def main(): Link Here
330
	if myspecfile:
330
	if myspecfile:
331
		spec = catalyst.config.SpecParser(myspecfile)
331
		spec = catalyst.config.SpecParser(myspecfile)
332
		addlargs.update(spec.get_values())
332
		addlargs.update(spec.get_values())
333
		
334
		name_components = []
335
		for key in ["target", "subarch", "version_stamp"]:
336
			if key in addlargs:
337
				name_components.append(addlargs[key])
338
		
339
		filename = "-".join(name_components) + ".DIGESTS"
340
		if not hash_map.check_chksum(myspecfile, filename, conf_values["storedir"], conf_values["hash_function"]):
341
			conf_values["options"].add("clear-autoresume")
333
342
334
	if mycmdline:
343
	if mycmdline:
335
		try:
344
		try:
336
- 

Return to bug 212403