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/defaults.py (+1 lines)
Lines 77-82 confdefaults={ Link Here
77
	"snapshot_name": "portage-",
77
	"snapshot_name": "portage-",
78
	"snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
78
	"snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
79
	"hash_function": "crc32",
79
	"hash_function": "crc32",
80
	"exit_on_error": True
80
	}
81
	}
81
82
82
83
(-)a/catalyst/hash_utils.py (-1 / +52 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, exit_on_error):
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
			chksum_equals = True
128
			# First check the modification time to save
129
			# resources, if it hasn't been modified, 
130
			# don't bother generating a second checksum.
131
			if not modtime == modtime_n:
132
				hash_value_n = self.calc_hash2(spec, hash_type.lower()).split()
133
				hash_value_n = hash_value_n[1]
134
				chksum_n = self.calc_hash2(spec, hash_type).split()
135
				chksum_n = chksum_n[3]
136
				# Check the hash value in the file against
137
				# the current hash value from the config.
138
				if not hash_value == hash_value_n:
139
					chksum_n = self.calc_hash2(spec, hash_value.lower()).split()
140
					chksum_n = chksum_n[3]
141
				
142
				if not chksum == chksum_n:
143
					chksum_equals = False
144
				# Rewrite the checksum file to be assured
145
				# that everything is up to date.
146
				self.gen_chksumfile(spec, filename, storedir, hash_value_n.lower(), exit_on_error)
147
			return chksum_equals
148
149
	def check_chksum(self, spec, filename, storedir, hash_type, exit_on_error):
150
		file_location=os.path.join(storedir,filename)
151
		if os.path.exists(file_location):
152
			return self.evaluate_spec(spec, filename, storedir, hash_type, exit_on_error)
153
		else:
154
			# If the checksum doesn't exist, this is the first time
155
			# using this spec file, so no need to check against it.
156
			return self.gen_chksumfile(spec, filename, storedir, hash_type, exit_on_error)
106
157
(-)a/catalyst/main.py (-3 / +11 lines)
Lines 106-118 def parse_config(myconfig): Link Here
106
	# now, load up the values into conf_values so that we can use them
106
	# now, load up the values into conf_values so that we can use them
107
	for x in list(confdefaults):
107
	for x in list(confdefaults):
108
		if x in myconf:
108
		if x in myconf:
109
			print "Setting",x,"to config file value \""+myconf[x]+"\""
109
			print "Setting",str(x),"to config file value \""+str(myconf[x])+"\""
110
			if x == 'options':
110
			if x == 'options':
111
				conf_values[x] = set(myconf[x].split())
111
				conf_values[x] = set(myconf[x].split())
112
			else:
112
			else:
113
				conf_values[x]=myconf[x]
113
				conf_values[x]=myconf[x]
114
		else:
114
		else:
115
			print "Setting",x,"to default value \""+confdefaults[x]+"\""
115
			print "Setting",str(x),"to default value \""+str(confdefaults[x])+"\""
116
			conf_values[x]=confdefaults[x]
116
			conf_values[x]=confdefaults[x]
117
117
118
	# add our python base directory to use for loading target arch's
118
	# add our python base directory to use for loading target arch's
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"], conf_values["exit_on_error"]):
341
			conf_values["options"].add("clear-autoresume")
333
342
334
	if mycmdline:
343
	if mycmdline:
335
		try:
344
		try:
336
- 

Return to bug 212403