|
|
|
@ -377,6 +377,19 @@ class Update(MethodsInterface):
|
|
|
|
|
self.endTask(True)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def checkUrl(self, host, host_urls, repname, dv, git):
|
|
|
|
|
url, rpath, revision = (
|
|
|
|
|
dv.Select([host_urls, "cl_update_rep_path",
|
|
|
|
|
"cl_update_rep_rev"],
|
|
|
|
|
where="cl_update_rep_name", eq=repname, limit=1))
|
|
|
|
|
if git.checkUrl(url):
|
|
|
|
|
working_host = host
|
|
|
|
|
return working_host, url, rpath, revision
|
|
|
|
|
self.printWARNING(_("Git %s is unavailable, scaning next host") % url)
|
|
|
|
|
return None, url, rpath, revision
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@variable_module("update")
|
|
|
|
|
def syncRepositories(self, repname, fallback_sync=False,
|
|
|
|
|
clean_on_error=True):
|
|
|
|
@ -386,30 +399,39 @@ class Update(MethodsInterface):
|
|
|
|
|
dv = self.clVars
|
|
|
|
|
check_status = dv.GetBool('update.cl_update_check_rep_set')
|
|
|
|
|
git = self.getGit()
|
|
|
|
|
saved_host = dv.Get('cl_update_rep_hosting') if 'cl_update_rep_hosting' in dv.allVars else ''
|
|
|
|
|
working_host = ''
|
|
|
|
|
# проверка необходимости синхронизации других оверлеев
|
|
|
|
|
a = self.clVars.Get("cl_update_inner_other_set")
|
|
|
|
|
if self.clVars.Get("cl_update_inner_other_set") != '':
|
|
|
|
|
self.clVars.Write("cl_update_other_set", self.clVars.Get("cl_update_inner_other_set"), header="update")
|
|
|
|
|
if dv.Get("cl_update_inner_other_set") != 'auto':
|
|
|
|
|
dv.Write("cl_update_other_set", dv.Get("cl_update_inner_other_set"), header="update")
|
|
|
|
|
dv.Set("cl_update_other_set", dv.Get("cl_update_inner_other_set"))
|
|
|
|
|
if 'cl_update_rep_list' in dv.allVars and dv.Get('cl_update_rep_list'):
|
|
|
|
|
#if dv.Get("cl_update_rep_hosting_choice"):
|
|
|
|
|
chosen_hosting = dv.Get("cl_update_rep_hosting_choice")
|
|
|
|
|
if chosen_hosting:
|
|
|
|
|
for host_urls, host in dv.Get('cl_update_inner_rep_list'):
|
|
|
|
|
if host == chosen_hosting:
|
|
|
|
|
working_host, url, rpath, revision = self.checkUrl(host, host_urls, repname, dv, git)
|
|
|
|
|
if working_host:
|
|
|
|
|
break
|
|
|
|
|
elif saved_host:
|
|
|
|
|
for host_urls, host in dv.Get('cl_update_inner_rep_list'):
|
|
|
|
|
if host == saved_host:
|
|
|
|
|
working_host, url, rpath, revision = self.checkUrl(host, host_urls, repname, dv, git)
|
|
|
|
|
if working_host:
|
|
|
|
|
break
|
|
|
|
|
# Берем первый доступный хостинг из списка
|
|
|
|
|
for host_urls, host in dv.Get('cl_update_inner_rep_list'):
|
|
|
|
|
url, rpath, revision = (
|
|
|
|
|
dv.Select([host_urls, "cl_update_rep_path",
|
|
|
|
|
"cl_update_rep_rev"],
|
|
|
|
|
where="cl_update_rep_name", eq=repname, limit=1))
|
|
|
|
|
if not url or not rpath:
|
|
|
|
|
raise UpdateError(_("Configuration variables for repositories "
|
|
|
|
|
"are not setup for %s") % host)
|
|
|
|
|
if git.checkUrl(url):
|
|
|
|
|
working_host = host
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
|
self.printWARNING(_("Git %s is unavailable, scaning next host") % url)
|
|
|
|
|
if not working_host:
|
|
|
|
|
for host_urls, host in dv.Get('cl_update_inner_rep_list'):
|
|
|
|
|
if chosen_hosting == host:
|
|
|
|
|
continue
|
|
|
|
|
working_host, url, rpath, revision = self.checkUrl(host, host_urls, repname, dv, git)
|
|
|
|
|
if working_host:
|
|
|
|
|
break
|
|
|
|
|
if not working_host:
|
|
|
|
|
dv.Write('cl_update_rep_hosting', ' ')
|
|
|
|
|
raise UpdateError(_("Git is unavailable"))
|
|
|
|
|
dv.Write('cl_update_rep_hosting', working_host)
|
|
|
|
|
if working_host:
|
|
|
|
|
dv.Write('cl_update_rep_hosting', working_host)
|
|
|
|
|
|
|
|
|
|
#--------------DEPRECATED--------------#
|
|
|
|
|
else:
|
|
|
|
@ -482,7 +504,6 @@ class Update(MethodsInterface):
|
|
|
|
|
"{repname} repository").format(
|
|
|
|
|
repname=repname) + _(": ") + str(e))
|
|
|
|
|
finally:
|
|
|
|
|
self.clVars.Write('cl_update_rep_hosting', val='', header='update')
|
|
|
|
|
if path.exists(rpath_new):
|
|
|
|
|
removeDir(rpath_new)
|
|
|
|
|
else:
|
|
|
|
@ -572,8 +593,6 @@ class Update(MethodsInterface):
|
|
|
|
|
for perc in p.progress():
|
|
|
|
|
self.setProgress(perc)
|
|
|
|
|
else:
|
|
|
|
|
p = process(emerge, "--sync", repname, stderr=STDOUT)
|
|
|
|
|
if p.failed():
|
|
|
|
|
rpath_old = f"{rpath}_old"
|
|
|
|
|
makeDirectory(rpath_old)
|
|
|
|
|
for root, dirs, files in os.walk(rpath):
|
|
|
|
@ -582,6 +601,8 @@ class Update(MethodsInterface):
|
|
|
|
|
for d in dirs:
|
|
|
|
|
shutil.move(os.path.join(rpath, d), os.path.join(rpath_old, d))
|
|
|
|
|
clearDirectory(rpath)
|
|
|
|
|
p = process(emerge, "--sync", repname, stderr=STDOUT)
|
|
|
|
|
if p.failed():
|
|
|
|
|
for root, dirs, files in os.walk(rpath_old):
|
|
|
|
|
for f in files:
|
|
|
|
|
os.replace(os.path.join(rpath_old, d), os.path.join(rpath, f))
|
|
|
|
|