|
|
|
@ -177,47 +177,5 @@ class InitRamFs:
|
|
|
|
|
|
|
|
|
|
def cleanInitRamFs(self,newinitrd=None,video=None):
|
|
|
|
|
"""Unpack initramfs clean and pack"""
|
|
|
|
|
if not newinitrd:
|
|
|
|
|
return True
|
|
|
|
|
if not video:
|
|
|
|
|
copy2(self.initrdFile,newinitrd)
|
|
|
|
|
return True
|
|
|
|
|
if not self._unpackInitRamfs():
|
|
|
|
|
return False
|
|
|
|
|
calcPath = path.join(self.tmpPath,"etc/calculate")
|
|
|
|
|
if not path.exists(calcPath):
|
|
|
|
|
os.mkdir(calcPath)
|
|
|
|
|
f = open(path.join(calcPath,"calculate.ini"),'w')
|
|
|
|
|
f.write('VIDEODRV="{0}"'.format(video))
|
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
|
|
res = self._packInitRamfs(newinitrd)
|
|
|
|
|
rmtree(self.tmpPath,ignore_errors=True)
|
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
|
def cleanInitRamFsOld(self,newinitrd=None):
|
|
|
|
|
"""Unpack initramfs, clean needless modules and pack"""
|
|
|
|
|
if not self._unpackInitRamfs():
|
|
|
|
|
return False
|
|
|
|
|
importantModules = KernelModules().getWorkModules(
|
|
|
|
|
forceKeep=['squashfs','zlib_inflate','aufs',
|
|
|
|
|
'exportfs','unionfs','dm_mod'],
|
|
|
|
|
forceRemove=['cifs','nfs','snd'])
|
|
|
|
|
# get walk data with modules files not exists in importantModules
|
|
|
|
|
deleteModulesData = \
|
|
|
|
|
map(lambda x:(x[0],
|
|
|
|
|
x[1],
|
|
|
|
|
filter(lambda x:x.endswith(".ko") and
|
|
|
|
|
not x[:-3].replace('-','_') in importantModules,
|
|
|
|
|
x[2])),
|
|
|
|
|
os.walk(self.tmpPath))
|
|
|
|
|
# get full path for all delete modules
|
|
|
|
|
deleteModulesData = \
|
|
|
|
|
reduce(lambda x,y:x+y,
|
|
|
|
|
map(lambda x:map(lambda y:path.join(x[0],y),x[2]),
|
|
|
|
|
deleteModulesData),
|
|
|
|
|
[])
|
|
|
|
|
map(lambda x:os.unlink(x),deleteModulesData)
|
|
|
|
|
res = self._packInitRamfs(newinitrd)
|
|
|
|
|
rmtree(self.tmpPath,ignore_errors=True)
|
|
|
|
|
return res
|
|
|
|
|
copy2(self.initrdFile,newinitrd)
|
|
|
|
|
return True
|
|
|
|
|