Changed algoritm applying clt template

develop
Самоукин Алексей 14 years ago
parent eaac552d30
commit e358500edb

@ -261,7 +261,7 @@ class fillVars(glob_attr):
def get_cl_template_clt_path(self):
'''Пути к файлам ,clt'''
if "CONFIG_PROTECT" in os.environ:
protectPaths = ["/etc"] + map(lambda x: x.strip(),
protectPaths = ["/etc"] + filter(lambda x: x.strip(),
os.environ["CONFIG_PROTECT"].split(" "))
else:
protectPaths = ["/etc", "/usr/share/X11/xkb", "var/lib/hsqldb",

@ -3593,10 +3593,9 @@ re.M|re.S)
self.cltObj.dictProcessedTemplates = self.dictProcessedTemplates
if self.cltFilter:
# Шаблоны + .clt которые будут применены
self.cltObj.filterApplyTemplates=\
self.cltObj.filterApplyTemplates +=\
map(lambda x: pathJoin('/', x.partition(self._baseDir)[2]),
self.dictProcessedTemplates.keys())
# Обрабатываем шаблоны clt
if not self.cltObj.applyTemplates():
return False
return (self.createdDirs, self.filesApply)
@ -4638,6 +4637,9 @@ class templateClt(scanDirectoryClt, template):
self.flagApplyTemplates = False
if self.objVar.Get("cl_name") in applyPackages:
self.flagApplyTemplates = True
# Базовая директория переноса шаблонов "/mnt/calculate" или "/" и.т.д
self._baseDir = pathJoin(self.objVar.Get("cl_chroot_path"),
self.objVar.Get("cl_root_path"))
def applyTemplate(self, path):
"""Применение отдельного .clt шаблона"""
@ -4666,6 +4668,7 @@ class templateClt(scanDirectoryClt, template):
else:
nameFileConfig = path
nameFileConfig = nameFileConfig[:-self.lenExtFileTemplate]
nameFileConfig = pathJoin(self._baseDir, nameFileConfig)
# файл в системе без условий
nameFileConfig = "/".join(map(lambda x:x.split("?")[0],\
nameFileConfig.split("/")))

@ -22,7 +22,7 @@ from cl_log import log
import cl_datavars
import cl_template
from cl_print import color_print as old_color_print
from cl_utils import runOsCommand
from cl_utils import runOsCommand, scanDirectory, pathJoin
import cl_overriding
import cl_lang
@ -189,7 +189,6 @@ class updateUserConfigs(shareUpdateConfigs):
self.logger.warn(_("Not found templates"))
return True
class updateSystemConfigs(shareUpdateConfigs):
"""Обновление системных конфигурационных файлов"""
@ -198,7 +197,7 @@ class updateSystemConfigs(shareUpdateConfigs):
if not "CONFIG_PROTECT" in os.environ:
self.printERROR(_("Missing environment variable CONFIG_PROTECT"))
exit(1)
protectPaths = ["/etc"] + map(lambda x: x.strip(),
protectPaths = ["/etc"] + filter(lambda x: x.strip(),
os.environ["CONFIG_PROTECT"].split(" "))
flagFoundProtect = False
for pPath in protectPaths:
@ -210,6 +209,21 @@ class updateSystemConfigs(shareUpdateConfigs):
return False
return True
def scanProtectDirs(self, configPath):
configFiles = []
scanObj = scanDirectory()
scanObj.processingFile = lambda path,prefix:configFiles.append(path) or\
True
protectPaths = ["/etc"] + filter(lambda x: x.strip(),
os.environ["CONFIG_PROTECT"].split(" "))
configPath = os.path.realpath(configPath)
for pPath in protectPaths:
realPath = pathJoin(configPath, pPath)
if os.path.exists(realPath):
scanObj.scanningDirectory(realPath)
configFiles = map(lambda x: x.partition(configPath)[2], configFiles)
return configFiles
def updateConfig(self, nameProgram, category, version, configPath):
"""Обновление системных конфигурационных файлов"""
cleanVer = self.reCleanVer.search(version)
@ -235,9 +249,18 @@ class updateSystemConfigs(shareUpdateConfigs):
clVars.Set("cl_root_path", configPath, True)
clVars.Set("cl_belong_pkg", nameProgram, True)
clVars.Set("cl_action", 'merge', True)
clTempl = cl_template.template(clVars)
configFiles = []
nameProg = clVars.Get("cl_name")
if nameProg == "calculate-install":
configFiles = self.scanProtectDirs(configPath)
cltObject = cl_template.templateClt(clVars)
if configFiles:
cltObject.filterApplyTemplates = configFiles
else:
cltObject.filterApplyTemplates = []
clTempl = cl_template.template(clVars, cltObj=cltObject)
dirsFiles = clTempl.applyTemplates()
nameAndVerPkg = clVars.Get("cl_name")+"-"+clVars.Get("cl_ver")
nameAndVerPkg = nameProg + "-"+clVars.Get("cl_ver")
if dirsFiles is False:
self.printERROR(_("Error template in a package %s")\
%nameAndVerPkg)
@ -251,10 +274,7 @@ class updateSystemConfigs(shareUpdateConfigs):
for calcPkg in dictPakkages:
self.printWARNING(_("Package %s has changed files")%calcPkg+":")
for nameF in dictPakkages[calcPkg]:
if nameF.startswith(configPath):
nameFile = nameF.partition(configPath)[2]
else:
nameFile = nameF
nameFile = nameF.partition(configPath)[2]
if nameFile[:1] != "/":
nameFile = "/" + nameFile
self.printWARNING(" "*5 + nameFile)

Loading…
Cancel
Save