|
|
|
@ -1689,12 +1689,11 @@ class Update(MethodsInterface):
|
|
|
|
|
_("Binary packages on the current binhost {} "
|
|
|
|
|
"are older than local").format(binhost_url))
|
|
|
|
|
elif not ignore_level and not self.is_binhost_level_valid(binhost):
|
|
|
|
|
# self.stash_binhost(binhost_url)
|
|
|
|
|
if self.compare_update_level(binhost.level) > 0:
|
|
|
|
|
self.set_migration_mode(True)
|
|
|
|
|
raise UpdateError((
|
|
|
|
|
_("Current binhost {} has wrong update level. Current level: {} Binhost level: {}").\
|
|
|
|
|
format(binhost_url, self.clVars.Get("update.cl_update_level"), binhost.level)))
|
|
|
|
|
if self.compare_update_level(binhost.level) > 0:
|
|
|
|
|
self.set_migration_mode(True)
|
|
|
|
|
raise UpdateError((
|
|
|
|
|
_("Current binhost {} has wrong update level. Current level: {} Binhost level: {}").\
|
|
|
|
|
format(binhost_url, self.clVars.Get("update.cl_update_level"), binhost.level)))
|
|
|
|
|
|
|
|
|
|
if self.binhosts_data.gpg:
|
|
|
|
|
packages_fn = self.clVars.Get('update.cl_update_package_cache')
|
|
|
|
@ -1772,7 +1771,6 @@ class Update(MethodsInterface):
|
|
|
|
|
|
|
|
|
|
def set_migration_mode(self, val=True):
|
|
|
|
|
val_to_write = Variable.On if val else Variable.Off
|
|
|
|
|
# self.clVars.Write("cl_update_use_migration_host", val_to_write, location="system")
|
|
|
|
|
self.clVars.Set("cl_update_use_migration_host", val_to_write)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
@ -1780,14 +1778,22 @@ class Update(MethodsInterface):
|
|
|
|
|
def cmp_rep_tag_to_current_calc_rep_tag(self):
|
|
|
|
|
#TODO value to Var
|
|
|
|
|
repname = 'calculate'
|
|
|
|
|
git = self.getGit()
|
|
|
|
|
rpath, revision = (
|
|
|
|
|
self.clVars.Select(["cl_update_rep_path",
|
|
|
|
|
"cl_update_rep_rev"],
|
|
|
|
|
revision = (self.clVars.Select(["cl_update_rep_rev"],
|
|
|
|
|
where="cl_update_rep_name",
|
|
|
|
|
eq=repname, limit=1))
|
|
|
|
|
#try ValueError?
|
|
|
|
|
return int(revision) - int(git.getCurrentTag(rpath))
|
|
|
|
|
eq=repname, limit=1))[0]
|
|
|
|
|
saved_tag = self.get_current_saved_tag()
|
|
|
|
|
# git = self.getGit()
|
|
|
|
|
# rpath = '/var/db/repos/calculate'
|
|
|
|
|
# tggg = git.getCurrentTag(rpath)
|
|
|
|
|
if saved_tag is not None:
|
|
|
|
|
return int(revision) - saved_tag
|
|
|
|
|
else:
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_current_saved_tag(self):
|
|
|
|
|
tg = self.clVars.Get("cl_update_saved_tag")
|
|
|
|
|
return int(tg) if tg else None
|
|
|
|
|
|
|
|
|
|
def set_migration_host(self):
|
|
|
|
|
self.startTask(_("Setting up migration host"))
|
|
|
|
@ -1926,15 +1932,33 @@ class Update(MethodsInterface):
|
|
|
|
|
self.startTask(_("Increasing local update level"))
|
|
|
|
|
self._update_increment_current_level()
|
|
|
|
|
self.set_migration_mode(False)
|
|
|
|
|
# self.unstash_binhost()
|
|
|
|
|
self.delete_binhost()
|
|
|
|
|
self.endTask()
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
#should not do when on a branch
|
|
|
|
|
def update_set_current_saved_tag(self):
|
|
|
|
|
#TODO add to var?
|
|
|
|
|
repname = "calculate"
|
|
|
|
|
git = self.getGit()
|
|
|
|
|
rpath, revision = (
|
|
|
|
|
self.clVars.Select(["cl_update_rep_path",
|
|
|
|
|
"cl_update_rep_rev"],
|
|
|
|
|
where="cl_update_rep_name",
|
|
|
|
|
eq=repname, limit=1))
|
|
|
|
|
try:
|
|
|
|
|
branch_name = self.clVars.Select(["cl_update_branch_name"],
|
|
|
|
|
where="cl_update_branch_rep", eq=repname, limit=1)[0]
|
|
|
|
|
tag = git.getCurrentTag(rpath)
|
|
|
|
|
if branch_name == Git.Reference.Tag and tag.isdigit():
|
|
|
|
|
self._set_saved_tag(tag)
|
|
|
|
|
return True
|
|
|
|
|
except ValueError as e:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def _update_increment_current_level(self):
|
|
|
|
|
current_level = int(self.clVars.Get('cl_update_level'))
|
|
|
|
|
self.clVars.Write('cl_update_level',
|
|
|
|
|
str(current_level + 1), location="system")
|
|
|
|
|
self._set_update_level(str(current_level + 1))
|
|
|
|
|
|
|
|
|
|
def is_current_level_a_digit(self):
|
|
|
|
|
"""
|
|
|
|
@ -1948,21 +1972,20 @@ class Update(MethodsInterface):
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def _set_update_level(self, level):
|
|
|
|
|
level = level if level else 0
|
|
|
|
|
self.clVars.Write('cl_update_level',
|
|
|
|
|
str(level), location="system")
|
|
|
|
|
|
|
|
|
|
# def stash_binhost(self, binhost_url):
|
|
|
|
|
# """
|
|
|
|
|
# Бекап адреса бинхоста
|
|
|
|
|
# """
|
|
|
|
|
# self.clVars.Write("cl_update_binhost_stash", binhost_url, location="system")
|
|
|
|
|
|
|
|
|
|
# def unstash_binhost(self):
|
|
|
|
|
# """
|
|
|
|
|
# Восстановление сохраненного бинхоста (если он есть)
|
|
|
|
|
# """
|
|
|
|
|
# val_to_write = self.clVars.Get("update.cl_update_binhost_stash")
|
|
|
|
|
# if val_to_write:
|
|
|
|
|
# self.clVars.Write('cl_update_binhost', val_to_write, location="system")
|
|
|
|
|
self._set_val_in_system(level, 'cl_update_level')
|
|
|
|
|
|
|
|
|
|
def _set_saved_tag(self, tag):
|
|
|
|
|
self._set_val_in_system(tag, 'cl_update_saved_tag')
|
|
|
|
|
|
|
|
|
|
def _set_val_in_system(self, val, val_name):
|
|
|
|
|
"""
|
|
|
|
|
val should be int >= 0
|
|
|
|
|
"""
|
|
|
|
|
if isinstance(val, str):
|
|
|
|
|
val = val if val.isdigit() else 0
|
|
|
|
|
elif isinstance(val, int):
|
|
|
|
|
val = val if val >= 0 else 0
|
|
|
|
|
else:
|
|
|
|
|
val = val if val else 0
|
|
|
|
|
self.clVars.Write(val_name, str(val), location="system")
|
|
|
|
|
|