diff --git a/lib/entropy/client/interfaces/dep.py b/lib/entropy/client/interfaces/dep.py index 8f83c6526..3064ee550 100644 --- a/lib/entropy/client/interfaces/dep.py +++ b/lib/entropy/client/interfaces/dep.py @@ -1555,7 +1555,7 @@ class CalculatorsMixin: continue if mymatch not in mydata: # check if not found - myaction = self.get_package_action(mymatch) + myaction = self._get_package_action(mymatch) # only if the package is not installed if myaction == 1: mydata.append(mymatch) @@ -1575,7 +1575,7 @@ class CalculatorsMixin: if (conflict_match == new_match) or (new_match[1] == 1): return - action = self.get_package_action( + action = self._get_package_action( new_match, installed_package_id = client_package_id) if (action == 0) and (not deep_deps): return @@ -1588,7 +1588,7 @@ class CalculatorsMixin: Lookup inverse dependencies and return them as a list of package matches. """ - cmpstat = self.get_package_action( + cmpstat = self._get_package_action( match, installed_package_id = installed_package_id) if cmpstat == 0: return set() @@ -1635,7 +1635,7 @@ class CalculatorsMixin: mymatch = self.atom_match(key_slot) if mymatch[0] == -1: continue - cmpstat = self.get_package_action( + cmpstat = self._get_package_action( mymatch, installed_package_id = inst_package_id) if cmpstat == 0: continue @@ -1738,7 +1738,7 @@ class CalculatorsMixin: continue # do we already have the latest version installed? - cmpstat = self.get_package_action( + cmpstat = self._get_package_action( (package_id, repository_id), installed_package_id = inst_package_id) if cmpstat == 0: @@ -2005,7 +2005,7 @@ class CalculatorsMixin: for _package_id, _repository_id in found_matches: _match = _package_id, _repository_id - cmpstat = self.get_package_action(_match) + cmpstat = self._get_package_action(_match) if cmpstat == 0: continue @@ -2060,7 +2060,7 @@ class CalculatorsMixin: continue pkg_match = package_id, repository_id - cmpstat = self.get_package_action( + cmpstat = self._get_package_action( pkg_match, installed_package_id = inst_package_id) if cmpstat == 0: continue diff --git a/lib/entropy/client/interfaces/methods.py b/lib/entropy/client/interfaces/methods.py index bae94cbd9..b90d1c7dc 100644 --- a/lib/entropy/client/interfaces/methods.py +++ b/lib/entropy/client/interfaces/methods.py @@ -2202,6 +2202,7 @@ class MiscMixin: class MatchMixin: + @sharedinstlock def get_package_action(self, package_match, installed_package_id = None): """ For given package match, return an action value representing the @@ -2218,6 +2219,15 @@ class MatchMixin: @return: package status @rtype: int """ + return self._get_package_action( + package_match, installed_package_id = installed_package_id) + + def _get_package_action(self, package_match, + installed_package_id = None): + """ + See get_package_action(), this internal method runs assuming that + repositories lock are already acquired. + """ inst_repo = self.installed_repository() pkg_id, pkg_repo = package_match dbconn = self.open_repository(pkg_repo) @@ -2231,31 +2241,30 @@ class MatchMixin: pkgver, pkgtag, pkgrev = dbconn.getVersioningData(pkg_id) - with inst_repo.shared(): - ver_data = inst_repo.getVersioningData(installed_package_id) - if ver_data is None: - # installed package_id is not available, - # race condition, probably - return 1 + ver_data = inst_repo.getVersioningData(installed_package_id) + if ver_data is None: + # installed package_id is not available, + # race condition, probably + return 1 - installed_ver, installed_tag, installed_rev = ver_data + installed_ver, installed_tag, installed_rev = ver_data - pkgcmp = entropy.dep.entropy_compare_versions( - (pkgver, pkgtag, pkgrev), - (installed_ver, installed_tag, installed_rev)) - if pkgcmp == 0: - # check digest, if it differs, we should mark pkg as update - # we don't want users to think that they are "reinstalling" - # stuff because it will just confuse them - inst_digest = inst_repo.retrieveDigest(installed_package_id) - repo_digest = dbconn.retrieveDigest(pkg_id) - if inst_digest != repo_digest: - return 2 - return 0 - elif pkgcmp > 0: + pkgcmp = entropy.dep.entropy_compare_versions( + (pkgver, pkgtag, pkgrev), + (installed_ver, installed_tag, installed_rev)) + if pkgcmp == 0: + # check digest, if it differs, we should mark pkg as update + # we don't want users to think that they are "reinstalling" + # stuff because it will just confuse them + inst_digest = inst_repo.retrieveDigest(installed_package_id) + repo_digest = dbconn.retrieveDigest(pkg_id) + if inst_digest != repo_digest: return 2 + return 0 + elif pkgcmp > 0: + return 2 - return -1 + return -1 def is_package_masked(self, package_match, live_check = True): """