[entropy.client] rename _repositories_hash() to repositories_checksum()
This commit is contained in:
@@ -30,8 +30,8 @@ class CacheMixin:
|
||||
Get available packages cache hash.
|
||||
"""
|
||||
# client digest not needed, cache is kept updated
|
||||
c_hash = "%s|%s|%s" % (
|
||||
self._repositories_hash(),
|
||||
c_hash = "%s|%s|%s|v1" % (
|
||||
self.repositories_checksum(),
|
||||
self.filter_repositories(self.repositories()),
|
||||
# needed when users do bogus things like editing config files
|
||||
# manually (branch setting)
|
||||
@@ -39,42 +39,3 @@ class CacheMixin:
|
||||
sha = hashlib.sha1()
|
||||
sha.update(const_convert_to_rawstring(repr(c_hash)))
|
||||
return sha.hexdigest()
|
||||
|
||||
def _repositories_hash(self):
|
||||
"""
|
||||
Return the checksum of all the available repositories, including
|
||||
package repos.
|
||||
"""
|
||||
repository_ids = self.repositories()
|
||||
sha = hashlib.sha1()
|
||||
|
||||
sha.update(const_convert_to_rawstring(",".join(repository_ids)))
|
||||
sha.update(const_convert_to_rawstring("-begin-"))
|
||||
|
||||
for repository_id in repository_ids:
|
||||
|
||||
mtime = None
|
||||
checksum = None
|
||||
|
||||
try:
|
||||
repo = self.open_repository(repository_id)
|
||||
except RepositoryError:
|
||||
repo = None
|
||||
|
||||
if repo is not None:
|
||||
try:
|
||||
mtime = repo.mtime()
|
||||
except (EntropyRepositoryError, OSError, IOError):
|
||||
pass
|
||||
|
||||
try:
|
||||
checksum = repo.checksum()
|
||||
except EntropyRepositoryError:
|
||||
pass
|
||||
|
||||
cache_s = "{%s:{%r;%s}}" % (repository_id, mtime, checksum)
|
||||
sha.update(const_convert_to_unicode(cache_s))
|
||||
|
||||
sha.update(const_convert_to_rawstring("-end-"))
|
||||
|
||||
return sha.hexdigest()
|
||||
|
||||
@@ -187,14 +187,13 @@ class CalculatorsMixin:
|
||||
sha = hashlib.sha1()
|
||||
|
||||
cache_fmt = "a{%s}mr{%s}ms{%s}rh{%s}mf{%s}"
|
||||
cache_fmt += "er{%s}ar{%s}m{%s}cm{%s}s{%s;%s;%s}"
|
||||
cache_fmt += "ar{%s}m{%s}cm{%s}s{%s;%s;%s}"
|
||||
cache_s = cache_fmt % (
|
||||
atom,
|
||||
";".join(match_repo),
|
||||
match_slot,
|
||||
self._repositories_hash(),
|
||||
self.repositories_checksum(),
|
||||
mask_filter,
|
||||
";".join(self._enabled_repos),
|
||||
";".join(sorted(self._settings['repositories']['available'])),
|
||||
self._settings.packages_configuration_hash(),
|
||||
self._settings_client_plugin.packages_configuration_hash(),
|
||||
@@ -368,14 +367,13 @@ class CalculatorsMixin:
|
||||
if self.xcache and use_cache:
|
||||
sha = hashlib.sha1()
|
||||
|
||||
cache_s = "k{%s}re{%s}de{%s}rh{%s}m{%s}cm{%s}er{%s}ar{%s}" % (
|
||||
cache_s = "k{%s}re{%s}de{%s}rh{%s}m{%s}cm{%s}ar{%s}" % (
|
||||
keyword,
|
||||
";".join(repositories),
|
||||
description,
|
||||
self._repositories_hash(),
|
||||
self.repositories_checksum(),
|
||||
self._settings.packages_configuration_hash(),
|
||||
self._settings_client_plugin.packages_configuration_hash(),
|
||||
";".join(self._enabled_repos),
|
||||
";".join(sorted(self._settings['repositories']['available'])),
|
||||
)
|
||||
sha.update(const_convert_to_rawstring(cache_s))
|
||||
@@ -647,14 +645,13 @@ class CalculatorsMixin:
|
||||
if self.xcache:
|
||||
sha = hashlib.sha1()
|
||||
|
||||
cache_s = "%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|v6" % (
|
||||
cache_s = "%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|v7" % (
|
||||
";".join(sorted(dependencies)),
|
||||
deep_deps,
|
||||
inst_repo.checksum(),
|
||||
self._repositories_hash(),
|
||||
self.repositories_checksum(),
|
||||
self._settings.packages_configuration_hash(),
|
||||
self._settings_client_plugin.packages_configuration_hash(),
|
||||
";".join(self._enabled_repos),
|
||||
";".join(sorted(self._settings['repositories']['available'])),
|
||||
relaxed_deps,
|
||||
ignore_spm_downgrades,
|
||||
@@ -1879,14 +1876,13 @@ class CalculatorsMixin:
|
||||
cache_key = None
|
||||
|
||||
if self.xcache:
|
||||
cache_s = "%s|%s|%s|%s|%s|%s|%s|%s|r6" % (
|
||||
cache_s = "%s|%s|%s|%s|%s|%s|%s|r7" % (
|
||||
match,
|
||||
installed_package_id,
|
||||
inst_repo.checksum(),
|
||||
self._repositories_hash(),
|
||||
self.repositories_checksum(),
|
||||
self._settings.packages_configuration_hash(),
|
||||
self._settings_client_plugin.packages_configuration_hash(),
|
||||
";".join(self._enabled_repos),
|
||||
";".join(sorted(self._settings['repositories']['available'])),
|
||||
)
|
||||
sha = hashlib.sha1()
|
||||
@@ -2174,7 +2170,7 @@ class CalculatorsMixin:
|
||||
only_deps,
|
||||
recursive,
|
||||
inst_repo.checksum(),
|
||||
self._repositories_hash(),
|
||||
self.repositories_checksum(),
|
||||
self._settings.packages_configuration_hash(),
|
||||
self._settings_client_plugin.packages_configuration_hash(),
|
||||
";".join(sorted(self._settings['repositories']['available'])),
|
||||
@@ -2444,7 +2440,7 @@ class CalculatorsMixin:
|
||||
if self.xcache:
|
||||
sha = hashlib.sha1()
|
||||
|
||||
cache_s = "ma{%s}s{%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s}v4" % (
|
||||
cache_s = "ma{%s}s{%s;%s;%s;%s;%s;%s;%s;%s;%s;%s}v5" % (
|
||||
";".join(["%s" % (x,) for x in sorted(matched_atoms)]),
|
||||
deep,
|
||||
recursive,
|
||||
@@ -2452,10 +2448,9 @@ class CalculatorsMixin:
|
||||
system_packages,
|
||||
elf_needed_scanning,
|
||||
inst_repo.checksum(),
|
||||
self._repositories_hash(),
|
||||
self.repositories_checksum(),
|
||||
self._settings.packages_configuration_hash(),
|
||||
self._settings_client_plugin.packages_configuration_hash(),
|
||||
";".join(self._enabled_repos),
|
||||
";".join(sorted(self._settings['repositories']['available'])),
|
||||
)
|
||||
sha.update(const_convert_to_rawstring(cache_s))
|
||||
@@ -2983,11 +2978,10 @@ class CalculatorsMixin:
|
||||
|
||||
inst_repo = self.installed_repository()
|
||||
|
||||
cache_s = "%s|%s|%s|%s|%s|%s|%s|%s|%s|v4" % (
|
||||
self._repositories_hash(),
|
||||
cache_s = "%s|%s|%s|%s|%s|%s|%s|%s|v5" % (
|
||||
enabled_repos,
|
||||
inst_repo.checksum(),
|
||||
self._repositories_hash(),
|
||||
self.repositories_checksum(),
|
||||
self._settings.packages_configuration_hash(),
|
||||
self._settings_client_plugin.packages_configuration_hash(),
|
||||
";".join(sorted(self._settings['repositories']['available'])),
|
||||
@@ -3127,12 +3121,11 @@ class CalculatorsMixin:
|
||||
repo_order = [x for x in self._settings['repositories']['order'] if
|
||||
x in enabled_repos]
|
||||
|
||||
cache_s = "%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|v6" % (
|
||||
self._repositories_hash(),
|
||||
cache_s = "%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|v7" % (
|
||||
empty,
|
||||
enabled_repos,
|
||||
inst_repo.checksum(),
|
||||
self._repositories_hash(),
|
||||
self.repositories_checksum(),
|
||||
self._settings.packages_configuration_hash(),
|
||||
self._settings_client_plugin.packages_configuration_hash(),
|
||||
";".join(sorted(self._settings['repositories']['available'])),
|
||||
@@ -3536,14 +3529,13 @@ class CalculatorsMixin:
|
||||
if self.xcache:
|
||||
sha = hashlib.sha1()
|
||||
|
||||
cache_s = "{%s;%s;%s;%s;%s;%s;%s;%s}v4" % (
|
||||
cache_s = "{%s;%s;%s;%s;%s;%s;%s}v5" % (
|
||||
atom,
|
||||
deep,
|
||||
inst_repo.checksum(),
|
||||
self._repositories_hash(),
|
||||
self.repositories_checksum(),
|
||||
self._settings.packages_configuration_hash(),
|
||||
self._settings_client_plugin.packages_configuration_hash(),
|
||||
";".join(self._enabled_repos),
|
||||
";".join(sorted(self._settings['repositories']['available'])),
|
||||
)
|
||||
sha.update(const_convert_to_rawstring(cache_s))
|
||||
|
||||
@@ -984,6 +984,51 @@ class RepositoryMixin:
|
||||
x.endswith(etpConst['packagesext'])]
|
||||
return enabled_repos
|
||||
|
||||
def repositories_checksum(self):
|
||||
"""
|
||||
Return a SHA1 of the checksums and mtimes of all the repositories.
|
||||
|
||||
This method can be used for cache validation/lookup purposes.
|
||||
|
||||
@return: a SHA1 string of the checksum and mtimes of all the
|
||||
available repositories, including package repositories,
|
||||
excluding the installed packages repository
|
||||
@rtype: string
|
||||
"""
|
||||
repository_ids = self.repositories()
|
||||
sha = hashlib.sha1()
|
||||
|
||||
sha.update(const_convert_to_rawstring(",".join(repository_ids)))
|
||||
sha.update(const_convert_to_rawstring("-begin-"))
|
||||
|
||||
for repository_id in repository_ids:
|
||||
|
||||
mtime = None
|
||||
checksum = None
|
||||
|
||||
try:
|
||||
repo = self.open_repository(repository_id)
|
||||
except RepositoryError:
|
||||
repo = None
|
||||
|
||||
if repo is not None:
|
||||
try:
|
||||
mtime = repo.mtime()
|
||||
except (EntropyRepositoryError, OSError, IOError):
|
||||
pass
|
||||
|
||||
try:
|
||||
checksum = repo.checksum()
|
||||
except EntropyRepositoryError:
|
||||
pass
|
||||
|
||||
cache_s = "{%s:{%r;%s}}" % (repository_id, mtime, checksum)
|
||||
sha.update(const_convert_to_unicode(cache_s))
|
||||
|
||||
sha.update(const_convert_to_rawstring("-end-"))
|
||||
|
||||
return sha.hexdigest()
|
||||
|
||||
def installed_repository(self):
|
||||
"""
|
||||
Return Entropy Client installed packages repository.
|
||||
|
||||
@@ -584,7 +584,7 @@ class System(object):
|
||||
inst_pkgs_cksum = inst_repo.checksum(
|
||||
do_order=True, strict=False)
|
||||
|
||||
repo_cksum = self._entropy._repositories_hash()
|
||||
repo_cksum = self._entropy.repositories_checksum()
|
||||
|
||||
cache_s = "rc{%s}irc{%s}b{%s}dp{%s}dt{%s}r{%s}" % (
|
||||
repo_cksum,
|
||||
|
||||
Reference in New Issue
Block a user