def __init__ (self, cpv): """Constructor. @param cpv: The cpv which describes the package to create. @type cpv: string (cat/pkg-ver)""" Package.__init__(self, cpv) self._scpv = system.split_cpv(self._cpv) if not self._scpv: raise ValueError("invalid cpv: %s" % cpv) self._settings = system.settings self._settingslock = system.settings.settingslock self._settings_installed = None self._trees = system.settings.trees self.forced_flags = set() with self._settingslock: self._init_settings(True) self.forced_flags.update(self._settings.settings.usemask) self.forced_flags.update(self._settings.settings.useforce) try: self._status = portage.getmaskingstatus(self.get_cpv(), settings = self._settings.settings) except KeyError: # package is not located in the system self._status = None if self._status and len(self._status) == 1 and self._status[0] == "corrupted": self._status = None
def mask(Package, version): return portage.getmaskingstatus( "%s/%s-%s" % (Package.category, Package.package, version), settings=SETTINGS, portdb=PORTTREE, myrepo=Package.repository )
def mask_status(self): """Shortcut to L{portage.getmaskingstatus}. @rtype: None or list @return: a list containing none or some of: 'profile' 'package.mask' license(s) "kmask" keyword 'missing keyword' """ if self._settings.locked: self._settings.unlock() try: result = portage.getmaskingstatus( self.cpv, settings=self._settings, portdb=portage.db[portage.root]["porttree"].dbapi) except KeyError: # getmaskingstatus doesn't support packages without ebuilds in the # Portage tree. result = None return result
def __init__(self, cpv): """Constructor. @param cpv: The cpv which describes the package to create. @type cpv: string (cat/pkg-ver)""" Package.__init__(self, cpv) self._scpv = system.split_cpv(self._cpv) if not self._scpv: raise ValueError("invalid cpv: %s" % cpv) self._settings = system.settings self._settingslock = system.settings.settingslock self._settings_installed = None self._trees = system.settings.trees self.forced_flags = set() with self._settingslock: self._init_settings(True) self.forced_flags.update(self._settings.settings.usemask) self.forced_flags.update(self._settings.settings.useforce) try: self._status = portage.getmaskingstatus( self.get_cpv(), settings=self._settings.settings) except KeyError: # package is not located in the system self._status = None if self._status and len( self._status) == 1 and self._status[0] == "corrupted": self._status = None
def is_package_masked(self, cpv): """ Returns if the cpv in parameter is masked. Parameter: cpv (string): the name of the package """ return 'package.mask' in portage.getmaskingstatus( cpv, portdb=portage.portdb)
def is_package_keyworded(self, cpv): """ Returns if the cpv in parameter is masked by a keyword. Parameter: cpv (string): the name of the package """ return 'missing keyword' in portage.getmaskingstatus( cpv, portdb=portage.portdb)
def __getMaskStatus(self, cpv): """Figure out if package is pmasked.""" try: if "package.mask" in port.getmaskingstatus(cpv, settings=self.mysettings): return True except: # occurs when package is not known by portdb # so we consider it unmasked pass return False
def get_masking_status(ebuild): """returns the masking status of an ebuild @param ebuild: str @return list """ try: status = portage.getmaskingstatus(ebuild) except KeyError: status = ['unavailable'] return status
def __getMaskStatus(self, cpv): """Figure out if package is pmasked.""" try: if "package.mask" in port.getmaskingstatus( cpv, settings=self.mysettings): return True except: # occurs when package is not known by portdb # so we consider it unmasked pass return False
def find_best(self, include_keyworded=True, include_masked=True): """Returns the "best" version available. Order of preference: highest available stable => highest available keyworded => highest available masked @rtype: Package object or None @return: best of up to three options @raise errors.GentoolkitInvalidAtom: if query is not valid input """ best = keyworded = masked = None try: best = portage.db[portage.root]["porttree"].dbapi.xmatch( "bestmatch-visible", self.query) except portage.exception.InvalidAtom as err: message = ("query.py: find_best(), bestmatch-visible, " + "query=%s, InvalidAtom=%s" % (self.query, str(err))) raise errors.GentoolkitInvalidAtom(message) # xmatch can return an empty string, so checking for None is not enough if not best: if not (include_keyworded or include_masked): return None try: matches = portage.db[portage.root]["porttree"].dbapi.xmatch( "match-all", self.query) except portage.exception.InvalidAtom as err: message = ( "query.py: find_best(), match-all, query=%s, InvalidAtom=%s" % (self.query, str(err))) raise errors.GentoolkitInvalidAtom(message) masked = portage.best(matches) keywordable = [] for m in matches: status = portage.getmaskingstatus(m) if "package.mask" not in status or "profile" not in status: keywordable.append(m) if matches: keyworded = portage.best(keywordable) else: return Package(best) if include_keyworded and keyworded: return Package(keyworded) if include_masked and masked: return Package(masked) return None
def find_best(self, include_keyworded=True, include_masked=True): """Returns the "best" version available. Order of preference: highest available stable => highest available keyworded => highest available masked @rtype: Package object or None @return: best of up to three options @raise errors.GentoolkitInvalidAtom: if query is not valid input """ best = keyworded = masked = None try: best = portage.db[portage.root]["porttree"].dbapi.xmatch("bestmatch-visible", self.query) except portage.exception.InvalidAtom as err: message = "query.py: find_best(), bestmatch-visible, " + \ "query=%s, InvalidAtom=%s" %(self.query, str(err)) raise errors.GentoolkitInvalidAtom(message) # xmatch can return an empty string, so checking for None is not enough if not best: if not (include_keyworded or include_masked): return None try: matches = portage.db[portage.root]["porttree"].dbapi.xmatch("match-all", self.query) except portage.exception.InvalidAtom as err: message = "query.py: find_best(), match-all, query=%s, InvalidAtom=%s" %( self.query, str(err)) raise errors.GentoolkitInvalidAtom(message) masked = portage.best(matches) keywordable = [] for m in matches: status = portage.getmaskingstatus(m) if 'package.mask' not in status or 'profile' not in status: keywordable.append(m) if matches: keyworded = portage.best(keywordable) else: return Package(best) if include_keyworded and keyworded: return Package(keyworded) if include_masked and masked: return Package(masked) return None
def get_package_status(aname): """ Return the status of a package: stable, unstable, hardmasked, unkeyworded Notice that "stable" could mean "previously unmasked" as well. """ arch = get_arch() archstatus = "~%s keyword" % arch try: res = portage.getmaskingstatus(aname) if not res: return "STABLE" if ( res[0] == "missing keyword" ): return "UNKEYWORDED" if ( res[0] == archstatus): return "UNSTABLE" if (( res[0] == "package.mask" )&(res[1] == archstatus)): return "HARDMASKED" except ValueError as e: print >> warn, "Unable to parse the status of %s.\n" % aname,e
def mask_status(self): """Shortcut to L{portage.getmaskingstatus}. @rtype: None or list @return: a list containing none or some of: 'profile' 'package.mask' license(s) "kmask" keyword 'missing keyword' """ if self._settings.locked: self._settings.unlock() try: result = portage.getmaskingstatus(self.cpv, settings=self._settings, portdb=portage.db[portage.root]["porttree"].dbapi) except KeyError: # getmaskingstatus doesn't support packages without ebuilds in the # Portage tree. result = None return result
def get_masking_status(ebuild): try: status = portage.getmaskingstatus(ebuild) except KeyError: status = ['deprecated'] return status
def _get_atom_mask_keyword_filter(cpv): l = portage.getmaskingstatus(cpv, portdb=portage.portdb) ll = len(l) return (ll is 0) or ((ll is 1) and (l[0][0] == 'p'))