|
|
|
@ -385,17 +385,42 @@ class Update(MethodsInterface):
|
|
|
|
|
"""
|
|
|
|
|
dv = self.clVars
|
|
|
|
|
check_status = dv.GetBool('update.cl_update_check_rep_set')
|
|
|
|
|
url, rpath, revision = (
|
|
|
|
|
dv.Select(["cl_update_rep_url", "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"))
|
|
|
|
|
git = self.getGit()
|
|
|
|
|
if not git.checkUrl(url):
|
|
|
|
|
raise UpdateError(_("Git %s is unavailable") % url)
|
|
|
|
|
working_host = ''
|
|
|
|
|
if 'cl_update_rep_list' in dv.allVars and dv.Get('cl_update_rep_list'):
|
|
|
|
|
# Берем первый доступный хостинг из списка
|
|
|
|
|
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:
|
|
|
|
|
raise UpdateError(_("Git is unavailable"))
|
|
|
|
|
dv.Write('cl_update_rep_hosting', working_host)
|
|
|
|
|
|
|
|
|
|
#--------------DEPRECATED--------------#
|
|
|
|
|
else:
|
|
|
|
|
url, rpath, revision = (
|
|
|
|
|
dv.Select(["cl_update_rep_url", "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"))
|
|
|
|
|
git = self.getGit()
|
|
|
|
|
if not git.checkUrl(url):
|
|
|
|
|
raise UpdateError(_("Git %s is unavailable") % url)
|
|
|
|
|
# --------------DEPRECATED--------------#
|
|
|
|
|
|
|
|
|
|
chroot_path = path.normpath(self.clVars.Get('cl_chroot_path'))
|
|
|
|
|
if chroot_path == '/':
|
|
|
|
|
rpath_orig = rpath
|
|
|
|
@ -452,6 +477,7 @@ 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:
|
|
|
|
@ -1315,7 +1341,8 @@ class Update(MethodsInterface):
|
|
|
|
|
if hosts[0] != self.clVars.Get('update.cl_update_binhost'):
|
|
|
|
|
self.refresh_binhost = True
|
|
|
|
|
self.clVars.Set('cl_update_package_cache_set', 'on')
|
|
|
|
|
self.clVars.Write('cl_update_binhost', hosts[0], location="system")
|
|
|
|
|
if not self.clVars.GetBool('cl_update_binhost_set'):
|
|
|
|
|
self.clVars.Write('cl_update_binhost', hosts[0], location="system")
|
|
|
|
|
new_ts = self.clVars.Get("update.cl_update_binhost_timestamp")
|
|
|
|
|
if new_ts:
|
|
|
|
|
new_ts = new_ts[0]
|
|
|
|
@ -1371,28 +1398,29 @@ class Update(MethodsInterface):
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def delete_binhost(self):
|
|
|
|
|
self.clVars.Delete('cl_update_binhost', location="system")
|
|
|
|
|
try:
|
|
|
|
|
bin_cache_fn = self.get_bin_cache_filename()
|
|
|
|
|
if path.exists(bin_cache_fn):
|
|
|
|
|
os.unlink(bin_cache_fn)
|
|
|
|
|
except OSError:
|
|
|
|
|
raise UpdateError(
|
|
|
|
|
_("Failed to remove cached ini.env of binary repository"))
|
|
|
|
|
try:
|
|
|
|
|
for varname in ('update.cl_update_package_cache',
|
|
|
|
|
'update.cl_update_package_cache_sign'):
|
|
|
|
|
fn = self.clVars.Get(varname)
|
|
|
|
|
if path.exists(fn):
|
|
|
|
|
os.unlink(fn)
|
|
|
|
|
except OSError:
|
|
|
|
|
raise UpdateError(
|
|
|
|
|
_("Failed to remove cached Package index"))
|
|
|
|
|
# удалить binhost
|
|
|
|
|
binhost_fn = self.inchroot(
|
|
|
|
|
self.clVars.Get("update.cl_update_portage_binhost_path"))
|
|
|
|
|
if path.exists(binhost_fn):
|
|
|
|
|
os.unlink(binhost_fn)
|
|
|
|
|
if not self.clVars.GetBool('cl_update_binhost_set'):
|
|
|
|
|
self.clVars.Write('cl_update_binhost', ' ', location="system")
|
|
|
|
|
try:
|
|
|
|
|
bin_cache_fn = self.get_bin_cache_filename()
|
|
|
|
|
if path.exists(bin_cache_fn):
|
|
|
|
|
os.unlink(bin_cache_fn)
|
|
|
|
|
except OSError:
|
|
|
|
|
raise UpdateError(
|
|
|
|
|
_("Failed to remove cached ini.env of binary repository"))
|
|
|
|
|
try:
|
|
|
|
|
for varname in ('update.cl_update_package_cache',
|
|
|
|
|
'update.cl_update_package_cache_sign'):
|
|
|
|
|
fn = self.clVars.Get(varname)
|
|
|
|
|
if path.exists(fn):
|
|
|
|
|
os.unlink(fn)
|
|
|
|
|
except OSError:
|
|
|
|
|
raise UpdateError(
|
|
|
|
|
_("Failed to remove cached Package index"))
|
|
|
|
|
# удалить binhost
|
|
|
|
|
binhost_fn = self.inchroot(
|
|
|
|
|
self.clVars.Get("update.cl_update_portage_binhost_path"))
|
|
|
|
|
if path.exists(binhost_fn):
|
|
|
|
|
os.unlink(binhost_fn)
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def update_binhost_list(self, dv=None):
|
|
|
|
@ -1420,7 +1448,7 @@ class Update(MethodsInterface):
|
|
|
|
|
|
|
|
|
|
if not changes:
|
|
|
|
|
return False
|
|
|
|
|
self.create_binhost_data()
|
|
|
|
|
self.create_binhost_data(a)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def drop_binhosts(self, dv):
|
|
|
|
@ -1546,10 +1574,24 @@ class Update(MethodsInterface):
|
|
|
|
|
def create_binhost_data(self):
|
|
|
|
|
dv = self.clVars
|
|
|
|
|
last_ts = dv.Get('cl_update_last_timestamp')
|
|
|
|
|
if dv.GetBool('cl_update_binhost_stable_opt_set'):
|
|
|
|
|
binhost_list = dv.Get('cl_update_binhost_list')
|
|
|
|
|
a = dv.Get('cl_update_binhost')
|
|
|
|
|
c = self.clVars.getIniVar('cl_update_binhost')
|
|
|
|
|
d = dv.Get('cl_update_binhost_choice')
|
|
|
|
|
b = dv.GetBool('cl_update_binhost_set')
|
|
|
|
|
if (not dv.Get('cl_update_binhost_choice') and not dv.GetBool('cl_update_binhost_set')) \
|
|
|
|
|
or dv.Get('cl_update_binhost_choice') == 'auto':
|
|
|
|
|
if dv.Get('cl_update_binhost_stable_opt_set'):
|
|
|
|
|
binhost_list = dv.Get('cl_update_binhost_list')
|
|
|
|
|
else:
|
|
|
|
|
binhost_list = dv.Get('cl_update_binhost_unstable_list')
|
|
|
|
|
dv.Write('cl_update_binhost_set', "off")
|
|
|
|
|
else:
|
|
|
|
|
binhost_list = dv.Get('cl_update_binhost_unstable_list')
|
|
|
|
|
if dv.Get('cl_update_binhost_choice'):
|
|
|
|
|
dv.Write('cl_update_binhost', dv.Get('cl_update_binhost_choice'))
|
|
|
|
|
dv.Write('cl_update_binhost_set', "on")
|
|
|
|
|
binhost_list = [dv.Get('cl_update_binhost')]
|
|
|
|
|
|
|
|
|
|
#dv.Write('cl_update_binhost_set', "off")
|
|
|
|
|
self.binhosts_data = Binhosts(
|
|
|
|
|
# значение малозначимо, поэтому берётся из собирающей системы
|
|
|
|
|
dv.GetInteger('cl_update_binhost_timeout'),
|
|
|
|
|