예제 #1
0
	def clean(self):
		if self.check_autoresume("clean"):
			msg("Resume point detected, skipping clean operation...")
		else:
			for x in self.settings["cleanables"]:
				msg("Cleaning chroot: " + x +"...")
				catalyst.util.remove_path(self.settings["destpath"] + x)

		""" Put /etc/hosts back into place """
		if os.path.exists(self.settings["chroot_path"]+"/etc/hosts.catalyst"):
			catalyst.util.move(self.settings["chroot_path"] + "/etc/hosts.catalyst", \
				self.settings["chroot_path"]+"/etc/hosts", force=True)

		""" Remove our overlay """
		if os.path.exists(self.settings["chroot_path"]+"/usr/local/portage"):
			catalyst.util.remove_path(self.settings["chroot_path"] + "/usr/local/portage")
			cmd("sed -i '/^PORTDIR_OVERLAY/d' "+self.settings["chroot_path"]+\
				"/etc/make.conf",\
				"Could not remove PORTDIR_OVERLAY from make.conf",env=self.env)

		""" Clean up old and obsoleted files in /etc """
		if os.path.exists(self.settings["stage_path"]+"/etc"):
			cmd("find "+self.settings["stage_path"]+\
				"/etc -maxdepth 1 -name \"*-\" | xargs rm -f",\
				"Could not remove stray files in /etc",env=self.env)

		self.run_controller_action("clean")
		self.set_autoresume("clean")
예제 #2
0
	def run_controller_action(self, action, args=""):
		if os.path.exists(self.settings["controller_file"]):
			command = action
			if args:
				command += " " + args
			cmd("/bin/bash " + self.settings["controller_file"] + " " + command, \
				action + " script failed.", env=self.env)
예제 #3
0
	def kill_chroot_pids(self):
		msg("Checking for processes running in chroot and killing them.")

		"""
		Force environment variables to be exported so script can see them
		"""
		self.setup_environment()

		if os.path.exists(self.settings["sharedir"]+\
			"/targets/support/kill-chroot-pids.sh"):
			cmd("/bin/bash "+self.settings["sharedir"]+\
				"/targets/support/kill-chroot-pids.sh",\
				"kill-chroot-pids script failed.",env=self.env)
예제 #4
0
	def unpack(self):
		unpack=True
		display_msg=None

		clst_unpack_hash = catalyst.util.readfile(self.settings["autoresume_path"]+"unpack")

		if os.path.isdir(self.settings["source_path"]):
			unpack_cmd="rsync -a --delete "+self.settings["source_path"]+" "+self.settings["chroot_path"]
			display_msg="\nStarting rsync from "+self.settings["source_path"]+"\nto "+\
				self.settings["chroot_path"]+" (This may take some time) ...\n"
			error_msg="Rsync of "+self.settings["source_path"]+" to "+self.settings["chroot_path"]+" failed."
			invalid_snapshot=False

		if self.check_autoresume():
			if os.path.isdir(self.settings["source_path"]) and \
				self.check_autoresume("unpack"):
				msg("Resume point detected, skipping unpack operation...")
				unpack=False
			elif "source_path_hash" in self.settings:
				if self.settings["source_path_hash"] != clst_unpack_hash:
					invalid_snapshot=True

		if unpack:
			self.mount_safety_check()
			if invalid_snapshot:
				msg("No Valid Resume point detected, cleaning up...")
				#os.remove(self.settings["autoresume_path"]+"dir_setup")
				self.clear_autoresume()
				self.clear_chroot()
				#self.dir_setup()

			if not os.path.exists(self.settings["chroot_path"]):
				os.makedirs(self.settings["chroot_path"])

			if not os.path.exists(self.settings["chroot_path"]+"/tmp"):
				os.makedirs(self.settings["chroot_path"]+"/tmp",1777)

			if "PKGCACHE" in self.settings:
				if not os.path.exists(self.settings["pkgcache_path"]):
					os.makedirs(self.settings["pkgcache_path"],0755)

			if not display_msg:
				raise CatalystError,"Could not find appropriate source. Please check the 'source_subpath' setting in the spec file."

			msg(display_msg)
			cmd(unpack_cmd,error_msg,env=self.env)

			if "source_path_hash" in self.settings:
				self.set_autoresume("unpack", self.settings["source_path_hash"])
			else:
				self.set_autoresume("unpack")