def open( self, package=None ): if self.url: ProjectProperties.requireIsURL( self.url ) package = ProjectProperties.splitURL( self.url )[1] else: ProjectProperties.requireIsCanonicalPath( package ) topLevelDir = os.path.join( SIT.getRootPath(), package ) super( BSTGloballyInstalledPackage, self ).open( topLevelDir )
def getReverseDependencies(self, packageURL): ProjectProperties.requireIsURL(packageURL) result = set() for candidateURL, detector in self._cache.items(): ProjectProperties.requireIsURL(candidateURL) if packageURL in detector.dependencies: result.add(candidateURL) return result
def retrieveReverseDependencies( self, recursive ): self._ensureMetaInfoCache() self.revDepSet = set() self.revDepTree = list() for depURL in self._metaInfoCache.getReverseDependencies( self.url ): ProjectProperties.requireIsURL( depURL ) # no Debian packages can appear in reverse dependencies of SIT packages depPackage = BSTInstalledPackage( depURL ) depPackage.detector = self._metaInfoCache.getDetector( depURL ) if recursive: depPackage.retrieveReverseDependencies( recursive ) self.revDepSet.update( depPackage.revDepSet ) self.revDepSet.add( depURL ) self.revDepTree.append( depPackage )
def retrieveDependencies( self, recursive, normalDeps=True, buildDeps=False, recommendations=False, suggestions=False ): Any.requireIsNotNone( self.detector, 'Please call .open() first' ) Any.requireIsBool( recursive ) Any.requireIsBool( normalDeps ) Any.requireIsBool( buildDeps ) Any.requireIsBool( recommendations ) Any.requireIsBool( suggestions ) self.detector.retrieveMakefileInfo() self.depSet = set() self.depTree = list() debPrefix = 'deb://' sitPrefix = 'sit://' hostPlatform = getHostPlatform() if normalDeps: self.depSet = set( self.detector.dependencies ) try: self.depSet.update( self.detector.dependsArch[ hostPlatform ] ) except KeyError: pass # no such setting, this is OK if buildDeps: self.depSet.update( self.detector.buildDependencies ) try: self.depSet.update( self.detector.buildDependsArch[ hostPlatform ] ) except KeyError: pass # no such setting, this is OK # create a temporary copy of self.depSet while iterating, # otherwise leads to "RuntimeError: Set changed size during iteration" for packageURL in copy.copy( self.depSet ): ProjectProperties.requireIsURL( packageURL ) error = False if packageURL.startswith( sitPrefix ): depPkg = BSTProxyInstalledPackage( packageURL ) try: depPkg.open() if recursive: depPkg.retrieveDependencies( recursive, normalDeps, buildDeps, recommendations, suggestions ) else: depPkg.depSet = set() depPkg.depTree = list() except AssertionError as details: logging.debug( details ) depPkg.depSet = set() depPkg.depTree = list() error = True elif packageURL.startswith( debPrefix ): depPkg = DebianPackage( packageURL ) try: depPkg.retrieveDependencies() except EnvironmentError as details: logging.warning( details ) depPkg.depSet = set() depPkg.depTree = list() else: raise ValueError( 'Unknown URL prefix in "%s"' % packageURL ) if not error: self.depSet.update( depPkg.depSet ) self.depSet.add( packageURL ) self.depTree.append( depPkg )
def getDetector(self, packageURL): ProjectProperties.requireIsURL(packageURL) return self._cache[packageURL]