def addDependencies(self, category, package, version = "", dep_type="both"): """Add a new root dependency tree to this graph.""" pi = portage.PortageInstance if portage.emergePlatform.isCrossCompilingEnabled() \ or utils.isSourceOnly(): sp = pi.getCorrespondingSourcePackage(package) if sp: # we found such a package and we're allowed to replace it category = sp[0] package = sp[1] version = pi.getNewestVersion(category, package) if category == "": category = pi.getCategory(package) if version == "": version = pi.getNewestVersion(category, package) try: tag = pi.getDefaultTarget( category, package, version ) except ImportError: tag = "1" if not os.path.exists( os.path.join( portage.getDirname( category, package ), package + "-package.xml" ) ): node = self.buildDepNode( category, package, version, tag, dep_type ) else: node = self.buildVirtualNodes( category, package, version, tag, dep_type ) if not node in self.roots: self.roots.append(node)
def isInstalled( category, package, version, buildtype='' ): """ deprecated, use InstallDB.installdb.isInstalled() instead """ utils.debug( "isInstalled(%s, %s, %s, %s)" % (category, package, version, buildtype), 2 ) # find in old style database path = utils.etcDir() fileName = os.path.join(path,'installed') found = False if os.path.isfile( fileName ): with open( fileName, "rb" ) as f: for line in f.read().splitlines(): (_category, _packageVersion) = line.split( "/" ) (_package, _version) = utils.packageSplit(_packageVersion) if category != '' and version != '' and category == _category and package == _package and version == _version: found = True break elif category == '' and version == '' and package == _package: found = True break utils.debug("...%s found in main database" % (' ' if found else ' not'), 2 ) if found: return True # find in release mode database if buildtype != '': fileName = os.path.join(path,'installed-' + buildtype ) if os.path.isfile( fileName ): with open( fileName, "rb" ) as f: for line in f.read().splitlines(): (_category, _packageVersion) = line.split( "/" ) (_package, _version) = utils.packageSplit(_packageVersion) if category != '' and version != '' and category == _category and package == _package and version == _version: found = True break elif category == '' and version == '' and package == _package: found = True break utils.debug( "...%s found in %s database" % ( (' ' if found else ' not'), buildtype), 2 ) if found: return True # try to detect packages from the installer binary = utils.checkManifestFile( os.path.join( os.getenv( "KDEROOT" ), "manifest", package + "-" + version + "-bin.ver"), category, package, version ) lib = utils.checkManifestFile( os.path.join( os.getenv( "KDEROOT" ), "manifest", package + "-" + version + "-lib.ver"), category, package, version ) found = found or binary or lib if not utils.envAsBool("EMERGE_VERSIONING", default=True) or utils.isSourceOnly(): # check for any installation except data packages if not os.path.exists(os.path.join( os.getenv( "KDEROOT" ), "manifest" ) ): return False if package.endswith( "-src" ): package = package[:-4] for filename in os.listdir( os.path.join( os.getenv( "KDEROOT" ), "manifest" ) ): if filename.startswith( package ) and not \ filename.startswith( package + "-data" ): return True return False
def getPackageInstance(self, category, package, buildtarget=None): """return instance of class Package from package file""" if emergePlatform.isCrossCompilingEnabled() or utils.isSourceOnly(): sp = self.getCorrespondingSourcePackage(package) if sp: category = sp[0] package = sp[1] version = self.getNewestVersion(category, package) fileName = getFilename(category, package, version) module = __import__(fileName) p = module.Package() p.setup(fileName, category, package, version, buildtarget) return p
def buildDepNode(self, category, package, version, tag, dep_type="both"): """Recursive method to construct the nodes of the dependency tree.""" pi = portage.PortageInstance if portage.emergePlatform.isCrossCompilingEnabled() \ or utils.isSourceOnly(): sp = pi.getCorrespondingSourcePackage(package) if sp: # we found such a package and we're allowed to replace it category = sp[0] package = sp[1] version = pi.getNewestVersion(category, package) try: tag = pi.getDefaultTarget( category, package, version ) except ImportError: tag = "1" key = "%s-%s-%s-%s" % (category, package, version, tag) try: node = self.key2node[key] return node except KeyError: pass children = [] for t in portage.getDependencies(category, package, version, (dep_type=="runtime")): sub_node = self.buildDepNode(t[0], t[1], t[2], tag, dep_type) children.append(sub_node) node = DependenciesNode(category, package, version, tag, children) node.metaData = pi.getMetaData(category, package, version) for child in children: child.parents.append(node) self.key2node[key] = node return node
def __readDependenciesForChildren(self, deps): children = [] if deps: for line in deps: (category, package) = line.split("/") if emergePlatform.isCrossCompilingEnabled() or utils.isSourceOnly(): sp = PortageInstance.getCorrespondingSourcePackage(package) if sp: # we found such a package and we're allowed to replace it category = sp[0] package = sp[1] line = "%s/%s" % (category, package) utils.debug("category: %s, name: %s" % (category, package), 1) version = PortageInstance.getNewestVersion(category, package) if not line in packageDict.keys(): p = DependencyPackage(category, package, version) utils.debug("adding package p %s/%s-%s" % (category, package, version), 1) packageDict[line] = p else: p = packageDict[line] children.append(p) return children
def solveDependencies(category, package, version, depList, dep_type="both"): depList.reverse() if emergePlatform.isCrossCompilingEnabled() or utils.isSourceOnly(): sp = PortageInstance.getCorrespondingSourcePackage(package) if sp: # we found such a package and we're allowed to replace it category = sp[0] package = sp[1] version = PortageInstance.getNewestVersion(category, package) utils.debug("found corresponding source package for %s" % package, 1) if category == "": category = PortageInstance.getCategory(package) utils.debug("found package in category %s" % category, 2) if version == "": version = PortageInstance.getNewestVersion(category, package) utils.debug("found package with newest version %s" % version, 2) pac = DependencyPackage(category, package, version) depList = pac.getDependencies(depList, dep_type=dep_type) depList.reverse() return depList