|
|
@ -31,6 +31,20 @@ from cl_kernel_utils import KernelConfig,InitRamFs
|
|
|
|
from cl_lang import lang
|
|
|
|
from cl_lang import lang
|
|
|
|
lang().setLanguage(sys.modules[__name__])
|
|
|
|
lang().setLanguage(sys.modules[__name__])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class changer:
|
|
|
|
|
|
|
|
initReduce = [False,[]]
|
|
|
|
|
|
|
|
def __call__(self,x,y):
|
|
|
|
|
|
|
|
if self.drop(y):
|
|
|
|
|
|
|
|
x[0] = False
|
|
|
|
|
|
|
|
if self.up(y):
|
|
|
|
|
|
|
|
x[0] = True
|
|
|
|
|
|
|
|
if x[0]:
|
|
|
|
|
|
|
|
y = self.change(y)
|
|
|
|
|
|
|
|
return [x[0],x[1] + [y]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def reduce(self,obj):
|
|
|
|
|
|
|
|
return reduce(self,obj,self.initReduce)[1]
|
|
|
|
|
|
|
|
|
|
|
|
class cl_kernel(color_print):
|
|
|
|
class cl_kernel(color_print):
|
|
|
|
"""Primary class for kernel manipulation"""
|
|
|
|
"""Primary class for kernel manipulation"""
|
|
|
|
kernelCurPath = '/usr/src/linux'
|
|
|
|
kernelCurPath = '/usr/src/linux'
|
|
|
@ -323,43 +337,46 @@ class cl_kernel(color_print):
|
|
|
|
clVars = self.clVars
|
|
|
|
clVars = self.clVars
|
|
|
|
clKernelUid = clVars.Get('cl_kernel_uid')
|
|
|
|
clKernelUid = clVars.Get('cl_kernel_uid')
|
|
|
|
clVars.Write('cl_kernel_uid',clKernelUid,force=True)
|
|
|
|
clVars.Write('cl_kernel_uid',clKernelUid,force=True)
|
|
|
|
reChangeKernel = \
|
|
|
|
|
|
|
|
re.compile("(/boot/(?:vmlinuz))(?:-\S+?)?((?:-install)?) ")
|
|
|
|
|
|
|
|
reChangeInitrd = \
|
|
|
|
|
|
|
|
re.compile("(/boot/)(?:initrd|initramfs)(?:-\S+?)?((?:-install)?)$")
|
|
|
|
|
|
|
|
grubconf = '/boot/grub/grub.conf'
|
|
|
|
grubconf = '/boot/grub/grub.conf'
|
|
|
|
rootdev = clVars.Get('os_root_dev')
|
|
|
|
rootdev = clVars.Get('os_root_dev')
|
|
|
|
|
|
|
|
x11video = clVars.Get('os_x11_video_drv')
|
|
|
|
|
|
|
|
|
|
|
|
def grubsetUID(x,y):
|
|
|
|
class grubsetUID(changer):
|
|
|
|
if y.startswith('title'):
|
|
|
|
reChangeKernel = \
|
|
|
|
x[0] = False
|
|
|
|
re.compile("(/boot/(?:vmlinuz))(?:-\S+?)?((?:-install)?) ")
|
|
|
|
elif y.startswith('kernel') and "root=%s"%rootdev in y:
|
|
|
|
reChangeInitrd = \
|
|
|
|
x[0] = True
|
|
|
|
re.compile("(/boot/)(?:initrd|initramfs)"
|
|
|
|
if x[0]:
|
|
|
|
"(?:-\S+?)?((?:-install)?)$")
|
|
|
|
|
|
|
|
drop = lambda self,y: y.startswith('title')
|
|
|
|
|
|
|
|
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 = reChangeKernel.sub("\\1-%s\\2 "%clKernelUid,y)
|
|
|
|
y = reChangeInitrd.sub("\\1initrd-%s\\2"%clKernelUid,y)
|
|
|
|
y = reChangeInitrd.sub("\\1initrd-%s\\2"%clKernelUid,y)
|
|
|
|
return [x[0],x[1] + [y]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def grubchangeCONSOLE(x,y):
|
|
|
|
class grubchangeCONSOLE(grubsetUID):
|
|
|
|
if y.startswith('title'):
|
|
|
|
up = lambda self,y: y.startswith('kernel') and \
|
|
|
|
x[0] = False
|
|
|
|
"/boot/vmlinuz-%s"%clKernelUid in y
|
|
|
|
elif y.startswith('kernel') and "/boot/vmlinuz-%s"%clKernelUid in y:
|
|
|
|
change = lambda self,y: y.replace('CONSOLE=/dev/','console=')
|
|
|
|
x[0] = True
|
|
|
|
|
|
|
|
if x[0]:
|
|
|
|
class grubchangeVideo(grubchangeCONSOLE):
|
|
|
|
y = y.replace('CONSOLE=/dev/','console=')
|
|
|
|
reChangeCalculate = re.compile(r'(?: calculate=\S+|$)')
|
|
|
|
return [x[0],x[1] + [y]]
|
|
|
|
drop = lambda self,y: not y.startswith('kernel')
|
|
|
|
|
|
|
|
change = lambda self,y:self.reChangeCalculate.sub(
|
|
|
|
|
|
|
|
' calculate=video:%s'%x11video,y,1)
|
|
|
|
|
|
|
|
|
|
|
|
if not os.access(grubconf,os.W_OK):
|
|
|
|
if not os.access(grubconf,os.W_OK):
|
|
|
|
self.printERROR(_("No permissions to write to '%s'")%grubconf)
|
|
|
|
self.printERROR(_("No permissions to write to '%s'")%grubconf)
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
newGrub = reduce(grubsetUID,open(grubconf,'r'),[False,[]])[1]
|
|
|
|
|
|
|
|
calcKernel = filter(lambda x:x['PN'] == 'calckernel',
|
|
|
|
calcKernel = filter(lambda x:x['PN'] == 'calckernel',
|
|
|
|
map(reVerSplitToPV,
|
|
|
|
map(reVerSplitToPV,
|
|
|
|
filter(lambda x:x,
|
|
|
|
filter(lambda x:x,
|
|
|
|
map(lambda x:reVerSplit.search(x),
|
|
|
|
map(lambda x:reVerSplit.search(x),
|
|
|
|
listDirectory('/var/db/pkg/sys-kernel')))))
|
|
|
|
listDirectory('/var/db/pkg/sys-kernel')))))
|
|
|
|
|
|
|
|
newGrub = grubsetUID().reduce(open(grubconf,'r'))
|
|
|
|
if calcKernel and cmpVersion(calcKernel[-1]['PVR'],"3.4.14") >= 0:
|
|
|
|
if calcKernel and cmpVersion(calcKernel[-1]['PVR'],"3.4.14") >= 0:
|
|
|
|
newGrub = reduce(grubchangeCONSOLE,newGrub,[False,[]])[1]
|
|
|
|
newGrub = grubchangeCONSOLE().reduce(newGrub)
|
|
|
|
|
|
|
|
newGrub = grubchangeVideo().reduce(newGrub)
|
|
|
|
|
|
|
|
|
|
|
|
open(grubconf,'w').writelines(newGrub)
|
|
|
|
open(grubconf,'w').writelines(newGrub)
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|