diff --git a/pym/cl_install.py b/pym/cl_install.py index 2640875..d96fec2 100644 --- a/pym/cl_install.py +++ b/pym/cl_install.py @@ -21,9 +21,11 @@ import os import re import sys import traceback -from os.path import exists as pathexists,join as pathjoin +from os.path import exists as pathexists,join as pathjoin,dirname from cl_utils import runOsCommand,appendProgramToEnvFile, \ - removeProgramToEnvFile + removeProgramToEnvFile,pathJoin, \ + scanDirectory + from cl_kernel import KernelConfig,InitRamFs import cl_overriding @@ -61,6 +63,7 @@ from server.utils import dialogYesNo from cl_migrate_users import migrate, currentUsers from cl_utils import getUserPassword from encrypt import encrypt +from shutil import copy2 tr = lang() tr.setGlobalDomain('cl_install') @@ -595,6 +598,31 @@ class convertDictOpt: dictOptions.update(dictUpdateProperty) return dictOptions +class cltCopy(scanDirectory): + """Copy clt files + + Example: + cltCopier = cltCopy(target="/targetdir") + # copy all clt files from etc directory to /targetdir/etc + cltCopier.performCopy('/etc') + """ + def __init__(self,target='/tmp'): + self.target = target + + performCopy = scanningDirectory.scanningDirectory + + def processingFile(self,path,prefix): + try: + if path.endswith(".clt"): + targetDir = pathJoin(self.target,dirname(path)) + if not pathexists(targetDir): + os.makedirs(targetDir) + copy2(path,pathJoin(targetDir,path)) + except Exception,e: + raise InstallError(_("Can not copy '%s' to '%s'")% + (path,pathJoin(self.target,path))) + return True + class cl_install(color_print): """Primary class for templates appling and system installation""" @@ -1498,7 +1526,12 @@ the system") + " (yes/no)" self.prepareBoot(targetDistr) self.printByResult(True) # optimize initrd - self.printMessageForTest(_("Create new initrd file")) + self.printMessageForTest(_("Coping clt templates to new system")) + cltCpy = cltCopy(target=targetDistr.getDirectory()) + for directory in self.clVars.Get('cl_template_clt_path'): + cltCpy.performCopy(directory) + self.printByResult(True) + self.printMessageForTest(_("Creating new initrd file")) self.printByResult(self.cleanInitrd()) else: return False