Fix: /etc/portage cache logic was reworked. Binhost cache logic was
remorked
master 3.7.2.57
root 1 year ago
parent b8f1789db3
commit 8b275377a5

@ -15,7 +15,6 @@
# limitations under the License.
from functools import wraps
import random
import asyncio
import sys
from os import path
@ -251,7 +250,6 @@ class Update(MethodsInterface):
info_outdated = True
if info_outdated:
self.raiseOutdate()
# dv.Set('cl_update_outdate_set', 'on', force=True)
finally:
self.unstash_cache(rpath, name)
# TODO: debug1
@ -405,9 +403,6 @@ class Update(MethodsInterface):
saved_host = dv.Get('cl_update_rep_hosting') if 'cl_update_rep_hosting' in dv.allVars else ''
working_host = ''
# проверка необходимости синхронизации других оверлеев
#if dv.Get("cl_update_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'):
chosen_hosting = dv.Get("cl_update_rep_hosting_choice")
if chosen_hosting:
@ -466,15 +461,13 @@ class Update(MethodsInterface):
try:
if clean_on_error:
try:
repconf = ReposConf(dv.Get('cl_update_reposconf'),
dv.Get('cl_update_reposconf_dir'),
prefix=chroot_path)
repconf.add(repname, url, rpath_orig)
if not self._syncRepository(repname, url, rpath, revision,
cb_progress=self.setProgress,
clean=check_status,
notask=fallback_sync):
self.compare_repo_cache(repname, url, rpath_orig, chroot_path)
return "skip"
self.compare_repo_cache(repname, url, rpath_orig, chroot_path)
return True
except GitError as e:
if not isinstance(e, NotGitError):
@ -526,6 +519,24 @@ class Update(MethodsInterface):
metadata_cache_names = ("metadata/md5-cache", "metadata/cache")
def compare_repo_cache(self, repname, url, rpath_orig, chroot_path):
if not self.clVars.GetBool('cl_update_settings_changes_set'):
repconf = ReposConf(self.clVars.Get('cl_update_reposconf'),
self.clVars.Get('cl_update_reposconf_dir'),
prefix=chroot_path)
repconf.add(repname, url, rpath_orig)
ini = SystemIni(self.clVars)
ps = PortageState()
new_portage_state_hash = ps.get_state()
ini.setVar('system', {'portage_hash': new_portage_state_hash})
self.clVars.Set('cl_update_package_cache_set', Variable.Off, force=True)
else:
repconf = ReposConf(self.clVars.Get('cl_update_reposconf'),
self.clVars.Get('cl_update_reposconf_dir'),
prefix=chroot_path)
repconf.add(repname, url, rpath_orig)
def stash_cache(self, rpath, name):
"""
Спрятать кэш
@ -593,9 +604,6 @@ class Update(MethodsInterface):
self.stash_cache(rpath, repdirname)
rpath_old = f"{rpath}_old"
makeDirectory(rpath_old)
old_hash = PortageState()
old_hash.paths = [f'{rpath}']
old_hash = old_hash.get_state()
try:
if Git.is_git(rpath):
self.addProgress()
@ -623,8 +631,6 @@ class Update(MethodsInterface):
finally:
removeDir(rpath_old)
self.unstash_cache(rpath, repdirname)
new_hash = PortageState()
new_hash.paths = [f'{rpath}']
return True
def _regenCache_process(self, progname, repname, cpu_num):
@ -1410,54 +1416,6 @@ class Update(MethodsInterface):
location="system")
return True
# def update_local_info_binhost(self, write_binhost=True):
# """
# Проверить, что доступен хотя бы один из binhost'ов
# :return:
# """
# hosts = self.clVars.Get("update.cl_update_binhost_host")
# datas = self.clVars.Get("update.cl_update_binhost_revisions")
# if not hosts:
# self.delete_binhost()
# raise UpdateError(_("Failed to find the server with "
# "appropriate updates"))
# else:
# with writeFile(self.get_bin_cache_filename()) as f:
# f.write(datas[0].strip()+"\n")
# if write_binhost:
# if hosts[0] != self.clVars.Get('update.cl_update_binhost'):
# self.refresh_binhost = True
# self.clVars.Set('cl_update_package_cache_set', 'on')
# if self.clVars.GetBool('update.cl_update_binhost_recheck_set'):
# self.clVars.Write('cl_update_binhost', hosts[0], location="system")
# self.clVars.Write('cl_update_binhost_set', Variable.Off, location="system")
# elif self.clVars.Get('cl_update_binhost_choice') and self.clVars.Get('cl_update_binhost_choice') != 'auto':
# cur_binhost = self.clVars.Get('cl_update_binhost_choice')
# if not cur_binhost.startswith("http://") \
# and not cur_binhost.startswith("ftp://")\
# and not cur_binhost.startswith("https://"):
# cur_binhost = f"https://{cur_binhost}"
# self.clVars.Write('cl_update_binhost', cur_binhost, location="system")
# self.clVars.Write('cl_update_binhost_set', Variable.On, location="system")
# elif not self.clVars.GetBool('update.cl_update_binhost_set'):
# self.clVars.Write('cl_update_binhost', hosts[0], location="system")
# self.clVars.Write('cl_update_binhost_set', Variable.Off, location="system")
# new_ts = self.clVars.Get("update.cl_update_binhost_timestamp")
# if new_ts:
# new_ts = new_ts[0]
# if new_ts.isdigit():
# ini = SystemIni(self.clVars)
# ini.setVar('system', {'last_update': new_ts})
# if self.is_update_action(self.clVars.Get("cl_action")):
# value = self.clVars.GetBool('update.cl_update_binhost_stable_set')
# new_value = self.clVars.GetBool('update.cl_update_binhost_stable_opt_set')
# if value != new_value:
# self.clVars.Write(
# 'cl_update_binhost_stable_set',
# self.clVars.Get('update.cl_update_binhost_stable_opt_set'),
# location="system")
# return True
def is_update_action(self, action):
return action == 'sync'
@ -1629,11 +1587,6 @@ class Update(MethodsInterface):
self.clVars.Set('update.cl_update_binhost_recheck_set', Variable.On)
self.clVars.Set('cl_update_package_cache_set', Variable.Off, force=True)
raise
# self.clVars.Write('cl_update_binhost', url_binhost.split('/grp/')[0])
# self.clVars.Set('update.cl_update_binhost', url_binhost.split('/grp/')[0])
# if self.clVars.Get('update.cl_update_binhost_choice') \
# and self.clVars.Get('update.cl_update_binhost_choice') != 'auto':
# self.clVars.Write('cl_update_binhost_set', Variable.On)
return True
class Reason():
@ -1728,8 +1681,7 @@ class Update(MethodsInterface):
retval = []
skip_check_status = False
actual_reason = self.Reason.UnknownError
#for binhost in sorted(binhosts_data.get_binhosts(), reverse=True):
for binhost in sorted(asyncio.run(binhosts_data.get_asyncbinhosts()), reverse=True):
for binhost in sorted(binhosts_data.get_binhosts(), reverse=True):
host = binhost.host
if not binhost.valid:
reason = self.Reason.WrongBinhost
@ -1785,7 +1737,7 @@ class Update(MethodsInterface):
else:
raise UpdateError(_("Failed to find the working server with updates"))
return retval
def is_binhost_level_valid(self, binhost):
return self.compare_update_level(binhost.level) == 0

@ -457,7 +457,6 @@ class VariableClUpdateSettingsChangesSet(Variable):
old_portage_state_hash = ini.getVar('system', 'portage_hash') or ""
ps = PortageState()
new_portage_state_hash = ps.get_state()
a = new_portage_state_hash != old_portage_state_hash
return "on" if new_portage_state_hash != old_portage_state_hash else "off"
@ -1882,11 +1881,16 @@ class VariableClUpdatePackageCacheSet(Variable):
Необходимость обновить Packages
"""
type = "bool"
value = ''
def get(self):
if self.value:
return self.value
packages_fn = self.Get('cl_update_package_cache')
gpg = self.Get('cl_update_gpg')
packages_asc_fn = self.Get('cl_update_package_cache_sign')
a = path.exists(packages_fn)
b = path.exists(packages_asc_fn)
if (not path.exists(packages_fn) or
gpg and not path.exists(packages_asc_fn)):
return "on"

Loading…
Cancel
Save