|
|
|
@ -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'):
|
|
|
|
|