|
|
|
@ -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
|
|
|
|
|
if nameFile[:1] != "/":
|
|
|
|
|
nameFile = "/" + nameFile
|
|
|
|
|
self.printWARNING(" "*5 + nameFile)
|
|
|
|
|