|
|
|
@ -21,7 +21,8 @@ import sys
|
|
|
|
|
import traceback
|
|
|
|
|
from os import path
|
|
|
|
|
from cl_builder import DataVarsBuilder, printNoColor, __version__, __app__
|
|
|
|
|
from cl_utils import process,listDirectory,cmpVersion,reVerSplitToPV,reVerSplit
|
|
|
|
|
from cl_utils import process,listDirectory,cmpVersion,reVerSplitToPV, \
|
|
|
|
|
reVerSplit
|
|
|
|
|
from subprocess import STDOUT,PIPE
|
|
|
|
|
from cl_print import color_print
|
|
|
|
|
from shutil import copy2 as copy_with_perm
|
|
|
|
@ -32,6 +33,20 @@ from cl_lang import lang
|
|
|
|
|
lang().setLanguage(sys.modules[__name__])
|
|
|
|
|
|
|
|
|
|
class changer:
|
|
|
|
|
"""Reducer for change block by condition
|
|
|
|
|
|
|
|
|
|
def up(self,y) - condition to start change
|
|
|
|
|
def drop(self,y) - condition to stop change
|
|
|
|
|
def change(self,y) - perform string change.
|
|
|
|
|
|
|
|
|
|
Using:
|
|
|
|
|
class changer:
|
|
|
|
|
up = lambda self,y: "test" in y
|
|
|
|
|
drop = lambda self,y: "stop" in y
|
|
|
|
|
change = lambda self,y: y.replace("abc","zxc")
|
|
|
|
|
|
|
|
|
|
listing = changer().reduce(listing)
|
|
|
|
|
"""
|
|
|
|
|
initReduce = [False,[]]
|
|
|
|
|
def __call__(self,x,y):
|
|
|
|
|
if self.drop(y):
|
|
|
|
@ -43,6 +58,7 @@ class changer:
|
|
|
|
|
return [x[0],x[1] + [y]]
|
|
|
|
|
|
|
|
|
|
def reduce(self,obj):
|
|
|
|
|
"""Perform reduce"""
|
|
|
|
|
return reduce(self,obj,self.initReduce)[1]
|
|
|
|
|
|
|
|
|
|
class cl_kernel(color_print):
|
|
|
|
@ -351,8 +367,8 @@ class cl_kernel(color_print):
|
|
|
|
|
up = lambda self,y: y.startswith('kernel') and \
|
|
|
|
|
"root=%s"%rootdev in y
|
|
|
|
|
def change(self,y):
|
|
|
|
|
y = reChangeKernel.sub("\\1-%s\\2 "%clKernelUid,y)
|
|
|
|
|
y = reChangeInitrd.sub("\\1initrd-%s\\2"%clKernelUid,y)
|
|
|
|
|
y = self.reChangeKernel.sub("\\1-%s\\2 "%clKernelUid,y)
|
|
|
|
|
return self.reChangeInitrd.sub("\\1initrd-%s\\2"%clKernelUid,y)
|
|
|
|
|
|
|
|
|
|
class grubchangeCONSOLE(grubsetUID):
|
|
|
|
|
up = lambda self,y: y.startswith('kernel') and \
|
|
|
|
@ -486,3 +502,4 @@ class cl_kernel(color_print):
|
|
|
|
|
except (OSError,IOError),e:
|
|
|
|
|
self.printERROR(str(e))
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|