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 : master_file = os.path.join( metafile[str(self)] , "Release" ) else : master_file = metafile[str(self)] release = debian_bundle.deb822.Release( sequence=open( master_file ) ) _name = "%sRelease" % self.metadata_path() localname = os.path.join( self.repo_path() , _name ) if os.path.isfile( localname ) : _name = "%sRelease" % self.metadata_path(True) if self.verify( localname , _name , release , params ) : repolib.logger.info( "Local copy of '%s' is up-to-date, skipping." % _name ) if not os.path.isfile( localname ) : if download : repolib.logger.info( "No local Release file exist for %s. Downloading." % self ) url = "%sRelease" % self.metadata_path() if self.downloadRawFile( url , localname ) : _name = "%sRelease" % self.metadata_path(True) if not self.verify( localname , _name , release , params ) : repolib.logger.warning( "No valid Release file found for %s" % self ) localname = False for ( extension , read_handler ) in config.mimetypes.iteritems() : _name = "%sPackages%s" % ( self.metadata_path() , extension ) localname = os.path.join( self.repo_path() , _name ) if os.path.isfile( localname ) : _name = "%sPackages%s" % ( self.metadata_path(True) , extension ) if self.verify( localname , _name , release , params ) : if self.mode == "init" : break repolib.logger.info( "Local copy of '%s' is up-to-date, skipping." % _name ) return True continue else : localname = False if download : repolib.logger.info( "No local Packages file exist for %s. Downloading." % self ) localname = SimpleComponent.get_metafile( self , release , _params , True ) if isinstance(localname,str) : return read_handler( localname ) return localname
def get_metafile(self, metafile, _params=None): params = self.params if _params: params.update(_params) masterfile = metafile[self] if isinstance(masterfile, bool): raise Exception("Calling %s.get_metafile( %s )" % (self, metafile)) release = debian_bundle.deb822.Release(sequence=open(masterfile)) if self.mode in ("init", "metadata"): # NOTE : ubuntu has no Release file on installer components localname = os.path.join(self.repo_path(), self.repomd) if os.path.isfile(localname): _name = "%sRelease" % self.metadata_path(True) if self.verify(localname, _name, release, params): repolib.logger.info( "Local copy of '%s' is up-to-date, skipping." % _name) else: os.unlink(localname) if not os.path.isfile(localname): repolib.logger.info( "No local Release file exist for %s. Downloading." % self) url = "%sRelease" % self.metadata_path() if self.downloadRawFile(url, localname): _name = "%sRelease" % self.metadata_path(True) if not self.verify(localname, _name, release, params): os.unlink(localname) repolib.logger.warning( "No valid Release file found for %s" % self) localname = False for (extension, read_handler) in config.mimetypes.iteritems(): _name = "%sPackages%s" % (self.metadata_path(), extension) localname = os.path.join(self.repo_path(), _name) if os.path.isfile(localname): _name = "%sPackages%s" % (self.metadata_path(True), extension) if self.verify(localname, _name, release, params): if self.mode == "init": break repolib.logger.info( "Local copy of '%s' is up-to-date, skipping." % _name) return True elif self.mode == "keep": # FIXME : could happen that another compression is OK return False os.unlink(localname) else: localname = False if self.mode != "keep": repolib.logger.info( "No local Packages file exist for %s. Downloading." % self) localname = SimpleComponent.get_metafile( self, release, _params) if not isinstance(localname, bool): classname = "%s" % localname.__class__ if str(self).endswith("/debian-installer" ) and classname != "gzip.GzipFile": repolib.logger.info( "Force download of Packages.gz for installer components" ) url = "%sPackages%s" % (self.metadata_path(), ".gz") _localname = os.path.join(self.repo_path(), url) if self.downloadRawFile(url, _localname): _name = "%sPackages%s" % (self.metadata_path(True), ".gz") if not self.verify(_localname, _name, release, params): os.unlink(_localname) if isinstance(localname, str): return read_handler(localname) return localname
class DebianComponent(SimpleComponent): def __init__(self, (arch, comp), config): SimpleComponent.__init__(self, "%s/%s" % (arch, comp), config) self.archname, self.component = arch, comp self.repomd = os.path.join(self.metadata_path(), "Release")
def get_metafile( self , metafile , _params=None ) : params = self.params if _params : params.update( _params ) masterfile = metafile[self] if isinstance(masterfile,bool) : raise Exception( "Calling %s.get_metafile( %s )" % ( self , metafile ) ) release = debian_bundle.deb822.Release( sequence=open( masterfile ) ) if self.mode in ( "init" , "metadata" ) : # NOTE : ubuntu has no Release file on installer components localname = os.path.join( self.repo_path() , self.repomd ) if os.path.isfile( localname ) : _name = "%sRelease" % self.metadata_path(True) if self.verify( localname , _name , release , params ) : repolib.logger.info( "Local copy of '%s' is up-to-date, skipping." % _name ) else : os.unlink( localname ) if not os.path.isfile( localname ) : repolib.logger.info( "No local Release file exist for %s. Downloading." % self ) url = "%sRelease" % self.metadata_path() if self.downloadRawFile( url , localname ) : _name = "%sRelease" % self.metadata_path(True) if not self.verify( localname , _name , release , params ) : os.unlink( localname ) repolib.logger.warning( "No valid Release file found for %s" % self ) localname = False for ( extension , read_handler ) in config.mimetypes.iteritems() : _name = "%sPackages%s" % ( self.metadata_path() , extension ) localname = os.path.join( self.repo_path() , _name ) if os.path.isfile( localname ) : _name = "%sPackages%s" % ( self.metadata_path(True) , extension ) if self.verify( localname , _name , release , params ) : if self.mode == "init" : break repolib.logger.info( "Local copy of '%s' is up-to-date, skipping." % _name ) return True elif self.mode == "keep" : # FIXME : could happen that another compression is OK return False os.unlink( localname ) else : localname = False if self.mode != "keep" : repolib.logger.info( "No local Packages file exist for %s. Downloading." % self ) localname = SimpleComponent.get_metafile( self , release , _params ) if not isinstance(localname,bool) : classname = "%s" % localname.__class__ if str(self).endswith("/debian-installer") and classname != "gzip.GzipFile" : repolib.logger.info( "Force download of Packages.gz for installer components" ) url = "%sPackages%s" % ( self.metadata_path() , ".gz" ) _localname = os.path.join( self.repo_path() , url ) if self.downloadRawFile( url , _localname ) : _name = "%sPackages%s" % ( self.metadata_path(True) , ".gz" ) if not self.verify( _localname , _name , release , params ) : os.unlink( _localname ) if isinstance(localname,str) : return read_handler( localname ) return localname
def repo_path ( self ) : if self.subdir : return os.path.join( self.destdir , self.subdir ) return SimpleComponent.repo_path(self)