kernel: allow install to be run as a separate phase in combination with boot

Allow the install phase to be run separatly from the boot phase if
required.  The tag to which the install is directed is then recorded
so that a subsequent boot will boot the tag to which the install
was directed.  Where the boot is called without first installing
boot will install to the default tag 'autotest' and boot that.

Signed-off-by: Andy Whitcroft <apw@shadowen.org>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@708 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/bin/kernel.py b/client/bin/kernel.py
index 5534d91..48c428e 100755
--- a/client/bin/kernel.py
+++ b/client/bin/kernel.py
@@ -60,6 +60,8 @@
 		self.results_dir = os.path.join(subdir, 'results')
 		self.subdir	= os.path.basename(subdir)
 
+		self.installed_as = None
+
 		if not leave:
 			if os.path.isdir(self.src_dir):
 				system('rm -rf ' + self.src_dir)
@@ -327,6 +329,11 @@
 
 	def _install(self, tag='autotest', prefix = '/'):
 		"""make install in the kernel tree"""
+
+		# Record that we have installed the kernel, and
+		# the tag under which we installed it.
+		self.installed_as = tag
+
 		os.chdir(self.build_dir)
 
 		if not os.path.isdir(prefix):
@@ -478,11 +485,15 @@
 			self.job.next_step_prepend(["job.kernel_check_ident",
 						when, ident, self.subdir])
 
-		# Install this kernel.
-		self.install()
-		self.add_to_bootloader(args=args, tag='autotest')
+		# Check if the kernel has been installed, if not install
+		# as the default tag and boot that.
+		if not self.installed_as:
+			self.install()
+
+		# Boot the selected tag.
+		self.add_to_bootloader(args=args, tag=self.installed_as)
 		if once:
-			self.job.bootloader.boot_once('autotest')
+			self.job.bootloader.boot_once(self.installed_as)
 
 		# Boot it.
 		self.job.reboot()