diff options
Diffstat (limited to '')
-rw-r--r-- | portato/backend/flags.py | 58 | ||||
-rw-r--r-- | portato/backend/package.py | 8 | ||||
-rw-r--r-- | portato/backend/portage/package.py | 27 |
3 files changed, 77 insertions, 16 deletions
diff --git a/portato/backend/flags.py b/portato/backend/flags.py index 7f37766..d43f567 100644 --- a/portato/backend/flags.py +++ b/portato/backend/flags.py @@ -420,13 +420,13 @@ def set_masked (pkg, masked = True): copy = link_neq[cpv][:] for file, line in copy: if line != "-1": - link_neq[cpv].remove(file, line) + link_neq[cpv].remove((file, line)) if masked == pkg.is_masked(): return data = get_data(pkg, path) - debug("data: "+str(link_eq)) + debug("data:", str(data)) done = False for file, line, crit, flags in data: if pkg.matches(crit): @@ -469,12 +469,56 @@ def new_masking_status (cpv): if isinstance(cpv, package.Package): cpv = cpv.get_cpv() - if cpv in new_masked and new_masked[cpv] != []: - return "masked" - elif cpv in new_unmasked and new_unmasked[cpv] != []: - return "unmasked" - else: return None + def get(list): + ret = None + if cpv in list and list[cpv] != []: + for file, line in list[cpv]: + _ret = (int(line) == -1) + if ret is not None and _ret != ret: + debug("Conflicting values for masking status!", list, error = True) + else: + ret = _ret + return ret + + masked = get(new_masked) + if masked is None: + masked = get(new_unmasked) + if masked is not None: + masked = not masked # revert for new_unmasked + + if masked is not None: + if masked: return "masked" + else: return "unmasked" + else: + return None + +def is_locally_masked (pkg, changes = True): + + if not isinstance(pkg, package.Package): + pkg = system.new_package(pkg) # assume it is a cpv or a gentoolkit.Package + if changes: + if new_masking_status(pkg) == "masked": # we masked it ourselves, but did not save it yet + # but sometimes, new_masking_status() returns "masked" if a package's unmask is removed + # then it is masked by the system but not locally (except rarely exotic cases) + if pkg.get_cpv() in new_unmasked: + if new_unmasked[pkg.get_cpv()]: return False # assume that there only exists one entry for this package + # else new_masking_status should have printed an error + return True + + if new_masking_status(pkg) == "unmasked": # we unmasked it + return False + + list = get_data(pkg, CONST.mask_path()) + + if not list: return False + + for file, line, crit, fl in list: + if pkg.matches(crit): + return True + + return False + def write_masked (): global new_unmasked, new_masked file_cache = {} diff --git a/portato/backend/package.py b/portato/backend/package.py index 70773cc..f9b675d 100644 --- a/portato/backend/package.py +++ b/portato/backend/package.py @@ -58,6 +58,14 @@ class Package: flags.remove_new_masked(self.get_cpv()) + def is_locally_masked (self): + """Checks whether the package is masked by the user. + + @returns: True if masked by the user; False if not + @rtype: bool""" + + return flags.is_locally_masked(self) + def get_installed_use_flags (self): """Returns a list of the useflags enabled at installation time. If package is not installed, it returns an empty list. diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py index b455530..38e7369 100644 --- a/portato/backend/portage/package.py +++ b/portato/backend/portage/package.py @@ -82,20 +82,29 @@ class PortagePackage (Package): if status == "masked": return True elif status == "unmasked": return False else: - debug("BUG in flags.new_masking_status. It returns",status) + debug("BUG in flags.new_masking_status. It returns", status, error = True) else: # we have not touched the status if self._status and ("profile" in self._status or "package.mask" in self._status): return True return False - else: - try: - masked = self._settings.settings.pmaskdict[self.get_cp()] - except KeyError: # key error: not masked - return False - - for cpv in masked: - if self.matches(cpv): + else: # we want the original portage value XXX: bug if masked by user AND by system + + # get the normal masked ones + if self._status and ("profile" in self._status or "package.mask" in self._status): + if not flags.is_locally_masked(self, changes = False): # assume that if it is locally masked, it is not masked by the system return True + else: # more difficult: get the ones we unmasked, but are masked by the system + try: + masked = self._settings.settings.pmaskdict[self.get_cp()] + except KeyError: # key error: not masked + return False + + for cpv in masked: + if self.matches(cpv): + if not flags.is_locally_masked(self, changes = False): # assume that if it is locally masked, it is not masked by the system + return True + else: + return False return False |