Ejemplo n.º 1
0
    def get_metafile ( self , _params=None , keep=False ) :

      params = self.params
      if _params : params.update( _params )

      repomd = {}

      for subrepo in self.subrepos :
        metafile = repolib.MirrorRepository.get_metafile( self , self.repomd[subrepo] , params , keep )

        if not metafile :
            repolib.logger.error( "Metadata for '%s' not found" % self.version )
        else :
            if metafile is not True :
                repolib.logger.info( "Content verification of metafile %s" % metafile )
                item , filelist = filelist_xmlparser.get_filelist( metafile )

                if not item or not filelist :
                    repolib.logger.error( "No primary or filelist node within repomd file" )
                    os.unlink( metafile )
                    metafile = False
    
        repomd[ subrepo ] = metafile

      return repomd
Ejemplo n.º 2
0
    def get_metafile( self , metafile , _params=None , download=True ) :

        # Currently unused, but relevant to verification flags
        params = self.params
        if _params : params.update( _params )

        if download :
            local_repodata = metafile[str(self)]
            master_file = os.path.join( local_repodata , "repodata/repomd.xml" )
        else :
            local_repodata = os.path.join( self.repo_path() , self.metadata_path(True) )
            master_file = metafile[str(self)]

        primary , secondary = False , False

        # FIXME : the same extraction was already performed on master.get_metafile()
        item , filelist = filelist_xmlparser.get_filelist( master_file )

        _primary = os.path.join( local_repodata , item['href'] )
    
        if os.path.isfile( _primary ) :
            if self.verify( _primary , item , params ) :
                primary = True
                if self.mode == "init" :
                    primary = _primary
    
        if not primary :
          if download :
            repolib.logger.warning( "No local primary file exist for %s. Downloading." % self )
            url = repolib.utils.urljoin( self.metadata_path(True) , item['href'] )
            if self.downloadRawFile( url , _primary ) :
                if self.verify( _primary , item , params ) :
                    primary = _primary
    
        _secondary = os.path.join( local_repodata , filelist['href'] )
    
        if os.path.isfile( _secondary ) :
            if self.verify( _secondary , filelist , params ) :
                secondary = True
                if self.mode == "init" :
                    secondary = _secondary
    
        if not secondary :
          if download :
            repolib.logger.warning( "No local filelists file exist for %s. Downloading." % self )
            url = repolib.utils.urljoin( self.metadata_path(True) , filelist['href'] )
            if self.downloadRawFile( url , _secondary ) :
                if self.verify( _secondary , filelist , params ) :
                    secondary = _secondary
    
        # Workaround for easily detect True,True and False,False pairs
        if primary == secondary and isinstance(primary,bool) :
            return primary

        return primary , secondary