From 78ef6501495eff12cb9c121a7b90ab90be0cd83a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 9 Feb 2013 15:45:34 -0500 Subject: [PATCH] generic_stage_target: Split ._copy_kernel_config() from ._build_kernel() _copy_kernel_config() is one idea with a bunch of error handling. Isolating it in its own function makes _build_kernel() easier to read. Reviewed-by: Matt Turner --- modules/generic_stage_target.py | 49 +++++++++++++++++---------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py index af7cbe7c..2c32c00f 100644 --- a/modules/generic_stage_target.py +++ b/modules/generic_stage_target.py @@ -1426,29 +1426,7 @@ class generic_stage_target(generic_target): +"build_kernel_"+kname): print "Resume point detected, skipping build_kernel for "+kname+" operation..." else: # TODO: make this not require a kernel config - try: - if not os.path.exists(self.settings["boot/kernel/"+kname+"/config"]): - self.unbind() - raise CatalystError,\ - "Can't find kernel config: "+\ - self.settings["boot/kernel/"+kname+\ - "/config"] - - except TypeError: - raise CatalystError,\ - "Required value boot/kernel/config not specified" - - try: - cmd("cp "+self.settings["boot/kernel/"+kname+\ - "/config"]+" "+\ - self.settings["chroot_path"]+"/var/tmp/"+\ - kname+".config",\ - "Couldn't copy kernel config: "+\ - self.settings["boot/kernel/"+kname+\ - "/config"],env=self.env) - - except CatalystError: - self.unbind() + self._copy_kernel_config(kname=kname) """ If we need to pass special options to the bootloader @@ -1516,6 +1494,31 @@ class generic_stage_target(generic_target): " post-kmerge ", "Runscript post-kmerge failed",env=self.env) + def _copy_kernel_config(self, kname): + try: + if not os.path.exists(self.settings["boot/kernel/"+kname+"/config"]): + self.unbind() + raise CatalystError,\ + "Can't find kernel config: "+\ + self.settings["boot/kernel/"+kname+\ + "/config"] + + except TypeError: + raise CatalystError,\ + "Required value boot/kernel/config not specified" + + try: + cmd("cp "+self.settings["boot/kernel/"+kname+\ + "/config"]+" "+\ + self.settings["chroot_path"]+"/var/tmp/"+\ + kname+".config",\ + "Couldn't copy kernel config: "+\ + self.settings["boot/kernel/"+kname+\ + "/config"],env=self.env) + + except CatalystError: + self.unbind() + def bootloader(self): if "AUTORESUME" in self.settings \ and os.path.exists(self.settings["autoresume_path"]+"bootloader"): -- 2.26.2