Pulls the kernel/rpm_kernel autoselection code out of job.py and into a helper
function in kernel.py, and move the site-specific hook that allows
pre-processing of kernel paths out of rpm_kernel and into this new helper
function.
Signed-off-by: John Admanski <jadmanski@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@939 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/bin/kernel.py b/client/bin/kernel.py
index f7b1528..977e8b3 100755
--- a/client/bin/kernel.py
+++ b/client/bin/kernel.py
@@ -574,21 +574,9 @@
""" Class for installing rpm kernel package
"""
- # pull in some optional site-specific rpm pre-processing
- try:
- import site_kernel
- preprocess_rpm = staticmethod(site_kernel.preprocess_rpm)
- del site_kernel
- except ImportError:
- # just make the preprocessor a nop
- @staticmethod
- def preprocess_rpm(rpm_package):
- return rpm_package
-
-
def __init__(self, job, rpm_package, subdir):
self.job = job
- self.rpm_package = self.preprocess_rpm(rpm_package)
+ self.rpm_package = rpm_package
self.log_dir = os.path.join(subdir, 'debug')
self.subdir = os.path.basename(subdir)
if os.path.exists(self.log_dir):
@@ -693,3 +681,25 @@
# Boot it.
self.job.reboot(tag=self.installed_as)
+
+
+# pull in some optional site-specific path pre-processing
+try:
+ import site_kernel
+ preprocess_path = site_kernel.preprocess_path
+ del site_kernel
+except ImportError:
+ # just make the preprocessor a nop
+ def preprocess_path(path):
+ return path
+
+def auto_kernel(job, path, subdir, tmp_dir, build_dir, leave=False):
+ """\
+ Create a kernel object, dynamically selecting the appropriate class to use
+ based on the path provided.
+ """
+ path = preprocess_path(path)
+ if path.endswith('.rpm'):
+ return rpm_kernel(job, path, subdir)
+ else:
+ return kernel(job, path, subdir, tmp_dir, build_dir, leave)