|
|
|
@ -80,9 +80,24 @@ class CommonMethods(MethodsInterface):
|
|
|
|
|
out = []
|
|
|
|
|
orig, data = data
|
|
|
|
|
data = data[0]
|
|
|
|
|
binary_file = False
|
|
|
|
|
try:
|
|
|
|
|
origdata = readFile(orig)
|
|
|
|
|
newdata = readFile(data[i_cfgname])
|
|
|
|
|
except UnicodeDecodeError as e:
|
|
|
|
|
binary_file = True
|
|
|
|
|
dv = DataVars()
|
|
|
|
|
dv.importVariables()
|
|
|
|
|
if not (dv.Get('cl_env_debug_set') == 'off' or \
|
|
|
|
|
dv.Get('cl_root_readonly') == 'on' or \
|
|
|
|
|
dv.Get('cl_ebuild_phase') or os.getuid()):
|
|
|
|
|
logger = log("core-action.log",
|
|
|
|
|
filename="/var/log/calculate/core-action.log",
|
|
|
|
|
formatter="%(asctime)s - %(levelname)s - %(message)s")
|
|
|
|
|
logger.info("dispatch_conf: encountered binary config file {file}. \
|
|
|
|
|
Overwriting.".format(file=data[i_cfgname]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
origdata = readFile(orig)
|
|
|
|
|
newdata = readFile(data[i_cfgname])
|
|
|
|
|
pattern = "%s/._cfg????_%s" % (os.path.dirname(orig),
|
|
|
|
|
os.path.basename(orig))
|
|
|
|
|
answ_map = {'usenew': 'use new', 'skip': 'next'}
|
|
|
|
@ -94,14 +109,17 @@ class CommonMethods(MethodsInterface):
|
|
|
|
|
os.unlink(fn)
|
|
|
|
|
except (OSError, IndexError):
|
|
|
|
|
pass
|
|
|
|
|
if (self.clVars.Get('cl_autoupdate_set') == 'on' or
|
|
|
|
|
if (binary_file or self.clVars.Get('cl_autoupdate_set') == 'on' or
|
|
|
|
|
origdata == newdata):
|
|
|
|
|
answ = "use new"
|
|
|
|
|
elif dispatch_var in answ_map:
|
|
|
|
|
answ = answ_map.get(dispatch_var)
|
|
|
|
|
else:
|
|
|
|
|
orig_content = normalize_config(readFile(orig))
|
|
|
|
|
new_content = normalize_config(readFile(data[i_cfgname]))
|
|
|
|
|
# why are we reading them again?
|
|
|
|
|
# orig_content = normalize_config(readFile(orig))
|
|
|
|
|
# new_content = normalize_config(readFile(data[i_cfgname]))
|
|
|
|
|
orig_content = normalize_config(origdata)
|
|
|
|
|
new_content = normalize_config(newdata)
|
|
|
|
|
if orig_content == new_content:
|
|
|
|
|
answ = "use new"
|
|
|
|
|
else:
|
|
|
|
@ -125,8 +143,8 @@ class CommonMethods(MethodsInterface):
|
|
|
|
|
continue
|
|
|
|
|
elif answ == "use new":
|
|
|
|
|
try:
|
|
|
|
|
with open(orig, 'w') as fd:
|
|
|
|
|
fd.write(readFile(data[i_cfgname]))
|
|
|
|
|
with open(orig, 'wb') as fd:
|
|
|
|
|
fd.write(readFile(data[i_cfgname], binary=True))
|
|
|
|
|
os.unlink(data[i_cfgname])
|
|
|
|
|
if filesApply:
|
|
|
|
|
try:
|
|
|
|
|