feature: new cache logic for current binhost
master 3.7.2.60
root 1 year ago
parent 157c642386
commit 9faf04df67

@ -1559,13 +1559,19 @@ class Update(MethodsInterface):
def download_packages(self, url_binhost, packages_fn, packages_sign_fn, gpg):
quite_unlink(packages_fn)
packages_ini = os.path.join(packages_sign_fn.split("/Packages.as")[0], 'ini.env')
quite_unlink(packages_ini)
orig_ini = Binhosts.packages_check_ini(url_binhost.split("/grp")[0]).decode('utf-8')
orig_packages = Binhosts.fetch_packages(url_binhost)
try:
with writeFile(packages_fn) as f:
pi = PackagesIndex(orig_packages)
pi["TTL"] = str(30 * DAYS)
pi["DOWNLOAD_TIMESTAMP"] = str(int(time.time()))
pi.write(f)
with open(packages_ini, 'w') as f:
f.write(orig_ini)
except (OSError, IOError):
raise UpdateError(_("Failed to save Packages"))
self.endTask(True)
@ -1581,11 +1587,7 @@ class Update(MethodsInterface):
f.write(Binhosts.fetch_packages_sign(url_binhost).decode("UTF-8"))
except BinhostSignError:
for fn in (packages_fn, packages_sign_fn):
if path.exists(fn):
try:
os.unlink(fn)
except OSError:
pass
quite_unlink(fn)
self.clVars.Set("update.cl_update_bad_sign_set", Variable.On)
self.clVars.Set('update.cl_update_binhost_recheck_set', Variable.On)
self.clVars.Set('cl_update_package_cache_set', Variable.Off, force=True)
@ -1814,27 +1816,20 @@ class Update(MethodsInterface):
if self.binhosts_data.gpg:
packages_fn = self.clVars.Get('update.cl_update_package_cache')
packages_sign_fn = self.clVars.Get('update.cl_update_package_cache_sign')
if path.exists(packages_fn) and path.exists(packages_sign_fn):
packages_sign = readFile(packages_sign_fn, binary=True)
pi = PackagesIndex(readFile(packages_fn))
pi.clean()
packages_ini = os.path.join(packages_sign_fn.split("/Packages.as")[0], 'ini.env')
if path.exists(packages_fn) and path.exists(packages_sign_fn) and path.exists(packages_ini):
local_ini = readFile(packages_ini, binary=True)
try:
Binhosts.check_packages_signature(
None, pi.get_value(), self.binhosts_data.gpg,
sign=packages_sign)
orig_ini = Binhosts.packages_check_ini(binhost.host)
if not orig_ini == local_ini:
for fn in (packages_fn, packages_sign_fn, packages_ini):
quite_unlink(fn)
self.clVars.Set('cl_update_package_cache_set', Variable.On)
except BinhostError:
for fn in (packages_fn, packages_sign_fn, packages_ini):
quite_unlink(fn)
raise UpdateError(_("Failed to find ini.env on current binhost"))
return True
except BinhostSignError:
for fn in (packages_fn, packages_sign_fn):
if path.exists(fn):
try:
os.unlink(fn)
except OSError:
pass
if binhost.bad_sign:
raise UpdateError(
_("Current binhost {} has wrong signature").format(
binhost_url))
if rewrite_binhost:
self.clVars.Write('cl_update_binhost', binhost_url)
return True
@ -2043,6 +2038,14 @@ class Update(MethodsInterface):
ini.delVar('system', 'portage_hash')
return True
def drop_packages_cache(self):
packages_fn = self.clVars.Get('update.cl_update_package_cache')
packages_sign_fn = self.clVars.Get('update.cl_update_package_cache_sign')
packages_ini = os.path.join(packages_sign_fn.split("/Packages.as")[0], 'ini.env')
for fn in (packages_fn, packages_sign_fn, packages_ini):
quite_unlink(fn)
return True
def update_fastlogin_domain_path(self):
try:
if not self.clVars.Get('client.cl_remote_host'):

@ -64,6 +64,10 @@ def get_synchronization_tasks(object_name):
Get('update.cl_update_binhost') and
Get('update.cl_update_use_migration_host') == 'off')
},
{'name': 'drop_packeges_cache',
'method': 'Update.drop_packages_cache()',
'depend': AllTasks.failed_all("check_current_binhost")
},
{'name': 'not_use_search:failed_base_binhost',
'error': __("Failed to use base binhost"),
'method': Object("delete_binhost()"),

@ -1889,8 +1889,6 @@ class VariableClUpdatePackageCacheSet(Variable):
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